diff --git a/Projects/Server.Tests/Network/Packets/GumpUtilities.cs b/Projects/Server.Tests/Network/Packets/GumpUtilities.cs index 0448c5f75..9394b98fa 100644 --- a/Projects/Server.Tests/Network/Packets/GumpUtilities.cs +++ b/Projects/Server.Tests/Network/Packets/GumpUtilities.cs @@ -33,7 +33,10 @@ namespace Server.Tests.Network.Packets var packLength = (ulong)dest.Length - 8; ZlibError ce = Zlib.Pack(dest.Slice(pos + 8), ref packLength, source, ZlibQuality.Default); - if (ce != ZlibError.Okay) Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce); + if (ce != ZlibError.Okay) + { + Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce); + } dest.Write(ref pos, (int)(4 + packLength)); dest.Write(ref pos, length); diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/AccountPacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/AccountPacketTests.cs index e7804e786..8ec3d5004 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/AccountPacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/AccountPacketTests.cs @@ -137,15 +137,23 @@ namespace Server.Tests.Network.Packets flags &= ~FeatureFlags.UOTD; if (ns.Account.Limit > 6) + { flags |= FeatureFlags.SeventhCharacterSlot; + } else + { flags |= FeatureFlags.SixthCharacterSlot; + } } if (ns.ExtendedSupportedFeatures) + { expectedData.Write(ref pos, (uint)flags); + } else + { expectedData.Write(ref pos, (ushort)flags); + } AssertThat.Equal(data, expectedData); } @@ -194,7 +202,9 @@ namespace Server.Tests.Network.Packets var map = m.Map; if (map == null || map == Map.Internal) + { map = m.LogoutMap; + } expectedData.Write(ref pos, (ushort)(map?.Width ?? Map.Felucca.Width)); expectedData.Write(ref pos, (ushort)(map?.Height ?? Map.Felucca.Height)); @@ -234,11 +244,13 @@ namespace Server.Tests.Network.Packets var highSlot = -1; for (var i = account.Length - 1; i >= 0; i--) + { if (account[i] != null) { highSlot = i; break; } + } var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5); expectedData.Write(ref pos, (byte)count); @@ -303,11 +315,13 @@ namespace Server.Tests.Network.Packets var highSlot = -1; for (var i = account.Length - 1; i >= 0; i--) + { if (account[i] != null) { highSlot = i; break; } + } var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5); expectedData.Write(ref pos, (byte)count); @@ -367,13 +381,19 @@ namespace Server.Tests.Network.Packets var flags = ExpansionInfo.GetInfo(Expansion.EJ).CharacterListFlags; if (count > 6) + { flags |= CharacterListFlags.SeventhCharacterSlot | CharacterListFlags.SixthCharacterSlot; // 7th Character Slot + } else if (count == 6) + { flags |= CharacterListFlags.SixthCharacterSlot; // 6th Character Slot + } else if (account.Limit == 1) + { flags |= CharacterListFlags.SlotLimit & CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character + } expectedData.Write(ref pos, (int)flags); expectedData.Write(ref pos, (short)-1); @@ -404,11 +424,13 @@ namespace Server.Tests.Network.Packets var highSlot = -1; for (var i = account.Length - 1; i >= 0; i--) + { if (account[i] != null) { highSlot = i; break; } + } var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5); expectedData.Write(ref pos, (byte)count); @@ -458,13 +480,19 @@ namespace Server.Tests.Network.Packets var flags = ExpansionInfo.GetInfo(Expansion.EJ).CharacterListFlags; if (count > 6) + { flags |= CharacterListFlags.SeventhCharacterSlot | CharacterListFlags.SixthCharacterSlot; // 7th Character Slot + } else if (count == 6) + { flags |= CharacterListFlags.SixthCharacterSlot; // 6th Character Slot + } else if (account.Limit == 1) + { flags |= CharacterListFlags.SlotLimit & CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character + } expectedData.Write(ref pos, (int)flags); @@ -546,8 +574,12 @@ namespace Server.Tests.Network.Packets { m_Mobiles = mobiles; foreach (var mobile in mobiles) + { if (mobile != null) + { mobile.Account = this; + } + } Length = mobiles.Length; Count = mobiles.Count(t => t != null); @@ -571,7 +603,10 @@ namespace Server.Tests.Network.Packets public bool WithdrawGold(int amount) { - if (TotalGold - amount < 0) return false; + if (TotalGold - amount < 0) + { + return false; + } TotalGold -= amount; return true; @@ -579,7 +614,10 @@ namespace Server.Tests.Network.Packets public bool WithdrawPlat(int amount) { - if (TotalPlat - amount < 0) return false; + if (TotalPlat - amount < 0) + { + return false; + } TotalPlat -= amount; return true; diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/EquipmentPacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/EquipmentPacketTests.cs index 9130751e3..8e4b161dc 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/EquipmentPacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/EquipmentPacketTests.cs @@ -32,7 +32,10 @@ namespace Server.Tests.Network.Packets var attrs = info.Attributes; var length = 17 + (info.Unidentified ? 4 : 0) + attrs.Length * 6; - if (info.Crafter != null) length += 6 + (info.Crafter.Name?.Length ?? 0); + if (info.Crafter != null) + { + length += 6 + (info.Crafter.Name?.Length ?? 0); + } Span expectedData = stackalloc byte[length]; @@ -51,7 +54,10 @@ namespace Server.Tests.Network.Packets expectedData.WriteAscii(ref pos, name); } - if (info.Unidentified) expectedData.Write(ref pos, -4); + if (info.Unidentified) + { + expectedData.Write(ref pos, -4); + } for (var i = 0; i < attrs.Length; i++) { diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/GumpPacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/GumpPacketTests.cs index 430bc2f61..21903a81b 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/GumpPacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/GumpPacketTests.cs @@ -120,7 +120,9 @@ namespace Server.Tests.Network.Packets expectedData.Write(ref pos, (ushort)gump.Strings.Count); for (var i = 0; i < gump.Strings.Count; ++i) + { expectedData.WriteBigUni(ref pos, gump.Strings[i] ?? ""); + } expectedData.Slice(1, 2).Write((ushort)pos); // Length @@ -198,7 +200,9 @@ namespace Server.Tests.Network.Packets var bufferPos = 0; foreach (var layout in layoutList) + { buffer.WriteAscii(ref bufferPos, layout); + } #if NO_LOCAL_INIT buffer.Write(ref bufferPos, (byte)0); // Layout terminator @@ -216,7 +220,9 @@ namespace Server.Tests.Network.Packets bufferPos = 0; foreach (var str in gump.Strings) + { buffer.WriteBigUni(ref bufferPos, str); + } expectedData.WritePacked(ref pos, buffer.Slice(0, bufferPos)); diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/ItemPacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/ItemPacketTests.cs index ffa5ab808..85c01f227 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/ItemPacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/ItemPacketTests.cs @@ -43,23 +43,35 @@ namespace Server.Tests.Network.Packets pos += 2; // Length if (item.Amount != 0) + { expectedData.Write(ref pos, serial | 0x80000000); + } else + { expectedData.Write(ref pos, serial & 0x7FFFFFFF); + } if (item is BaseMulti) + { expectedData.Write(ref pos, (ushort)(item.ItemID | 0x4000)); + } else + { expectedData.Write(ref pos, (ushort)item.ItemID); + } if (item.Amount != 0) + { expectedData.Write(ref pos, (ushort)item.Amount); + } var direction = (byte)item.Direction; var x = (ushort)(item.X & 0x7FFF); if (direction != 0) + { x |= 0x8000; + } expectedData.Write(ref pos, x); @@ -67,21 +79,34 @@ namespace Server.Tests.Network.Packets var flags = item.GetPacketFlags(); var y = (ushort)(item.Y & 0x3FFF); - if (hue != 0) y |= 0x8000; - if (flags != 0) y |= 0x4000; + if (hue != 0) + { + y |= 0x8000; + } + + if (flags != 0) + { + y |= 0x4000; + } expectedData.Write(ref pos, y); if (direction != 0) + { expectedData.Write(ref pos, direction); + } expectedData.Write(ref pos, (byte)item.Z); if (hue != 0) + { expectedData.Write(ref pos, (ushort)hue); + } if (flags != 0) + { expectedData.Write(ref pos, (byte)flags); + } // Length expectedData.Slice(1, 2).Write((ushort)pos); @@ -321,6 +346,7 @@ namespace Server.Tests.Network.Packets ushort count = 0; for (var i = 0; i < 64; i++) + { if ((content & (1ul << i)) != 0) { expectedData.Write(ref pos, 0x7FFFFFFF - i); @@ -344,6 +370,7 @@ namespace Server.Tests.Network.Packets #endif count++; } + } expectedData.Slice(1, 2).Write((ushort)pos); // Length expectedData.Slice(3, 2).Write(count); // Count @@ -371,6 +398,7 @@ namespace Server.Tests.Network.Packets ushort count = 0; for (var i = 0; i < 64; i++) + { if ((content & (1ul << i)) != 0) { expectedData.Write(ref pos, 0x7FFFFFFF - i); @@ -395,6 +423,7 @@ namespace Server.Tests.Network.Packets #endif count++; } + } expectedData.Slice(1, 2).Write((ushort)pos); // Length expectedData.Slice(3, 2).Write(count); // Count @@ -489,7 +518,9 @@ namespace Server.Tests.Network.Packets { var child = cont.Items[i]; if (child.Deleted || !m.CanSee(child)) + { continue; + } expectedData.Write(ref pos, child.Serial); expectedData.Write(ref pos, (ushort)child.ItemID); @@ -539,7 +570,9 @@ namespace Server.Tests.Network.Packets { var child = cont.Items[i]; if (child.Deleted || !m.CanSee(child)) + { continue; + } expectedData.Write(ref pos, child.Serial); expectedData.Write(ref pos, (ushort)child.ItemID); diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/MenuPacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/MenuPacketTests.cs index 63ad0997c..8814c379a 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/MenuPacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/MenuPacketTests.cs @@ -52,7 +52,9 @@ namespace Server.Tests.Network.Packets { length += 5 + entry.Name.Length; if (entriesCount == 255) + { break; + } entriesCount++; } @@ -104,7 +106,9 @@ namespace Server.Tests.Network.Packets { length += 5 + answer.Length; if (answersCount == 255) + { break; + } answersCount++; } @@ -171,10 +175,14 @@ namespace Server.Tests.Network.Packets var range = entry.Range; if (range == -1) + { range = 18; + } if (!(entry.Enabled && menu.From.InRange(item.GetWorldLocation(), range))) + { flags |= CMEFlags.Disabled; + } expectedData.Write(ref pos, (ushort)flags); } @@ -218,20 +226,28 @@ namespace Server.Tests.Network.Packets var color = entry.Color & 0xFFFF; if (color != 0xFFFF) + { flags |= CMEFlags.Colored; + } var range = entry.Range; if (range == -1) + { range = 18; + } if (!(entry.Enabled && menu.From.InRange(item.GetWorldLocation(), range))) + { flags |= CMEFlags.Disabled; + } expectedData.Write(ref pos, (ushort)flags); if ((flags & CMEFlags.Colored) != 0) + { expectedData.Write(ref pos, (ushort)color); + } } AssertThat.Equal(data, expectedData); diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs index 813696c28..4e7bc6309 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs @@ -261,10 +261,22 @@ namespace Server.Tests.Network.Packets int type; var notSelf = beholder != beheld; - if (notSelf) type = 0; - else if (Core.HS && ns.ExtendedStatus) type = 6; - else if (Core.ML && ns.SupportsExpansion(Expansion.ML)) type = 5; - else type = Core.AOS ? 4 : 3; + if (notSelf) + { + type = 0; + } + else if (Core.HS && ns.ExtendedStatus) + { + type = 6; + } + else if (Core.ML && ns.SupportsExpansion(Expansion.ML)) + { + type = 5; + } + else + { + type = Core.AOS ? 4 : 3; + } expectedData.Write(ref pos, beheld.Serial); expectedData.WriteAsciiFixed(ref pos, beheld.Name, 30); @@ -320,8 +332,12 @@ namespace Server.Tests.Network.Packets expectedData.Write(ref pos, beheld.TithingPoints); if (type >= 6) + { for (var i = 0; i < 15; ++i) + { expectedData.Write(ref pos, (ushort)beheld.GetAOSStatus(i)); + } + } } expectedData.Slice(1, 2).Write((ushort)pos); // Length @@ -502,9 +518,14 @@ namespace Server.Tests.Network.Packets var count = items.Count; if (beheld.HairItemID > 0) + { count++; + } + if (beheld.FacialHairItemID > 0) + { count++; + } var length = 23 + count * 9; // Max Size @@ -645,9 +666,14 @@ namespace Server.Tests.Network.Packets var count = items.Count; if (beheld.HairItemID > 0) + { count++; + } + if (beheld.FacialHairItemID > 0) + { count++; + } var length = 23 + count * 9; // Max Size @@ -686,7 +712,9 @@ namespace Server.Tests.Network.Packets hue = isSolidHue ? beheld.SolidHueOverride : item.Hue; if (hue != 0) + { itemId |= 0x8000; + } expectedData.Write(ref pos, item.Serial); expectedData.Write(ref pos, (ushort)itemId); @@ -703,7 +731,9 @@ namespace Server.Tests.Network.Packets hue = isSolidHue ? beheld.SolidHueOverride : beheld.HairHue; if (hue != 0) + { itemId |= 0x8000; + } expectedData.Write(ref pos, HairInfo.FakeSerial(beheld)); expectedData.Write(ref pos, (ushort)itemId); @@ -719,7 +749,9 @@ namespace Server.Tests.Network.Packets hue = isSolidHue ? beheld.SolidHueOverride : beheld.FacialHairHue; if (hue != 0) + { itemId |= 0x8000; + } expectedData.Write(ref pos, FacialHairInfo.FakeSerial(beheld)); expectedData.Write(ref pos, (ushort)itemId); diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/PlayerPacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/PlayerPacketTests.cs index 81523a3b6..3eb0b17c4 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/PlayerPacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/PlayerPacketTests.cs @@ -374,9 +374,14 @@ namespace Server.Tests.Network.Packets expectedData.WriteAsciiFixed(ref pos, title, 60); byte flags = 0x00; if (warmode) + { flags |= 0x01; + } + if (canLift) + { flags |= 0x02; + } expectedData.Write(ref pos, flags); diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/SecureTradePacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/SecureTradePacketTests.cs index 28551081a..8955fedbf 100644 --- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/SecureTradePacketTests.cs +++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/SecureTradePacketTests.cs @@ -34,7 +34,9 @@ namespace Server.Tests.Network.Packets expectedData.Write(ref pos, secondCont.Serial); expectedData.Write(ref pos, hasName); if (hasName) + { expectedData.WriteAsciiFixed(ref pos, name, 30); + } AssertThat.Equal(data, expectedData); } diff --git a/Projects/UOContent.Tests/Accounting/Security/PasswordProtectionTest.cs b/Projects/UOContent.Tests/Accounting/Security/PasswordProtectionTest.cs index 014777b35..b53308490 100644 --- a/Projects/UOContent.Tests/Accounting/Security/PasswordProtectionTest.cs +++ b/Projects/UOContent.Tests/Accounting/Security/PasswordProtectionTest.cs @@ -19,7 +19,9 @@ namespace Server.Tests.Accounting.Security { var passwordProtection = Activator.CreateInstance(protectionType) as IPasswordProtection; if (passwordProtection == null) + { Assert.False(true, $"{protectionType.Name} is not an IPasswordProtection."); + } var encryptedPassword = passwordProtection.EncryptPassword(plainPassword); @@ -36,7 +38,9 @@ namespace Server.Tests.Accounting.Security { var passwordProtection = Activator.CreateInstance(protectionType) as IPasswordProtection; if (passwordProtection == null) + { Assert.False(true, $"{protectionType.Name} is not an IPasswordProtection."); + } var encryptedPassword = passwordProtection.EncryptPassword(plainPassword); diff --git a/Projects/UOContent/Accounting/Accounts.cs b/Projects/UOContent/Accounting/Accounts.cs index 1c6a3aa21..3dcc609ae 100644 --- a/Projects/UOContent/Accounting/Accounts.cs +++ b/Projects/UOContent/Accounting/Accounts.cs @@ -47,7 +47,9 @@ namespace Server.Accounting var filePath = Path.Combine("Saves/Accounts", "accounts.xml"); if (!File.Exists(filePath)) + { return; + } var doc = new XmlDocument(); doc.Load(filePath); @@ -55,6 +57,7 @@ namespace Server.Accounting var root = doc["accounts"]; foreach (XmlElement account in root.GetElementsByTagName("account")) + { try { new Account(account); @@ -63,12 +66,15 @@ namespace Server.Accounting { Console.WriteLine("Warning: Account instance load failed"); } + } } public static void Save(bool message) { if (!Directory.Exists("Saves/Accounts")) + { Directory.CreateDirectory("Saves/Accounts"); + } var filePath = Path.Combine("Saves/Accounts", "accounts.xml"); @@ -82,7 +88,9 @@ namespace Server.Accounting xml.WriteAttributeString("count", m_Accounts.Count.ToString()); foreach (Account a in GetAccounts()) + { a.Save(xml); + } xml.WriteEndElement(); diff --git a/Projects/UOContent/Accounting/Firewall.cs b/Projects/UOContent/Accounting/Firewall.cs index a40aefc38..5267303af 100644 --- a/Projects/UOContent/Accounting/Firewall.cs +++ b/Projects/UOContent/Accounting/Firewall.cs @@ -22,7 +22,9 @@ namespace Server line = line.Trim(); if (line.Length == 0) + { continue; + } List.Add(ToFirewallEntry(line)); @@ -46,11 +48,19 @@ namespace Server public static IFirewallEntry ToFirewallEntry(object entry) { if (entry is IFirewallEntry firewallEntry) + { return firewallEntry; + } + if (entry is IPAddress address) + { return new IPFirewallEntry(address); + } + if (entry is string s) + { return ToFirewallEntry(s); + } return null; } @@ -58,15 +68,23 @@ namespace Server public static IFirewallEntry ToFirewallEntry(string entry) { if (IPAddress.TryParse(entry, out var addr)) + { return new IPFirewallEntry(addr); + } // Try CIDR parse var str = entry.Split('/'); if (str.Length == 2) + { if (IPAddress.TryParse(str[0], out var cidrPrefix)) + { if (int.TryParse(str[1], out var cidrLength)) + { return new CIDRFirewallEntry(cidrPrefix, cidrLength); + } + } + } return new WildcardIPFirewallEntry(entry); } @@ -91,17 +109,25 @@ namespace Server public static void Add(object obj) { if (obj is IPAddress address) + { Add(address); + } else if (obj is string s) + { Add(s); + } else if (obj is IFirewallEntry entry) + { Add(entry); + } } public static void Add(IFirewallEntry entry) { if (!List.Contains(entry)) + { List.Add(entry); + } Save(); } @@ -111,7 +137,9 @@ namespace Server var entry = ToFirewallEntry(pattern); if (!List.Contains(entry)) + { List.Add(entry); + } Save(); } @@ -121,7 +149,9 @@ namespace Server IFirewallEntry entry = new IPFirewallEntry(ip); if (!List.Contains(entry)) + { List.Add(entry); + } Save(); } @@ -132,14 +162,20 @@ namespace Server using var op = new StreamWriter(path); for (var i = 0; i < List.Count; ++i) + { op.WriteLine(List[i]); + } } public static bool IsBlocked(IPAddress ip) { for (var i = 0; i < List.Count; i++) + { if (List[i].IsBlocked(ip)) + { return true; + } + } return false; /* @@ -182,11 +218,16 @@ namespace Server public override bool Equals(object obj) { if (obj is IPAddress) + { return obj.Equals(m_Address); + } + if (obj is string s) { if (IPAddress.TryParse(s, out var otherAddress)) + { return otherAddress.Equals(m_Address); + } } else if (obj is IPFirewallEntry entry) { @@ -221,9 +262,15 @@ namespace Server var str = entry.Split('/'); if (str.Length == 2) + { if (IPAddress.TryParse(str[0], out var cidrPrefix)) + { if (int.TryParse(str[1], out var cidrLength)) + { return m_CIDRPrefix.Equals(cidrPrefix) && m_CIDRLength.Equals(cidrLength); + } + } + } } else if (obj is CIDRFirewallEntry cidrEntry) { @@ -247,7 +294,9 @@ namespace Server public bool IsBlocked(IPAddress address) { if (!m_Valid) + { return false; // Why process if it's invalid? it'll return false anyway after processing it. + } var matched = Utility.IPMatch(m_Entry, address, out var valid); m_Valid = valid; @@ -259,7 +308,9 @@ namespace Server public override bool Equals(object obj) { if (obj is string) + { return obj.Equals(m_Entry); + } return obj is WildcardIPFirewallEntry entry && m_Entry.Equals(entry.m_Entry); } diff --git a/Projects/UOContent/Accounting/IPLimiter.cs b/Projects/UOContent/Accounting/IPLimiter.cs index 60a8e797e..405a7ff42 100644 --- a/Projects/UOContent/Accounting/IPLimiter.cs +++ b/Projects/UOContent/Accounting/IPLimiter.cs @@ -27,7 +27,9 @@ namespace Server.Misc public static bool Verify(IPAddress ourAddress) { if (!Enabled || IsExempt(ourAddress)) + { return true; + } var netStates = TcpServer.Instances; @@ -42,7 +44,9 @@ namespace Server.Misc ++count; if (count >= MaxAddresses) + { return false; + } } } diff --git a/Projects/UOContent/Accounting/Security/AccountSecurity.cs b/Projects/UOContent/Accounting/Security/AccountSecurity.cs index 45bd06e34..0725b3af8 100644 --- a/Projects/UOContent/Accounting/Security/AccountSecurity.cs +++ b/Projects/UOContent/Accounting/Security/AccountSecurity.cs @@ -46,7 +46,9 @@ namespace Server.Accounting.Security ); if (CurrentAlgorithm < PasswordProtectionAlgorithm.SHA2) + { throw new Exception($"Security: {CurrentAlgorithm} is obsolete and not secure. Do not use it."); + } } public static IPasswordProtection GetPasswordProtection(PasswordProtectionAlgorithm algorithm) diff --git a/Projects/UOContent/Commands/Batch.cs b/Projects/UOContent/Commands/Batch.cs index ac38a41b0..257126153 100644 --- a/Projects/UOContent/Commands/Batch.cs +++ b/Projects/UOContent/Commands/Batch.cs @@ -60,7 +60,10 @@ namespace Server.Commands return; } - if (!command.ValidateArgs(Scope, eventArgs[i])) return; + if (!command.ValidateArgs(Scope, eventArgs[i])) + { + return; + } } for (var i = 0; i < commands.Length; ++i) @@ -69,7 +72,9 @@ namespace Server.Commands var bc = BatchCommands[i]; if (list.Count > 20) + { CommandLogging.Enabled = false; + } List usedList; @@ -88,12 +93,15 @@ namespace Server.Commands var obj = list[j]; if (obj == null) + { continue; + } var type = obj.GetType(); var failReason = ""; if (!propertyChains.TryGetValue(type, out var chain)) + { propertyChains[type] = chain = Properties.GetPropertyInfoChain( e.Mobile, type, @@ -101,21 +109,28 @@ namespace Server.Commands PropertyAccess.Read, ref failReason ); + } if (chain == null) + { continue; + } var endProp = Properties.GetPropertyInfo(ref obj, chain, ref failReason); if (endProp == null) + { continue; + } try { obj = endProp.GetValue(obj, null); if (obj != null) + { usedList.Add(obj); + } } catch { @@ -127,7 +142,9 @@ namespace Server.Commands command.ExecuteList(eventArgs[i], usedList); if (list.Count > 20) + { CommandLogging.Enabled = true; + } command.Flush(e.Mobile, list.Count > 20); } @@ -304,12 +321,16 @@ namespace Server.Commands public override void OnResponse(NetState sender, RelayInfo info) { if (!SplitButtonID(info.ButtonID, 1, out var type, out var index)) + { return; + } var entry = info.GetTextEntry(0); if (entry != null) + { m_Batch.Condition = entry.Text; + } for (var i = m_Batch.BatchCommands.Count - 1; i >= 0; --i) { @@ -318,15 +339,21 @@ namespace Server.Commands entry = info.GetTextEntry(1 + i * 2); if (entry != null) + { sc.Command = entry.Text; + } entry = info.GetTextEntry(2 + i * 2); if (entry != null) + { sc.Object = entry.Text; + } if (sc.Command.Length == 0 && sc.Object.Length == 0) + { m_Batch.BatchCommands.RemoveAt(i); + } } switch (type) @@ -388,7 +415,9 @@ namespace Server.Commands var impl = BaseCommandImplementor.Implementors[i]; if (m_From.AccessLevel < impl.AccessLevel) + { continue; + } AddNewLine(); @@ -402,6 +431,7 @@ namespace Server.Commands public override void OnResponse(NetState sender, RelayInfo info) { if (SplitButtonID(info.ButtonID, 1, out var type, out var index)) + { switch (type) { case 0: @@ -411,12 +441,15 @@ namespace Server.Commands var impl = BaseCommandImplementor.Implementors[index]; if (m_From.AccessLevel >= impl.AccessLevel) + { m_Batch.Scope = impl; + } } break; } } + } m_From.SendGump(new BatchGump(m_From, m_Batch)); } diff --git a/Projects/UOContent/Commands/BoundingBoxPicker.cs b/Projects/UOContent/Commands/BoundingBoxPicker.cs index b0e0cdb8a..40566bb6e 100644 --- a/Projects/UOContent/Commands/BoundingBoxPicker.cs +++ b/Projects/UOContent/Commands/BoundingBoxPicker.cs @@ -38,10 +38,14 @@ namespace Server protected override void OnTarget(Mobile from, object targeted) { if (!(targeted is IPoint3D p)) + { return; + } if (p is Item item) + { p = item.GetWorldTop(); + } if (m_First) { diff --git a/Projects/UOContent/Commands/Docs.cs b/Projects/UOContent/Commands/Docs.cs index 9583c4037..627b494d8 100644 --- a/Projects/UOContent/Commands/Docs.cs +++ b/Projects/UOContent/Commands/Docs.cs @@ -158,13 +158,17 @@ namespace Server.Commands var nspace = type.Namespace; if (nspace == null || type.IsSpecialName) + { continue; + } var info = new TypeInfo(type); m_Types[type] = info; if (!m_Namespaces.TryGetValue(nspace, out var nspaces)) + { m_Namespaces[nspace] = nspaces = new List(); + } nspaces.Add(info); @@ -175,7 +179,9 @@ namespace Server.Commands m_Types.TryGetValue(baseType, out var baseInfo); if (baseInfo == null) + { m_Types[baseType] = baseInfo = new TypeInfo(baseType); + } baseInfo.m_Derived ??= new List(); @@ -189,7 +195,9 @@ namespace Server.Commands m_Types.TryGetValue(decType, out var decInfo); if (decInfo == null) + { m_Types[decType] = decInfo = new TypeInfo(decType); + } decInfo.m_Nested ??= new List(); @@ -201,12 +209,16 @@ namespace Server.Commands var iface = info.m_Interfaces[j]; if (!InAssemblies(iface, asms)) + { continue; + } m_Types.TryGetValue(iface, out var ifaceInfo); if (ifaceInfo == null) + { m_Types[iface] = ifaceInfo = new TypeInfo(iface); + } ifaceInfo.m_Derived ??= new List(); @@ -220,8 +232,12 @@ namespace Server.Commands var a = t.Assembly; for (var i = 0; i < asms.Length; ++i) + { if (a == asms[i]) + { return true; + } + } return false; } @@ -270,7 +286,9 @@ namespace Server.Commands nsHtml.WriteLine("

{0}

", name); for (var i = 0; i < types.Count; ++i) + { SaveType(types[i], nsHtml, fileName, name); + } nsHtml.WriteLine(" "); nsHtml.WriteLine(""); @@ -279,7 +297,9 @@ namespace Server.Commands private static void SaveType(TypeInfo info, StreamWriter nsHtml, string nsFileName, string nsName) { if (info.m_Declaring == null) + { nsHtml.WriteLine($" {info.LinkName("../types/")}
"); + } using var typeHtml = GetWriter(info.FileName); typeHtml.WriteLine(""); @@ -292,9 +312,13 @@ namespace Server.Commands typeHtml.WriteLine("

Back to {1}

", nsFileName, nsName); if (info.m_Type.IsEnum) + { WriteEnum(info, typeHtml); + } else + { WriteType(info, typeHtml); + } typeHtml.WriteLine(" "); typeHtml.WriteLine(""); @@ -342,11 +366,15 @@ namespace Server.Commands nameBuilder.Append(sanitizedName); fnamBuilder.Append("T"); if (DontLink(typeArguments[i])) + { linkBuilder.Append($"{aliasedName}"); + } else + { linkBuilder.Append( $"{aliasedName}" ); + } } nameBuilder.Append(">"); @@ -364,11 +392,15 @@ namespace Server.Commands fileName = fnam == null ? $"docs/types/{SanitizeType(type.Name)}.html" : $"{fnam}.html"; if (link == null) + { linkName = DontLink(type) ? $"{SanitizeType(type.Name)}" : $"{SanitizeType(type.Name)}"; + } else + { linkName = link; + } // Console.WriteLine( typeName+":"+fileName+":"+linkName ); } @@ -378,17 +410,28 @@ namespace Server.Commands var anonymousType = name.Contains("<"); var sb = new StringBuilder(name); for (var i = 0; i < ReplaceChars.Length; ++i) + { sb.Replace(ReplaceChars[i], '-'); + } + + if (anonymousType) + { + return $"(Anonymous-Type){sb}"; + } - if (anonymousType) return $"(Anonymous-Type){sb}"; return sb.ToString(); } public static string AliasForName(string name) { for (var i = 0; i < m_AliasLength; ++i) + { if (m_Aliases[i, 0] == name) + { return m_Aliases[i, 1]; + } + } + return name; } @@ -419,10 +462,14 @@ namespace Server.Commands public static bool DontLink(Type type) { if (type.Name == "T" || string.IsNullOrEmpty(type.Namespace) || m_Namespaces == null) + { return true; + } if (type.Namespace.StartsWith("Server")) + { return false; + } return !m_Namespaces.ContainsKey(type.Namespace); } @@ -433,7 +480,10 @@ namespace Server.Commands { var sb = new StringBuilder(name); - for (var i = 0; i < ReplaceChars.Length; ++i) sb.Replace(ReplaceChars[i], '-'); + for (var i = 0; i < ReplaceChars.Length; ++i) + { + sb.Replace(ReplaceChars[i], '-'); + } name = sb.ToString(); } @@ -441,7 +491,10 @@ namespace Server.Commands var index = 0; var file = string.Concat(name, ext); - while (File.Exists(Path.Combine(root, file))) file = string.Concat(name, ++index, ext); + while (File.Exists(Path.Combine(root, file))) + { + file = string.Concat(name, ++index, ext); + } return file; } @@ -451,7 +504,9 @@ namespace Server.Commands path = Path.Combine(m_RootDirectory, path); if (!Directory.Exists(path)) + { Directory.CreateDirectory(path); + } } private static void DeleteDirectory(string path) @@ -459,7 +514,9 @@ namespace Server.Commands path = Path.Combine(m_RootDirectory, path); if (Directory.Exists(path)) + { Directory.Delete(path, true); + } } private static StreamWriter GetWriter(string root, string name) => @@ -477,7 +534,9 @@ namespace Server.Commands if (varType.IsByRef) { if (!ignoreRef) + { prepend = RefString; + } realType = varType.GetElementType(); } @@ -493,7 +552,9 @@ namespace Server.Commands append.Append('['); for (var i = 1; i < realType.GetArrayRank(); ++i) + { append.Append(','); + } append.Append(']'); @@ -515,7 +576,9 @@ namespace Server.Commands append.Append('['); for (var i = 1; i < realType.GetArrayRank(); ++i) + { append.Append(','); + } append.Append(']'); @@ -546,11 +609,13 @@ namespace Server.Commands else { for (var i = 0; i < m_AliasLength; ++i) + { if (m_Aliases[i, 0] == fullName) { aliased = m_Aliases[i, 1]; break; } + } } aliased ??= realType?.Name ?? ""; @@ -590,12 +655,16 @@ namespace Server.Commands var assemblies = new List { Core.Assembly }; foreach (var asm in AssemblyHandler.Assemblies) + { assemblies.Add(asm); + } var asms = assemblies.ToArray(); for (var i = 0; i < asms.Length; ++i) + { LoadTypes(asms[i], asms); + } DocumentLoadedTypes(); DocumentConstructibleObjects(); @@ -795,7 +864,9 @@ namespace Server.Commands for (var mat = BulkMaterialType.None; mat <= BulkMaterialType.Barbed; ++mat) { if (mat >= BulkMaterialType.DullCopper && mat <= BulkMaterialType.Valorite) + { continue; + } sbod.Material = mat; DocumentTailorBOD(html, sbod.ComputeRewards(true), "10, 15", sbod.Material, sbod.Type); @@ -816,7 +887,9 @@ namespace Server.Commands for (var mat = BulkMaterialType.None; mat <= BulkMaterialType.Barbed; ++mat) { if (mat >= BulkMaterialType.DullCopper && mat <= BulkMaterialType.Valorite) + { continue; + } sbod.Material = mat; DocumentTailorBOD(html, sbod.ComputeRewards(true), "20", sbod.Material, sbod.Type); @@ -839,7 +912,9 @@ namespace Server.Commands for (var mat = BulkMaterialType.None; mat <= BulkMaterialType.Barbed; ++mat) { if (mat >= BulkMaterialType.DullCopper && mat <= BulkMaterialType.Valorite) + { continue; + } sbod.Material = mat; DocumentTailorBOD(html, sbod.ComputeRewards(true), "10, 15", sbod.Material, sbod.Type); @@ -860,7 +935,9 @@ namespace Server.Commands for (var mat = BulkMaterialType.None; mat <= BulkMaterialType.Barbed; ++mat) { if (mat >= BulkMaterialType.DullCopper && mat <= BulkMaterialType.Valorite) + { continue; + } sbod.Material = mat; DocumentTailorBOD(html, sbod.ComputeRewards(true), "20", sbod.Material, sbod.Type); @@ -1181,26 +1258,44 @@ namespace Server.Commands else if (item is PowerScroll ps) { if (ps.Value == 105.0) + { rewards[6] = true; + } else if (ps.Value == 110.0) + { rewards[7] = true; + } else if (ps.Value == 115.0) + { rewards[8] = true; + } else if (ps.Value == 120.0) + { rewards[9] = true; + } } else if (item is UncutCloth) { if (item.Hue == 0x483 || item.Hue == 0x48C || item.Hue == 0x488 || item.Hue == 0x48A) + { rewards[0] = true; + } else if (item.Hue == 0x495 || item.Hue == 0x48B || item.Hue == 0x486 || item.Hue == 0x485) + { rewards[1] = true; + } else if (item.Hue == 0x48D || item.Hue == 0x490 || item.Hue == 0x48E || item.Hue == 0x491) + { rewards[2] = true; + } else if (item.Hue == 0x48F || item.Hue == 0x494 || item.Hue == 0x484 || item.Hue == 0x497) + { rewards[3] = true; + } else + { rewards[4] = true; + } } else if (item is RunicSewingKit rkit) { @@ -1254,6 +1349,7 @@ namespace Server.Commands var index = 0; while (index < 20) + { if (rewards[index]) { html.WriteLine("
X
", style); @@ -1269,7 +1365,9 @@ namespace Server.Commands ++index; if (index == 5 || index == 6 || index == 10 || index == 17) + { break; + } } html.WriteLine( @@ -1278,6 +1376,7 @@ namespace Server.Commands count == 1 ? "" : $" colspan=\"{count}\"" ); } + } html.WriteLine(" "); } @@ -1477,13 +1576,21 @@ namespace Server.Commands else if (item is PowerScroll ps) { if (ps.Value == 105.0) + { rewards[8] = true; + } else if (ps.Value == 110.0) + { rewards[9] = true; + } else if (ps.Value == 115.0) + { rewards[10] = true; + } else if (ps.Value == 120.0) + { rewards[11] = true; + } } else if (item is RunicHammer rh) { @@ -1492,13 +1599,21 @@ namespace Server.Commands else if (item is AncientSmithyHammer ash) { if (ash.Bonus == 10) + { rewards[20] = true; + } else if (ash.Bonus == 15) + { rewards[21] = true; + } else if (ash.Bonus == 30) + { rewards[22] = true; + } else if (ash.Bonus == 60) + { rewards[23] = true; + } } item.Delete(); @@ -1557,6 +1672,7 @@ namespace Server.Commands var index = 0; while (index < 24) + { if (rewards[index]) { html.WriteLine("
X
", style); @@ -1572,7 +1688,9 @@ namespace Server.Commands ++index; if (index == 4 || index == 8 || index == 12 || index == 20) + { break; + } } html.WriteLine( @@ -1581,6 +1699,7 @@ namespace Server.Commands count == 1 ? "" : $" colspan=\"{count}\"" ); } + } html.WriteLine(" "); } @@ -1601,7 +1720,9 @@ namespace Server.Commands line = line.Trim(); if (line.Length == 0 || line.StartsWith("#")) + { continue; + } var split = line.Split('\t'); @@ -1614,7 +1735,9 @@ namespace Server.Commands var entry = new BodyEntry(body, type, name); if (!list.Contains(entry)) + { list.Add(entry); + } } } } @@ -1652,7 +1775,9 @@ namespace Server.Commands if (type != lastType) { if (lastType != ModelBodyType.Invalid) + { html.WriteLine("
"); + } lastType = type; @@ -1751,7 +1876,9 @@ namespace Server.Commands for (var j = 0; j < entry.Strings.Count; ++j) { if (j > 0) + { html.Write("
"); + } var v = entry.Strings[j]; @@ -1760,19 +1887,33 @@ namespace Server.Commands var c = v[k]; if (c == '<') + { html.Write("<"); + } else if (c == '>') + { html.Write(">"); + } else if (c == '&') + { html.Write("&"); + } else if (c == '"') + { html.Write("""); + } else if (c == '\'') + { html.Write("'"); + } else if (c >= 0x20 && c < 0x7F) + { html.Write(c); + } else + { html.Write("&#{0};", (int)c); + } } } @@ -1807,20 +1948,28 @@ namespace Server.Commands var text = Encoding.UTF8.GetString(bin.ReadBytes(length)).Trim(); if (text.Length == 0) + { continue; + } if (table == null || lastIndex > index) { if (index == 0 && text == "*withdraw*") + { tables.Insert(0, table = new Dictionary()); + } else + { tables.Add(table = new Dictionary()); + } } lastIndex = index; if (!table.TryGetValue(index, out var entry)) + { table[index] = entry = new SpeechEntry(index); + } entry.Strings.Add(text); } @@ -1858,17 +2007,23 @@ namespace Server.Commands var attrs = mi.GetCustomAttributes(typeof(UsageAttribute), false); if (attrs.Length == 0) + { continue; + } var usage = attrs[0] as UsageAttribute; attrs = mi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attrs.Length == 0) + { continue; + } if (usage == null || !(attrs[0] is DescriptionAttribute desc)) + { continue; + } attrs = mi.GetCustomAttributes(typeof(AliasesAttribute), false); @@ -1877,9 +2032,13 @@ namespace Server.Commands var descString = desc.Description.Replace("<", "<").Replace(">", ">"); if (aliases == null) + { list.Add(new DocCommandEntry(e.AccessLevel, e.Command, null, usage.Usage, descString)); + } else + { list.Add(new DocCommandEntry(e.AccessLevel, e.Command, aliases.Aliases, usage.Usage, descString)); + } } for (var i = 0; i < TargetCommands.AllCommands.Count; ++i) @@ -1890,14 +2049,18 @@ namespace Server.Commands var desc = command.Description; if (usage == null || desc == null) + { continue; + } var cmds = command.Commands; var cmd = cmds[0]; var aliases = new string[cmds.Length - 1]; for (var j = 0; j < aliases.Length; ++j) + { aliases[j] = cmds[j + 1]; + } desc = desc.Replace("<", "<").Replace(">", ">"); @@ -1908,25 +2071,39 @@ namespace Server.Commands sb.Append("Modifiers: "); if ((command.Supports & CommandSupport.Global) != 0) + { sb.Append("Global, "); + } if ((command.Supports & CommandSupport.Online) != 0) + { sb.Append("Online, "); + } if ((command.Supports & CommandSupport.Region) != 0) + { sb.Append("Region, "); + } if ((command.Supports & CommandSupport.Contained) != 0) + { sb.Append("Contained, "); + } if ((command.Supports & CommandSupport.Multi) != 0) + { sb.Append("Multi, "); + } if ((command.Supports & CommandSupport.Area) != 0) + { sb.Append("Area, "); + } if ((command.Supports & CommandSupport.Self) != 0) + { sb.Append("Self, "); + } sb.Remove(sb.Length - 2, 2); sb.Append("
"); @@ -1948,14 +2125,18 @@ namespace Server.Commands var desc = command.Description; if (usage == null || desc == null) + { continue; + } var cmds = command.Accessors; var cmd = cmds[0]; var aliases = new string[cmds.Length - 1]; for (var j = 0; j < aliases.Length; ++j) + { aliases[j] = cmds[j + 1]; + } desc = desc.Replace("<", "<").Replace(">", ">"); @@ -1971,7 +2152,9 @@ namespace Server.Commands if (e.AccessLevel != last) { if (last != AccessLevel.Player) + { html.WriteLine("
"); + } last = e.AccessLevel; @@ -2069,7 +2252,9 @@ namespace Server.Commands for (var i = 0; i < aliases.Length; ++i) { if (i != 0) + { html.Write(", "); + } html.Write(aliases[i]); } @@ -2098,15 +2283,22 @@ namespace Server.Commands var t = types[i].m_Type; if (t.IsAbstract || !IsConstructible(t, out var isItem)) + { continue; + } var ctors = t.GetConstructors(); var anyConstructible = false; for (var j = 0; !anyConstructible && j < ctors.Length; ++j) + { anyConstructible = IsConstructible(ctors[j]); + } - if (anyConstructible) (isItem ? items : mobiles).Add((t, ctors)); + if (anyConstructible) + { + (isItem ? items : mobiles).Add((t, ctors)); + } } using var html = GetWriter("docs/", "objects.html"); @@ -2168,10 +2360,14 @@ namespace Server.Commands var ctor = ctors[i]; if (!IsConstructible(ctor)) + { continue; + } if (!first) + { html.Write("
"); + } first = false; @@ -2184,7 +2380,9 @@ namespace Server.Commands html.Write(" {1}", GetTooltipFor(parms[j]), parms[j].Name); } @@ -2202,7 +2400,9 @@ namespace Server.Commands var checkType = (Type)m_Tooltips[i, 0]; if (paramType == checkType) + { return string.Format((string)m_Tooltips[i, 1], HtmlNewLine); + } } if (paramType.IsEnum) @@ -2214,7 +2414,9 @@ namespace Server.Commands var names = Enum.GetNames(paramType); for (var i = 0; i < names.Length; ++i) + { sb.AppendFormat("{0}- {1}", HtmlNewLine, names[i]); + } return sb.ToString(); } @@ -2232,7 +2434,9 @@ namespace Server.Commands var names = attr.Names; for (var i = 0; i < names.Length; ++i) + { sb.AppendFormat("{0}- {1}", HtmlNewLine, names[i]); + } return sb.ToString(); } @@ -2246,7 +2450,9 @@ namespace Server.Commands var names = Map.GetMapNames(); for (var i = 0; i < names.Length; ++i) + { sb.AppendFormat("{0}- {1}", HtmlNewLine, names[i]); + } return sb.ToString(); } @@ -2266,9 +2472,13 @@ namespace Server.Commands string format; if (flags) + { format = " {0:G} = 0x{1:X}{2}
"; + } else + { format = " {0:G} = {1:D}{2}
"; + } for (var i = 0; i < names.Length; ++i) { @@ -2295,10 +2505,14 @@ namespace Server.Commands m_Types.TryGetValue(decType, out var decInfo); if (decInfo == null) + { typeHtml.Write(decType.Name); + } else // typeHtml.Write( "{1}", decInfo.m_FileName, decInfo.m_TypeName ); + { typeHtml.Write(decInfo.LinkName(null)); + } typeHtml.Write(") - "); } @@ -2317,9 +2531,13 @@ namespace Server.Commands m_Types.TryGetValue(baseType, out var baseInfo); if (baseInfo == null) + { typeHtml.Write(baseType.Name); + } else + { typeHtml.Write($"{baseInfo.LinkName(null)}"); + } ++extendCount; } @@ -2327,7 +2545,9 @@ namespace Server.Commands if (ifaces.Length > 0) { if (extendCount == 0) + { typeHtml.Write(" : "); + } for (var i = 0; i < ifaces.Length; ++i) { @@ -2335,7 +2555,9 @@ namespace Server.Commands m_Types.TryGetValue(iface, out var ifaceInfo); if (extendCount != 0) + { typeHtml.Write(", "); + } ++extendCount; @@ -2366,7 +2588,9 @@ namespace Server.Commands var derivedInfo = derived[i]; if (i != 0) + { typeHtml.Write(", "); + } // typeHtml.Write( "{1}", derivedInfo.m_FileName, derivedInfo.m_TypeName ); typeHtml.Write($"{derivedInfo.LinkName(null)}"); @@ -2388,7 +2612,9 @@ namespace Server.Commands var nestedInfo = nested[i]; if (i != 0) + { typeHtml.Write(", "); + } // typeHtml.Write( "{1}", nestedInfo.m_FileName, nestedInfo.m_TypeName ); typeHtml.Write($"{nestedInfo.LinkName(null)}"); @@ -2409,11 +2635,17 @@ namespace Server.Commands var mi = membs[i]; if (mi is PropertyInfo propertyInfo) + { WriteProperty(propertyInfo, typeHtml); + } else if (mi is ConstructorInfo constructorInfo) + { WriteCtor(info.TypeName, constructorInfo, typeHtml); + } else if (mi is MethodInfo methodInfo) + { WriteMethod(methodInfo, typeHtml); + } } } @@ -2425,16 +2657,22 @@ namespace Server.Commands var setMethod = pi.GetSetMethod(); if (getMethod?.IsStatic == true || setMethod?.IsStatic == true) + { html.Write(StaticString); + } html.Write(GetPair(pi.PropertyType, pi.Name, false)); html.Write('('); if (pi.CanRead) + { html.Write(GetString); + } if (pi.CanWrite) + { html.Write(SetString); + } html.WriteLine(" )
"); } @@ -2442,7 +2680,9 @@ namespace Server.Commands private static void WriteCtor(string name, ConstructorInfo ctor, StreamWriter html) { if (ctor.IsStatic) + { return; + } html.Write(" "); html.Write(CtorString); @@ -2460,12 +2700,18 @@ namespace Server.Commands var pi = parms[i]; if (i != 0) + { html.Write(", "); + } if (pi.IsIn) + { html.Write(InString); + } else if (pi.IsOut) + { html.Write(OutString); + } html.Write(GetPair(pi.ParameterType, pi.Name, pi.IsOut)); } @@ -2479,15 +2725,21 @@ namespace Server.Commands private static void WriteMethod(MethodInfo mi, StreamWriter html) { if (mi.IsSpecialName) + { return; + } html.Write(" "); if (mi.IsStatic) + { html.Write(StaticString); + } if (mi.IsVirtual) + { html.Write(VirtString); + } html.Write(GetPair(mi.ReturnType, mi.Name, false)); html.Write('('); @@ -2503,12 +2755,18 @@ namespace Server.Commands var pi = parms[i]; if (i != 0) + { html.Write(", "); + } if (pi.IsIn) + { html.Write(InString); + } else if (pi.IsOut) + { html.Write(OutString); + } html.Write(GetPair(pi.ParameterType, pi.Name, pi.IsOut)); } @@ -2524,7 +2782,9 @@ namespace Server.Commands public int Compare(object x, object y) { if (x == y) + { return 0; + } var aCtor = x as ConstructorInfo; var bCtor = y as ConstructorInfo; @@ -2539,16 +2799,23 @@ namespace Server.Commands var bStatic = GetStaticFor(bCtor, bProp, bMethod); if (aStatic && !bStatic) + { return -1; + } + if (!aStatic && bStatic) + { return 1; + } var v = 0; if (aCtor != null) { if (bCtor == null) + { v = -1; + } } else if (bCtor != null) { @@ -2557,7 +2824,9 @@ namespace Server.Commands else if (aProp != null) { if (bProp == null) + { v = -1; + } } else if (bProp != null) { @@ -2565,12 +2834,18 @@ namespace Server.Commands } if (v == 0) + { v = GetNameFrom(aCtor, aProp, aMethod).CompareTo(GetNameFrom(bCtor, bProp, bMethod)); + } if (v == 0 && aCtor != null && bCtor != null) + { v = aCtor.GetParameters().Length.CompareTo(bCtor.GetParameters().Length); + } else if (v == 0 && aMethod != null && bMethod != null) + { v = aMethod.GetParameters().Length.CompareTo(bMethod.GetParameters().Length); + } return v; } @@ -2578,9 +2853,14 @@ namespace Server.Commands private bool GetStaticFor(ConstructorInfo ctor, PropertyInfo prop, MethodInfo method) { if (ctor != null) + { return ctor.IsStatic; + } + if (method != null) + { return method.IsStatic; + } if (prop != null) { @@ -2651,7 +2931,11 @@ namespace Server.Commands { public int Compare(SpeechEntry x, SpeechEntry y) { - if (x == null && y == null) return 0; + if (x == null && y == null) + { + return 0; + } + return x?.Index.CompareTo(y?.Index) ?? 1; } } @@ -2682,12 +2966,17 @@ namespace Server.Commands { public int Compare(DocCommandEntry a, DocCommandEntry b) { - if (a == null && b == null) return 0; + if (a == null && b == null) + { + return 0; + } var v = b?.AccessLevel.CompareTo(a?.AccessLevel) ?? 1; if (v != 0) + { return v; + } return a?.Name.CompareTo(b?.Name) ?? 1; } @@ -2733,14 +3022,22 @@ namespace Server.Commands { public int Compare(BodyEntry a, BodyEntry b) { - if (a == null && b == null) return 0; + if (a == null && b == null) + { + return 0; + } + var v = a?.BodyType.CompareTo(b?.BodyType) ?? 1; if (v == 0) + { v = a?.Body.BodyID.CompareTo(b?.Body.BodyID) ?? 1; + } if (v != 0) + { return v; + } return a?.Name.CompareTo(b?.Name) ?? 1; } diff --git a/Projects/UOContent/Commands/Dupe.cs b/Projects/UOContent/Commands/Dupe.cs index 6bb6fb7b0..3d01bf907 100644 --- a/Projects/UOContent/Commands/Dupe.cs +++ b/Projects/UOContent/Commands/Dupe.cs @@ -19,7 +19,10 @@ namespace Server.Commands { var amount = 1; if (e.Length >= 1) + { amount = e.GetInt32(0); + } + e.Mobile.Target = new DupeTarget(false, amount > 0 ? amount : 1); e.Mobile.SendMessage("What do you wish to dupe?"); } @@ -30,7 +33,9 @@ namespace Server.Commands { var amount = 1; if (e.Length >= 1) + { amount = e.GetInt32(0); + } e.Mobile.Target = new DupeTarget(true, amount > 0 ? amount : 1); e.Mobile.SendMessage("What do you wish to dupe?"); @@ -41,14 +46,19 @@ namespace Server.Commands var props = src.GetType().GetProperties(); for (var i = 0; i < props.Length; i++) + { try { - if (props[i].CanRead && props[i].CanWrite) props[i].SetValue(dest, props[i].GetValue(src, null), null); + if (props[i].CanRead && props[i].CanWrite) + { + props[i].SetValue(dest, props[i].GetValue(src, null), null); + } } catch { // Console.WriteLine( "Denied" ); } + } } private class DupeTarget : Target @@ -88,9 +98,13 @@ namespace Server.Commands if (m_InBag) { if (copy.Parent is Container cont) + { pack = cont; + } else if (copy.Parent is Mobile m) + { pack = m.Backpack; + } } else { @@ -102,11 +116,16 @@ namespace Server.Commands { var paramList = c.GetParameters(); var args = paramList.Length == 0 ? null : new object[paramList.Length]; - if (args != null) Array.Fill(args, Type.Missing); + if (args != null) + { + Array.Fill(args, Type.Missing); + } + try { from.SendMessage("Duping {0}...", m_Amount); for (var i = 0; i < m_Amount; i++) + { if (c.Invoke(args) is Item newItem) { CopyProperties(newItem, copy); // copy.Dupe( item, copy.Amount ); @@ -114,21 +133,26 @@ namespace Server.Commands newItem.Parent = null; if (pack != null) + { pack.DropItem(newItem); + } else - newItem.MoveToWorld(from.Location, from.Map); + { + newItem.MoveToWorld(@from.Location, @from.Map); + } newItem.InvalidateProperties(); CommandLogging.WriteLine( - from, + @from, "{0} {1} duped {2} creating {3}", - from.AccessLevel, - CommandLogging.Format(from), + @from.AccessLevel, + CommandLogging.Format(@from), CommandLogging.Format(targ), CommandLogging.Format(newItem) ); } + } from.SendMessage("Done"); done = true; @@ -140,7 +164,10 @@ namespace Server.Commands } } - if (!done) from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor."); + if (!done) + { + @from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor."); + } } } } diff --git a/Projects/UOContent/Commands/ExportWSC.cs b/Projects/UOContent/Commands/ExportWSC.cs index 71e9e203d..67e9c4c52 100644 --- a/Projects/UOContent/Commands/ExportWSC.cs +++ b/Projects/UOContent/Commands/ExportWSC.cs @@ -23,6 +23,7 @@ namespace Server.Commands e.Mobile.SendMessage("This will delete all static items in the world. Please make a backup."); foreach (var item in World.Items.Values) + { if ((item is Static || item is BaseFloor || item is BaseWall) && item.RootParent == null) { @@ -50,11 +51,14 @@ namespace Server.Commands remove.Add(item); w.Flush(); } + } w.Close(); foreach (var item in remove) + { item.Delete(); + } e.Mobile.SendMessage("Export complete. Exported {0} statics.", count); } diff --git a/Projects/UOContent/Commands/Generic/Commands/BaseCommand.cs b/Projects/UOContent/Commands/Generic/Commands/BaseCommand.cs index 14698fd01..9dc2ebe37 100644 --- a/Projects/UOContent/Commands/Generic/Commands/BaseCommand.cs +++ b/Projects/UOContent/Commands/Generic/Commands/BaseCommand.cs @@ -32,14 +32,20 @@ namespace Server.Commands.Generic public static bool IsAccessible(Mobile from, object obj) { if (from.AccessLevel >= AccessLevel.Administrator || obj == null) + { return true; + } Mobile mob = null; if (obj is Mobile m) + { mob = m; + } else if (obj is Item item) + { mob = item.RootParent as Mobile; + } return mob == null || mob == from || from.AccessLevel > mob.AccessLevel; } @@ -47,7 +53,9 @@ namespace Server.Commands.Generic public virtual void ExecuteList(CommandEventArgs e, List list) { for (var i = 0; i < list.Count; ++i) + { Execute(e, list[i]); + } } public virtual void Execute(CommandEventArgs e, object obj) @@ -70,7 +78,9 @@ namespace Server.Commands.Generic } if (m_Responses.Count == 10) + { return; + } m_Responses.Add(new MessageEntry(message)); } @@ -89,7 +99,9 @@ namespace Server.Commands.Generic } if (m_Failures.Count == 10) + { return; + } m_Failures.Add(new MessageEntry(message)); } @@ -97,18 +109,26 @@ namespace Server.Commands.Generic public void Flush(Mobile from, bool flushToLog) { if (m_Responses.Count > 0) + { for (var i = 0; i < m_Responses.Count; ++i) { var entry = m_Responses[i]; - from.SendMessage(entry.ToString()); + @from.SendMessage(entry.ToString()); if (flushToLog) - CommandLogging.WriteLine(from, entry.ToString()); + { + CommandLogging.WriteLine(@from, entry.ToString()); + } } + } else + { for (var i = 0; i < m_Failures.Count; ++i) - from.SendMessage(m_Failures[i].ToString()); + { + @from.SendMessage(m_Failures[i].ToString()); + } + } m_Responses.Clear(); m_Failures.Clear(); diff --git a/Projects/UOContent/Commands/Generic/Commands/Commands.cs b/Projects/UOContent/Commands/Generic/Commands/Commands.cs index c5c80a450..fd3edeb15 100644 --- a/Projects/UOContent/Commands/Generic/Commands/Commands.cs +++ b/Projects/UOContent/Commands/Generic/Commands/Commands.cs @@ -80,7 +80,9 @@ namespace Server.Commands.Generic var impl = impls[i]; if ((command.Supports & impl.SupportRequirement) != 0) + { impl.Register(command); + } } } } @@ -106,10 +108,16 @@ namespace Server.Commands.Generic var condition = ObjectConditional.Parse(e.Mobile, ref args); for (var i = 0; i < list.Count; ++i) + { if (condition.CheckCondition(list[i])) + { AddResponse("True - that object matches the condition."); + } else + { AddResponse("False - that object does not match the condition."); + } + } } catch (Exception ex) { @@ -135,9 +143,13 @@ namespace Server.Commands.Generic if (obj is Item item) { if (e.Mobile.PlaceInBackpack(item)) + { AddResponse("The item has been placed in your backpack."); + } else + { AddResponse("Your backpack could not hold the item."); + } } } } @@ -194,9 +206,13 @@ namespace Server.Commands.Generic public override void ExecuteList(CommandEventArgs e, List list) { if (list.Count == 1) + { AddResponse("There is one matching object."); + } else + { AddResponse($"There are {list.Count} matching objects."); + } } } @@ -217,14 +233,18 @@ namespace Server.Commands.Generic if (okay) { if (echo) - gm.SendMessage("{0} : has opened their web browser to : {1}", from.Name, url); + { + gm.SendMessage("{0} : has opened their web browser to : {1}", @from.Name, url); + } from.LaunchBrowser(url); } else { if (echo) - gm.SendMessage("{0} : has chosen not to open their web browser to : {1}", from.Name, url); + { + gm.SendMessage("{0} : has chosen not to open their web browser to : {1}", @from.Name, url); + } from.SendMessage("You have chosen not to open your web browser."); } @@ -259,9 +279,13 @@ namespace Server.Commands.Generic ); if (echo) + { AddResponse("Awaiting user confirmation..."); + } else + { AddResponse("Open web browser request sent."); + } mob.SendGump( new WarningGump( @@ -295,7 +319,9 @@ namespace Server.Commands.Generic public override void ExecuteList(CommandEventArgs e, List list) { for (var i = 0; i < list.Count; ++i) + { Execute(e, list[i], false); + } } } @@ -324,9 +350,13 @@ namespace Server.Commands.Generic if (result == "The property has been increased." || result == "The properties have been increased." || result == "The property has been decreased." || result == "The properties have been decreased." || result == "The properties have been changed.") + { AddResponse(result); + } else + { LogFailure(result); + } } else { @@ -415,9 +445,13 @@ namespace Server.Commands.Generic ); if (m_InGump) - mob.SendGump(new MessageSentGump(mob, from.Name, e.ArgString)); + { + mob.SendGump(new MessageSentGump(mob, @from.Name, e.ArgString)); + } else + { mob.SendMessage(e.ArgString); + } } } @@ -438,7 +472,9 @@ namespace Server.Commands.Generic public override void ExecuteList(CommandEventArgs e, List list) { if (e.Arguments.Length == 0) + { return; + } var packs = new List(list.Count); @@ -448,14 +484,22 @@ namespace Server.Commands.Generic Container cont = null; if (obj is Mobile mobile) + { cont = mobile.Backpack; + } else if (obj is Container container) + { cont = container; + } if (cont != null) + { packs.Add(cont); + } else + { LogFailure("That is not a container."); + } } Add.Invoke(e.Mobile, e.Mobile.Location, e.Mobile.Location, e.Arguments, packs); @@ -513,12 +557,18 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { if (!(obj is IPoint3D p)) + { return; + } if (p is Item item) + { p = item.GetWorldTop(); + } else if (p is Mobile m) + { p = m.Location; + } Add.Invoke(e.Mobile, new Point3D(p), new Point3D(p), e.Arguments); } @@ -539,7 +589,9 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { if (!(obj is IPoint3D p)) + { return; + } var from = e.Mobile; @@ -617,7 +669,9 @@ namespace Server.Commands.Generic } if (mob.Items.IndexOf(item) == -1) + { --i; + } } } @@ -634,9 +688,13 @@ namespace Server.Commands.Generic } if (takenAction) + { AddResponse("They have been dismounted."); + } else + { LogFailure("They were not mounted."); + } } } @@ -698,9 +756,13 @@ namespace Server.Commands.Generic var type = obj.GetType(); if (type.DeclaringType == null) + { AddResponse($"The type of that object is {type.Name}."); + } else + { AddResponse($"The type of that object is {type.FullName}."); + } } } } @@ -720,18 +782,26 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { if (e.Length >= 1) + { for (var i = 0; i < e.Length; ++i) { var result = Properties.GetValue(e.Mobile, obj, e.GetString(i)); if (result == "Property not found." || result == "Property is write only." || result.StartsWith("Getting this property")) + { LogFailure(result); + } else + { AddResponse(result); + } } + } else + { LogFailure("Format: Get "); + } } } @@ -748,11 +818,17 @@ namespace Server.Commands.Generic AccessLevel = level; if (objects == ObjectTypes.Items) + { Supports = CommandSupport.AllItems; + } else if (objects == ObjectTypes.Mobiles) + { Supports = CommandSupport.AllMobiles; + } else + { Supports = CommandSupport.All; + } Commands = new[] { command }; ObjectTypes = objects; @@ -765,9 +841,13 @@ namespace Server.Commands.Generic var result = Properties.SetValue(e.Mobile, obj, m_Name, m_Value); if (result == "Property has been set.") + { AddResponse(result); + } else + { LogFailure(result); + } } } @@ -786,17 +866,25 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { if (e.Length >= 2) + { for (var i = 0; i + 1 < e.Length; i += 2) { var result = Properties.SetValue(e.Mobile, obj, e.GetString(i), e.GetString(i + 1)); if (result == "Property has been set.") + { AddResponse(result); + } else + { LogFailure(result); + } } + } else + { LogFailure("Format: Set "); + } } } @@ -1055,9 +1143,13 @@ namespace Server.Commands.Generic m.Hidden = m_Value; if (m_Value) + { AddResponse("They have been hidden."); + } else + { AddResponse("They have been revealed."); + } } } @@ -1195,7 +1287,9 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { if (!(obj is Item item)) + { return; + } if (!item.IsLockedDown && !item.IsSecure) { @@ -1204,11 +1298,13 @@ namespace Server.Commands.Generic } foreach (var house in BaseHouse.AllHouses) + { if (house.HasSecureItem(item) || house.HasLockedDownItem(item)) { e.Mobile.SendGump(new PropertiesGump(e.Mobile, house)); return; } + } LogFailure("No house was found."); } diff --git a/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs b/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs index 4de111399..b0c312b09 100644 --- a/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs +++ b/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs @@ -36,19 +36,25 @@ namespace Server.Commands.Generic house = null; if (item == null || item is BaseMulti || item is HouseSign || staticsOnly && !(item is Static)) + { return DesignInsertResult.InvalidItem; + } house = BaseHouse.FindHouseAt(item) as HouseFoundation; if (house == null) + { return DesignInsertResult.NotInHouse; + } var x = item.X - house.X; var y = item.Y - house.Y; var z = item.Z - house.Z; if (!TryInsertIntoState(house.CurrentState, item.ItemID, x, y, z)) + { return DesignInsertResult.OutsideHouseBounds; + } TryInsertIntoState(house.DesignState, item.ItemID, x, y, z); item.Delete(); @@ -61,7 +67,9 @@ namespace Server.Commands.Generic var mcl = state.Components; if (x < mcl.Min.X || y < mcl.Min.Y || x > mcl.Max.X || y > mcl.Max.Y) + { return false; + } mcl.Add(itemID, x, y, z); state.OnRevised(); @@ -112,7 +120,9 @@ namespace Server.Commands.Generic AddResponse("The item has been inserted into the house design."); if (!foundations.Contains(house)) + { foundations.Add(house); + } break; } @@ -131,7 +141,9 @@ namespace Server.Commands.Generic } foreach (var house in foundations) + { house.Delta(ItemDelta.Update); + } } else { @@ -160,7 +172,9 @@ namespace Server.Commands.Generic from.SendMessage("Your changes have been committed. Updating..."); foreach (var house in m_Foundations) + { house.Delta(ItemDelta.Update); + } } } @@ -173,14 +187,20 @@ namespace Server.Commands.Generic case DesignInsertResult.Valid: { if (m_Foundations.Count == 0) - from.SendMessage( + { + @from.SendMessage( "The item has been inserted into the house design. Press ESC when you are finished." ); + } else - from.SendMessage("The item has been inserted into the house design."); + { + @from.SendMessage("The item has been inserted into the house design."); + } if (!m_Foundations.Contains(house)) + { m_Foundations.Add(house); + } break; } diff --git a/Projects/UOContent/Commands/Generic/Commands/Interface.cs b/Projects/UOContent/Commands/Generic/Commands/Interface.cs index 4b49fc921..6c6c78cfd 100644 --- a/Projects/UOContent/Commands/Generic/Commands/Interface.cs +++ b/Projects/UOContent/Commands/Generic/Commands/Interface.cs @@ -29,10 +29,14 @@ namespace Server.Commands.Generic var offset = 0; if (Insensitive.Equals(e.GetString(0), "view")) + { ++offset; + } while (offset < e.Length) + { columns.Add(e.GetString(offset++)); + } } e.Mobile.SendGump(new InterfaceGump(e.Mobile, columns.ToArray(), list, 0, null)); @@ -75,9 +79,13 @@ namespace Server.Commands.Generic AddNewPage(); if (m_Page > 0) + { AddEntryButton(20, ArrowLeftID1, ArrowLeftID2, 1, ArrowLeftWidth, ArrowLeftHeight); + } else + { AddEntryHeader(20); + } AddEntryHtml( 40 + m_Columns.Length * 130 - 20 + (m_Columns.Length - 2) * OffsetSize, @@ -87,9 +95,13 @@ namespace Server.Commands.Generic ); if ((m_Page + 1) * EntriesPerPage < m_List.Count) + { AddEntryButton(20, ArrowRightID1, ArrowRightID2, 2, ArrowRightWidth, ArrowRightHeight); + } else + { AddEntryHeader(20); + } if (m_Columns.Length > 1) { @@ -119,7 +131,9 @@ namespace Server.Commands.Generic for (var j = 0; j < chain.Length; ++j) { if (j > 0) + { m_Columns[i] += '.'; + } m_Columns[i] += chain[j].Name; } @@ -143,12 +157,16 @@ namespace Server.Commands.Generic if (obj is Item item) { if (!(isDeleted = item.Deleted)) + { AddEntryHtml(40 + 130, item.GetType().Name); + } } else if (obj is Mobile mob) { if (!(isDeleted = mob.Deleted)) + { AddEntryHtml(40 + 130, mob.Name); + } } if (isDeleted) @@ -156,7 +174,9 @@ namespace Server.Commands.Generic AddEntryHtml(40 + 130, "(deleted)"); for (var j = 1; j < m_Columns.Length; ++j) + { AddEntryHtml(130, "---"); + } AddEntryHeader(20); } @@ -186,9 +206,13 @@ namespace Server.Commands.Generic var p = Properties.GetPropertyInfo(ref src, chain, ref failReason); if (p == null) + { value = "---"; + } else + { value = PropertiesGump.ValueToString(src, p); + } } AddEntryHtml(130, value); @@ -217,14 +241,18 @@ namespace Server.Commands.Generic case 1: { if (m_Page > 0) + { m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page - 1, m_Select)); + } break; } case 2: { if ((m_Page + 1) * EntriesPerPage < m_List.Count) + { m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page + 1, m_Select)); + } break; } @@ -244,11 +272,17 @@ namespace Server.Commands.Generic } if (obj is Item item && !item.Deleted) + { m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, item)); + } else if (obj is Mobile mobile && !mobile.Deleted) + { m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, mobile)); + } else + { m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select)); + } } break; @@ -561,7 +595,9 @@ namespace Server.Commands.Generic case 7: // Kill { if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) + { m_Mobile.Kill(); + } m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); @@ -586,7 +622,9 @@ namespace Server.Commands.Generic m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); if (m_Mobile.NetState != null) + { m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState)); + } break; } diff --git a/Projects/UOContent/Commands/Generic/Extensions/BaseExtension.cs b/Projects/UOContent/Commands/Generic/Extensions/BaseExtension.cs index 9a339d355..74808f9f8 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/BaseExtension.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/BaseExtension.cs @@ -41,8 +41,12 @@ namespace Server.Commands.Generic public bool IsValid(object obj) { for (var i = 0; i < Count; ++i) + { if (!this[i].IsValid(obj)) + { return false; + } + } return true; } @@ -50,7 +54,9 @@ namespace Server.Commands.Generic public void Filter(List list) { for (var i = 0; i < Count; ++i) + { this[i].Filter(list); + } } public static Extensions Parse(Mobile from, ref string[] args) @@ -64,17 +70,23 @@ namespace Server.Commands.Generic for (var i = args.Length - 1; i >= 0; --i) { if (!ExtensionInfo.Table.TryGetValue(args[i], out var extInfo)) + { continue; + } if (extInfo.IsFixedSize && i != size - extInfo.Size - 1) + { throw new Exception("Invalid extended argument count."); + } var ext = extInfo.Constructor(); ext.Parse(from, args, i + 1, size - i - 1); if (ext is WhereExtension extension) + { baseType = extension.Conditional.Type; + } parsed.Add(ext); @@ -86,7 +98,9 @@ namespace Server.Commands.Generic AssemblyEmitter emitter = null; foreach (var update in parsed) - update.Optimize(from, baseType, ref emitter); + { + update.Optimize(@from, baseType, ref emitter); + } if (size != args.Length) { @@ -94,7 +108,9 @@ namespace Server.Commands.Generic args = new string[size]; for (var i = 0; i < args.Length; ++i) + { args[i] = old[i]; + } } return parsed; diff --git a/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs b/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs index ae4521178..25d9c3e5c 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs @@ -69,30 +69,50 @@ namespace Server.Commands.Generic else { if (Value is int i) + { method.Load(i); + } else if (Value is long l) + { method.Load(l); + } else if (Value is float f) + { method.Load(f); + } else if (Value is double d) + { method.Load(d); + } else if (Value is char c) + { method.Load(c); + } else if (Value is bool b) + { method.Load(b); + } else if (Value is string s) + { method.Load(s); + } else if (Value is Enum e) + { method.Load(e); + } else + { throw new InvalidOperationException("Unrecognized comparison value."); + } } } public void Acquire(TypeBuilder typeBuilder, ILGenerator il, string fieldName) { if (!(Value is string toParse)) + { return; + } if (!Type.IsValueType && toParse == "null") { @@ -101,7 +121,9 @@ namespace Server.Commands.Generic else if (Type == typeof(string)) { if (toParse == @"@""null""") + { toParse = "null"; + } Value = toParse; } @@ -169,7 +191,9 @@ namespace Server.Commands.Generic il.Emit(OpCodes.Ldstr, toParse); if (parseArgs.Length == 2) // dirty evil hack :-( + { il.Emit(OpCodes.Ldc_I4, (int)parseArgs[1]); + } il.Emit(OpCodes.Call, parseMethod); il.Emit(OpCodes.Stfld, Field); @@ -330,7 +354,9 @@ namespace Server.Commands.Generic } if (m_Not != inverse) + { emitter.LogicalNot(); + } } } @@ -437,7 +463,9 @@ namespace Server.Commands.Generic } if (m_Not != inverse) + { emitter.LogicalNot(); + } } } @@ -464,7 +492,9 @@ namespace Server.Commands.Generic il.Emit(OpCodes.Call, typeof(object).GetConstructor(Type.EmptyTypes)); for (var i = 0; i < conditions.Length; ++i) + { conditions[i].Construct(typeBuilder, il, i); + } // return; il.Emit(OpCodes.Ret); diff --git a/Projects/UOContent/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs b/Projects/UOContent/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs index fc86e8651..fade103e3 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs @@ -94,7 +94,9 @@ namespace Server.Commands.Generic ); if (!couldCompare) + { throw new InvalidOperationException("Property is not comparable."); + } emitter.StoreLocal(v); } @@ -225,7 +227,9 @@ namespace Server.Commands.Generic } if (i > 0) + { emitter.Xor(); + } } emitter.Return(); diff --git a/Projects/UOContent/Commands/Generic/Extensions/Compilers/SortCompiler.cs b/Projects/UOContent/Commands/Generic/Extensions/Compilers/SortCompiler.cs index 9cba852f8..da890e15d 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/Compilers/SortCompiler.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/Compilers/SortCompiler.cs @@ -39,7 +39,9 @@ namespace Server.Commands.Generic m_Order = Math.Sign(value); if (m_Order == 0) + { throw new InvalidOperationException("Sign cannot be zero."); + } } } } @@ -133,7 +135,9 @@ namespace Server.Commands.Generic ); if (!couldCompare) + { throw new InvalidOperationException("Property is not comparable."); + } emitter.StoreLocal(v); } diff --git a/Projects/UOContent/Commands/Generic/Extensions/DistinctExtension.cs b/Projects/UOContent/Commands/Generic/Extensions/DistinctExtension.cs index b92311113..889ee6d48 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/DistinctExtension.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/DistinctExtension.cs @@ -24,7 +24,9 @@ namespace Server.Commands.Generic public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly) { if (baseType == null) + { throw new Exception("Distinct extension may only be used in combination with an object conditional."); + } foreach (var prop in m_Properties) { @@ -40,7 +42,9 @@ namespace Server.Commands.Generic public override void Parse(Mobile from, string[] arguments, int offset, int size) { if (size < 1) + { throw new Exception("Invalid distinction syntax."); + } var end = offset + size; @@ -55,7 +59,9 @@ namespace Server.Commands.Generic public override void Filter(List list) { if (m_Comparer == null) + { throw new InvalidOperationException("The extension must first be optimized."); + } var copy = new List(list); diff --git a/Projects/UOContent/Commands/Generic/Extensions/LimitExtension.cs b/Projects/UOContent/Commands/Generic/Extensions/LimitExtension.cs index f70068687..dfcd341a8 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/LimitExtension.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/LimitExtension.cs @@ -21,13 +21,17 @@ namespace Server.Commands.Generic Limit = Utility.ToInt32(arguments[offset]); if (Limit < 0) + { throw new Exception("Limit cannot be less than zero."); + } } public override void Filter(List list) { if (list.Count > Limit) + { list.RemoveRange(Limit, list.Count - Limit); + } } } } diff --git a/Projects/UOContent/Commands/Generic/Extensions/SortExtension.cs b/Projects/UOContent/Commands/Generic/Extensions/SortExtension.cs index 13dc5096c..99a0c53a2 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/SortExtension.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/SortExtension.cs @@ -23,7 +23,9 @@ namespace Server.Commands.Generic public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly) { if (baseType == null) + { throw new Exception("The ordering extension may only be used in combination with an object conditional."); + } foreach (var order in m_Orders) { @@ -39,7 +41,9 @@ namespace Server.Commands.Generic public override void Parse(Mobile from, string[] arguments, int offset, int size) { if (size < 1) + { throw new Exception("Invalid ordering syntax."); + } if (Insensitive.Equals(arguments[offset], "by")) { @@ -47,7 +51,9 @@ namespace Server.Commands.Generic --size; if (size < 1) + { throw new Exception("Invalid ordering syntax."); + } } var end = offset + size; @@ -91,7 +97,9 @@ namespace Server.Commands.Generic public override void Filter(List list) { if (m_Comparer == null) + { throw new InvalidOperationException("The extension must first be optimized."); + } list.Sort(m_Comparer); } diff --git a/Projects/UOContent/Commands/Generic/Extensions/WhereExtension.cs b/Projects/UOContent/Commands/Generic/Extensions/WhereExtension.cs index 0703f855a..dc06ccb3b 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/WhereExtension.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/WhereExtension.cs @@ -18,7 +18,9 @@ namespace Server.Commands.Generic public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly) { if (baseType == null) + { throw new InvalidOperationException("Insanity."); + } Conditional.Compile(ref assembly); } @@ -26,7 +28,9 @@ namespace Server.Commands.Generic public override void Parse(Mobile from, string[] arguments, int offset, int size) { if (size < 1) + { throw new Exception("Invalid condition syntax."); + } Conditional = ObjectConditional.ParseDirect(from, arguments, offset, size); } diff --git a/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs index 306a0ed8d..e10ed2c79 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs @@ -34,18 +34,26 @@ namespace Server.Commands.Generic var ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out var items, out var mobiles)) + { return; + } if (!(items || mobiles)) + { return; + } var eable = map.GetObjectsInBounds(rect, items, mobiles); var objs = new List(); foreach (var obj in eable) - if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj)) + { + if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(@from, obj) && ext.IsValid(obj)) + { objs.Add(obj); + } + } eable.Free(); ext.Filter(objs); diff --git a/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs index b8d8a07df..9e4321a90 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/BaseCommandImplementor.cs @@ -86,7 +86,9 @@ namespace Server.Commands.Generic public virtual void Register(BaseCommand command) { for (var i = 0; i < command.Commands.Length; ++i) + { Commands[command.Commands[i]] = command; + } } public bool CheckObjectTypes(Mobile from, BaseCommand command, Extensions ext, out bool items, out bool mobiles) @@ -96,12 +98,14 @@ namespace Server.Commands.Generic var cond = ObjectConditional.Empty; foreach (var check in ext) + { if (check is WhereExtension extension) { cond = extension.Conditional; break; } + } var condIsItem = cond.IsItem; var condIsMobile = cond.IsMobile; @@ -112,10 +116,14 @@ namespace Server.Commands.Generic case ObjectTypes.Both: { if (condIsItem) + { items = true; + } if (condIsMobile) + { mobiles = true; + } break; } @@ -171,7 +179,9 @@ namespace Server.Commands.Generic public string GenerateArgString(string[] args) { if (args.Length == 0) + { return ""; + } // NOTE: this does not preserve the case where quotation marks are used on a single word @@ -180,7 +190,9 @@ namespace Server.Commands.Generic for (var i = 0; i < args.Length; ++i) { if (i > 0) + { sb.Append(' '); + } if (args[i].IndexOf(' ') >= 0) { @@ -204,16 +216,22 @@ namespace Server.Commands.Generic var e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args); if (!command.ValidateArgs(this, e)) + { return; + } var flushToLog = false; if (obj is List list) { if (list.Count > 20) + { CommandLogging.Enabled = false; + } else if (list.Count == 0) + { command.LogFailure("Nothing was found to use this command on."); + } command.ExecuteList(e, list); @@ -226,9 +244,13 @@ namespace Server.Commands.Generic else if (obj != null) { if (command.ListOptimized) + { command.ExecuteList(e, new List { obj }); + } else + { command.Execute(e, obj); + } } command.Flush(from, flushToLog); @@ -264,7 +286,9 @@ namespace Server.Commands.Generic var args = new string[oldArgs.Length - 1]; for (var i = 0; i < args.Length; ++i) + { args[i] = oldArgs[i + 1]; + } Process(e.Mobile, command, args); } @@ -278,10 +302,14 @@ namespace Server.Commands.Generic public void Register() { if (Accessors == null) + { return; + } for (var i = 0; i < Accessors.Length; ++i) + { CommandSystem.Register(Accessors[i], AccessLevel, Execute); + } } public static void Register(BaseCommandImplementor impl) diff --git a/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs index 15373dd1d..a9d79adf8 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs @@ -20,13 +20,15 @@ namespace Server.Commands.Generic public override void Process(Mobile from, BaseCommand command, string[] args) { if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args))) - from.BeginTarget( + { + @from.BeginTarget( -1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None, (m, targeted, a) => OnTarget(m, targeted, command, a), args ); + } } public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args) @@ -38,7 +40,9 @@ namespace Server.Commands.Generic } if (command.ObjectTypes == ObjectTypes.Mobiles) + { return; // sanity check + } if (!(targeted is Container cont)) { @@ -51,7 +55,9 @@ namespace Server.Commands.Generic var ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out var items, out var _)) + { return; + } if (!items) { @@ -62,8 +68,12 @@ namespace Server.Commands.Generic var list = new List(); foreach (var item in cont.FindItemsByType()) + { if (ext.IsValid(item)) + { list.Add(item); + } + } ext.Filter(list); diff --git a/Projects/UOContent/Commands/Generic/Implementors/FacetCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/FacetCommandImplementor.cs index 8726155fa..2497dcb68 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/FacetCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/FacetCommandImplementor.cs @@ -18,12 +18,16 @@ namespace Server.Commands.Generic var impl = AreaCommandImplementor.Instance; if (impl == null) + { return; + } var map = from.Map; if (map == null || map == Map.Internal) + { return; + } impl.OnTarget(from, map, Point3D.Zero, new Point3D(map.Width - 1, map.Height - 1, 0), command, args); } diff --git a/Projects/UOContent/Commands/Generic/Implementors/GlobalCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/GlobalCommandImplementor.cs index 628c6bfd2..af0ca419f 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/GlobalCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/GlobalCommandImplementor.cs @@ -23,19 +23,33 @@ namespace Server.Commands.Generic var ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out var items, out var mobiles)) + { return; + } var list = new List(); if (items) + { foreach (var item in World.Items.Values) + { if (ext.IsValid(item)) + { list.Add(item); + } + } + } if (mobiles) + { foreach (var mob in World.Mobiles.Values) + { if (ext.IsValid(mob)) + { list.Add(mob); + } + } + } ext.Filter(list); diff --git a/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs index b9a85fd02..8af8c9c1b 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/IPAddressCommandImplementor.cs @@ -25,7 +25,9 @@ namespace Server.Commands.Generic var ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles)) + { return; + } if (!mobiles) // sanity check { diff --git a/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs index 000121a21..aad5cedd7 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs @@ -16,13 +16,15 @@ namespace Server.Commands.Generic public override void Process(Mobile from, BaseCommand command, string[] args) { if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args))) - from.BeginTarget( + { + @from.BeginTarget( -1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None, (m, targeted, a) => OnTarget(m, targeted, command, a), args ); + } } public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args) diff --git a/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs b/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs index cd60c7a45..f3a3e59a9 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/ObjectConditional.cs @@ -35,13 +35,17 @@ namespace Server.Commands.Generic m_Conditionals = new IConditional[m_Conditions.Length]; for (var i = 0; i < m_Conditionals.Length; ++i) + { m_Conditionals[i] = ConditionalCompiler.Compile(emitter, Type, m_Conditions[i], i); + } } public bool CheckCondition(object obj) { if (Type == null) + { return true; // null type means no condition + } if (!HasCompiled) { @@ -51,8 +55,12 @@ namespace Server.Commands.Generic } for (var i = 0; i < m_Conditionals.Length; ++i) + { if (m_Conditionals[i].Verify(obj)) + { return true; + } + } return false; // all conditions false } @@ -62,6 +70,7 @@ namespace Server.Commands.Generic string[] conditionArgs = null; for (var i = 0; i < args.Length; ++i) + { if (Insensitive.Equals(args[i], "where")) { var origArgs = args; @@ -69,15 +78,20 @@ namespace Server.Commands.Generic args = new string[i]; for (var j = 0; j < args.Length; ++j) + { args[j] = origArgs[j]; + } conditionArgs = new string[origArgs.Length - i - 1]; for (var j = 0; j < conditionArgs.Length; ++j) + { conditionArgs[j] = origArgs[i + j + 1]; + } break; } + } return ParseDirect(from, conditionArgs, 0, conditionArgs?.Length ?? 0); } @@ -85,14 +99,18 @@ namespace Server.Commands.Generic public static ObjectConditional ParseDirect(Mobile from, string[] args, int offset, int size) { if (args == null || size == 0) + { return Empty; + } var index = 0; var objectType = AssemblyHandler.FindFirstTypeForName(args[offset + index], true); if (objectType == null) + { throw new Exception($"No type with that name ({args[offset + index]}) was found."); + } ++index; @@ -113,7 +131,9 @@ namespace Server.Commands.Generic ++index; if (index >= size) + { throw new Exception("Improperly formatted object conditional."); + } } else if (Insensitive.Equals(cur, "or") || cur == "||") { @@ -134,13 +154,17 @@ namespace Server.Commands.Generic index++; if (index >= size) + { throw new Exception("Improperly formatted object conditional."); + } var oper = args[offset + index]; index++; if (index >= size) + { throw new Exception("Improperly formatted object conditional."); + } var val = args[offset + index]; index++; @@ -181,7 +205,9 @@ namespace Server.Commands.Generic }; if (condition == null) + { throw new InvalidOperationException($"Unrecognized operator (\"{oper}\")."); + } current.Add(condition); } diff --git a/Projects/UOContent/Commands/Generic/Implementors/OnlineCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/OnlineCommandImplementor.cs index 476b74244..0dda6f751 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/OnlineCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/OnlineCommandImplementor.cs @@ -24,7 +24,9 @@ namespace Server.Commands.Generic var ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles)) + { return; + } if (!mobiles) // sanity check { @@ -42,13 +44,19 @@ namespace Server.Commands.Generic var mob = ns.Mobile; if (mob == null) + { continue; + } if (!BaseCommand.IsAccessible(from, mob)) + { continue; + } if (ext.IsValid(mob)) + { list.Add(mob); + } } ext.Filter(list); diff --git a/Projects/UOContent/Commands/Generic/Implementors/RangeCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/RangeCommandImplementor.cs index f163bcb75..bdeff52c9 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/RangeCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/RangeCommandImplementor.cs @@ -47,7 +47,9 @@ namespace Server.Commands.Generic var args = new string[oldArgs.Length - 2]; for (var i = 0; i < args.Length; ++i) + { args[i] = oldArgs[i + 2]; + } Process(range, e.Mobile, command, args); } @@ -64,12 +66,16 @@ namespace Server.Commands.Generic var impl = AreaCommandImplementor.Instance; if (impl == null) + { return; + } var map = from.Map; if (map == null || map == Map.Internal) + { return; + } var start = new Point3D(from.X - range, from.Y - range, from.Z); var end = new Point3D(from.X + range, from.Y + range, from.Z); diff --git a/Projects/UOContent/Commands/Generic/Implementors/RegionCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/RegionCommandImplementor.cs index 2e657185e..03a629a9e 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/RegionCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/RegionCommandImplementor.cs @@ -23,7 +23,9 @@ namespace Server.Commands.Generic var ext = Extensions.Parse(from, ref args); if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles)) + { return; + } var reg = from.Region; @@ -34,10 +36,14 @@ namespace Server.Commands.Generic foreach (var mob in reg.GetMobiles()) { if (!BaseCommand.IsAccessible(from, mob)) + { continue; + } if (ext.IsValid(mob)) + { list.Add(mob); + } } } else diff --git a/Projects/UOContent/Commands/Generic/Implementors/SelfCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/SelfCommandImplementor.cs index fab269b62..e9bc35d5f 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/SelfCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/SelfCommandImplementor.cs @@ -14,7 +14,9 @@ namespace Server.Commands.Generic public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj) { if (command.ObjectTypes == ObjectTypes.Items) + { return; // sanity check + } obj = from; } diff --git a/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs index 51daa43ee..af9392e76 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs @@ -20,9 +20,13 @@ namespace Server.Commands.Generic object obj = null; if (serial.IsItem) + { obj = World.FindItem(serial); + } else if (serial.IsMobile) + { obj = World.FindMobile(serial); + } if (obj == null) { @@ -72,7 +76,9 @@ namespace Server.Commands.Generic var args = new string[oldArgs.Length - 2]; for (var i = 0; i < args.Length; ++i) + { args[i] = oldArgs[i + 2]; + } RunCommand(e.Mobile, obj, command, args); } diff --git a/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs index e05511660..3e3b810ec 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs @@ -19,7 +19,9 @@ namespace Server.Commands.Generic base.Register(command); for (var i = 0; i < command.Commands.Length; ++i) + { CommandSystem.Register(command.Commands[i], command.AccessLevel, Redirect); + } } public void Redirect(CommandEventArgs e) @@ -27,23 +29,31 @@ namespace Server.Commands.Generic Commands.TryGetValue(e.Command, out var command); if (command == null) + { e.Mobile.SendMessage("That is either an invalid command name or one that does not support this modifier."); + } else if (e.Mobile.AccessLevel < command.AccessLevel) + { e.Mobile.SendMessage("You do not have access to that command."); + } else if (command.ValidateArgs(this, e)) + { Process(e.Mobile, command, e.Arguments); + } } public override void Process(Mobile from, BaseCommand command, string[] args) { if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args))) - from.BeginTarget( + { + @from.BeginTarget( -1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None, (m, targeted, a) => OnTarget(m, targeted, command, a), args ); + } } public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args) diff --git a/Projects/UOContent/Commands/Handlers.cs b/Projects/UOContent/Commands/Handlers.cs index 921363c99..d80c5fe59 100644 --- a/Projects/UOContent/Commands/Handlers.cs +++ b/Projects/UOContent/Commands/Handlers.cs @@ -161,17 +161,25 @@ namespace Server.Commands var pe = PageQueue.GetEntry(targ); if (pe?.Handler == from) - from.SendMessage("You may only use this command if you are handling their help page."); + { + @from.SendMessage("You may only use this command if you are handling their help page."); + } else - from.SendMessage("You may only use this command on someone who has paged you."); + { + @from.SendMessage("You may only use this command on someone who has paged you."); + } return; } if (targ.AddToBackpack(held)) - from.SendMessage("The item they were holding has been placed into their backpack."); + { + @from.SendMessage("The item they were holding has been placed into their backpack."); + } else - from.SendMessage("The item they were holding has been placed at their feet."); + { + @from.SendMessage("The item they were holding has been placed at their feet."); + } held.ClearBounce(); @@ -201,7 +209,9 @@ namespace Server.Commands NetState.Pause(); for (var i = 0; i < list.Count; ++i) + { list[i].Delete(); + } NetState.Resume(); @@ -229,12 +239,20 @@ namespace Server.Commands var list = new List(); foreach (var item in World.Items.Values) + { if (item.Map == map && item.Parent == null) + { list.Add(item); + } + } foreach (var m in World.Mobiles.Values) + { if (m.Map == map && !m.Player) + { list.Add(m); + } + } if (list.Count > 0) { @@ -297,7 +315,9 @@ namespace Server.Commands var pet = pets[i]; if (pet is IMount mount) + { mount.Rider = null; // make sure it's dismounted + } pet.MoveToWorld(from.Location, from.Map); } @@ -312,9 +332,15 @@ namespace Server.Commands var pets = new List(); foreach (var m in World.Mobiles.Values) + { if (m is BaseCreature bc) + { if (bc.Controlled && bc.ControlMaster == master || bc.Summoned && bc.SummonMaster == master) + { pets.Add(bc); + } + } + } if (pets.Count > 0) { @@ -333,7 +359,9 @@ namespace Server.Commands Mobile pet = pets[i]; if (pet is IMount mount) + { mount.Rider = null; // make sure it's dismounted + } pet.MoveToWorld(from.Location, from.Map); } @@ -364,11 +392,17 @@ namespace Server.Commands public static void Sound_OnCommand(CommandEventArgs e) { if (e.Length == 1) + { PlaySound(e.Mobile, e.GetInt32(0), true); + } else if (e.Length == 2) + { PlaySound(e.Mobile, e.GetInt32(0), e.GetBoolean(1)); + } else + { e.Mobile.SendMessage("Format: Sound [toAll]"); + } } private static void PlaySound(Mobile m, int index, bool toAll) @@ -376,7 +410,9 @@ namespace Server.Commands var map = m.Map; if (map == null) + { return; + } CommandLogging.WriteLine( m, @@ -392,8 +428,12 @@ namespace Server.Commands p.Acquire(); foreach (var state in m.GetClientsInRange(12)) + { if (toAll || state.Mobile.CanSee(m)) + { state.Send(p); + } + } p.Release(); } @@ -405,9 +445,13 @@ namespace Server.Commands var toEcho = e.ArgString.Trim(); if (toEcho.Length > 0) + { e.Mobile.SendMessage(toEcho); + } else + { e.Mobile.SendMessage("Format: Echo \"\""); + } } [Usage("Bank")] @@ -561,7 +605,9 @@ namespace Server.Commands map = Map.AllMaps[i]; if (map.MapIndex == 0x7F || map.MapIndex == 0xFF) + { continue; + } if (Insensitive.Equals(name, map.Name)) { @@ -588,20 +634,28 @@ namespace Server.Commands map = Map.AllMaps[i]; if (map.MapIndex == 0x7F || map.MapIndex == 0xFF || from.Map == map) + { continue; + } foreach (var r in map.Regions.Values) + { if (Insensitive.Equals(r.Name, name)) { - from.MoveToWorld(r.GoLocation, map); + @from.MoveToWorld(r.GoLocation, map); return; } + } } if (ser != 0) - from.SendMessage("No object with that serial was found."); + { + @from.SendMessage("No object with that serial was found."); + } else - from.SendMessage("No region with that name was found."); + { + @from.SendMessage("No region with that name was found."); + } return; } @@ -618,6 +672,7 @@ namespace Server.Commands var map = from.Map; if (map != null) + { try { /* @@ -628,12 +683,13 @@ namespace Server.Commands var y = int.Parse(e.GetString(1)); var z = e.Length == 3 ? int.Parse(e.GetString(2)) : map.GetAverageZ(x, y); - from.Location = new Point3D(x, y, z); + @from.Location = new Point3D(x, y, z); } catch { - from.SendMessage("Region name not found."); + @from.SendMessage("Region name not found."); } + } } else if (e.Length == 6) { @@ -652,9 +708,13 @@ namespace Server.Commands ); if (p != Point3D.Zero) - from.Location = p; + { + @from.Location = p; + } else - from.SendMessage("Sextant reverse lookup failed."); + { + @from.SendMessage("Sextant reverse lookup failed."); + } } } else @@ -672,15 +732,21 @@ namespace Server.Commands var list = new List(); foreach (var entry in CommandSystem.Entries.Values) + { if (m.AccessLevel >= entry.AccessLevel) + { list.Add(entry); + } + } list.Sort(); var sb = new StringBuilder(); if (list.Count > 0) + { sb.Append(list[0].Command); + } for (var i = 1; i < list.Count; ++i) { @@ -700,7 +766,9 @@ namespace Server.Commands } if (sb.Length > 0) + { m.SendAsciiMessage(0x482, sb.ToString()); + } } [Usage("SMsg ")] @@ -727,7 +795,9 @@ namespace Server.Commands var m = state.Mobile; if (m?.AccessLevel >= ac) + { m.SendMessage(hue, message); + } } } @@ -748,6 +818,7 @@ namespace Server.Commands public static void Animate_OnCommand(CommandEventArgs e) { if (e.Length == 6) + { e.Mobile.Animate( e.GetInt32(0), e.GetInt32(1), @@ -756,8 +827,11 @@ namespace Server.Commands e.GetBoolean(4), e.GetInt32(5) ); + } else + { e.Mobile.SendMessage("Format: Animate "); + } } [Usage("Cast ")] @@ -767,14 +841,20 @@ namespace Server.Commands if (e.Length == 1) { if (!DesignContext.Check(e.Mobile)) + { return; // They are customizing + } var spell = SpellRegistry.NewSpell(e.GetString(0), e.Mobile, null); if (spell != null) + { spell.Cast(); + } else + { e.Mobile.SendMessage("That spell was not found."); + } } else { @@ -820,7 +900,9 @@ namespace Server.Commands } if (targeted is Mobile mobile) - from.SendMenu(new EquipMenu(from, mobile, GetEquip(mobile))); + { + @from.SendMenu(new EquipMenu(@from, mobile, GetEquip(mobile))); + } } private static ItemListEntry[] GetEquip(Mobile m) @@ -949,9 +1031,13 @@ namespace Server.Commands ); if (from == m) + { box.Open(); + } else - box.DisplayTo(from); + { + box.DisplayTo(@from); + } } else { @@ -988,10 +1074,14 @@ namespace Server.Commands var mount = mountItem.Mount; if (mount != null) + { mount.Rider = null; + } if (targ.Items.IndexOf(item) == -1) + { --i; + } } } @@ -1042,9 +1132,13 @@ namespace Server.Commands if (targeted is Mobile mobile) { if (mobile.AccessLevel >= from.AccessLevel && mobile != from) - from.SendMessage("You can't do that to someone with higher Accesslevel than you!"); + { + @from.SendMessage("You can't do that to someone with higher Accesslevel than you!"); + } else - from.SendGump(new StuckMenu(from, mobile, false)); + { + @from.SendGump(new StuckMenu(@from, mobile, false)); + } } } } diff --git a/Projects/UOContent/Commands/LocationCommand.cs b/Projects/UOContent/Commands/LocationCommand.cs index eb33b5a99..fa98a7043 100644 --- a/Projects/UOContent/Commands/LocationCommand.cs +++ b/Projects/UOContent/Commands/LocationCommand.cs @@ -46,13 +46,17 @@ namespace Server.Commands var numberStyles = arg.ToLower().StartsWith("0x") ? NumberStyles.HexNumber : NumberStyles.Integer; if (int.TryParse(arg, numberStyles, CultureInfo.InvariantCulture, out var result)) + { graphics.Add(result); + } } } var item = EffectItem.Create(new Point3D(point), e.Mobile.Map, EffectItem.DefaultDuration); foreach (var graphic in graphics) + { Effects.SendLocationParticles(item, graphic, 10, 50, 2023); + } item.LabelTo(e.Mobile, label); } diff --git a/Projects/UOContent/Commands/Logging.cs b/Projects/UOContent/Commands/Logging.cs index 736c6dc44..73fa30833 100644 --- a/Projects/UOContent/Commands/Logging.cs +++ b/Projects/UOContent/Commands/Logging.cs @@ -17,12 +17,16 @@ namespace Server.Commands EventSink.Command += EventSink_Command; if (!Directory.Exists("Logs")) + { Directory.CreateDirectory("Logs"); + } var directory = "Logs/Commands"; if (!Directory.Exists(directory)) + { Directory.CreateDirectory(directory); + } try { @@ -45,12 +49,17 @@ namespace Server.Commands if (o is Mobile m) { if (m.Account == null) + { return $"{m} (no account)"; + } return $"{m} ('{m.Account.Username}')"; } - if (o is Item item) return $"0x{item.Serial.Value:X} ({item.GetType().Name})"; + if (o is Item item) + { + return $"0x{item.Serial.Value:X} ({item.GetType().Name})"; + } return o; } @@ -58,7 +67,9 @@ namespace Server.Commands public static void WriteLine(Mobile from, string format, params object[] args) { if (!Enabled) + { return; + } WriteLine(from, string.Format(format, args)); } @@ -66,7 +77,9 @@ namespace Server.Commands public static void WriteLine(Mobile from, string text) { if (!Enabled) + { return; + } try { @@ -95,28 +108,38 @@ namespace Server.Commands path = Path.Combine(path, toAppend); if (!Directory.Exists(path)) + { Directory.CreateDirectory(path); + } } public static string Safe(string ip) { if (ip == null) + { return "null"; + } ip = ip.Trim().IsNullOrDefault("empty"); var isSafe = true; for (var i = 0; isSafe && i < m_NotSafe.Length; ++i) + { isSafe = ip.IndexOf(m_NotSafe[i]) == -1; + } if (isSafe) + { return ip; + } var sb = new StringBuilder(ip); for (var i = 0; i < m_NotSafe.Length; ++i) + { sb.Replace(m_NotSafe[i], '_'); + } return sb.ToString(); } diff --git a/Projects/UOContent/Commands/Object Creation/Add.cs b/Projects/UOContent/Commands/Object Creation/Add.cs index 59778790c..8aa7a68cd 100644 --- a/Projects/UOContent/Commands/Object Creation/Add.cs +++ b/Projects/UOContent/Commands/Object Creation/Add.cs @@ -64,14 +64,20 @@ namespace Server.Commands sb.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from)); if (start == end) - sb.AppendFormat("at {0} in {1}", start, from.Map); + { + sb.AppendFormat("at {0} in {1}", start, @from.Map); + } else - sb.AppendFormat("from {0} to {1} in {2}", start, end, from.Map); + { + sb.AppendFormat("from {0} to {1} in {2}", start, end, @from.Map); + } sb.Append(":"); for (var i = 0; i < args.Length; ++i) + { sb.AppendFormat(" \"{0}\"", args[i]); + } CommandLogging.WriteLine(from, sb.ToString()); @@ -82,6 +88,7 @@ namespace Server.Commands string[,] props = null; for (var i = 0; i < args.Length; ++i) + { if (Insensitive.Equals(args[i], "set")) { var remains = args.Length - i - 1; @@ -103,6 +110,7 @@ namespace Server.Commands break; } + } var type = AssemblyHandler.FindFirstTypeForName(name); @@ -117,14 +125,18 @@ namespace Server.Commands var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg); if (built > 0) - from.SendMessage( + { + @from.SendMessage( "{0} object{1} generated in {2:F1} seconds.", built, built != 1 ? "s" : "", (DateTime.UtcNow - time).TotalSeconds ); + } else - SendUsage(type, from); + { + SendUsage(type, @from); + } } public static void FixSetString(ref string[] args, int index) @@ -166,8 +178,12 @@ namespace Server.Commands var propName = props[i, 0]; for (var j = 0; thisProp == null && j < allProps.Length; ++j) + { if (Insensitive.Equals(propName, allProps[j].Name)) + { thisProp = allProps[j]; + } + } if (thisProp == null) { @@ -178,17 +194,25 @@ namespace Server.Commands var attr = Properties.GetCPA(thisProp); if (attr == null) - from.SendMessage("Property ({0}) not found.", propName); + { + @from.SendMessage("Property ({0}) not found.", propName); + } else if (from.AccessLevel < attr.WriteLevel) - from.SendMessage( + { + @from.SendMessage( "Setting this property ({0}) requires at least {1} access level.", propName, Mobile.GetAccessLevelName(attr.WriteLevel) ); + } else if (!thisProp.CanWrite || attr.ReadOnly) - from.SendMessage("Property ({0}) is read only.", propName); + { + @from.SendMessage("Property ({0}) is read only.", propName); + } else + { realProps[i] = thisProp; + } } } } @@ -200,7 +224,9 @@ namespace Server.Commands var ctor = ctors[i]; if (!IsConstructible(ctor, from.AccessLevel)) + { continue; + } // Handle optional constructors var paramList = ctor.GetParameters(); @@ -211,12 +237,16 @@ namespace Server.Commands var paramValues = ParseValues(paramList, args); if (paramValues == null) + { continue; + } var built = Build(from, start, end, ctor, paramValues, props, realProps, packs, outline, mapAvg); if (built > 0) + { return built; + } } } @@ -233,11 +263,17 @@ namespace Server.Commands var value = ParseValue(param.ParameterType, a < args.Length ? args[a++] : null); if (value != null) + { values[i] = value; + } else if (param.HasDefaultValue) + { values[i] = Type.Missing; + } else + { return null; + } } return values; @@ -247,23 +283,43 @@ namespace Server.Commands { try { - if (IsEnum(type)) return Enum.Parse(type, value, true); - if (IsType(type)) return AssemblyHandler.FindFirstTypeForName(value); - if (IsParsable(type)) return ParseParsable(type, value); + if (IsEnum(type)) + { + return Enum.Parse(type, value, true); + } + + if (IsType(type)) + { + return AssemblyHandler.FindFirstTypeForName(value); + } + + if (IsParsable(type)) + { + return ParseParsable(type, value); + } + object obj = value; if (value?.StartsWith("0x") == true) { if (IsSignedNumeric(type)) + { obj = Convert.ToInt64(value.Substring(2), 16); + } else if (IsUnsignedNumeric(type)) + { obj = Convert.ToUInt64(value.Substring(2), 16); + } else + { obj = Convert.ToInt32(value.Substring(2), 16); + } } if (obj == null && !type.IsValueType) + { return null; + } return Convert.ChangeType(obj, type); } @@ -287,7 +343,9 @@ namespace Server.Commands for (var i = 0; i < realProps.Length; ++i) { if (realProps[i] == null) + { continue; + } var result = Properties.InternalSetValue(from, built, built, realProps[i], props[i, 1], props[i, 1], false); @@ -295,14 +353,18 @@ namespace Server.Commands if (result != "Property has been set.") { if (sendError) - from.SendMessage(result); + { + @from.SendMessage(result); + } hadError = true; } } if (hadError) + { sendError = false; + } } return (IEntity)built; @@ -321,19 +383,29 @@ namespace Server.Commands var height = end.Y - start.Y + 1; if (outline && (width < 3 || height < 3)) + { outline = false; + } int objectCount; if (packs != null) + { objectCount = packs.Count; + } else if (outline) + { objectCount = (width + height - 2) * 2; + } else + { objectCount = width * height; + } if (objectCount >= 20) - from.SendMessage("Constructing {0} objects, please wait.", objectCount); + { + @from.SendMessage("Constructing {0} objects, please wait.", objectCount); + } var sendError = true; @@ -349,9 +421,13 @@ namespace Server.Commands sb.AppendFormat("0x{0:X}; ", built.Serial.Value); if (built is Item item) + { packs[i].DropItem(item); + } else if (built is Mobile m) + { m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map); + } } } else @@ -359,23 +435,33 @@ namespace Server.Commands var z = start.Z; for (var x = start.X; x <= end.X; ++x) + { for (var y = start.Y; y <= end.Y; ++y) { if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y) + { continue; + } if (mapAvg) + { z = map.GetAverageZ(x, y); + } - var built = Build(from, ctor, values, props, realProps, ref sendError); + var built = Build(@from, ctor, values, props, realProps, ref sendError); sb.AppendFormat("0x{0:X}; ", built.Serial.Value); if (built is Item item) + { item.MoveToWorld(new Point3D(x, y, z), map); + } else if (built is Mobile m) + { m.MoveToWorld(new Point3D(x, y, z), map); + } } + } } CommandLogging.WriteLine(from, sb.ToString()); @@ -399,7 +485,9 @@ namespace Server.Commands var ctor = ctors[i]; if (!IsConstructible(ctor, from.AccessLevel)) + { continue; + } if (!foundCtor) { @@ -411,7 +499,9 @@ namespace Server.Commands } if (!foundCtor) - from.SendMessage("That type is not marked constructible."); + { + @from.SendMessage("That type is not marked constructible."); + } } public static void SendCtor(Type type, ConstructorInfo ctor, Mobile from) @@ -425,7 +515,9 @@ namespace Server.Commands for (var i = 0; i < paramList.Length; ++i) { if (i != 0) + { sb.Append(','); + } sb.Append(' '); @@ -463,16 +555,20 @@ namespace Server.Commands var from = e.Mobile; if (e.Length >= 1) + { BoundingBoxPicker.Begin( - from, + @from, (map, start, end) => - TileBox_Callback(from, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline)) + TileBox_Callback(@from, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline)) ); + } else - from.SendMessage( + { + @from.SendMessage( "Format: {0} [params] [set {{ ...}}]", outline ? "Outline" : "Tile" ); + } } private static void InternalRXYZ_OnCommand(CommandEventArgs e, bool outline) @@ -485,7 +581,9 @@ namespace Server.Commands var subArgs = new string[e.Length - 5]; for (var i = 0; i < subArgs.Length; ++i) + { subArgs[i] = e.Arguments[i + 5]; + } Invoke(e.Mobile, p, p2, subArgs, null, outline); } @@ -508,7 +606,9 @@ namespace Server.Commands var subArgs = new string[e.Length - 5]; for (var i = 0; i < subArgs.Length; ++i) + { subArgs[i] = e.Arguments[i + 5]; + } Invoke(e.Mobile, p, p2, subArgs, null, outline); } @@ -530,7 +630,9 @@ namespace Server.Commands var subArgs = new string[e.Length - 1]; for (var i = 0; i < subArgs.Length; ++i) + { subArgs[i] = e.Arguments[i + 1]; + } BoundingBoxPicker.Begin( from, @@ -552,16 +654,20 @@ namespace Server.Commands var from = e.Mobile; if (e.Length >= 1) + { BoundingBoxPicker.Begin( - from, + @from, (map, start, end) => - TileBox_Callback(from, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline)) + TileBox_Callback(@from, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline)) ); + } else - from.SendMessage( + { + @from.SendMessage( "Format: {0}Avg [params] [set {{ ...}}]", outline ? "Outline" : "Tile" ); + } } [Usage("Tile [params] [set { ...}]")] @@ -681,8 +787,12 @@ namespace Server.Commands public static bool IsSignedNumeric(Type type) { for (var i = 0; i < m_SignedNumerics.Length; ++i) + { if (type == m_SignedNumerics[i]) + { return true; + } + } return false; } @@ -690,8 +800,12 @@ namespace Server.Commands public static bool IsUnsignedNumeric(Type type) { for (var i = 0; i < m_UnsignedNumerics.Length; ++i) + { if (type == m_UnsignedNumerics[i]) + { return true; + } + } return false; } diff --git a/Projects/UOContent/Commands/Object Creation/AddGump.cs b/Projects/UOContent/Commands/Object Creation/AddGump.cs index 5b7b7fc44..df9e9b39b 100644 --- a/Projects/UOContent/Commands/Object Creation/AddGump.cs +++ b/Projects/UOContent/Commands/Object Creation/AddGump.cs @@ -41,6 +41,7 @@ namespace Server.Gumps AddAlphaRegion(10, 40, 400, 200); if (searchResults.Length > 0) + { for (var i = page * 10; i < (page + 1) * 10 && i < searchResults.Length; ++i) { var index = i % 10; @@ -48,23 +49,34 @@ namespace Server.Gumps AddLabel(44, 39 + index * 20, 0x480, searchResults[i].Name); AddButton(10, 39 + index * 20, 4023, 4025, 4 + i); } + } else + { AddLabel(15, 44, 0x480, explicitSearch ? "Nothing matched your search terms." : "No results to display."); + } AddImageTiled(10, 250, 400, 20, 2624); AddAlphaRegion(10, 250, 400, 20); if (m_Page > 0) + { AddButton(10, 249, 4014, 4016, 2); + } else + { AddImage(10, 249, 4014); + } AddHtmlLocalized(44, 250, 170, 20, 1061028, m_Page > 0 ? 0x7FFF : 0x5EF7); // Previous page if ((m_Page + 1) * 10 < searchResults.Length) + { AddButton(210, 249, 4005, 4007, 3); + } else + { AddImage(210, 249, 4005); + } AddHtmlLocalized( 244, @@ -112,7 +124,9 @@ namespace Server.Gumps private static void Match(string match, Type[] types, List results) { if (match.Length == 0) + { return; + } match = match.ToLower(); @@ -126,12 +140,14 @@ namespace Server.Gumps var ctors = t.GetConstructors(); for (var j = 0; j < ctors.Length; ++j) + { if (ctors[j].GetParameters().Length == 0 && ctors[j].IsDefined(typeof(ConstructibleAttribute), false)) { results.Add(t); break; } + } } } } @@ -183,14 +199,18 @@ namespace Server.Gumps case 2: // Previous page { if (m_Page > 0) - from.SendGump(new AddGump(from, m_SearchString, m_Page - 1, m_SearchResults, true)); + { + @from.SendGump(new AddGump(@from, m_SearchString, m_Page - 1, m_SearchResults, true)); + } break; } case 3: // Next page { if ((m_Page + 1) * 10 < m_SearchResults.Length) - from.SendGump(new AddGump(from, m_SearchString, m_Page + 1, m_SearchResults, true)); + { + @from.SendGump(new AddGump(@from, m_SearchString, m_Page + 1, m_SearchResults, true)); + } break; } @@ -258,7 +278,9 @@ namespace Server.Gumps protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { if (cancelType == TargetCancelType.Canceled) - from.SendGump(new AddGump(from, m_SearchString, m_Page, m_SearchResults, true)); + { + @from.SendGump(new AddGump(@from, m_SearchString, m_Page, m_SearchResults, true)); + } } } } diff --git a/Projects/UOContent/Commands/Object Creation/Categorization.cs b/Projects/UOContent/Commands/Object Creation/Categorization.cs index ddea70010..e2cee8b2b 100644 --- a/Projects/UOContent/Commands/Object Creation/Categorization.cs +++ b/Projects/UOContent/Commands/Object Creation/Categorization.cs @@ -22,7 +22,9 @@ namespace Server.Commands get { if (m_RootItems == null) + { Load(); + } return m_RootItems; } @@ -33,7 +35,9 @@ namespace Server.Commands get { if (m_RootMobiles == null) + { Load(); + } return m_RootMobiles; } @@ -62,7 +66,9 @@ namespace Server.Commands { var list = new List(); foreach (var ce in ceList) + { RecurseExport(list, ce, null); + } JsonConfig.Serialize(fileName, list); } @@ -72,6 +78,7 @@ namespace Server.Commands category = string.IsNullOrWhiteSpace(category) ? ce.Title : $"{category}{ce.Title}"; if (ce.Matched.Count > 0) + { list.Add( new CAGJson { @@ -84,15 +91,21 @@ namespace Server.Commands var itemID = item.ItemID; if (item is BaseAddon addon && addon.Components.Count == 1) + { itemID = addon.Components[0].ItemID; + } if (itemID > TileData.MaxItemValue) + { itemID = 1; + } int? hue = item.Hue & 0x7FFF; if ((hue & 0x4000) != 0) + { hue = 0; + } return new CAGObject { @@ -109,7 +122,9 @@ namespace Server.Commands int? hue = m.Hue & 0x7FFF; if ((hue & 0x4000) != 0) + { hue = 0; + } return new CAGObject { @@ -127,6 +142,7 @@ namespace Server.Commands .ToArray() } ); + } var subCats = new List(ce.SubCategories); @@ -146,7 +162,9 @@ namespace Server.Commands AddTypes(Core.Assembly, types); for (var i = 0; i < AssemblyHandler.Assemblies.Length; ++i) + { AddTypes(AssemblyHandler.Assemblies[i], types); + } m_RootItems = Load(types, "Data/items.cfg"); m_RootMobiles = Load(types, "Data/mobiles.cfg"); @@ -156,7 +174,10 @@ namespace Server.Commands { var lines = CategoryLine.Load(config); - if (lines.Length <= 0) return new CategoryEntry(); + if (lines.Length <= 0) + { + return new CategoryEntry(); + } var index = 0; var root = new CategoryEntry(null, lines, ref index); @@ -169,7 +190,9 @@ namespace Server.Commands private static bool IsConstructible(Type type) { if (!type.IsSubclassOf(typeofItem) && !type.IsSubclassOf(typeofMobile)) + { return false; + } var ctor = type.GetConstructor(Type.EmptyTypes); @@ -185,10 +208,14 @@ namespace Server.Commands var type = allTypes[i]; if (type.IsAbstract) + { continue; + } if (IsConstructible(type)) + { types.Add(type); + } } } @@ -200,7 +227,9 @@ namespace Server.Commands var match = GetDeepestMatch(root, type); if (match == null) + { continue; + } try { @@ -216,14 +245,18 @@ namespace Server.Commands private static CategoryEntry GetDeepestMatch(CategoryEntry root, Type type) { if (!root.IsMatch(type)) + { return null; + } for (var i = 0; i < root.SubCategories.Length; ++i) { var check = GetDeepestMatch(root.SubCategories[i], type); if (check != null) + { return check; + } } return root; @@ -295,14 +328,18 @@ namespace Server.Commands var start = text.IndexOf('('); if (start < 0) + { throw new FormatException($"Input string not correctly formatted ('{text}')"); + } Title = text.Substring(0, start).Trim(); var end = text.IndexOf(')', ++start); if (end < start) + { throw new FormatException($"Input string not correctly formatted ('{text}')"); + } text = text.Substring(start, end - start); var split = text.Split(';'); @@ -314,9 +351,13 @@ namespace Server.Commands var type = AssemblyHandler.FindFirstTypeForName(split[i].Trim()); if (type == null) + { Console.WriteLine("Match type not found ('{0}')", split[i].Trim()); + } else + { list.Add(type); + } } Matches = list.ToArray(); @@ -329,7 +370,9 @@ namespace Server.Commands var entryList = new List(); while (index < lines.Length && lines[index].Indentation > ourIndentation) + { entryList.Add(new CategoryEntry(this, lines, ref index)); + } SubCategories = entryList.ToArray(); entryList.Clear(); @@ -352,7 +395,9 @@ namespace Server.Commands var isMatch = false; for (var i = 0; !isMatch && i < Matches.Length; ++i) + { isMatch = type == Matches[i] || type.IsSubclassOf(Matches[i]); + } return isMatch; } @@ -365,11 +410,17 @@ namespace Server.Commands int index; for (index = 0; index < input.Length; ++index) + { if (char.IsLetter(input, index)) + { break; + } + } if (index >= input.Length) + { throw new FormatException($"Input string not correctly formatted ('{input}')"); + } Indentation = index; Text = input.Substring(index); @@ -389,7 +440,9 @@ namespace Server.Commands string line; while ((line = ip.ReadLine()) != null) + { list.Add(new CategoryLine(line)); + } } return list.ToArray(); diff --git a/Projects/UOContent/Commands/Object Creation/CategorizedAddGump.cs b/Projects/UOContent/Commands/Object Creation/CategorizedAddGump.cs index 50e32ebed..65f7ca76a 100644 --- a/Projects/UOContent/Commands/Object Creation/CategorizedAddGump.cs +++ b/Projects/UOContent/Commands/Object Creation/CategorizedAddGump.cs @@ -110,16 +110,22 @@ namespace Server.Gumps var y = BorderSize + OffsetSize; if (OldStyle) + { AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); + } else + { AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + } if (m_Category.Parent != null) { AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); if (PrevLabel) + { AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); + } } x += PrevWidth + OffsetSize; @@ -128,6 +134,7 @@ namespace Server.Gumps (OldStyle ? SetWidth + OffsetSize : 0); if (!OldStyle) + { AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, @@ -135,6 +142,7 @@ namespace Server.Gumps EntryHeight, EntryGumpID ); + } AddHtml( x + TextOffsetX, @@ -147,29 +155,39 @@ namespace Server.Gumps x += emptyWidth + OffsetSize; if (OldStyle) + { AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); + } else + { AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + } if (page > 0) { AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2); if (PrevLabel) + { AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); + } } x += PrevWidth + OffsetSize; if (!OldStyle) + { AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID); + } if ((page + 1) * EntryCount < nodes.Length) { AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1); if (NextLabel) + { AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next"); + } } for (int i = 0, index = page * EntryCount; i < EntryCount && index < nodes.Length; ++i, ++index) @@ -192,7 +210,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4); @@ -205,17 +225,21 @@ namespace Server.Gumps if (itemID != 1 && bounds.Height < EntryHeight * 2) { if (bounds.Height < EntryHeight) + { AddItem( x - OffsetSize - 22 - i % 2 * 44 - bounds.Width / 2 - bounds.X, y + EntryHeight / 2 - bounds.Height / 2 - bounds.Y, itemID ); + } else + { AddItem( x - OffsetSize - 22 - i % 2 * 44 - bounds.Width / 2 - bounds.X, y + EntryHeight - 1 - bounds.Height - bounds.Y, itemID ); + } } } } @@ -238,7 +262,9 @@ namespace Server.Gumps var index = Array.IndexOf(m_Category.Parent.Nodes, m_Category) / EntryCount; if (index < 0) + { index = 0; + } from.SendGump(new CategorizedAddGump(from, m_Category.Parent, index)); } @@ -248,14 +274,18 @@ namespace Server.Gumps case 2: // Previous { if (m_Page > 0) - from.SendGump(new CategorizedAddGump(from, m_Category, m_Page - 1)); + { + @from.SendGump(new CategorizedAddGump(@from, m_Category, m_Page - 1)); + } break; } case 3: // Next { if ((m_Page + 1) * EntryCount < m_Category.Nodes.Length) - from.SendGump(new CategorizedAddGump(from, m_Category, m_Page + 1)); + { + @from.SendGump(new CategorizedAddGump(@from, m_Category, m_Page + 1)); + } break; } @@ -264,7 +294,9 @@ namespace Server.Gumps var index = m_Page * EntryCount + (info.ButtonID - 4); if (index >= 0 && index < m_Category.Nodes.Length) - m_Category.Nodes[index].OnClick(from, m_Page); + { + m_Category.Nodes[index].OnClick(@from, m_Page); + } break; } diff --git a/Projects/UOContent/Commands/Object Creation/Decorate.cs b/Projects/UOContent/Commands/Object Creation/Decorate.cs index 99a7962d0..a40bf0138 100644 --- a/Projects/UOContent/Commands/Object Creation/Decorate.cs +++ b/Projects/UOContent/Commands/Object Creation/Decorate.cs @@ -42,7 +42,9 @@ namespace Server.Commands public static void Generate(string folder, params Map[] maps) { if (!Directory.Exists(folder)) + { return; + } var files = Directory.GetFiles(folder, "*.cfg"); @@ -51,7 +53,9 @@ namespace Server.Commands var list = DecorationList.ReadAll(files[i]); for (var j = 0; j < list.Count; ++j) + { m_Count += list[j].Generate(maps); + } } } } @@ -82,7 +86,9 @@ namespace Server.Commands public Item Construct() { if (m_Type == null) + { return null; + } Item item; @@ -97,6 +103,7 @@ namespace Server.Commands var labelNumber = 0; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("LabelNumber")) { var indexOf = m_Params[i].IndexOf('='); @@ -107,6 +114,7 @@ namespace Server.Commands break; } } + } item = new LocalizedStatic(m_ItemID, labelNumber); } @@ -115,6 +123,7 @@ namespace Server.Commands var labelNumber = 0; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("LabelNumber")) { var indexOf = m_Params[i].IndexOf('='); @@ -125,6 +134,7 @@ namespace Server.Commands break; } } + } item = new LocalizedSign(m_ItemID, labelNumber); } @@ -133,12 +143,18 @@ namespace Server.Commands var bloodied = false; for (var i = 0; !bloodied && i < m_Params.Length; ++i) + { bloodied = m_Params[i] == "Bloodied"; + } if (m_Type == typeofAnkhWest) + { item = new AnkhWest(bloodied); + } else + { item = new AnkhNorth(bloodied); + } } else if (m_Type == typeofMarkContainer) { @@ -147,6 +163,7 @@ namespace Server.Commands var map = Map.Malas; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i] == "Bone") { bone = true; @@ -160,8 +177,11 @@ namespace Server.Commands var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { map = Map.Parse(m_Params[i].Substring(++indexOf)); + } } + } var mc = new MarkContainer(bone, locked); @@ -180,48 +200,62 @@ namespace Server.Commands var resetDelay = TimeSpan.Zero; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Range")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("WarningString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("WarningNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("HintString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { hintString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("HintNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { hintNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("ResetDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } var hi = new HintItem(m_ItemID, range, messageNumber, hintNumber); @@ -239,34 +273,44 @@ namespace Server.Commands var resetDelay = TimeSpan.Zero; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Range")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("WarningString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("WarningNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("ResetDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } var wi = new WarningItem(m_ItemID, range, messageNumber); @@ -280,17 +324,21 @@ namespace Server.Commands var direction = CannonDirection.North; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("CannonDirection")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { direction = (CannonDirection)Enum.Parse( typeof(CannonDirection), m_Params[i].Substring(++indexOf), true ); + } } + } item = new Cannon(direction); } @@ -300,27 +348,35 @@ namespace Server.Commands var destination = new Rectangle2D(); for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Word")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { word = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("DestStart")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { destination.Start = Point2D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEnd")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { destination.End = Point2D.Parse(m_Params[i].Substring(++indexOf)); + } } + } item = new SerpentPillar(word, destination); } @@ -330,6 +386,7 @@ namespace Server.Commands var fill = false; for (var i = 0; !fill && i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Content")) { var indexOf = m_Params[i].IndexOf('='); @@ -344,17 +401,23 @@ namespace Server.Commands fill = true; } } + } if (fill) + { item = (Item)ActivatorUtil.CreateInstance(m_Type, content); + } else + { item = (Item)ActivatorUtil.CreateInstance(m_Type); + } } else if (m_Type.IsSubclassOf(typeofBaseDoor)) { var facing = DoorFacing.WestCW; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Facing")) { var indexOf = m_Params[i].IndexOf('='); @@ -365,6 +428,7 @@ namespace Server.Commands break; } } + } item = (Item)ActivatorUtil.CreateInstance(m_Type, facing); } @@ -383,13 +447,17 @@ namespace Server.Commands if (addon is MaabusCoffin coffin) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("SpawnLocation")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { coffin.SpawnLocation = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } + } } else if (m_ItemID > 0) { @@ -400,7 +468,9 @@ namespace Server.Commands var comp = comps[i]; if (comp.Offset == Point3D.Zero) + { comp.ItemID = m_ItemID; + } } } } @@ -411,54 +481,76 @@ namespace Server.Commands for (var i = 0; i < m_Params.Length; ++i) { if (!unlit && m_Params[i] == "Unlit") + { unlit = true; + } else if (!unprotected && m_Params[i] == "Unprotected") + { unprotected = true; + } if (unlit && unprotected) + { break; + } } if (!unlit) + { light.Ignite(); + } + if (!unprotected) + { light.Protected = true; + } if (m_ItemID > 0) + { light.ItemID = m_ItemID; + } } else if (item is Spawner sp) { sp.NextSpawn = TimeSpan.Zero; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Spawn")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.AddEntry(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MinDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.MinDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MaxDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.MaxDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("NextSpawn")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.NextSpawn = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Count")) { @@ -468,7 +560,9 @@ namespace Server.Commands { sp.Count = Utility.ToInt32(m_Params[i].Substring(++indexOf)); for (var se = 0; se < sp.Entries.Count; se++) + { sp.Entries[se].SpawnedMaxCount = sp.Count; + } } } else if (m_Params[i].StartsWith("Team")) @@ -476,303 +570,398 @@ namespace Server.Commands var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.Team = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("HomeRange")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.HomeRange = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Running")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.Running = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Group")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.Group = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } + } } else if (item is RecallRune rune) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Description")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.Description = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("Marked")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.Marked = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("TargetMap")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.TargetMap = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Target")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.Target = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } + } } else if (item is SkillTeleporter st) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Skill")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Skill = (SkillName)Enum.Parse(typeof(SkillName), m_Params[i].Substring(++indexOf), true); + } } else if (m_Params[i].StartsWith("RequiredFixedPoint")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Required = Utility.ToInt32(m_Params[i].Substring(++indexOf)) * 0.1; + } } else if (m_Params[i].StartsWith("Required")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Required = Utility.ToDouble(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MessageString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.MessageString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("MessageNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.MessageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("PointDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MapDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Creatures")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SourceEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SoundID")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Delay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } if (m_ItemID > 0) + { st.ItemID = m_ItemID; + } } else if (item is KeywordTeleporter kt) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Substring")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Substring = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("Keyword")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Keyword = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Range")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("PointDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MapDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Creatures")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SourceEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SoundID")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Delay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } if (m_ItemID > 0) + { kt.ItemID = m_ItemID; + } } else if (item is Teleporter tp) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("PointDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MapDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Creatures")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SourceEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SoundID")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Delay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } if (m_ItemID > 0) + { tp.ItemID = m_ItemID; + } } else if (item is FillableContainer cont) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("ContentType")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { cont.ContentType = (FillableContentType)Enum.Parse( typeof(FillableContentType), m_Params[i].Substring(++indexOf), true ); + } } + } if (m_ItemID > 0) + { cont.ItemID = m_ItemID; + } } else if (m_ItemID > 0) { @@ -782,12 +971,15 @@ namespace Server.Commands item.Movable = false; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Light")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { item.Light = (LightType)Enum.Parse(typeof(LightType), m_Params[i].Substring(++indexOf), true); + } } else if (m_Params[i].StartsWith("Hue")) { @@ -798,9 +990,13 @@ namespace Server.Commands var hue = Utility.ToInt32(m_Params[i].Substring(++indexOf)); if (item is DyeTub tub) + { tub.DyedHue = hue; + } else + { item.Hue = hue; + } } } else if (m_Params[i].StartsWith("Name")) @@ -808,7 +1004,9 @@ namespace Server.Commands var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { item.Name = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("Amount")) { @@ -825,6 +1023,7 @@ namespace Server.Commands item.Stackable = wasStackable; } } + } return item; } @@ -844,7 +1043,9 @@ namespace Server.Commands foreach (var item in eable) { if (!(item is BaseDoor)) + { continue; + } var bd = (BaseDoor)item; Point3D p; @@ -862,12 +1063,18 @@ namespace Server.Commands } if (p.X != x || p.Y != y) + { continue; + } if (item.Z == z && bdItemID == itemID) + { res = true; + } else if (Math.Abs(item.Z - z) < 8) + { m_DeleteQueue.Enqueue(item); + } } } else if ((TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.LightSource) != 0) @@ -878,20 +1085,26 @@ namespace Server.Commands var srcName = srcItem.ItemData.Name; foreach (var item in eable) + { if (item.Z == z) { if (item.ItemID == itemID) { if (item.Light != lt) + { m_DeleteQueue.Enqueue(item); + } else + { res = true; + } } else if ((item.ItemData.Flags & TileFlag.LightSource) != 0 && item.ItemData.Name == srcName) { m_DeleteQueue.Enqueue(item); } } + } } else if (srcItem is Teleporter || srcItem is FillableContainer || srcItem is BaseBook) { @@ -900,13 +1113,19 @@ namespace Server.Commands var type = srcItem.GetType(); foreach (var item in eable) + { if (item.Z == z && item.ItemID == itemID) { if (item.GetType() != type) + { m_DeleteQueue.Enqueue(item); + } else + { res = true; + } } + } } else { @@ -922,7 +1141,9 @@ namespace Server.Commands eable.Free(); while (m_DeleteQueue.Count > 0) + { m_DeleteQueue.Dequeue().Delete(); + } return res; } @@ -954,7 +1175,9 @@ namespace Server.Commands } if (item == null) + { continue; + } if (FindItem(loc.X, loc.Y, loc.Z, maps[j], item)) { @@ -971,12 +1194,14 @@ namespace Server.Commands var itemType = door.GetType(); foreach (var link in eable) + { if (link != item && link.Z == door.Z && link.GetType() == itemType) { door.Link = link; link.Link = door; break; } + } eable.Free(); } @@ -1009,7 +1234,9 @@ namespace Server.Commands DecorationList v; while ((v = Read(ip)) != null) + { list.Add(v); + } return list; } @@ -1023,11 +1250,15 @@ namespace Server.Commands line = line.Trim(); if (line.Length > 0 && !line.StartsWith("#")) + { break; + } } if (string.IsNullOrEmpty(line)) + { return null; + } var list = new DecorationList(); @@ -1036,7 +1267,9 @@ namespace Server.Commands list.m_Type = AssemblyHandler.FindFirstTypeForName(line.Substring(0, indexOf++), true); if (list.m_Type == null) + { throw new ArgumentException($"Type not found for header: '{line}'"); + } line = line.Substring(indexOf); indexOf = line.IndexOf('('); @@ -1047,12 +1280,16 @@ namespace Server.Commands var parms = line.Substring(++indexOf); if (line.EndsWith(")")) + { parms = parms.Substring(0, parms.Length - 1); + } list.m_Params = parms.Split(';'); for (var i = 0; i < list.m_Params.Length; ++i) + { list.m_Params[i] = list.m_Params[i].Trim(); + } } else { @@ -1067,10 +1304,14 @@ namespace Server.Commands line = line.Trim(); if (line.Length == 0) + { break; + } if (line.StartsWith("#")) + { continue; + } list.m_Entries.Add(new DecorationEntry(line)); } diff --git a/Projects/UOContent/Commands/Object Creation/DecorateMag.cs b/Projects/UOContent/Commands/Object Creation/DecorateMag.cs index c29d8461e..5ae20aa2a 100644 --- a/Projects/UOContent/Commands/Object Creation/DecorateMag.cs +++ b/Projects/UOContent/Commands/Object Creation/DecorateMag.cs @@ -39,7 +39,9 @@ namespace Server.Commands public static void Generate(string folder, params Map[] maps) { if (!Directory.Exists(folder)) + { return; + } var files = Directory.GetFiles(folder, "*.cfg"); @@ -48,7 +50,9 @@ namespace Server.Commands var list = DecorationListMag.ReadAll(files[i]); for (var j = 0; j < list.Count; ++j) + { m_Count += list[j].Generate(maps); + } } } } @@ -79,7 +83,9 @@ namespace Server.Commands public Item Construct() { if (m_Type == null) + { return null; + } Item item; @@ -94,6 +100,7 @@ namespace Server.Commands var labelNumber = 0; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("LabelNumber")) { var indexOf = m_Params[i].IndexOf('='); @@ -104,6 +111,7 @@ namespace Server.Commands break; } } + } item = new LocalizedStatic(m_ItemID, labelNumber); } @@ -112,6 +120,7 @@ namespace Server.Commands var labelNumber = 0; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("LabelNumber")) { var indexOf = m_Params[i].IndexOf('='); @@ -122,6 +131,7 @@ namespace Server.Commands break; } } + } item = new LocalizedSign(m_ItemID, labelNumber); } @@ -130,12 +140,18 @@ namespace Server.Commands var bloodied = false; for (var i = 0; !bloodied && i < m_Params.Length; ++i) + { bloodied = m_Params[i] == "Bloodied"; + } if (m_Type == typeofAnkhWest) + { item = new AnkhWest(bloodied); + } else + { item = new AnkhNorth(bloodied); + } } else if (m_Type == typeofMarkContainer) { @@ -144,6 +160,7 @@ namespace Server.Commands var map = Map.Malas; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i] == "Bone") { bone = true; @@ -157,8 +174,11 @@ namespace Server.Commands var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { map = Map.Parse(m_Params[i].Substring(++indexOf)); + } } + } var mc = new MarkContainer(bone, locked); @@ -177,48 +197,62 @@ namespace Server.Commands var resetDelay = TimeSpan.Zero; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Range")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("WarningString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("WarningNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("HintString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { hintString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("HintNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { hintNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("ResetDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } var hi = new HintItem(m_ItemID, range, messageNumber, hintNumber); @@ -236,34 +270,44 @@ namespace Server.Commands var resetDelay = TimeSpan.Zero; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Range")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("WarningString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("WarningNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("ResetDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } var wi = new WarningItem(m_ItemID, range, messageNumber); @@ -277,17 +321,21 @@ namespace Server.Commands var direction = CannonDirection.North; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("CannonDirection")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { direction = (CannonDirection)Enum.Parse( typeof(CannonDirection), m_Params[i].Substring(++indexOf), true ); + } } + } item = new Cannon(direction); } @@ -297,27 +345,35 @@ namespace Server.Commands var destination = new Rectangle2D(); for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Word")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { word = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("DestStart")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { destination.Start = Point2D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEnd")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { destination.End = Point2D.Parse(m_Params[i].Substring(++indexOf)); + } } + } item = new SerpentPillar(word, destination); } @@ -327,6 +383,7 @@ namespace Server.Commands var fill = false; for (var i = 0; !fill && i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Content")) { var indexOf = m_Params[i].IndexOf('='); @@ -341,17 +398,23 @@ namespace Server.Commands fill = true; } } + } if (fill) + { item = (Item)ActivatorUtil.CreateInstance(m_Type, content); + } else + { item = (Item)ActivatorUtil.CreateInstance(m_Type); + } } else if (m_Type.IsSubclassOf(typeofBaseDoor)) { var facing = DoorFacing.WestCW; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Facing")) { var indexOf = m_Params[i].IndexOf('='); @@ -362,6 +425,7 @@ namespace Server.Commands break; } } + } item = (Item)ActivatorUtil.CreateInstance(m_Type, facing); } @@ -380,13 +444,17 @@ namespace Server.Commands if (addon is MaabusCoffin coffin) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("SpawnLocation")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { coffin.SpawnLocation = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } + } } else if (m_ItemID > 0) { @@ -397,7 +465,9 @@ namespace Server.Commands var comp = comps[i]; if (comp.Offset == Point3D.Zero) + { comp.ItemID = m_ItemID; + } } } } @@ -408,54 +478,76 @@ namespace Server.Commands for (var i = 0; i < m_Params.Length; ++i) { if (!unlit && m_Params[i] == "Unlit") + { unlit = true; + } else if (!unprotected && m_Params[i] == "Unprotected") + { unprotected = true; + } if (unlit && unprotected) + { break; + } } if (!unlit) + { light.Ignite(); + } + if (!unprotected) + { light.Protected = true; + } if (m_ItemID > 0) + { light.ItemID = m_ItemID; + } } else if (item is Spawner sp) { sp.NextSpawn = TimeSpan.Zero; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Spawn")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.AddEntry(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MinDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.MinDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MaxDelay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.MaxDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("NextSpawn")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.NextSpawn = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Count")) { @@ -465,7 +557,9 @@ namespace Server.Commands { sp.Count = Utility.ToInt32(m_Params[i].Substring(++indexOf)); for (var se = 0; se < sp.Entries.Count; se++) + { sp.Entries[se].SpawnedMaxCount = sp.Count; + } } } else if (m_Params[i].StartsWith("Team")) @@ -473,303 +567,398 @@ namespace Server.Commands var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.Team = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("HomeRange")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.HomeRange = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Running")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.Running = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Group")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { sp.Group = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } + } } else if (item is RecallRune rune) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Description")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.Description = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("Marked")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.Marked = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("TargetMap")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.TargetMap = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Target")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { rune.Target = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } + } } else if (item is SkillTeleporter st) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Skill")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Skill = (SkillName)Enum.Parse(typeof(SkillName), m_Params[i].Substring(++indexOf), true); + } } else if (m_Params[i].StartsWith("RequiredFixedPoint")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Required = Utility.ToInt32(m_Params[i].Substring(++indexOf)) * 0.1; + } } else if (m_Params[i].StartsWith("Required")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Required = Utility.ToDouble(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MessageString")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.MessageString = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("MessageNumber")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.MessageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("PointDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MapDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Creatures")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SourceEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SoundID")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Delay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { st.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } if (m_ItemID > 0) + { st.ItemID = m_ItemID; + } } else if (item is KeywordTeleporter kt) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Substring")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Substring = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("Keyword")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Keyword = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Range")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("PointDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MapDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Creatures")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SourceEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SoundID")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Delay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { kt.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } if (m_ItemID > 0) + { kt.ItemID = m_ItemID; + } } else if (item is Teleporter tp) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("PointDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("MapDest")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Creatures")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SourceEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("DestEffect")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("SoundID")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); + } } else if (m_Params[i].StartsWith("Delay")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); + } } + } if (m_ItemID > 0) + { tp.ItemID = m_ItemID; + } } else if (item is FillableContainer cont) { for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("ContentType")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { cont.ContentType = (FillableContentType)Enum.Parse( typeof(FillableContentType), m_Params[i].Substring(++indexOf), true ); + } } + } if (m_ItemID > 0) + { cont.ItemID = m_ItemID; + } } else if (m_ItemID > 0) { @@ -779,12 +968,15 @@ namespace Server.Commands item.Movable = false; for (var i = 0; i < m_Params.Length; ++i) + { if (m_Params[i].StartsWith("Light")) { var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { item.Light = (LightType)Enum.Parse(typeof(LightType), m_Params[i].Substring(++indexOf), true); + } } else if (m_Params[i].StartsWith("Hue")) { @@ -795,9 +987,13 @@ namespace Server.Commands var hue = Utility.ToInt32(m_Params[i].Substring(++indexOf)); if (item is DyeTub tub) + { tub.DyedHue = hue; + } else + { item.Hue = hue; + } } } else if (m_Params[i].StartsWith("Name")) @@ -805,7 +1001,9 @@ namespace Server.Commands var indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) + { item.Name = m_Params[i].Substring(++indexOf); + } } else if (m_Params[i].StartsWith("Amount")) { @@ -822,6 +1020,7 @@ namespace Server.Commands item.Stackable = wasStackable; } } + } return item; } @@ -841,7 +1040,9 @@ namespace Server.Commands foreach (var item in eable) { if (!(item is BaseDoor)) + { continue; + } var bd = (BaseDoor)item; Point3D p; @@ -859,12 +1060,18 @@ namespace Server.Commands } if (p.X != x || p.Y != y) + { continue; + } if (item.Z == z && bdItemID == itemID) + { res = true; + } else if (Math.Abs(item.Z - z) < 8) + { m_DeleteQueue.Enqueue(item); + } } } else if ((TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.LightSource) != 0) @@ -875,20 +1082,26 @@ namespace Server.Commands var srcName = srcItem.ItemData.Name; foreach (var item in eable) + { if (item.Z == z) { if (item.ItemID == itemID) { if (item.Light != lt) + { m_DeleteQueue.Enqueue(item); + } else + { res = true; + } } else if ((item.ItemData.Flags & TileFlag.LightSource) != 0 && item.ItemData.Name == srcName) { m_DeleteQueue.Enqueue(item); } } + } } else if (srcItem is Teleporter || srcItem is FillableContainer || srcItem is BaseBook) { @@ -897,13 +1110,19 @@ namespace Server.Commands var type = srcItem.GetType(); foreach (var item in eable) + { if (item.Z == z && item.ItemID == itemID) { if (item.GetType() != type) + { m_DeleteQueue.Enqueue(item); + } else + { res = true; + } } + } } else { @@ -919,7 +1138,9 @@ namespace Server.Commands eable.Free(); while (m_DeleteQueue.Count > 0) + { ((Item)m_DeleteQueue.Dequeue()).Delete(); + } return res; } @@ -941,7 +1162,9 @@ namespace Server.Commands item ??= Construct(); if (item == null) + { continue; + } if (FindItem(loc.X, loc.Y, loc.Z, maps[j], item)) { @@ -958,12 +1181,14 @@ namespace Server.Commands var itemType = door.GetType(); foreach (var link in eable) + { if (link != item && link.Z == door.Z && link.GetType() == itemType) { door.Link = link; link.Link = door; break; } + } eable.Free(); } @@ -996,7 +1221,9 @@ namespace Server.Commands DecorationListMag v; while ((v = Read(ip)) != null) + { list.Add(v); + } return list; } @@ -1010,11 +1237,15 @@ namespace Server.Commands line = line.Trim(); if (line.Length > 0 && !line.StartsWith("#")) + { break; + } } if (string.IsNullOrEmpty(line)) + { return null; + } var list = new DecorationListMag(); @@ -1023,7 +1254,9 @@ namespace Server.Commands list.m_Type = AssemblyHandler.FindFirstTypeForName(line.Substring(0, indexOf++), true); if (list.m_Type == null) + { throw new ArgumentException($"Type not found for header: '{line}'"); + } line = line.Substring(indexOf); indexOf = line.IndexOf('('); @@ -1034,12 +1267,16 @@ namespace Server.Commands var parms = line.Substring(++indexOf); if (line.EndsWith(")")) + { parms = parms.Substring(0, parms.Length - 1); + } list.m_Params = parms.Split(';'); for (var i = 0; i < list.m_Params.Length; ++i) + { list.m_Params[i] = list.m_Params[i].Trim(); + } } else { @@ -1054,10 +1291,14 @@ namespace Server.Commands line = line.Trim(); if (line.Length == 0) + { break; + } if (line.StartsWith("#")) + { continue; + } list.m_Entries.Add(new DecorationEntryMag(line)); } diff --git a/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs b/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs index 2e66b53b8..cfcc41457 100644 --- a/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs +++ b/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs @@ -56,13 +56,19 @@ namespace Server.Commands void ProcessDeletion(TeleporterDefinition x) { count += TeleportersCreator.DeleteTeleporters(x.Source); - if (x.Back) count += TeleportersCreator.DeleteTeleporters(x.Destination); + if (x.Back) + { + count += TeleportersCreator.DeleteTeleporters(x.Destination); + } } if (!ProcessTeleporterData(from, ProcessDeletion)) { if (count > 0) - from.SendMessage(WarningHue, $"Partial Completion, {count} Teleporters Removed."); + { + @from.SendMessage(WarningHue, $"Partial Completion, {count} Teleporters Removed."); + } + return; } @@ -81,9 +87,15 @@ namespace Server.Commands if (!ProcessTeleporterData(from, c.CreateTeleporter)) { if (c.DelCount > 0) - from.SendMessage(WarningHue, $"Partial Completion: {c.DelCount} Teleporters Removed."); + { + @from.SendMessage(WarningHue, $"Partial Completion: {c.DelCount} Teleporters Removed."); + } + if (c.Count > 0) - from.SendMessage(WarningHue, $"Partial Completion: {c.Count} Teleporters Added."); + { + @from.SendMessage(WarningHue, $"Partial Completion: {c.Count} Teleporters Added."); + } + return; } @@ -104,7 +116,9 @@ namespace Server.Commands var teleporters = JsonSerializer.Deserialize>(json, JsonOptions); for (var i = 0; i < teleporters.Count; i++) + { processor(teleporters[i]); + } } catch (Exception ex) { @@ -144,7 +158,11 @@ namespace Server.Commands DelCount += DeleteTeleporters(telDef.Source); Count++; new Teleporter(telDef.Destination, telDef.Destination.Map).MoveToWorld(telDef.Source, telDef.Source.Map); - if (!telDef.Back) return; + if (!telDef.Back) + { + return; + } + DelCount += DeleteTeleporters(telDef.Destination); Count++; new Teleporter(telDef.Source, telDef.Source.Map).MoveToWorld(telDef.Destination, telDef.Destination.Map); diff --git a/Projects/UOContent/Commands/Profiling.cs b/Projects/UOContent/Commands/Profiling.cs index a8f02cbc5..dc0737eba 100644 --- a/Projects/UOContent/Commands/Profiling.cs +++ b/Projects/UOContent/Commands/Profiling.cs @@ -60,9 +60,13 @@ namespace Server.Commands public static void SetProfiles_OnCommand(CommandEventArgs e) { if (e.Length == 1) + { Core.Profiling = e.GetBoolean(0); + } else + { Core.Profiling = !Core.Profiling; + } e.Mobile.SendMessage("Profiling has been {0}.", Core.Profiling ? "enabled" : "disabled"); } @@ -148,29 +152,43 @@ namespace Server.Commands var flags = item.GetExpandFlags(); if ((flags & ~(ExpandFlag.TempFlag | ExpandFlag.SaveFlag)) == 0) + { continue; + } var itemType = item.GetType(); do { if (!typeTable.TryGetValue(itemType, out var countTable)) + { typeTable[itemType] = countTable = new int[9]; + } if ((flags & ExpandFlag.Name) != 0) + { ++countTable[0]; + } if ((flags & ExpandFlag.Items) != 0) + { ++countTable[1]; + } if ((flags & ExpandFlag.Bounce) != 0) + { ++countTable[2]; + } if ((flags & ExpandFlag.Holder) != 0) + { ++countTable[3]; + } if ((flags & ExpandFlag.Blessed) != 0) + { ++countTable[4]; + } /*if (( flags & ExpandFlag.TempFlag ) != 0) ++countTable[5]; @@ -179,10 +197,14 @@ namespace Server.Commands ++countTable[6];*/ if ((flags & ExpandFlag.Weight) != 0) + { ++countTable[7]; + } if ((flags & ExpandFlag.Spawner) != 0) + { ++countTable[8]; + } itemType = itemType.BaseType; } while (itemType != typeof(object)); @@ -215,8 +237,12 @@ namespace Server.Commands op.WriteLine("# {0}", kvp.Key.FullName); for (var i = 0; i < countTable.Length; ++i) + { if (countTable[i] > 0) + { op.WriteLine("{0}\t{1:N0}", names[i], countTable[i]); + } + } op.WriteLine(); } @@ -237,7 +263,9 @@ namespace Server.Commands foreach (var item in World.Items.Values) { if (item.Parent != null || item.Map != Map.Internal) + { continue; + } ++totalCount; @@ -295,7 +323,9 @@ namespace Server.Commands var count = bin.ReadInt32(); for (var i = 0; i < count; ++i) + { types.Add(AssemblyHandler.FindFirstTypeForName(bin.ReadString())); + } } long total = 0; diff --git a/Projects/UOContent/Commands/Properties.cs b/Projects/UOContent/Commands/Properties.cs index 832803d21..dcd63b3bc 100644 --- a/Projects/UOContent/Commands/Properties.cs +++ b/Projects/UOContent/Commands/Properties.cs @@ -58,11 +58,17 @@ namespace Server.Commands var ent = World.FindEntity(e.GetUInt32(0)); if (ent == null) + { e.Mobile.SendMessage("No object with that serial was found."); + } else if (!BaseCommand.IsAccessible(e.Mobile, ent)) + { e.Mobile.SendLocalizedMessage(500447); // That is not accessible. + } else + { e.Mobile.SendGump(new PropertiesGump(e.Mobile, ent)); + } } else { @@ -77,7 +83,9 @@ namespace Server.Commands var attrs = p.GetCustomAttributes(typeofCPA, false); if (attrs.Length == 0) + { return null; + } return attrs[0] as CPA; } @@ -90,7 +98,9 @@ namespace Server.Commands var split = propertyString.Split('.'); if (split.Length == 0) + { return null; + } var info = new PropertyInfo[split.Length]; @@ -99,7 +109,9 @@ namespace Server.Commands var propertyName = split[i]; if (CIEqual(propertyName, "current")) + { continue; + } var props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); @@ -108,7 +120,9 @@ namespace Server.Commands var access = endAccess; if (!isFinal) + { access |= PropertyAccess.Read; + } for (var j = 0; j < props.Length; ++j) { @@ -189,7 +203,9 @@ namespace Server.Commands for (var i = 0; i < chain.Length - 1; ++i) { if (chain[i] == null) + { continue; + } obj = chain[i].GetValue(obj, null); @@ -210,7 +226,9 @@ namespace Server.Commands var chain = GetPropertyInfoChain(from, o.GetType(), name, PropertyAccess.Read, ref failReason); if (chain == null || chain.Length == 0) + { return failReason; + } var p = GetPropertyInfo(ref o, chain, ref failReason); @@ -237,9 +255,13 @@ namespace Server.Commands var valueString = args[1 + i * 2]; if (valueString.StartsWith("0x")) + { realValues[i] = Convert.ToInt32(valueString.Substring(2), 16); + } else + { realValues[i] = Convert.ToInt32(valueString); + } } catch { @@ -247,21 +269,31 @@ namespace Server.Commands } if (realValues[i] > 0) + { positive = true; + } else if (realValues[i] < 0) + { negative = true; + } else + { return "Zero is not a valid value to offset."; + } string failReason = null; realObjs[i] = o; realProps[i] = GetPropertyInfo(from, ref realObjs[i], name, PropertyAccess.ReadWrite, ref failReason); if (failReason != null) + { return failReason; + } if (realProps[i] == null) + { return "Property not found."; + } } for (var i = 0; i < realProps.Length; ++i) @@ -269,7 +301,9 @@ namespace Server.Commands var obj = realProps[i].GetValue(realObjs[i], null); if (!(obj is IConvertible)) + { return "Property is not IConvertable."; + } try { @@ -287,16 +321,22 @@ namespace Server.Commands if (realProps.Length == 1) { if (positive) + { return "The property has been increased."; + } return "The property has been decreased."; } if (positive && negative) + { return "The properties have been changed."; + } if (positive) + { return "The properties have been increased."; + } return "The properties have been decreased."; } @@ -309,20 +349,34 @@ namespace Server.Commands string toString; if (value == null) + { toString = "null"; + } else if (IsNumeric(type)) + { toString = $"{value} (0x{value:X})"; + } else if (IsChar(type)) + { toString = $"'{value}' ({(int)value} [0x{(int)value:X}])"; + } else if (IsString(type)) + { toString = (string)value == "null" ? @"@""null""" : $"\"{value}\""; + } else if (IsText(type)) + { toString = ((TextDefinition)value).Format(false); + } else + { toString = value.ToString(); + } if (chain == null) + { return $"{p.Name} = {toString}"; + } var concat = new string[chain.Length * 2 + 1]; @@ -378,12 +432,17 @@ namespace Server.Commands var isSerial = IsSerial(type); if (isSerial) // mutate into int32 + { type = m_NumericTypes[4]; + } if (value == "(-null-)" && !type.IsValueType) + { value = null; + } if (IsEnum(type)) + { try { toSet = Enum.Parse(type, value ?? "", true); @@ -392,19 +451,25 @@ namespace Server.Commands { return "That is not a valid enumeration member."; } + } else if (IsType(type)) + { try { toSet = AssemblyHandler.FindFirstTypeForName(value); if (toSet == null) + { return "No type with that name was found."; + } } catch { return "No type with that name was found."; } + } else if (IsParsable(type)) + { try { toSet = Parse(obj, type, value); @@ -413,9 +478,13 @@ namespace Server.Commands { return "That is not properly formatted."; } + } else if (value == null) + { toSet = null; + } else if (value.StartsWith("0x") && IsNumeric(type)) + { try { toSet = Convert.ChangeType(Convert.ToUInt64(value.Substring(2), 16), type); @@ -424,7 +493,9 @@ namespace Server.Commands { return "That is not properly formatted."; } + } else + { try { toSet = Convert.ChangeType(value, type); @@ -433,9 +504,12 @@ namespace Server.Commands { return "That is not properly formatted."; } + } if (isSerial) // mutate back + { toSet = (Serial)(toSet ?? Serial.MinusOne); + } constructed = toSet; return null; @@ -453,21 +527,29 @@ namespace Server.Commands var reqLevel = AccessLevel.Administrator; if (newLevel == AccessLevel.Administrator) + { reqLevel = AccessLevel.Developer; + } else if (newLevel >= AccessLevel.Developer) + { reqLevel = AccessLevel.Owner; + } if (from.AccessLevel < reqLevel) + { return "You do not have access to that level."; + } } if (shouldLog) + { CommandLogging.LogChangeProperty( - from, + @from, logObject, givenName, toSet?.ToString() ?? "(-null-)" ); + } prop.SetValue(obj, toSet, null); return "Property has been set."; @@ -482,7 +564,10 @@ namespace Server.Commands { try { - if (toSet is AccessLevel) return "You do not have access to that level."; + if (toSet is AccessLevel) + { + return "You do not have access to that level."; + } prop.SetValue(obj, toSet, null); return "Property has been set."; @@ -521,9 +606,13 @@ namespace Server.Commands protected override void OnTarget(Mobile from, object o) { if (!BaseCommand.IsAccessible(from, o)) - from.SendLocalizedMessage(500447); // That is not accessible. + { + @from.SendLocalizedMessage(500447); // That is not accessible. + } else - from.SendGump(new PropertiesGump(from, o)); + { + @from.SendGump(new PropertiesGump(@from, o)); + } } } } @@ -655,7 +744,9 @@ namespace Server get { if (!IsBound) + { throw new NotYetBoundException(this); + } return m_Chain; } @@ -666,7 +757,9 @@ namespace Server get { if (!IsBound) + { throw new NotYetBoundException(this); + } return m_Chain[^1].PropertyType; } @@ -675,7 +768,9 @@ namespace Server public bool CheckAccess(Mobile from) { if (!IsBound) + { throw new NotYetBoundException(this); + } for (var i = 0; i < m_Chain.Length; ++i) { @@ -686,18 +781,26 @@ namespace Server var access = Access; if (!isFinal) + { access |= PropertyAccess.Read; + } var security = Properties.GetCPA(prop); if (security == null) + { throw new InternalAccessException(this); + } if ((access & PropertyAccess.Read) != 0 && from.AccessLevel < security.ReadLevel) - throw new ReadAccessException(this, from.AccessLevel, security.ReadLevel); + { + throw new ReadAccessException(this, @from.AccessLevel, security.ReadLevel); + } if ((access & PropertyAccess.Write) != 0 && (from.AccessLevel < security.WriteLevel || security.ReadOnly)) - throw new WriteAccessException(this, from.AccessLevel, security.ReadLevel); + { + throw new WriteAccessException(this, @from.AccessLevel, security.ReadLevel); + } } return true; @@ -706,7 +809,9 @@ namespace Server public void BindTo(Type objectType, PropertyAccess desiredAccess) { if (IsBound) + { throw new AlreadyBoundException(this); + } var split = Binding.Split('.'); @@ -722,20 +827,28 @@ namespace Server ); if (chain[i] == null) + { throw new UnknownPropertyException(this, split[i]); + } objectType = chain[i].PropertyType; var access = desiredAccess; if (!isFinal) + { access |= PropertyAccess.Read; + } if ((access & PropertyAccess.Read) != 0 && !chain[i].CanRead) + { throw new WriteOnlyException(this); + } if ((access & PropertyAccess.Write) != 0 && !chain[i].CanWrite) + { throw new ReadOnlyException(this); + } } Access = desiredAccess; @@ -745,12 +858,16 @@ namespace Server public override string ToString() { if (!IsBound) + { return Binding; + } var toJoin = new string[m_Chain.Length]; for (var i = 0; i < toJoin.Length; ++i) + { toJoin[i] = m_Chain[i].Name; + } return string.Join(".", toJoin); } diff --git a/Projects/UOContent/Commands/SignParser.cs b/Projects/UOContent/Commands/SignParser.cs index f379cd831..224b2b773 100644 --- a/Projects/UOContent/Commands/SignParser.cs +++ b/Projects/UOContent/Commands/SignParser.cs @@ -74,7 +74,9 @@ namespace Server.Commands }; for (var j = 0; maps?.Length > j; ++j) + { Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); + } } from.SendMessage("Sign generating complete."); @@ -90,13 +92,19 @@ namespace Server.Commands var eable = map.GetItemsInRange(location, 0); foreach (var item in eable) + { if (item is Sign && item.Z == location.Z && item.ItemID == itemID) + { m_ToDelete.Enqueue(item); + } + } eable.Free(); while (m_ToDelete.Count > 0) + { m_ToDelete.Dequeue().Delete(); + } Item sign; @@ -113,9 +121,13 @@ namespace Server.Commands if (map == Map.Malas) { if (location.X >= 965 && location.Y >= 502 && location.X <= 1012 && location.Y <= 537) + { sign.Hue = 0x47E; + } else if (location.X >= 1960 && location.Y >= 1278 && location.X < 2106 && location.Y < 1413) + { sign.Hue = 0x44E; + } } sign.MoveToWorld(location, map); diff --git a/Projects/UOContent/Commands/Skills.cs b/Projects/UOContent/Commands/Skills.cs index 3e8914fcc..1f341e96b 100644 --- a/Projects/UOContent/Commands/Skills.cs +++ b/Projects/UOContent/Commands/Skills.cs @@ -23,9 +23,13 @@ namespace Server.Commands else { if (Enum.TryParse(arg.GetString(0), true, out SkillName skill)) + { arg.Mobile.Target = new SkillTarget(skill, arg.GetDouble(1)); + } else + { arg.Mobile.SendLocalizedMessage(1005631); // You have specified an invalid skill to set. + } } } @@ -34,9 +38,13 @@ namespace Server.Commands public static void SetAllSkills_OnCommand(CommandEventArgs arg) { if (arg.Length != 1) + { arg.Mobile.SendMessage("SetAllSkills "); + } else + { arg.Mobile.Target = new AllSkillsTarget(arg.GetDouble(0)); + } } [Usage("GetSkill ")] @@ -50,9 +58,13 @@ namespace Server.Commands else { if (Enum.TryParse(arg.GetString(0), true, out SkillName skill)) + { arg.Mobile.Target = new SkillTarget(skill); + } else + { arg.Mobile.SendMessage("You have specified an invalid skill to get."); + } } } @@ -69,7 +81,9 @@ namespace Server.Commands var skills = targ.Skills; for (var i = 0; i < skills.Length; ++i) + { skills[i].Base = m_Value; + } CommandLogging.LogChangeProperty(from, targ, "EverySkill.Base", m_Value.ToString()); } @@ -106,7 +120,9 @@ namespace Server.Commands var skill = targ.Skills[m_Skill]; if (skill == null) + { return; + } if (m_Set) { diff --git a/Projects/UOContent/Commands/SkillsMenu.cs b/Projects/UOContent/Commands/SkillsMenu.cs index fbfd6f618..327f316e4 100644 --- a/Projects/UOContent/Commands/SkillsMenu.cs +++ b/Projects/UOContent/Commands/SkillsMenu.cs @@ -31,7 +31,9 @@ namespace Server.Commands protected override void OnTarget(Mobile from, object o) { if (o is Mobile mobile) - from.SendGump(new SkillsGump(from, mobile)); + { + @from.SendGump(new SkillsGump(@from, mobile)); + } } } } diff --git a/Projects/UOContent/Commands/Statics.cs b/Projects/UOContent/Commands/Statics.cs index 68f25df59..b80973469 100644 --- a/Projects/UOContent/Commands/Statics.cs +++ b/Projects/UOContent/Commands/Statics.cs @@ -63,8 +63,9 @@ namespace Server var map = from.Map; if (map != null && map != Map.Internal) + { SendWarning( - from, + @from, "You are about to freeze all items in {0}.", BaseFreezeWarning, map, @@ -72,6 +73,7 @@ namespace Server NullP3D, FreezeWarning_Callback ); + } } [Usage("FreezeWorld")] @@ -123,7 +125,9 @@ namespace Server private static void FreezeWarning_Callback(Mobile from, bool okay, StateInfo si) { if (!okay) + { return; + } Freeze(from, si.m_Map, si.m_Start, si.m_End); } @@ -135,43 +139,57 @@ namespace Server if (start3d == NullP3D && end3d == NullP3D) { if (targetMap == null) + { CommandLogging.WriteLine( - from, + @from, "{0} {1} invoking freeze for every item in every map", - from.AccessLevel, - CommandLogging.Format(from) + @from.AccessLevel, + CommandLogging.Format(@from) ); + } else + { CommandLogging.WriteLine( - from, + @from, "{0} {1} invoking freeze for every item in {0}", - from.AccessLevel, - CommandLogging.Format(from), + @from.AccessLevel, + CommandLogging.Format(@from), targetMap ); + } foreach (var item in World.Items.Values) { if (targetMap != null && item.Map != targetMap) + { continue; + } if (item.Parent != null) + { continue; + } if (item is Static || item is BaseFloor || item is BaseWall) { var itemMap = item.Map; if (itemMap == null || itemMap == Map.Internal) + { continue; + } if (!mapTable.TryGetValue(itemMap, out var table)) + { mapTable[itemMap] = table = new Dictionary(); + } var p = new Point2D(item.X >> 3, item.Y >> 3); if (!table.TryGetValue(p, out var state)) + { table[p] = state = new DeltaState(p); + } state.m_List.Add(item); } @@ -195,23 +213,31 @@ namespace Server targetMap.GetItemsInBounds(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1)); foreach (var item in eable) + { if (item is Static || item is BaseFloor || item is BaseWall) { var itemMap = item.Map; if (itemMap == null || itemMap == Map.Internal) + { continue; + } if (!mapTable.TryGetValue(itemMap, out var table)) + { mapTable[itemMap] = table = new Dictionary(); + } var p = new Point2D(item.X >> 3, item.Y >> 3); if (!table.TryGetValue(p, out var state)) + { table[p] = state = new DeltaState(p); + } state.m_List.Add(item); } + } eable.Free(); } @@ -268,7 +294,9 @@ namespace Server ); if (oldTileCount < 0) + { continue; + } var newTileCount = 0; var newTiles = new StaticTile[state.m_List.Count]; @@ -281,7 +309,9 @@ namespace Server var yOffset = item.Y - state.m_Y * 8; if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8) + { continue; + } var newTile = new StaticTile( (ushort)item.ItemID, @@ -349,7 +379,8 @@ namespace Server } if (totalFrozen == 0 && badDataFile) - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -359,8 +390,10 @@ namespace Server 240 ) ); + } else - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -370,6 +403,7 @@ namespace Server 240 ) ); + } } [Usage("Unfreeze")] @@ -387,6 +421,7 @@ namespace Server var map = e.Mobile.Map; if (map != null && map != Map.Internal) + { SendWarning( e.Mobile, "You are about to unfreeze all items in {0}.", @@ -396,6 +431,7 @@ namespace Server NullP3D, UnfreezeWarning_Callback ); + } } [Usage("UnfreezeWorld")] @@ -429,7 +465,9 @@ namespace Server private static void UnfreezeWarning_Callback(Mobile from, bool okay, StateInfo si) { if (!okay) + { return; + } Unfreeze(from, si.m_Map, si.m_Start, si.m_End); } @@ -463,6 +501,7 @@ namespace Server var mulWriter = new BinaryWriter(mulStream); for (var x = xStartBlock; x <= xEndBlock; ++x) + { for (var y = yStartBlock; y <= yEndBlock; ++y) { var oldTiles = ReadStaticBlock( @@ -476,7 +515,9 @@ namespace Server ); if (oldTileCount < 0) + { continue; + } var newTileCount = 0; var newTiles = new StaticTile[oldTileCount]; @@ -543,6 +584,7 @@ namespace Server matrix.SetStaticBlock(x, y, null); } + } } public static void DoUnfreeze(Map map, ref bool badDataFile, ref int totalUnfrozen) @@ -598,7 +640,8 @@ namespace Server } if (totalUnfrozen == 0 && badDataFile) - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -608,8 +651,10 @@ namespace Server 240 ) ); + } else - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -619,12 +664,15 @@ namespace Server 240 ) ); + } } private static FileStream OpenWrite(FileStream orig) { if (orig == null) + { return null; + } try { @@ -665,18 +713,23 @@ namespace Server mulStream.Seek(lookup, SeekOrigin.Begin); if (m_TileBuffer.Length < count) + { m_TileBuffer = new StaticTile[count]; + } var staTiles = m_TileBuffer; if (m_Buffer == null || length > m_Buffer.Length) + { m_Buffer = new byte[length]; + } mulStream.Read(m_Buffer, 0, length); var index = 0; for (var i = 0; i < count; ++i) + { staTiles[i] .Set( (ushort)(m_Buffer[index++] | (m_Buffer[index++] << 8)), @@ -685,6 +738,7 @@ namespace Server (sbyte)m_Buffer[index++], (short)(m_Buffer[index++] | (m_Buffer[index++] << 8)) ); + } } } catch diff --git a/Projects/UOContent/Commands/VisibilityList.cs b/Projects/UOContent/Commands/VisibilityList.cs index 2b7e27bc2..fa4d8be94 100644 --- a/Projects/UOContent/Commands/VisibilityList.cs +++ b/Projects/UOContent/Commands/VisibilityList.cs @@ -47,7 +47,9 @@ namespace Server.Commands pm.SendMessage("You are visible to {0} mobile{1}:", list.Count, list.Count == 1 ? "" : "s"); for (var i = 0; i < list.Count; ++i) + { pm.SendMessage("#{0}: {1}", i + 1, list[i].Name); + } } else { @@ -72,7 +74,9 @@ namespace Server.Commands var m = list[i]; if (!m.CanSee(pm) && Utility.InUpdateRange(m, pm)) + { m.Send(pm.RemovePacket); + } } } } @@ -117,7 +121,9 @@ namespace Server.Commands ns.Send(pm.OPLPacket); foreach (var item in pm.Items) + { ns.Send(item.OPLPacket); + } } } else diff --git a/Projects/UOContent/Commands/Wipe.cs b/Projects/UOContent/Commands/Wipe.cs index 62dc2bf58..e6ccf37bd 100644 --- a/Projects/UOContent/Commands/Wipe.cs +++ b/Projects/UOContent/Commands/Wipe.cs @@ -81,22 +81,34 @@ namespace Server.Commands IPooledEnumerable eable; if (!items && !multis || !mobiles) + { return; + } eable = map.GetObjectsInBounds(rect); foreach (var obj in eable) + { if (items && obj is Item && !(obj is BaseMulti || obj is HouseSign)) + { toDelete.Add(obj); + } else if (multis && obj is BaseMulti) + { toDelete.Add(obj); + } else if (obj is Mobile mobile && !mobile.Player) + { toDelete.Add(mobile); + } + } eable.Free(); for (var i = 0; i < toDelete.Count; ++i) + { toDelete[i].Delete(); + } } } } diff --git a/Projects/UOContent/Configuration/ExpansionConfiguration.cs b/Projects/UOContent/Configuration/ExpansionConfiguration.cs index dcc52cd98..6fbdc6fe6 100644 --- a/Projects/UOContent/Configuration/ExpansionConfiguration.cs +++ b/Projects/UOContent/Configuration/ExpansionConfiguration.cs @@ -29,8 +29,10 @@ namespace Server AOS.DisableStatInfluences(); if (ObjectPropertyList.Enabled) + { PacketHandlers.SingleClickProps = true; // single click for everything is overridden to check object property list + } Mobile.AOSStatusHandler = AOS.GetStatus; } diff --git a/Projects/UOContent/Context Menus/AddToParty.cs b/Projects/UOContent/Context Menus/AddToParty.cs index 9b59f5914..a88cdc57f 100644 --- a/Projects/UOContent/Context Menus/AddToParty.cs +++ b/Projects/UOContent/Context Menus/AddToParty.cs @@ -19,19 +19,33 @@ namespace Server.ContextMenus var mp = Party.Get(m_Target); if (m_From == m_Target) + { m_From.SendLocalizedMessage(1005439); // You cannot add yourself to a party. + } else if (p != null && p.Leader != m_From) + { m_From.SendLocalizedMessage(1005453); // You may only add members to the party if you are the leader. + } else if (p != null && p.Members.Count + p.Candidates.Count >= Party.Capacity) + { m_From.SendLocalizedMessage(1008095); // You may only have 10 in your party (this includes candidates). + } else if (!m_Target.Player) + { m_From.SendLocalizedMessage(1005444); // The creature ignores your offer. + } else if (mp != null && mp == p) + { m_From.SendLocalizedMessage(1005440); // This person is already in your party! + } else if (mp != null) + { m_From.SendLocalizedMessage(1005441); // This person is already in a party! + } else + { Party.Invite(m_From, m_Target); + } } } } diff --git a/Projects/UOContent/Context Menus/AddToSpellbookEntry.cs b/Projects/UOContent/Context Menus/AddToSpellbookEntry.cs index 8c4f0dcbc..17bc9275c 100644 --- a/Projects/UOContent/Context Menus/AddToSpellbookEntry.cs +++ b/Projects/UOContent/Context Menus/AddToSpellbookEntry.cs @@ -13,7 +13,9 @@ namespace Server.ContextMenus public override void OnClick() { if (Owner.From.CheckAlive() && Owner.Target is SpellScroll scroll) + { Owner.From.Target = new InternalTarget(scroll); + } } private class InternalTarget : Target @@ -25,8 +27,9 @@ namespace Server.ContextMenus protected override void OnTarget(Mobile from, object targeted) { if (targeted is Spellbook book) - if (from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 && - m_Scroll.CheckItemUse(from)) + { + if (@from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 && + m_Scroll.CheckItemUse(@from)) { var type = Spellbook.GetTypeForSpell(m_Scroll.SpellID); @@ -35,7 +38,7 @@ namespace Server.ContextMenus } else if (book.HasSpell(m_Scroll.SpellID)) { - from.SendLocalizedMessage(500179); // That spell is already present in that spellbook. + @from.SendLocalizedMessage(500179); // That spell is already present in that spellbook. } else { @@ -47,10 +50,11 @@ namespace Server.ContextMenus m_Scroll.Consume(); - from.Send(new PlaySound(0x249, book.GetWorldLocation())); + @from.Send(new PlaySound(0x249, book.GetWorldLocation())); } } } + } } } } diff --git a/Projects/UOContent/Context Menus/EatEntry.cs b/Projects/UOContent/Context Menus/EatEntry.cs index 453face57..d78ffc9cf 100644 --- a/Projects/UOContent/Context Menus/EatEntry.cs +++ b/Projects/UOContent/Context Menus/EatEntry.cs @@ -16,7 +16,9 @@ namespace Server.ContextMenus public override void OnClick() { if (m_Food?.Deleted != false || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse(m_From)) + { return; + } m_Food.Eat(m_From); } diff --git a/Projects/UOContent/Context Menus/EjectPlayer.cs b/Projects/UOContent/Context Menus/EjectPlayer.cs index 91f0f3e9c..e00a87802 100644 --- a/Projects/UOContent/Context Menus/EjectPlayer.cs +++ b/Projects/UOContent/Context Menus/EjectPlayer.cs @@ -18,7 +18,9 @@ namespace Server.ContextMenus public override void OnClick() { if (!m_From.Alive || m_TargetHouse.Deleted || !m_TargetHouse.IsFriend(m_From)) + { return; + } m_TargetHouse.Kick(m_From, m_Target); } diff --git a/Projects/UOContent/Context Menus/OpenBankEntry.cs b/Projects/UOContent/Context Menus/OpenBankEntry.cs index 35036cbbb..66ccb4da7 100644 --- a/Projects/UOContent/Context Menus/OpenBankEntry.cs +++ b/Projects/UOContent/Context Menus/OpenBankEntry.cs @@ -9,12 +9,18 @@ namespace Server.ContextMenus public override void OnClick() { if (!Owner.From.CheckAlive()) + { return; + } if (Owner.From.Criminal) + { m_Banker.Say(500378); // Thou art a criminal and cannot access thy bank box. + } else + { Owner.From.BankBox.Open(); + } } } } diff --git a/Projects/UOContent/Context Menus/TeachEntry.cs b/Projects/UOContent/Context Menus/TeachEntry.cs index 5eeed3aad..e609041ff 100644 --- a/Projects/UOContent/Context Menus/TeachEntry.cs +++ b/Projects/UOContent/Context Menus/TeachEntry.cs @@ -16,13 +16,17 @@ namespace Server.ContextMenus m_From = from; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (!m_From.CheckAlive()) + { return; + } m_Mobile.Teach(m_Skill, m_From, 0, false); } diff --git a/Projects/UOContent/Engines/BulkOrders/BODTarget.cs b/Projects/UOContent/Engines/BulkOrders/BODTarget.cs index 774560158..650395c4e 100644 --- a/Projects/UOContent/Engines/BulkOrders/BODTarget.cs +++ b/Projects/UOContent/Engines/BulkOrders/BODTarget.cs @@ -11,7 +11,9 @@ namespace Server.Engines.BulkOrders protected override void OnTarget(Mobile from, object targeted) { if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack)) + { return; + } if (!(targeted is Item item && item.IsChildOf(from.Backpack))) { diff --git a/Projects/UOContent/Engines/BulkOrders/BaseBOD.cs b/Projects/UOContent/Engines/BulkOrders/BaseBOD.cs index 0a22ac616..8cd693229 100644 --- a/Projects/UOContent/Engines/BulkOrders/BaseBOD.cs +++ b/Projects/UOContent/Engines/BulkOrders/BaseBOD.cs @@ -71,7 +71,9 @@ namespace Server.Engines.BulkOrders for (var i = 0; i < chances.Length; ++i) { if (random < chances[i]) + { return i == 0 ? BulkMaterialType.None : start + (i - 1); + } random -= chances[i]; } @@ -108,7 +110,9 @@ namespace Server.Engines.BulkOrders var reward = rewardGroup.Items[i]; if (reward != null) + { list.Add(reward); + } } } else @@ -116,7 +120,9 @@ namespace Server.Engines.BulkOrders var reward = rewardGroup.AcquireItem(); if (reward != null) + { list.Add(reward); + } } return list; @@ -125,11 +131,15 @@ namespace Server.Engines.BulkOrders public virtual void BeginCombine(Mobile from) { if (Complete) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed. + } else - from.Target = new BODTarget(this); + { + @from.Target = new BODTarget(this); + } } public override void Serialize(IGenericWriter writer) @@ -161,7 +171,9 @@ namespace Server.Engines.BulkOrders } if (Parent == null && Map == Map.Internal && Location == Point3D.Zero) + { Delete(); + } } } } diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BOBFilterGump.cs b/Projects/UOContent/Engines/BulkOrders/Books/BOBFilterGump.cs index d7281cdd0..d02247c4c 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BOBFilterGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BOBFilterGump.cs @@ -129,7 +129,9 @@ namespace Server.Engines.BulkOrders var number = filters[i, 0]; if (number == 0) + { continue; + } var isSelected = filters[i, 1] == filterValue || i % xOffsets.Length == 0 && filterValue == 0; @@ -201,7 +203,9 @@ namespace Server.Engines.BulkOrders if (index >= 0 && index < filters.GetLength(0)) { if (filters[index, 0] == 0) + { break; + } switch (type) { diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BOBGump.cs b/Projects/UOContent/Engines/BulkOrders/Books/BOBGump.cs index efd324ba8..7652b116c 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BOBGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BOBGump.cs @@ -35,7 +35,9 @@ namespace Server.Engines.BulkOrders var entry = book.Entries[i]; if (CheckFilter(entry)) + { list.Add(entry); + } } } @@ -62,7 +64,9 @@ namespace Server.Engines.BulkOrders var width = 600; if (!canPrice) + { width = 516; + } X = (624 - width) / 2; @@ -78,7 +82,9 @@ namespace Server.Engines.BulkOrders } if (canDrop) + { AddImageTiled(24, 64, 32, 352, 1416); + } AddImageTiled(58, 64, 36, 352, 200); AddImageTiled(96, 64, 133, 352, 1416); @@ -91,7 +97,9 @@ namespace Server.Engines.BulkOrders var entry = list[i]; if (!CheckFilter(entry)) + { continue; + } AddImageTiled(24, 94 + tableIndex * 32, canPrice ? 573 : 489, 2, 2624); tableIndex += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; @@ -116,17 +124,25 @@ namespace Server.Engines.BulkOrders var f = from.UseOwnFilter ? from.BOBFilter : book.Filter; if (f.IsDefault) + { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927); // Using No Filter + } else if (from.UseOwnFilter) + { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927); // Using Your Filter + } else + { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927); // Using Book Filter + } AddButton(375, 416, 4017, 4018, 0); AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor); // EXIT if (canDrop) + { AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor); // Drop + } if (canPrice) { @@ -164,14 +180,18 @@ namespace Server.Engines.BulkOrders var entry = list[i]; if (!CheckFilter(entry)) + { continue; + } if (entry is BOBLargeEntry largeEntry) { var y = 96 + tableIndex * 32; if (canDrop) + { AddButton(35, y + 2, 5602, 5606, 5 + i * 2); + } if (canDrop || canBuy && entry.Price > 0) { @@ -188,16 +208,24 @@ namespace Server.Engines.BulkOrders AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor); if (entry.RequireExceptional) + { AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional + } else + { AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal + } var name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType); if (name.Number > 0) + { AddHtmlLocalized(316, y, 100, 20, name, LabelColor); + } else + { AddLabel(316, y, 1152, name); + } AddLabel(421, y, 1152, $"{sub.AmountCur} / {entry.AmountMax}"); @@ -212,7 +240,9 @@ namespace Server.Engines.BulkOrders var y = 96 + tableIndex++ * 32; if (canDrop) + { AddButton(35, y + 2, 5602, 5606, 5 + i * 2); + } if (canDrop || canBuy && smallEntry.Price > 0) { @@ -225,16 +255,24 @@ namespace Server.Engines.BulkOrders AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor); if (smallEntry.RequireExceptional) + { AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional + } else + { AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal + } var name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType); if (name.Number > 0) + { AddHtmlLocalized(316, y, 100, 20, name, LabelColor); + } else + { AddLabel(316, y, 1152, name); + } AddLabel(421, y, 1152, $"{smallEntry.AmountCur} / {smallEntry.AmountMax}"); } @@ -244,6 +282,7 @@ namespace Server.Engines.BulkOrders public bool CheckFilter(IBOBEntry entry) { if (entry is BOBLargeEntry largeEntry) + { return CheckFilter( entry.Material, entry.AmountMax, @@ -252,8 +291,10 @@ namespace Server.Engines.BulkOrders entry.DeedType, largeEntry.Entries.Length > 0 ? largeEntry.Entries[0].ItemType : null ); + } if (entry is BOBSmallEntry smallEntry) + { return CheckFilter( entry.Material, entry.AmountMax, @@ -262,6 +303,7 @@ namespace Server.Engines.BulkOrders entry.DeedType, smallEntry.ItemType ); + } return false; } @@ -274,24 +316,44 @@ namespace Server.Engines.BulkOrders var f = m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter; if (f.IsDefault) + { return true; + } if (f.Quality == 1 && reqExc) + { return false; + } + if (f.Quality == 2 && !reqExc) + { return false; + } if (f.Quantity == 1 && amountMax != 10) + { return false; + } + if (f.Quantity == 2 && amountMax != 15) + { return false; + } + if (f.Quantity == 3 && amountMax != 20) + { return false; + } if (f.Type == 1 && isLarge) + { return false; + } + if (f.Type == 2 && !isLarge) + { return false; + } return f.Material switch { @@ -320,7 +382,9 @@ namespace Server.Engines.BulkOrders var index = 0; while (page-- > 0) + { index += GetCountForIndex(index); + } return index; } @@ -341,7 +405,9 @@ namespace Server.Engines.BulkOrders var add = entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; if (slots + add > 10) + { break; + } slots += add; } @@ -355,7 +421,9 @@ namespace Server.Engines.BulkOrders public int GetPageForIndex(int index, int sizeDropped) { if (index <= 0) + { return 0; + } var count = 0; var page = 0; @@ -366,7 +434,9 @@ namespace Server.Engines.BulkOrders { var entry = list[i]; if (!CheckFilter(entry)) + { continue; + } var add = entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; count += add; @@ -393,13 +463,17 @@ namespace Server.Engines.BulkOrders { var entry = list[i]; if (CheckFilter(entry)) + { count += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; + } i++; } if (count > 10) + { page++; + } } return page; @@ -433,7 +507,9 @@ namespace Server.Engines.BulkOrders case BulkMaterialType.None: { if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))) + { return 1062235; + } return 1044286; } @@ -468,14 +544,18 @@ namespace Server.Engines.BulkOrders case 2: // Previous page { if (m_Page > 0) + { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List)); + } return; } case 3: // Next page { if (GetIndexForPage(m_Page + 1) < m_List.Count) + { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List)); + } break; } @@ -497,7 +577,9 @@ namespace Server.Engines.BulkOrders index /= 2; if (index < 0 || index >= m_List.Count) + { break; + } var bobEntry = m_List[index]; @@ -570,7 +652,9 @@ namespace Server.Engines.BulkOrders var vi = pv.GetVendorItem(m_Book); if (vi?.IsForSale != false) + { return; + } var sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; var price = bobEntry.Price; @@ -635,7 +719,9 @@ namespace Server.Engines.BulkOrders var entry = m_List[i]; if (!m_Book.Entries.Contains(entry)) + { continue; + } entry.Price = price; } @@ -643,14 +729,18 @@ namespace Server.Engines.BulkOrders from.SendMessage("Deed prices set."); if (from is PlayerMobile mobile) + { mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List)); + } } else { m_Entry.Price = price; from.SendLocalizedMessage(1062384); // Deed price set. if (from is PlayerMobile mobile) + { mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List)); + } } } } diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeEntry.cs b/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeEntry.cs index 62f400da5..a04333fc1 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeEntry.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeEntry.cs @@ -7,9 +7,13 @@ namespace Server.Engines.BulkOrders RequireExceptional = bod.RequireExceptional; if (bod is LargeTailorBOD) + { DeedType = BODType.Tailor; + } else if (bod is LargeSmithBOD) + { DeedType = BODType.Smith; + } Material = bod.Material; AmountMax = bod.AmountMax; @@ -17,7 +21,9 @@ namespace Server.Engines.BulkOrders Entries = new BOBLargeSubEntry[bod.Entries.Length]; for (var i = 0; i < Entries.Length; ++i) + { Entries[i] = new BOBLargeSubEntry(bod.Entries[i]); + } } public BOBLargeEntry(IGenericReader reader) @@ -39,7 +45,9 @@ namespace Server.Engines.BulkOrders Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()]; for (var i = 0; i < Entries.Length; ++i) + { Entries[i] = new BOBLargeSubEntry(reader); + } break; } @@ -63,12 +71,18 @@ namespace Server.Engines.BulkOrders LargeBOD bod = null; if (DeedType == BODType.Smith) + { bod = new LargeSmithBOD(AmountMax, RequireExceptional, Material, ReconstructEntries()); + } else if (DeedType == BODType.Tailor) + { bod = new LargeTailorBOD(AmountMax, RequireExceptional, Material, ReconstructEntries()); + } for (var i = 0; bod?.Entries.Length >= i; ++i) + { bod.Entries[i].Owner = bod; + } return bod; } @@ -78,11 +92,13 @@ namespace Server.Engines.BulkOrders var entries = new LargeBulkEntry[Entries.Length]; for (var i = 0; i < Entries.Length; ++i) + { entries[i] = new LargeBulkEntry( null, new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic) ) { Amount = Entries[i].AmountCur }; + } return entries; } @@ -101,7 +117,9 @@ namespace Server.Engines.BulkOrders writer.WriteEncodedInt(Entries.Length); for (var i = 0; i < Entries.Length; ++i) + { Entries[i].Serialize(writer); + } } } } diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeSubEntry.cs b/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeSubEntry.cs index 9621cafde..f6e7f6cef 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeSubEntry.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BOBLargeSubEntry.cs @@ -23,7 +23,9 @@ namespace Server.Engines.BulkOrders var type = reader.ReadString(); if (type != null) + { ItemType = AssemblyHandler.FindFirstTypeForName(type); + } AmountCur = reader.ReadEncodedInt(); Number = reader.ReadEncodedInt(); diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BOBSmallEntry.cs b/Projects/UOContent/Engines/BulkOrders/Books/BOBSmallEntry.cs index 10189dc6f..85b6dcffa 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BOBSmallEntry.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BOBSmallEntry.cs @@ -10,9 +10,13 @@ namespace Server.Engines.BulkOrders RequireExceptional = bod.RequireExceptional; if (bod is SmallTailorBOD) + { DeedType = BODType.Tailor; + } else if (bod is SmallSmithBOD) + { DeedType = BODType.Smith; + } Material = bod.Material; AmountCur = bod.AmountCur; @@ -32,7 +36,9 @@ namespace Server.Engines.BulkOrders var type = reader.ReadString(); if (type != null) + { ItemType = AssemblyHandler.FindFirstTypeForName(type); + } RequireExceptional = reader.ReadBool(); @@ -73,9 +79,13 @@ namespace Server.Engines.BulkOrders SmallBOD bod = null; if (DeedType == BODType.Smith) + { bod = new SmallSmithBOD(AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material); + } else if (DeedType == BODType.Tailor) + { bod = new SmallTailorBOD(AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material); + } return bod; } diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BODBuyGump.cs b/Projects/UOContent/Engines/BulkOrders/Books/BODBuyGump.cs index 32b758fe7..a51226f96 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BODBuyGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BODBuyGump.cs @@ -61,7 +61,9 @@ namespace Server.Engines.BulkOrders var price = 0; if (pv.GetVendorItem(m_Book)?.IsForSale == false) + { price = m_Entry.Price; + } if (price != m_Price) { @@ -116,9 +118,13 @@ namespace Server.Engines.BulkOrders } if (m_Book.Entries.Count > 0) + { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); + } else + { m_From.SendLocalizedMessage(1062381); // The book is empty. + } } else { diff --git a/Projects/UOContent/Engines/BulkOrders/Books/BulkOrderBook.cs b/Projects/UOContent/Engines/BulkOrders/Books/BulkOrderBook.cs index fff3fbbe6..35c4fec84 100644 --- a/Projects/UOContent/Engines/BulkOrders/Books/BulkOrderBook.cs +++ b/Projects/UOContent/Engines/BulkOrders/Books/BulkOrderBook.cs @@ -52,11 +52,17 @@ namespace Server.Engines.BulkOrders public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (Entries.Count == 0) - from.SendLocalizedMessage(1062381); // The book is empty. + { + @from.SendLocalizedMessage(1062381); // The book is empty. + } else if (from is PlayerMobile mobile) + { mobile.SendGump(new BOBGump(mobile, this)); + } } public override void OnDoubleClickSecureTrade(Mobile from) @@ -76,9 +82,13 @@ namespace Server.Engines.BulkOrders var trade = GetSecureTradeCont()?.Trade; if (trade?.From.Mobile == from) + { trade.To.Mobile.SendGump(new BOBGump((PlayerMobile)trade.To.Mobile, this)); + } else if (trade?.To.Mobile == from) + { trade.From.Mobile.SendGump(new BOBGump((PlayerMobile)trade.From.Mobile, this)); + } } } @@ -93,13 +103,20 @@ namespace Server.Engines.BulkOrders } if (!from.Backpack.CheckHold(from, dropped, true, true)) + { return false; + } + if (Entries.Count < 500) { if (dropped is LargeBOD bod) + { Entries.Add(new BOBLargeEntry(bod)); + } else + { Entries.Add(new BOBSmallEntry((SmallBOD)dropped)); + } InvalidateProperties(); @@ -113,7 +130,9 @@ namespace Server.Engines.BulkOrders from.SendLocalizedMessage(1062386); // Deed added to book. if (from is PlayerMobile pm) + { pm.SendGump(new BOBGump(pm, this)); + } dropped.Delete(); @@ -133,7 +152,9 @@ namespace Server.Engines.BulkOrders var total = base.GetTotal(type); if (type == TotalType.Items) + { total = ItemCount; + } return total; } @@ -244,7 +265,9 @@ namespace Server.Engines.BulkOrders list.Add(1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~ if (!string.IsNullOrEmpty(m_BookName)) + { list.Add(1062481, m_BookName); // Book Name: ~1_val~ + } } public override void OnSingleClick(Mobile from) @@ -254,7 +277,9 @@ namespace Server.Engines.BulkOrders LabelTo(from, 1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~ if (!string.IsNullOrEmpty(m_BookName)) - LabelTo(from, 1062481, m_BookName); + { + LabelTo(@from, 1062481, m_BookName); + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -262,7 +287,9 @@ namespace Server.Engines.BulkOrders base.GetContextMenuEntries(from, list); if (from.CheckAlive() && IsChildOf(from.Backpack)) - list.Add(new NameBookEntry(from, this)); + { + list.Add(new NameBookEntry(@from, this)); + } SetSecureLevelEntry.AddTo(from, this, list); } @@ -297,7 +324,9 @@ namespace Server.Engines.BulkOrders public override void OnResponse(Mobile from, string text) { if (text.Length > 40) + { text = text.Substring(0, 40); + } if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Engines/BulkOrders/BulkMaterialType.cs b/Projects/UOContent/Engines/BulkOrders/BulkMaterialType.cs index 45c9edf48..76a411439 100644 --- a/Projects/UOContent/Engines/BulkOrders/BulkMaterialType.cs +++ b/Projects/UOContent/Engines/BulkOrders/BulkMaterialType.cs @@ -31,7 +31,9 @@ namespace Server.Engines.BulkOrders public static BulkGenericType Classify(BODType deedType, Type itemType) { if (deedType != BODType.Tailor) + { return BulkGenericType.Iron; + } return itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)) ? BulkGenericType.Leather diff --git a/Projects/UOContent/Engines/BulkOrders/LargeBOD.cs b/Projects/UOContent/Engines/BulkOrders/LargeBOD.cs index 19764b217..b297409ea 100644 --- a/Projects/UOContent/Engines/BulkOrders/LargeBOD.cs +++ b/Projects/UOContent/Engines/BulkOrders/LargeBOD.cs @@ -35,8 +35,12 @@ namespace Server.Engines.BulkOrders get { for (var i = 0; i < m_Entries.Length; ++i) + { if (m_Entries[i].Amount < AmountMax) + { return false; + } + } return true; } @@ -51,15 +55,21 @@ namespace Server.Engines.BulkOrders list.Add(1060655); // large bulk order if (RequireExceptional) + { list.Add(1045141); // All items must be exceptional. + } if (Material != BulkMaterialType.None) + { list.Add(LargeBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material. + } list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~ for (var i = 0; i < m_Entries.Length; ++i) + { list.Add(1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount); // ~1_val~: ~2_val~ + } } public override void OnDoubleClickNotAccessible(Mobile from) @@ -75,9 +85,13 @@ namespace Server.Engines.BulkOrders public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor) - from.SendGump(new LargeBODGump(from, this)); + { + @from.SendGump(new LargeBODGump(@from, this)); + } else - from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it. + { + @from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it. + } } public override void EndCombine(Mobile from, Item item) @@ -91,11 +105,13 @@ namespace Server.Engines.BulkOrders LargeBulkEntry entry = null; for (var i = 0; i < m_Entries.Length; ++i) + { if (m_Entries[i].Details.Type == small.Type) { entry = m_Entries[i]; break; } + } if (entry == null) { @@ -140,7 +156,9 @@ namespace Server.Engines.BulkOrders from.SendGump(new LargeBODGump(from, this)); if (!Complete) - BeginCombine(from); + { + BeginCombine(@from); + } } } @@ -153,7 +171,9 @@ namespace Server.Engines.BulkOrders writer.Write(m_Entries.Length); for (var i = 0; i < m_Entries.Length; ++i) + { m_Entries[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -169,7 +189,9 @@ namespace Server.Engines.BulkOrders m_Entries = new LargeBulkEntry[reader.ReadInt()]; for (var i = 0; i < m_Entries.Length; ++i) + { m_Entries[i] = new LargeBulkEntry(this, reader); + } break; } diff --git a/Projects/UOContent/Engines/BulkOrders/LargeBODAcceptGump.cs b/Projects/UOContent/Engines/BulkOrders/LargeBODAcceptGump.cs index 264c7440b..8e8a054fe 100644 --- a/Projects/UOContent/Engines/BulkOrders/LargeBODAcceptGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/LargeBODAcceptGump.cs @@ -42,7 +42,9 @@ namespace Server.Engines.BulkOrders var y = 120; for (var i = 0; i < entries.Length; ++i, y += 24) + { AddHtmlLocalized(40, y, 210, 20, entries[i].Details.Number, 0x7FFF); + } if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { @@ -101,15 +103,22 @@ namespace Server.Engines.BulkOrders public override void OnServerClose(NetState owner) { if (m_Deed?.Deleted == false) + { m_Deed.Delete(); + } } public static int GetMaterialNumberFor(BulkMaterialType material) { if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite) + { return 1045142 + (material - BulkMaterialType.DullCopper); + } + if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed) + { return 1049348 + (material - BulkMaterialType.Spined); + } return 0; } diff --git a/Projects/UOContent/Engines/BulkOrders/LargeBODGump.cs b/Projects/UOContent/Engines/BulkOrders/LargeBODGump.cs index 0a1809ffd..648014f87 100644 --- a/Projects/UOContent/Engines/BulkOrders/LargeBODGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/LargeBODGump.cs @@ -64,6 +64,7 @@ namespace Server.Engines.BulkOrders } if (deed.Material != BulkMaterialType.None) + { AddHtmlLocalized( 75, y, @@ -72,6 +73,7 @@ namespace Server.Engines.BulkOrders GetMaterialNumberFor(deed.Material), 0x7FFF ); // All items must be made with x material. + } AddButton(125, 168 + entries.Length * 24, 4005, 4007, 2); AddHtmlLocalized( @@ -90,7 +92,9 @@ namespace Server.Engines.BulkOrders public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack)) + { return; + } if (info.ButtonID == 2) // Combine { @@ -102,9 +106,14 @@ namespace Server.Engines.BulkOrders public static int GetMaterialNumberFor(BulkMaterialType material) { if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite) + { return 1045142 + (material - BulkMaterialType.DullCopper); + } + if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed) + { return 1049348 + (material - BulkMaterialType.Spined); + } return 0; } diff --git a/Projects/UOContent/Engines/BulkOrders/LargeBulkEntry.cs b/Projects/UOContent/Engines/BulkOrders/LargeBulkEntry.cs index 9f8934ad3..c1823d68b 100644 --- a/Projects/UOContent/Engines/BulkOrders/LargeBulkEntry.cs +++ b/Projects/UOContent/Engines/BulkOrders/LargeBulkEntry.cs @@ -24,7 +24,9 @@ namespace Server.Engines.BulkOrders var type = reader.ReadString(); if (type != null) + { realType = AssemblyHandler.FindFirstTypeForName(type); + } Details = new SmallBulkEntry(realType, reader.ReadInt(), reader.ReadInt()); } @@ -92,10 +94,14 @@ namespace Server.Engines.BulkOrders m_Cache ??= new Dictionary>(); if (!m_Cache.TryGetValue(type, out var table)) + { m_Cache[type] = table = new Dictionary(); + } if (!table.TryGetValue(name, out var entries)) + { table[name] = entries = SmallBulkEntry.LoadEntries(type, name); + } return entries; } @@ -105,7 +111,9 @@ namespace Server.Engines.BulkOrders var large = new LargeBulkEntry[small.Length]; for (var i = 0; i < small.Length; ++i) + { large[i] = new LargeBulkEntry(owner, small[i]); + } return large; } diff --git a/Projects/UOContent/Engines/BulkOrders/LargeSmithBOD.cs b/Projects/UOContent/Engines/BulkOrders/LargeSmithBOD.cs index 2767902dc..5d0716b29 100644 --- a/Projects/UOContent/Engines/BulkOrders/LargeSmithBOD.cs +++ b/Projects/UOContent/Engines/BulkOrders/LargeSmithBOD.cs @@ -37,7 +37,9 @@ namespace Server.Engines.BulkOrders }; if (rand > 2 && rand < 8) + { useMaterials = false; + } var hue = 0x44E; var amountMax = Utility.RandomList(10, 15, 20, 20); diff --git a/Projects/UOContent/Engines/BulkOrders/Rewards.cs b/Projects/UOContent/Engines/BulkOrders/Rewards.cs index 4a88b8905..77eb67ec1 100644 --- a/Projects/UOContent/Engines/BulkOrders/Rewards.cs +++ b/Projects/UOContent/Engines/BulkOrders/Rewards.cs @@ -20,8 +20,12 @@ namespace Server.Engines.BulkOrders public bool Contains(Type type) { for (var i = 0; i < Types.Length; ++i) + { if (Types[i] == type) + { return true; + } + } return false; } @@ -70,14 +74,21 @@ namespace Server.Engines.BulkOrders public RewardItem AcquireItem() { if (Items.Length == 0) + { return null; + } + if (Items.Length == 1) + { return Items[0]; + } var totalWeight = 0; for (var i = 0; i < Items.Length; ++i) + { totalWeight += Items[i].Weight; + } var randomWeight = Utility.Random(totalWeight); @@ -86,7 +97,9 @@ namespace Server.Engines.BulkOrders var item = Items[i]; if (randomWeight < item.Weight) + { return item; + } randomWeight -= item.Weight; } @@ -159,7 +172,9 @@ namespace Server.Engines.BulkOrders var group = Groups[i]; if (points >= group.Points) - return group; + { + return @group; + } } return Groups[0]; @@ -168,8 +183,12 @@ namespace Server.Engines.BulkOrders public virtual int LookupTypePoints(RewardType[] types, Type type) { for (var i = 0; i < types.Length; ++i) + { if (types[i].Contains(type)) + { return types[i].Points; + } + } return 0; } @@ -394,20 +413,32 @@ namespace Server.Engines.BulkOrders var points = 0; if (quantity == 10) + { points += 10; + } else if (quantity == 15) + { points += 25; + } else if (quantity == 20) + { points += 50; + } if (exceptional) + { points += 200; + } if (itemCount > 1) + { points += LookupTypePoints(m_Types, type); + } if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite) + { points += 200 + 50 * (material - BulkMaterialType.DullCopper); + } return points; } @@ -416,18 +447,26 @@ namespace Server.Engines.BulkOrders { // Item count of 1 means it's a small BOD. if (itemCount == 1) + { return 0; + } var typeIdx = 0; // Loop through the RewardTypes defined earlier and find the correct one. for (; typeIdx < 7; ++typeIdx) + { if (m_Types[typeIdx].Contains(type)) + { break; + } + } // Types 5, 6 and 7 are Large Weapon BODs with the same rewards. if (typeIdx > 5) + { typeIdx = 5; + } return (typeIdx + 1) * 2; } @@ -449,7 +488,9 @@ namespace Server.Engines.BulkOrders : 0; if (exceptional) + { typeIndex++; + } var gold = goldTable[typeIndex][quanIndex][mtrlIndex]; @@ -483,7 +524,9 @@ namespace Server.Engines.BulkOrders private static Item CreateRunicHammer(int type) { if (type >= 1 && type <= 8) + { return new RunicHammer(CraftResource.Iron + type, Core.AOS ? 55 - type * 5 : 50); + } throw new InvalidOperationException(); } @@ -491,7 +534,9 @@ namespace Server.Engines.BulkOrders private static Item CreatePowerScroll(int type) { if (type == 5 || type == 10 || type == 15 || type == 20) + { return new PowerScroll(SkillName.Blacksmith, 100 + type); + } throw new InvalidOperationException(); } @@ -501,7 +546,9 @@ namespace Server.Engines.BulkOrders private static Item CreateAncientHammer(int type) { if (type == 10 || type == 15 || type == 30 || type == 60) + { return new AncientSmithyHammer(type); + } throw new InvalidOperationException(); } @@ -669,28 +716,48 @@ namespace Server.Engines.BulkOrders var points = 0; if (quantity == 10) + { points += 10; + } else if (quantity == 15) + { points += 25; + } else if (quantity == 20) + { points += 50; + } if (exceptional) + { points += 100; + } if (itemCount == 4) + { points += 300; + } else if (itemCount == 5) + { points += 400; + } else if (itemCount == 6) + { points += 500; + } if (material == BulkMaterialType.Spined) + { points += 50; + } else if (material == BulkMaterialType.Horned) + { points += 100; + } else if (material == BulkMaterialType.Barbed) + { points += 150; + } return points; } @@ -733,7 +800,9 @@ namespace Server.Engines.BulkOrders private static Item CreateCloth(int type) { if (type >= 0 && type < m_ClothHues.Length) + { return new UncutCloth(100) { Hue = m_ClothHues[type].RandomElement() }; + } throw new InvalidOperationException(); } @@ -770,7 +839,9 @@ namespace Server.Engines.BulkOrders private static Item CreateRunicKit(int type) { if (type >= 1 && type <= 3) + { return new RunicSewingKit(CraftResource.RegularLeather + type, 60 - type * 15); + } throw new InvalidOperationException(); } @@ -778,7 +849,9 @@ namespace Server.Engines.BulkOrders private static Item CreatePowerScroll(int type) { if (type == 5 || type == 10 || type == 15 || type == 20) + { return new PowerScroll(SkillName.Tailoring, 100 + type); + } throw new InvalidOperationException(); } diff --git a/Projects/UOContent/Engines/BulkOrders/SmallBOD.cs b/Projects/UOContent/Engines/BulkOrders/SmallBOD.cs index 4c2afa6a9..ee9e6cecc 100644 --- a/Projects/UOContent/Engines/BulkOrders/SmallBOD.cs +++ b/Projects/UOContent/Engines/BulkOrders/SmallBOD.cs @@ -68,10 +68,14 @@ namespace Server.Engines.BulkOrders list.Add(1060654); // small bulk order if (RequireExceptional) + { list.Add(1045141); // All items must be exceptional. + } if (Material != BulkMaterialType.None) + { list.Add(SmallBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material. + } list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~ list.Add(1060658, "#{0}\t{1}", m_Number, m_AmountCur); // ~1_val~: ~2_val~ @@ -80,9 +84,13 @@ namespace Server.Engines.BulkOrders public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor) - from.SendGump(new SmallBODGump(from, this)); + { + @from.SendGump(new SmallBODGump(@from, this)); + } else - from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it. + { + @from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it. + } } public override void OnDoubleClickNotAccessible(Mobile from) @@ -151,11 +159,17 @@ namespace Server.Engines.BulkOrders bool isExceptional; if (item is BaseWeapon weapon) + { isExceptional = weapon.Quality == WeaponQuality.Exceptional; + } else if (armor != null) + { isExceptional = armor.Quality == ArmorQuality.Exceptional; + } else + { isExceptional = clothing.Quality == ClothingQuality.Exceptional; + } if (RequireExceptional && !isExceptional) { @@ -170,7 +184,9 @@ namespace Server.Engines.BulkOrders from.SendGump(new SmallBODGump(from, this)); if (m_AmountCur < AmountMax) - BeginCombine(from); + { + BeginCombine(@from); + } } } } @@ -203,7 +219,9 @@ namespace Server.Engines.BulkOrders var type = reader.ReadString(); if (type != null) + { Type = AssemblyHandler.FindFirstTypeForName(type); + } m_Number = reader.ReadInt(); Graphic = reader.ReadInt(); diff --git a/Projects/UOContent/Engines/BulkOrders/SmallBODAcceptGump.cs b/Projects/UOContent/Engines/BulkOrders/SmallBODAcceptGump.cs index 48b915013..260e8c0ae 100644 --- a/Projects/UOContent/Engines/BulkOrders/SmallBODAcceptGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/SmallBODAcceptGump.cs @@ -43,9 +43,12 @@ namespace Server.Engines.BulkOrders AddHtmlLocalized(40, 144, 210, 20, 1045140, 0x7FFF); // Special requirements to meet: if (deed.RequireExceptional) + { AddHtmlLocalized(40, 168, 350, 20, 1045141, 0x7FFF); // All items must be exceptional. + } if (deed.Material != BulkMaterialType.None) + { AddHtmlLocalized( 40, deed.RequireExceptional ? 192 : 168, @@ -54,6 +57,7 @@ namespace Server.Engines.BulkOrders GetMaterialNumberFor(deed.Material), 0x7FFF ); // All items must be made with x material. + } } AddHtmlLocalized(40, 216, 350, 20, 1045139, 0x7FFF); // Do you want to accept this order? @@ -88,15 +92,22 @@ namespace Server.Engines.BulkOrders public override void OnServerClose(NetState owner) { if (m_Deed?.Deleted == false) + { m_Deed.Delete(); + } } public static int GetMaterialNumberFor(BulkMaterialType material) { if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite) + { return 1045142 + (material - BulkMaterialType.DullCopper); + } + if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed) + { return 1049348 + (material - BulkMaterialType.Spined); + } return 0; } diff --git a/Projects/UOContent/Engines/BulkOrders/SmallBODGump.cs b/Projects/UOContent/Engines/BulkOrders/SmallBODGump.cs index e15e1b10e..047e9205f 100644 --- a/Projects/UOContent/Engines/BulkOrders/SmallBODGump.cs +++ b/Projects/UOContent/Engines/BulkOrders/SmallBODGump.cs @@ -41,12 +41,17 @@ namespace Server.Engines.BulkOrders AddLabel(275, 96, 0x480, deed.AmountCur.ToString()); if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) + { AddHtmlLocalized(75, 120, 200, 20, 1045140, 0x7FFF); // Special requirements to meet: + } if (deed.RequireExceptional) + { AddHtmlLocalized(75, 144, 300, 20, 1045141, 0x7FFF); // All items must be exceptional. + } if (deed.Material != BulkMaterialType.None) + { AddHtmlLocalized( 75, deed.RequireExceptional ? 168 : 144, @@ -55,6 +60,7 @@ namespace Server.Engines.BulkOrders GetMaterialNumberFor(deed.Material), 0x7FFF ); // All items must be made with x material. + } AddButton(125, 192, 4005, 4007, 2); AddHtmlLocalized(160, 192, 300, 20, 1045154, 0x7FFF); // Combine this deed with the item requested. @@ -66,7 +72,9 @@ namespace Server.Engines.BulkOrders public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack)) + { return; + } if (info.ButtonID == 2) // Combine { @@ -78,9 +86,14 @@ namespace Server.Engines.BulkOrders public static int GetMaterialNumberFor(BulkMaterialType material) { if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite) + { return 1045142 + (material - BulkMaterialType.DullCopper); + } + if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed) + { return 1049348 + (material - BulkMaterialType.Spined); + } return 0; } diff --git a/Projects/UOContent/Engines/BulkOrders/SmallBulkEntry.cs b/Projects/UOContent/Engines/BulkOrders/SmallBulkEntry.cs index 163aca8ad..af4e57c62 100644 --- a/Projects/UOContent/Engines/BulkOrders/SmallBulkEntry.cs +++ b/Projects/UOContent/Engines/BulkOrders/SmallBulkEntry.cs @@ -32,13 +32,19 @@ namespace Server.Engines.BulkOrders public static SmallBulkEntry[] GetEntries(string type, string name) { if (m_Cache == null) + { m_Cache = new Dictionary>(); + } if (!m_Cache.TryGetValue(type, out var table)) + { m_Cache[type] = table = new Dictionary(); + } if (!table.TryGetValue(name, out var entries)) + { table[name] = entries = LoadEntries(type, name); + } return entries; } @@ -60,7 +66,9 @@ namespace Server.Engines.BulkOrders while ((line = ip.ReadLine()) != null) { if (line.Length == 0 || line.StartsWith("#")) + { continue; + } try { @@ -72,6 +80,7 @@ namespace Server.Engines.BulkOrders var graphic = Utility.ToInt32(split[^1]); if (type != null && graphic > 0) + { list.Add( new SmallBulkEntry( type, @@ -79,6 +88,7 @@ namespace Server.Engines.BulkOrders graphic ) ); + } } } catch diff --git a/Projects/UOContent/Engines/BulkOrders/SmallSmithBOD.cs b/Projects/UOContent/Engines/BulkOrders/SmallSmithBOD.cs index fa8152815..f253a98a6 100644 --- a/Projects/UOContent/Engines/BulkOrders/SmallSmithBOD.cs +++ b/Projects/UOContent/Engines/BulkOrders/SmallSmithBOD.cs @@ -32,7 +32,9 @@ namespace Server.Engines.BulkOrders var entries = useMaterials ? SmallBulkEntry.BlacksmithArmor : SmallBulkEntry.BlacksmithWeapons; if (entries.Length <= 0) + { return; + } var hue = 0x44E; var amountMax = Utility.RandomList(10, 15, 20); @@ -79,21 +81,30 @@ namespace Server.Engines.BulkOrders var entries = useMaterials ? SmallBulkEntry.BlacksmithArmor : SmallBulkEntry.BlacksmithWeapons; if (entries.Length <= 0) + { return null; + } var theirSkill = m.Skills.Blacksmith.Base; int amountMax; if (theirSkill >= 70.1) + { amountMax = Utility.RandomList(10, 15, 20, 20); + } else if (theirSkill >= 50.1) + { amountMax = Utility.RandomList(10, 15, 15, 20); + } else + { amountMax = Utility.RandomList(10, 10, 15, 20); + } var material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) + { for (var i = 0; i < 20; ++i) { var check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); @@ -120,6 +131,7 @@ namespace Server.Engines.BulkOrders break; } } + } var excChance = theirSkill >= 70.1 ? (theirSkill + 80.0) / 200.0 : 0.0; @@ -141,16 +153,22 @@ namespace Server.Engines.BulkOrders if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) + { chance = item.GetExceptionalChance(system, chance, m); + } if (chance > 0.0) + { validEntries.Add(entries[i]); + } } } } if (validEntries.Count <= 0) + { return null; + } var entry = validEntries.RandomElement(); return new SmallSmithBOD(entry, material, amountMax, reqExceptional); diff --git a/Projects/UOContent/Engines/BulkOrders/SmallTailorBOD.cs b/Projects/UOContent/Engines/BulkOrders/SmallTailorBOD.cs index 138e97d30..718af649c 100644 --- a/Projects/UOContent/Engines/BulkOrders/SmallTailorBOD.cs +++ b/Projects/UOContent/Engines/BulkOrders/SmallTailorBOD.cs @@ -26,7 +26,9 @@ namespace Server.Engines.BulkOrders var entries = useMaterials ? SmallBulkEntry.TailorLeather : SmallBulkEntry.TailorCloth; if (entries.Length <= 0) + { return; + } var hue = 0x483; var amountMax = Utility.RandomList(10, 15, 20); @@ -74,24 +76,35 @@ namespace Server.Engines.BulkOrders // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill. if (useMaterials && theirSkill >= 6.2) + { entries = SmallBulkEntry.TailorLeather; + } else + { entries = SmallBulkEntry.TailorCloth; + } if (entries.Length > 0) { int amountMax; if (theirSkill >= 70.1) + { amountMax = Utility.RandomList(10, 15, 20, 20); + } else if (theirSkill >= 50.1) + { amountMax = Utility.RandomList(10, 15, 15, 20); + } else + { amountMax = Utility.RandomList(10, 10, 15, 20); + } var material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) + { for (var i = 0; i < 20; ++i) { var check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances); @@ -116,11 +129,14 @@ namespace Server.Engines.BulkOrders break; } } + } var excChance = 0.0; if (theirSkill >= 70.1) + { excChance = (theirSkill + 80.0) / 200.0; + } var reqExceptional = excChance > Utility.RandomDouble(); @@ -140,10 +156,14 @@ namespace Server.Engines.BulkOrders if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) + { chance = item.GetExceptionalChance(system, chance, m); + } if (chance > 0.0) + { validEntries.Add(entries[i]); + } } } } diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionAltar.cs b/Projects/UOContent/Engines/CannedEvil/ChampionAltar.cs index d05680bf7..a852e9178 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionAltar.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionAltar.cs @@ -41,7 +41,9 @@ namespace Server.Engines.CannedEvil m_Spawn = reader.ReadItem() as ChampionSpawn; if (m_Spawn == null) + { Delete(); + } break; } diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionPlatform.cs b/Projects/UOContent/Engines/CannedEvil/ChampionPlatform.cs index 9df80d08d..ef10f9762 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionPlatform.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionPlatform.cs @@ -11,12 +11,20 @@ namespace Server.Engines.CannedEvil m_Spawn = spawn; for (var x = -2; x <= 2; ++x) + { for (var y = -2; y <= 2; ++y) + { AddComponent(0x750, x, y, -5); + } + } for (var x = -1; x <= 1; ++x) + { for (var y = -1; y <= 1; ++y) + { AddComponent(0x750, x, y, 0); + } + } for (var i = -1; i <= 1; ++i) { @@ -75,7 +83,9 @@ namespace Server.Engines.CannedEvil m_Spawn = reader.ReadItem() as ChampionSpawn; if (m_Spawn == null) + { Delete(); + } break; } diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSkull.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSkull.cs index 0dec4310a..6d4159c29 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSkull.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSkull.cs @@ -70,10 +70,14 @@ namespace Server.Items if (version == 0) { if (LootType != LootType.Cursed) + { LootType = LootType.Cursed; + } if (Insured) + { Insured = false; + } } } } diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSkullBrazier.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSkullBrazier.cs index 54547da96..6a3fad62a 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSkullBrazier.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSkullBrazier.cs @@ -59,10 +59,14 @@ namespace Server.Engines.CannedEvil public void BeginSacrifice(Mobile from) { if (Deleted) + { return; + } if (m_Skull?.Deleted == true) + { Skull = null; + } if (from.Map != Map || !from.InRange(GetWorldLocation(), 3)) { @@ -86,10 +90,14 @@ namespace Server.Engines.CannedEvil public void EndSacrifice(Mobile from, ChampionSkull skull) { if (Deleted) + { return; + } if (m_Skull?.Deleted == true) + { Skull = null; + } if (from.Map != Map || !from.InRange(GetWorldLocation(), 3)) { @@ -153,17 +161,23 @@ namespace Server.Engines.CannedEvil m_Skull = reader.ReadItem(); if (Platform == null) + { Delete(); + } break; } } if (Hue == 0x497) + { Hue = 0x455; + } if (Light != LightType.Circle300) + { Light = LightType.Circle300; + } } private class SacrificeTarget : Target diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSkullPlatform.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSkullPlatform.cs index a9d0a5ad8..867dd4cc3 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSkullPlatform.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSkullPlatform.cs @@ -63,7 +63,9 @@ namespace Server.Engines.CannedEvil Mobile harrower = Harrower.Spawn(new Point3D(X, Y, Z + 6), Map); if (harrower == null) + { return; + } Clear(m_Power); Clear(m_Enlightenment); diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs index 4fdf90dc8..4f294fdac 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSpawn.cs @@ -129,9 +129,13 @@ namespace Server.Engines.CannedEvil set { if (value) + { Start(); + } else + { Stop(); + } InvalidateProperties(); } @@ -230,7 +234,9 @@ namespace Server.Engines.CannedEvil public void Start() { if (m_Active || Deleted) + { return; + } m_Active = true; HasBeenAdvanced = false; @@ -247,19 +253,27 @@ namespace Server.Engines.CannedEvil if (m_Altar != null) { if (Champion != null) + { m_Altar.Hue = 0x26; + } else + { m_Altar.Hue = 0; + } } if (m_Platform != null) + { m_Platform.Hue = 0x452; + } } public void Stop() { if (!m_Active || Deleted) + { return; + } m_Active = false; HasBeenAdvanced = false; @@ -273,10 +287,14 @@ namespace Server.Engines.CannedEvil m_RestartTimer = null; if (m_Altar != null) + { m_Altar.Hue = 0; + } if (m_Platform != null) + { m_Platform.Hue = 0x497; + } } public void BeginRestart(TimeSpan ts) @@ -292,6 +310,7 @@ namespace Server.Engines.CannedEvil public void EndRestart() { if (RandomizeType) + { Type = Utility.Random(5) switch { 0 => ChampionSpawnType.VerminHorde, @@ -301,6 +320,7 @@ namespace Server.Engines.CannedEvil 4 => ChampionSpawnType.Arachnid, _ => Type }; + } HasBeenAdvanced = false; @@ -312,7 +332,9 @@ namespace Server.Engines.CannedEvil var level = Utility.RandomMinMax(1, 5); if (felucca) + { level += 5; + } return ScrollofTranscendence.CreateRandom(level, level); } @@ -320,12 +342,18 @@ namespace Server.Engines.CannedEvil public static void GiveScrollTo(Mobile killer, SpecialScroll scroll) { if (scroll == null || killer == null) // sanity + { return; + } if (scroll is ScrollofTranscendence) + { killer.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence! + } else + { killer.SendLocalizedMessage(1049524); // You have received a scroll of power! + } if (killer.Alive) { @@ -334,9 +362,13 @@ namespace Server.Engines.CannedEvil else { if (killer.Corpse.Deleted == false) + { killer.Corpse.DropItem(scroll); + } else + { killer.AddToBackpack(scroll); + } } // Justice reward @@ -347,7 +379,9 @@ namespace Server.Engines.CannedEvil if (prot.Map != killer.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(killer, prot)) + { continue; + } var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch { @@ -358,6 +392,7 @@ namespace Server.Engines.CannedEvil }; if (chance > Utility.Random(100)) + { try { prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice! @@ -373,13 +408,16 @@ namespace Server.Engines.CannedEvil { // ignored } + } } } public void OnSlice() { if (!m_Active || Deleted) + { return; + } if (Champion != null) { @@ -388,19 +426,25 @@ namespace Server.Engines.CannedEvil RegisterDamageTo(Champion); if (Champion is BaseChampion champion) + { AwardArtifact(champion.GetArtifact()); + } m_DamageEntries.Clear(); if (m_Platform != null) + { m_Platform.Hue = 0x497; + } if (m_Altar != null) { m_Altar.Hue = 0; if (!Core.ML || Map == Map.Felucca) + { new StarRoomGate(m_Altar.Location, m_Altar.Map, true); + } } Champion = null; @@ -420,7 +464,9 @@ namespace Server.Engines.CannedEvil if (m.Deleted) { if (m.Corpse?.Deleted == false) + { ((Corpse)m.Corpse).BeginDecay(TimeSpan.FromMinutes(1)); + } m_Creatures.RemoveAt(i); --i; @@ -431,13 +477,16 @@ namespace Server.Engines.CannedEvil RegisterDamageTo(m); if (killer is BaseCreature bc) + { killer = bc.GetMaster(); + } if (killer is PlayerMobile pm) { if (Core.ML) { if (Map == Map.Felucca) + { if (Utility.RandomDouble() < 0.001) { double random = Utility.Random(49); @@ -453,14 +502,17 @@ namespace Server.Engines.CannedEvil GiveScrollTo(pm, PS); } } + } if (Map == Map.Ilshenar || Map == Map.Tokuno || Map == Map.Malas) + { if (Utility.RandomDouble() < 0.0015) { pm.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence! var SoTT = CreateRandomSoT(false); pm.AddToBackpack(SoTT); } + } } var mobSubLevel = GetSubLevelFor(m) + 1; @@ -474,9 +526,13 @@ namespace Server.Engines.CannedEvil if (VirtueHelper.Award(pm, VirtueName.Valor, pointsToGain, ref gainedPath)) { if (gainedPath) + { m.SendLocalizedMessage(1054032); // You have gained a path in Valor! + } else + { m.SendLocalizedMessage(1054030); // You have gained in Valor! + } // No delay on Valor gains } @@ -491,18 +547,26 @@ namespace Server.Engines.CannedEvil // Only really needed once. if (m_Kills > kills) + { InvalidateProperties(); + } var n = m_Kills / (double)MaxKills; var p = (int)(n * 100); if (p >= 90) + { AdvanceLevel(); + } else if (p > 0) + { SetWhiteSkullCount(p / 20); + } if (DateTime.UtcNow >= ExpireTime) + { Expire(); + } Respawn(); } @@ -539,10 +603,14 @@ namespace Server.Engines.CannedEvil public void SpawnChampion() { if (m_Altar != null) + { m_Altar.Hue = 0x26; + } if (m_Platform != null) + { m_Platform.Hue = 0x452; + } m_Kills = 0; Level = 0; @@ -564,14 +632,18 @@ namespace Server.Engines.CannedEvil public void Respawn() { if (!m_Active || Deleted || Champion != null) + { return; + } while (m_Creatures.Count < m_SPawnSzMod * (200 / 12) - GetSubLevel() * m_SPawnSzMod * (40 / 12)) { var m = Spawn(); if (m == null) + { return; + } var loc = GetSpawnLocation(); @@ -617,7 +689,9 @@ namespace Server.Engines.CannedEvil var map = Map; if (map == null) + { return Location; + } // Try 20 times to find a spawnable location. for (var i = 0; i < 20; i++) @@ -633,11 +707,15 @@ namespace Server.Engines.CannedEvil var z = Map.GetAverageZ(x, y); if (Map.CanSpawnMobile(new Point2D(x, y), z)) + { return new Point3D(x, y, z); + } /* try @ platform Z if map z fails */ if (Map.CanSpawnMobile(new Point2D(x, y), m_Platform.Location.Z)) + { return new Point3D(x, y, m_Platform.Location.Z); + } } return Location; @@ -648,11 +726,19 @@ namespace Server.Engines.CannedEvil var level = Level; if (level <= Level1) + { return 0; + } + if (level <= Level2) + { return 1; + } + if (level <= Level3) + { return 2; + } return 3; } @@ -667,8 +753,12 @@ namespace Server.Engines.CannedEvil var individualTypes = types[i]; for (var j = 0; j < individualTypes.Length; j++) + { if (t == individualTypes[j]) + { return i; + } + } } return -1; @@ -681,7 +771,9 @@ namespace Server.Engines.CannedEvil var v = GetSubLevel(); if (v >= 0 && v < types.Length) + { return Spawn(types[v]); + } return null; } @@ -707,7 +799,9 @@ namespace Server.Engines.CannedEvil // They didn't even get 20%, go back a level if (Level > 0) + { --Level; + } InvalidateProperties(); } @@ -806,9 +900,13 @@ namespace Server.Engines.CannedEvil public override void OnSingleClick(Mobile from) { if (m_Active) - LabelTo(from, "{0} (Active; Level: {1}; Kills: {2}/{3})", m_Type, Level, m_Kills, MaxKills); + { + LabelTo(@from, "{0} (Active; Level: {1}; Kills: {2}/{3})", m_Type, Level, m_Kills, MaxKills); + } else - LabelTo(from, "{0} (Inactive)", m_Type); + { + LabelTo(@from, "{0} (Inactive)", m_Type); + } } public override void OnDoubleClick(Mobile from) @@ -819,24 +917,40 @@ namespace Server.Engines.CannedEvil public override void OnLocationChange(Point3D oldLoc) { if (Deleted) + { return; + } if (m_Platform != null) + { m_Platform.Location = new Point3D(X, Y, Z - 20); + } if (m_Altar != null) + { m_Altar.Location = new Point3D(X, Y, Z - 15); + } if (m_Idol != null) + { m_Idol.Location = new Point3D(X, Y, Z - 15); + } if (m_RedSkulls != null) + { for (var i = 0; i < m_RedSkulls.Count; ++i) + { m_RedSkulls[i].Location = GetRedSkullLocation(i); + } + } if (m_WhiteSkulls != null) + { for (var i = 0; i < m_WhiteSkulls.Count; ++i) + { m_WhiteSkulls[i].Location = GetWhiteSkullLocation(i); + } + } m_SpawnArea.X += Location.X - oldLoc.X; m_SpawnArea.Y += Location.Y - oldLoc.Y; @@ -847,24 +961,40 @@ namespace Server.Engines.CannedEvil public override void OnMapChange() { if (Deleted) + { return; + } if (m_Platform != null) + { m_Platform.Map = Map; + } if (m_Altar != null) + { m_Altar.Map = Map; + } if (m_Idol != null) + { m_Idol.Map = Map; + } if (m_RedSkulls != null) + { for (var i = 0; i < m_RedSkulls.Count; ++i) + { m_RedSkulls[i].Map = Map; + } + } if (m_WhiteSkulls != null) + { for (var i = 0; i < m_WhiteSkulls.Count; ++i) + { m_WhiteSkulls[i].Map = Map; + } + } UpdateRegion(); } @@ -882,7 +1012,9 @@ namespace Server.Engines.CannedEvil if (m_RedSkulls != null) { for (var i = 0; i < m_RedSkulls.Count; ++i) + { m_RedSkulls[i].Delete(); + } m_RedSkulls.Clear(); } @@ -890,7 +1022,9 @@ namespace Server.Engines.CannedEvil if (m_WhiteSkulls != null) { for (var i = 0; i < m_WhiteSkulls.Count; ++i) + { m_WhiteSkulls[i].Delete(); + } m_WhiteSkulls.Clear(); } @@ -902,14 +1036,18 @@ namespace Server.Engines.CannedEvil var mob = m_Creatures[i]; if (!mob.Player) + { mob.Delete(); + } } m_Creatures.Clear(); } if (Champion?.Player == false) + { Champion.Delete(); + } Stop(); @@ -919,19 +1057,25 @@ namespace Server.Engines.CannedEvil public virtual void RegisterDamageTo(Mobile m) { if (m == null) + { return; + } foreach (var de in m.DamageEntries) { if (de.HasExpired) + { continue; + } var damager = de.Damager; var master = damager.GetDamageMaster(m); if (master != null) + { damager = master; + } RegisterDamage(damager, de.DamageGiven); } @@ -940,7 +1084,9 @@ namespace Server.Engines.CannedEvil public void RegisterDamage(Mobile from, int amount) { if (from?.Player != true) + { return; + } m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out var value) ? value : 0); } @@ -948,18 +1094,22 @@ namespace Server.Engines.CannedEvil public void AwardArtifact(Item artifact) { if (artifact == null) + { return; + } var totalDamage = 0; var validEntries = new Dictionary(); foreach (var kvp in m_DamageEntries) + { if (IsEligible(kvp.Key, artifact)) { validEntries.Add(kvp.Key, kvp.Value); totalDamage += kvp.Value; } + } var randomDamage = Utility.RandomMinMax(1, totalDamage); @@ -982,16 +1132,22 @@ namespace Server.Engines.CannedEvil public void GiveArtifact(Mobile to, Item artifact) { if (to == null || artifact == null) + { return; + } var pack = to.Backpack; if (pack?.TryDropItem(to, artifact, false) != true) + { artifact.Delete(); + } else + { to.SendLocalizedMessage( 1062317 ); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. + } } public bool IsEligible(Mobile m, Item artifact) => @@ -1037,7 +1193,9 @@ namespace Server.Engines.CannedEvil writer.Write(m_RestartTimer != null); if (m_RestartTimer != null) + { writer.WriteDeltaTime(RestartTime); + } } public override void Deserialize(IGenericReader reader) @@ -1064,7 +1222,9 @@ namespace Server.Engines.CannedEvil var damage = reader.ReadInt(); if (m == null) + { continue; + } m_DamageEntries.Add(m, damage); } @@ -1110,8 +1270,10 @@ namespace Server.Engines.CannedEvil case 0: { if (version < 1) + { m_SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); // Default was 24 + } var active = reader.ReadBool(); m_Type = (ChampionSpawnType)reader.ReadInt(); @@ -1138,9 +1300,13 @@ namespace Server.Engines.CannedEvil } if (m_Platform == null || m_Altar == null || m_Idol == null) + { Delete(); + } else if (active) + { Start(); + } break; } @@ -1222,7 +1388,9 @@ namespace Server.Engines.CannedEvil Spawn = reader.ReadItem() as ChampionSpawn; if (Spawn == null) + { Delete(); + } break; } diff --git a/Projects/UOContent/Engines/CannedEvil/ChampionSpawnType.cs b/Projects/UOContent/Engines/CannedEvil/ChampionSpawnType.cs index ab166ee66..c4ffee7c4 100644 --- a/Projects/UOContent/Engines/CannedEvil/ChampionSpawnType.cs +++ b/Projects/UOContent/Engines/CannedEvil/ChampionSpawnType.cs @@ -166,7 +166,9 @@ namespace Server.Engines.CannedEvil var v = (int)type; if (v < 0 || v >= Table.Length) + { v = 0; + } return Table[v]; } diff --git a/Projects/UOContent/Engines/CannedEvil/HarrowerGate.cs b/Projects/UOContent/Engines/CannedEvil/HarrowerGate.cs index 389ef8dae..3d2a04299 100644 --- a/Projects/UOContent/Engines/CannedEvil/HarrowerGate.cs +++ b/Projects/UOContent/Engines/CannedEvil/HarrowerGate.cs @@ -43,14 +43,18 @@ namespace Server.Items m_Harrower = reader.ReadMobile(); if (m_Harrower == null) + { Delete(); + } break; } } if (Light != LightType.Circle300) + { Light = LightType.Circle300; + } } } } diff --git a/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs b/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs index fa7991f74..5c1b05c54 100644 --- a/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs +++ b/Projects/UOContent/Engines/CannedEvil/StarRoomGate.cs @@ -53,7 +53,9 @@ namespace Server.Items writer.Write(m_Decays); if (m_Decays) + { writer.WriteDeltaTime(m_DecayTime); + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Engines/Chat/Channel.cs b/Projects/UOContent/Engines/Chat/Channel.cs index a4de585e2..431439562 100644 --- a/Projects/UOContent/Engines/Chat/Channel.cs +++ b/Projects/UOContent/Engines/Chat/Channel.cs @@ -50,11 +50,15 @@ namespace Server.Engines.Chat m_VoiceRestricted = value; if (value) + { SendMessage( 56 ); // From now on, only moderators will have speaking privileges in this conference by default. + } else + { SendMessage(55); // From now on, everyone in the conference will have speaking privileges by default. + } } } @@ -88,7 +92,9 @@ namespace Server.Engines.Chat public bool ValidateAccess(ChatUser from, ChatUser target) { if (from == null || target == null || from.Mobile.AccessLevel >= target.Mobile.AccessLevel) + { return true; + } from.Mobile.SendMessage("Your access level is too low to do this."); return false; @@ -124,7 +130,9 @@ namespace Server.Engines.Chat user.CurrentChannel = this; if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || !AlwaysAvailable && m_Users.Count == 1) + { AddModerator(user); + } SendUsersTo(user); @@ -139,26 +147,36 @@ namespace Server.Engines.Chat user.CurrentChannel = null; if (m_Moderators.Contains(user)) + { m_Moderators.Remove(user); + } if (m_Voices.Contains(user)) + { m_Voices.Remove(user); + } SendCommand(ChatCommand.RemoveUserFromChannel, user, user.Username); ChatSystem.SendCommandTo(user.Mobile, ChatCommand.LeaveChannel); if (m_Users.Count == 0 && !AlwaysAvailable) + { RemoveChannel(this); + } } } public void AddBan(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) + { return; + } if (!m_Banned.Contains(user)) + { m_Banned.Add(user); + } Kick(user, moderator, true); } @@ -166,7 +184,9 @@ namespace Server.Engines.Chat public void RemoveBan(ChatUser user) { if (m_Banned.Contains(user)) + { m_Banned.Remove(user); + } } public void Kick(ChatUser user, ChatUser moderator = null) @@ -177,22 +197,28 @@ namespace Server.Engines.Chat public void Kick(ChatUser user, ChatUser moderator, bool wasBanned) { if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) + { return; + } if (Contains(user)) { if (moderator != null) { if (wasBanned) + { user.SendMessage( 63, moderator.Username ); // %1, a conference moderator, has banned you from the conference. + } else + { user.SendMessage( 45, moderator.Username ); // %1, a conference moderator, has kicked you out of the conference. + } } RemoveUser(user); @@ -206,24 +232,30 @@ namespace Server.Engines.Chat } if (wasBanned) + { moderator?.SendMessage(62, user.Username); // You are banning %1 from this conference. + } } public void AddVoiced(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator)) + { return; + } if (!IsBanned(user) && !IsModerator(user) && !IsVoiced(user)) { m_Voices.Add(user); if (moderator != null) + { user.SendMessage( 54, moderator .Username ); // %1, a conference moderator, has granted you speaking privileges in this conference. + } SendMessage(52, user, user.Username); // %1 now has speaking privileges in this conference. SendCommand(ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username); @@ -233,18 +265,22 @@ namespace Server.Engines.Chat public void RemoveVoiced(ChatUser user, ChatUser moderator) { if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) + { return; + } if (!IsModerator(user) && IsVoiced(user)) { m_Voices.Remove(user); if (moderator != null) + { user.SendMessage( 53, moderator .Username ); // %1, a conference moderator, has removed your speaking privileges for this conference. + } SendMessage(51, user, user.Username); // %1 no longer has speaking privileges in this conference. SendCommand(ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username); @@ -254,18 +290,26 @@ namespace Server.Engines.Chat public void AddModerator(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator)) + { return; + } if (IsBanned(user) || IsModerator(user)) + { return; + } if (IsVoiced(user)) + { m_Voices.Remove(user); + } m_Moderators.Add(user); if (moderator != null) + { user.SendMessage(50, moderator.Username); // %1 has made you a conference moderator. + } SendMessage(48, user, user.Username); // %1 is now a conference moderator. SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username); @@ -274,14 +318,18 @@ namespace Server.Engines.Chat public void RemoveModerator(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) + { return; + } if (IsModerator(user)) { m_Moderators.Remove(user); if (moderator != null) + { user.SendMessage(49, moderator.Username); // %1 has removed you from the list of conference moderators. + } SendMessage(47, user, user.Username); // %1 is no longer a conference moderator. SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username); @@ -300,12 +348,18 @@ namespace Server.Engines.Chat var user = m_Users[i]; if (user == initiator) + { continue; + } if (user.CheckOnline()) + { user.SendMessage(number, param1, param2); + } else if (!Contains(user)) + { --i; + } } } @@ -316,12 +370,18 @@ namespace Server.Engines.Chat var user = m_Users[i]; if (user.IsIgnored(from)) + { continue; + } if (user.CheckOnline()) - user.SendMessage(number, from.Mobile, param1, param2); + { + user.SendMessage(number, @from.Mobile, param1, param2); + } else if (!Contains(user)) + { --i; + } } } @@ -337,12 +397,18 @@ namespace Server.Engines.Chat var user = m_Users[i]; if (user == initiator) + { continue; + } if (user.CheckOnline()) + { ChatSystem.SendCommandTo(user.Mobile, command, param1, param2); + } else if (!Contains(user)) + { --i; + } } } @@ -363,7 +429,9 @@ namespace Server.Engines.Chat var channel = Channels[i]; if (!channel.IsBanned(user)) + { ChatSystem.SendCommandTo(user.Mobile, ChatCommand.AddChannel, channel.Name, "0"); + } } } @@ -390,7 +458,9 @@ namespace Server.Engines.Chat public static void RemoveChannel(Channel channel) { if (channel == null) + { return; + } if (Channels.Contains(channel) && channel.m_Users.Count == 0) { @@ -410,7 +480,9 @@ namespace Server.Engines.Chat var channel = Channels[i]; if (channel.m_Name == name) + { return channel; + } } return null; diff --git a/Projects/UOContent/Engines/Chat/Chat.cs b/Projects/UOContent/Engines/Chat/Chat.cs index dd07b6834..f28b7df0b 100644 --- a/Projects/UOContent/Engines/Chat/Chat.cs +++ b/Projects/UOContent/Engines/Chat/Chat.cs @@ -39,14 +39,18 @@ namespace Server.Engines.Chat string accountChatName = null; if (acct != null) + { accountChatName = acct.GetTag("ChatName"); + } accountChatName = accountChatName?.Trim(); if (!string.IsNullOrEmpty(accountChatName)) { if (chatName.Length > 0 && chatName != accountChatName) - from.SendMessage("You cannot change chat nickname once it has been set."); + { + @from.SendMessage("You cannot change chat nickname once it has been set."); + } } else { @@ -99,7 +103,9 @@ namespace Server.Engines.Chat var user = ChatUser.GetChatUser(name); if (user == null) - from.SendMessage(32, name); // There is no player named '%1'. + { + @from.SendMessage(32, name); // There is no player named '%1'. + } return user; } @@ -107,7 +113,9 @@ namespace Server.Engines.Chat public static void ChatAction(NetState state, PacketReader pvSrc) { if (!Enabled) + { return; + } try { @@ -115,7 +123,9 @@ namespace Server.Engines.Chat var user = ChatUser.GetChatUser(from); if (user == null) + { return; + } var lang = pvSrc.ReadStringSafe(4); int actionID = pvSrc.ReadInt16(); @@ -131,11 +141,17 @@ namespace Server.Engines.Chat /* You must be in a conference to do this. * To join a conference, select one from the Conference menu. */ + { user.SendMessage(31); + } else if (handler.RequireModerator && !user.IsModerator) + { user.SendMessage(29); // You must have operator status to do this. + } else + { handler.Callback(user, channel, param); + } } else { diff --git a/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs b/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs index 4470f2e7d..f5e410be9 100644 --- a/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs +++ b/Projects/UOContent/Engines/Chat/ChatActionHandlers.cs @@ -43,13 +43,17 @@ namespace Server.Engines.Chat public static void Register(int actionID, bool requireModerator, bool requireConference, OnChatAction callback) { if (actionID >= 0 && actionID < m_Handlers.Length) + { m_Handlers[actionID] = new ChatActionHandler(requireModerator, requireConference, callback); + } } public static ChatActionHandler GetHandler(int actionID) { if (actionID >= 0 && actionID < m_Handlers.Length) + { return m_Handlers[actionID]; + } return null; } @@ -57,17 +61,25 @@ namespace Server.Engines.Chat public static void ChannelMessage(ChatUser from, Channel channel, string param) { if (channel.CanTalk(from)) - channel.SendIgnorableMessage(57, from, from.GetColorCharacter() + from.Username, param); // %1: %2 + { + channel.SendIgnorableMessage(57, @from, @from.GetColorCharacter() + @from.Username, param); // %1: %2 + } else - from.SendMessage(36); // The moderator of this conference has not given you speaking privileges. + { + @from.SendMessage(36); // The moderator of this conference has not given you speaking privileges. + } } public static void EmoteMessage(ChatUser from, Channel channel, string param) { if (channel.CanTalk(from)) - channel.SendIgnorableMessage(58, from, from.GetColorCharacter() + from.Username, param); // %1 %2 + { + channel.SendIgnorableMessage(58, @from, @from.GetColorCharacter() + @from.Username, param); // %1 %2 + } else - from.SendMessage(36); // The moderator of this conference has not given you speaking privileges. + { + @from.SendMessage(36); // The moderator of this conference has not given you speaking privileges. + } } public static void PrivateMessage(ChatUser from, Channel channel, string param) @@ -80,17 +92,25 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, name); if (target == null) + { return; + } if (target.IsIgnored(from)) - from.SendMessage( + { + @from.SendMessage( 35, target.Username ); // %1 has chosen to ignore you. None of your messages to them will get through. + } else if (target.IgnorePrivateMessage) - from.SendMessage(42, target.Username); // %1 has chosen to not receive private messages at the moment. + { + @from.SendMessage(42, target.Username); // %1 has chosen to not receive private messages at the moment. + } else - target.SendMessage(59, from.Mobile, from.GetColorCharacter() + from.Username, text); // [%1]: %2 + { + target.SendMessage(59, @from.Mobile, @from.GetColorCharacter() + @from.Username, text); // [%1]: %2 + } } public static void LeaveChat(ChatUser from, Channel channel, string param) @@ -188,15 +208,21 @@ namespace Server.Engines.Chat var joined = Channel.FindChannelByName(name); if (joined == null) - from.SendMessage(33, name); // There is no conference named '%1'. + { + @from.SendMessage(33, name); // There is no conference named '%1'. + } else - joined.AddUser(from, password); + { + joined.AddUser(@from, password); + } } public static void JoinNewChannel(ChatUser from, Channel channel, string param) { if ((param = param.Trim()).Length == 0) + { return; + } string name; string password = null; @@ -210,7 +236,9 @@ namespace Server.Engines.Chat var end = param.IndexOf('}', start); if (end >= start) + { password = param.Substring(start, end - start); + } } else { @@ -227,7 +255,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target == null) + { return; + } from.AddIgnored(target); } @@ -237,7 +267,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target == null) + { return; + } from.RemoveIgnored(target); } @@ -247,12 +279,18 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target == null) + { return; + } if (from.IsIgnored(target)) - from.RemoveIgnored(target); + { + @from.RemoveIgnored(target); + } else - from.AddIgnored(target); + { + @from.AddIgnored(target); + } } public static void AddVoice(ChatUser from, Channel channel, string param) @@ -260,7 +298,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target != null) - channel.AddVoiced(target, from); + { + channel.AddVoiced(target, @from); + } } public static void RemoveVoice(ChatUser from, Channel channel, string param) @@ -268,7 +308,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target != null) - channel.RemoveVoiced(target, from); + { + channel.RemoveVoiced(target, @from); + } } public static void ToggleVoice(ChatUser from, Channel channel, string param) @@ -276,12 +318,18 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target == null) + { return; + } if (channel.IsVoiced(target)) - channel.RemoveVoiced(target, from); + { + channel.RemoveVoiced(target, @from); + } else - channel.AddVoiced(target, from); + { + channel.AddVoiced(target, @from); + } } public static void AddModerator(ChatUser from, Channel channel, string param) @@ -289,7 +337,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target != null) - channel.AddModerator(target, from); + { + channel.AddModerator(target, @from); + } } public static void RemoveModerator(ChatUser from, Channel channel, string param) @@ -297,7 +347,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target != null) - channel.RemoveModerator(target, from); + { + channel.RemoveModerator(target, @from); + } } public static void ToggleModerator(ChatUser from, Channel channel, string param) @@ -305,12 +357,18 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target == null) + { return; + } if (channel.IsModerator(target)) - channel.RemoveModerator(target, from); + { + channel.RemoveModerator(target, @from); + } else - channel.AddModerator(target, from); + { + channel.AddModerator(target, @from); + } } public static void RenameChannel(ChatUser from, Channel channel, string param) @@ -323,12 +381,18 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target == null) + { return; + } if (target.Anonymous) - from.SendMessage(41, target.Username); // %1 is remaining anonymous. + { + @from.SendMessage(41, target.Username); // %1 is remaining anonymous. + } else - from.SendMessage(43, target.Username, target.Mobile.Name); // %2 is known in the lands of Britannia as %2. + { + @from.SendMessage(43, target.Username, target.Mobile.Name); // %2 is known in the lands of Britannia as %2. + } } public static void Kick(ChatUser from, Channel channel, string param) @@ -336,7 +400,9 @@ namespace Server.Engines.Chat var target = ChatSystem.SearchForUser(from, param); if (target != null) - channel.Kick(target, from); + { + channel.Kick(target, @from); + } } public static void EnableDefaultVoice(ChatUser from, Channel channel, string param) diff --git a/Projects/UOContent/Engines/Chat/ChatUser.cs b/Projects/UOContent/Engines/Chat/ChatUser.cs index 7735b18c0..be0625618 100644 --- a/Projects/UOContent/Engines/Chat/ChatUser.cs +++ b/Projects/UOContent/Engines/Chat/ChatUser.cs @@ -30,14 +30,18 @@ namespace Server.Engines.Chat get { if (Mobile.Account is Account acct) + { return acct.GetTag("ChatName"); + } return null; } set { if (Mobile.Account is Account acct) + { acct.SetTag("ChatName", value); + } } } @@ -58,7 +62,9 @@ namespace Server.Engines.Chat public bool CheckOnline() { if (IsOnline) + { return true; + } RemoveChatUser(this); return false; @@ -67,13 +73,17 @@ namespace Server.Engines.Chat public void SendMessage(int number, string param1 = null, string param2 = null) { if (Mobile.NetState != null) + { Mobile.Send(new ChatMessagePacket(Mobile, number, param1, param2)); + } } public void SendMessage(int number, Mobile from, string param1, string param2) { if (Mobile.NetState != null) - Mobile.Send(new ChatMessagePacket(from, number, param1, param2)); + { + Mobile.Send(new ChatMessagePacket(@from, number, param1, param2)); + } } public bool IsIgnored(ChatUser check) => Ignored.Contains(check); @@ -103,7 +113,9 @@ namespace Server.Engines.Chat SendMessage(24, user.Username); // You are no longer ignoring %1. if (Ignored.Count == 0) + { SendMessage(26); // You are no longer ignoring anyone. + } } else { @@ -116,7 +128,9 @@ namespace Server.Engines.Chat var user = GetChatUser(from); if (user != null) + { return user; + } user = new ChatUser(from); @@ -132,7 +146,9 @@ namespace Server.Engines.Chat var c = list[i]; if (c.AddUser(user)) + { break; + } } // ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); @@ -143,10 +159,14 @@ namespace Server.Engines.Chat public static void RemoveChatUser(ChatUser user) { if (user == null) + { return; + } for (var i = 0; i < user.Ignoring.Count; ++i) + { user.Ignoring[i].RemoveIgnored(user); + } if (m_Users.Contains(user)) { @@ -179,7 +199,9 @@ namespace Server.Engines.Chat var user = m_Users[i]; if (user.Username == username) + { return user; + } } return null; @@ -199,10 +221,14 @@ namespace Server.Engines.Chat var user = m_Users[i]; if (user == initiator) + { continue; + } if (user.CheckOnline()) + { ChatSystem.SendCommandTo(user.Mobile, command, param1, param2); + } } } } diff --git a/Projects/UOContent/Engines/Chat/Packets.cs b/Projects/UOContent/Engines/Chat/Packets.cs index 34d7d0519..175a4f94b 100644 --- a/Projects/UOContent/Engines/Chat/Packets.cs +++ b/Projects/UOContent/Engines/Chat/Packets.cs @@ -14,9 +14,13 @@ namespace Server.Engines.Chat Stream.Write((ushort)(number - 20)); if (who != null) + { Stream.WriteAsciiFixed(who.Language, 4); + } else + { Stream.Write(0); + } Stream.WriteBigUniNull(param1); Stream.WriteBigUniNull(param2); diff --git a/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs b/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs index 9994c11fa..0429491b1 100644 --- a/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs +++ b/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs @@ -58,9 +58,13 @@ namespace Server.Engines.ConPVP string fmt; if (p.Contains(challenger)) + { fmt = "You have been asked to join sides with {0} in a duel. Do you accept?"; + } else + { fmt = "You have been challenged to a duel from {0}. Do you accept?"; + } AddHtml(22 - 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32)); AddHtml(22 + 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32)); @@ -104,7 +108,9 @@ namespace Server.Engines.ConPVP public void AutoReject() { if (!m_Active) + { return; + } m_Active = false; @@ -117,7 +123,9 @@ namespace Server.Engines.ConPVP public static void BeginIgnore(Mobile source, Mobile toIgnore) { if (!m_IgnoreLists.TryGetValue(source, out var list)) + { m_IgnoreLists[source] = list = new List(); + } for (var i = 0; i < list.Count; ++i) { @@ -130,7 +138,9 @@ namespace Server.Engines.ConPVP } if (ie.Expired) + { list.RemoveAt(i--); + } } list.Add(new IgnoreEntry(toIgnore)); @@ -139,16 +149,22 @@ namespace Server.Engines.ConPVP public static bool IsIgnored(Mobile source, Mobile check) { if (!m_IgnoreLists.TryGetValue(source, out var list)) + { return false; + } for (var i = 0; i < list.Count; ++i) { var ie = list[i]; if (ie.Expired) + { list.RemoveAt(i--); + } else if (ie.Ignored == check) + { return true; + } } return false; @@ -157,24 +173,34 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID != 1 || !m_Active || !m_Context.Registered) + { return; + } m_Active = false; if (!m_Context.Participants.Contains(m_Participant)) + { return; + } if (info.IsSwitched(1)) { if (!(m_Challenged is PlayerMobile pm)) + { return; + } if (pm.DuelContext != null) { if (pm.DuelContext.Initiator == pm) + { pm.SendMessage(0x22, "You have already started a duel."); + } else + { pm.SendMessage(0x22, "You have already been challenged in a duel."); + } m_Challenger.SendMessage("{0} cannot fight because they are already assigned to another duel.", pm.Name); } @@ -206,12 +232,14 @@ namespace Server.Engines.ConPVP else { for (var i = 0; i < m_Participant.Players.Length; ++i) + { if (m_Participant.Players[i] == null) { added = true; m_Participant.Players[i] = new DuelPlayer(m_Challenged, m_Participant); break; } + } } if (added) @@ -222,6 +250,7 @@ namespace Server.Engines.ConPVP var ns = m_Challenger.NetState; if (ns != null) + { foreach (var g in ns.Gumps) { if (g is ParticipantGump pg && pg.Participant == m_Participant) @@ -236,6 +265,7 @@ namespace Server.Engines.ConPVP break; } } + } } else { @@ -254,7 +284,9 @@ namespace Server.Engines.ConPVP else { if (info.IsSwitched(3)) + { BeginIgnore(m_Challenged, m_Challenger); + } m_Challenger.SendMessage("{0} does not wish to fight.", m_Challenged.Name); m_Challenged.SendMessage( diff --git a/Projects/UOContent/Engines/ConPVP/Arena.cs b/Projects/UOContent/Engines/ConPVP/Arena.cs index 6c1e4aa51..44610c7d8 100644 --- a/Projects/UOContent/Engines/ConPVP/Arena.cs +++ b/Projects/UOContent/Engines/ConPVP/Arena.cs @@ -44,7 +44,9 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) - from.SendGump(new PropertiesGump(from, Arena)); + { + @from.SendGump(new PropertiesGump(@from, Arena)); + } } public override void Serialize(IGenericWriter writer) @@ -93,7 +95,9 @@ namespace Server.Engines.ConPVP Points = new Point3D[reader.ReadEncodedInt()]; for (var i = 0; i < Points.Length; ++i) + { Points[i] = reader.ReadPoint3D(); + } } public Point3D[] Points { get; } @@ -161,7 +165,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(Points.Length); for (var i = 0; i < Points.Length; ++i) + { writer.Write(Points[i]); + } } } @@ -321,13 +327,19 @@ namespace Server.Engines.ConPVP } if (m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null) + { m_Region = new SafeZone(m_Zone, Outside, m_Facet, m_IsGuarded); + } if (IsOccupied) + { Timer.DelayCall(TimeSpan.FromSeconds(2.0), Evict); + } if (m_Tournament != null) + { Timer.DelayCall(AttachToTournament_Sandbox); + } } [CommandProperty(AccessLevel.GameMaster)] @@ -342,7 +354,9 @@ namespace Server.Engines.ConPVP m_IsGuarded = value; if (m_Region != null) + { m_Region.Disabled = !m_IsGuarded; + } } } @@ -370,7 +384,10 @@ namespace Server.Engines.ConPVP set { m_Name = value; - if (m_Active) Arenas.Sort(); + if (m_Active) + { + Arenas.Sort(); + } } } @@ -383,14 +400,20 @@ namespace Server.Engines.ConPVP m_Facet = value; if (Teleporter != null) + { Teleporter.Map = value; + } m_Region?.Unregister(); if (m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null) + { m_Region = new SafeZone(m_Zone, Outside, m_Facet, m_IsGuarded); + } else + { m_Region = null; + } } } @@ -440,7 +463,9 @@ namespace Server.Engines.ConPVP { m_GateOut = value; if (Teleporter != null) + { Teleporter.Location = m_GateOut; + } } } @@ -464,7 +489,9 @@ namespace Server.Engines.ConPVP set { if (m_Active == value) + { return; + } m_Active = value; @@ -486,7 +513,10 @@ namespace Server.Engines.ConPVP get => false; set { - if (value) Evict(); + if (value) + { + Evict(); + } } } @@ -498,11 +528,19 @@ namespace Server.Engines.ConPVP var b = c.m_Name; if (a == null && b == null) + { return 0; + } + if (a == null) + { return -1; + } + if (b == null) + { return +1; + } return a.CompareTo(b); } @@ -536,16 +574,22 @@ namespace Server.Engines.ConPVP var pl = players[i]; if (pl == null) + { continue; + } var mob = pl.Mobile; Point2D p; if (offset < offsets.Length) + { p = offsets[offset++]; + } else + { p = offsets[^1]; + } p.X = p.X * matrix[0, 0] + p.Y * matrix[0, 1]; p.Y = p.X * matrix[1, 0] + p.Y * matrix[1, 1]; @@ -585,13 +629,17 @@ namespace Server.Engines.ConPVP var mob = Players[i]; if (mob == null) + { continue; + } if (mob.Map == Map.Internal) { if ((m_Facet == null || mob.LogoutMap == m_Facet) && (!hasBounds || m_Bounds.Contains(mob.LogoutLocation))) + { mob.LogoutLocation = loc; + } } else if ((m_Facet == null || mob.Map == m_Facet) && (!hasBounds || m_Bounds.Contains(mob.Location))) { @@ -609,9 +657,13 @@ namespace Server.Engines.ConPVP var pets = new List(); foreach (var mob in facet.GetMobilesInBounds(m_Bounds)) + { if (mob is BaseCreature pet && pet.Controlled && pet.ControlMaster != null && Players.Contains(pet.ControlMaster)) + { pets.Add(pet); + } + } foreach (var pet in pets) { @@ -660,10 +712,14 @@ namespace Server.Engines.ConPVP var prefs = Preferences.Instance; if (prefs == null) + { return FindArena(); + } if (Arenas.Count == 0) + { return null; + } if (players.Count > 0) { @@ -687,9 +743,13 @@ namespace Server.Engines.ConPVP bool isNear; if (house == null) + { isNear = controller.Map == check.Map && check.InRange(controller, 24); + } else + { isNear = BaseHouse.FindHouseAt(check) == house; + } if (!isNear) { @@ -699,7 +759,9 @@ namespace Server.Engines.ConPVP } if (allNear) + { return controller.Arena; + } } } } @@ -711,11 +773,15 @@ namespace Server.Engines.ConPVP var arena = Arenas[i]; if (!arena.IsOccupied) + { arenas.Add(new ArenaEntry(arena)); + } } if (arenas.Count == 0) + { return Arenas[0]; + } var tc = 0; @@ -728,9 +794,13 @@ namespace Server.Engines.ConPVP var pe = prefs.Find(players[j]); if (pe.Disliked.Contains(ae.m_Arena.Name)) + { ++ae.m_VotesAgainst; + } else + { ++ae.m_VotesFor; + } } tc += ae.Value; @@ -743,7 +813,9 @@ namespace Server.Engines.ConPVP var ae = arenas[i]; if (rn < ae.Value) + { return ae.m_Arena; + } rn -= ae.Value; } @@ -754,7 +826,9 @@ namespace Server.Engines.ConPVP public static Arena FindArena() { if (Arenas.Count == 0) + { return null; + } var offset = Utility.Random(Arenas.Count); @@ -763,7 +837,9 @@ namespace Server.Engines.ConPVP var arena = Arenas[(i + offset) % Arenas.Count]; if (!arena.IsOccupied) + { return arena; + } } return Arenas[offset]; diff --git a/Projects/UOContent/Engines/ConPVP/DuelContext.cs b/Projects/UOContent/Engines/ConPVP/DuelContext.cs index 8eb597302..321038ac7 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelContext.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelContext.cs @@ -101,7 +101,9 @@ namespace Server.Engines.ConPVP public static bool IsFreeConsume(Mobile mob) { if (!(mob is PlayerMobile pm) || pm.DuelContext?.m_EventGame == null) + { return false; + } return pm.DuelContext.m_EventGame.FreeConsume; } @@ -117,25 +119,37 @@ namespace Server.Engines.ConPVP public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move) { if (!StartedBeginCountdown) + { return true; + } var pl = Find(from); if (pl?.Eliminated != false) + { return true; + } if (CantDoAnything(from)) + { return false; + } string title = null; if (move is NinjaMove) + { title = "Bushido"; + } else if (move is SamuraiMove) + { title = "Ninjitsu"; + } if (title == null || name == null || Ruleset.GetOption(title, name)) + { return true; + } from.SendMessage("The dueling ruleset prevents you from using this move."); return false; @@ -144,16 +158,24 @@ namespace Server.Engines.ConPVP public bool AllowSpellCast(Mobile from, Spell spell) { if (!StartedBeginCountdown) + { return true; + } if (Find(from)?.Eliminated != false) + { return true; + } if (CantDoAnything(from)) + { return false; + } if (spell is RecallSpell) - from.SendMessage("You may not cast this spell."); + { + @from.SendMessage("You may not cast this spell."); + } string title; string option; @@ -203,7 +225,9 @@ namespace Server.Engines.ConPVP } if (title == null || option == null || Ruleset.GetOption(title, option)) + { return true; + } from.SendMessage("The dueling ruleset prevents you from casting this spell."); return false; @@ -212,15 +236,21 @@ namespace Server.Engines.ConPVP public bool AllowItemEquip(Mobile from, Item item) { if (!StartedBeginCountdown) + { return true; + } var pl = Find(from); if (pl?.Eliminated != false) + { return true; + } if (item is Dagger || CheckItemEquip(from, item)) + { return true; + } from.SendMessage("The dueling ruleset prevents you from equipping this item."); return false; @@ -229,7 +259,9 @@ namespace Server.Engines.ConPVP public static bool AllowSpecialAbility(Mobile from, string name, bool message) { if (!(from is PlayerMobile pm)) + { return true; + } var dc = pm.DuelContext; @@ -240,21 +272,31 @@ namespace Server.Engines.ConPVP public bool InstAllowSpecialAbility(Mobile from, string name, bool message) { if (!StartedBeginCountdown) + { return true; + } var pl = Find(from); if (pl?.Eliminated != false) + { return true; + } if (CantDoAnything(from)) + { return false; + } if (Ruleset.GetOption("Combat Abilities", name)) + { return true; + } if (message) - from.SendMessage("The dueling ruleset prevents you from using this combat ability."); + { + @from.SendMessage("The dueling ruleset prevents you from using this combat ability."); + } return false; } @@ -264,40 +306,60 @@ namespace Server.Engines.ConPVP if (item is Fists) { if (!Ruleset.GetOption("Weapons", "Wrestling")) + { return false; + } } else if (item is BaseArmor armor) { if (armor.ProtectionLevel > ArmorProtectionLevel.Regular && !Ruleset.GetOption("Armor", "Magical")) + { return false; + } if (!Core.AOS && armor.Resource != armor.DefaultResource && !Ruleset.GetOption("Armor", "Colored")) + { return false; + } if (armor is BaseShield && !Ruleset.GetOption("Armor", "Shields")) + { return false; + } } else if (item is BaseWeapon weapon) { if ((weapon.DamageLevel > WeaponDamageLevel.Regular || weapon.AccuracyLevel > WeaponAccuracyLevel.Regular) && !Ruleset.GetOption("Weapons", "Magical")) + { return false; + } if (!Core.AOS && weapon.Resource != CraftResource.Iron && weapon.Resource != CraftResource.None && !Ruleset.GetOption("Weapons", "Runics")) + { return false; + } if (weapon is BaseRanged && !Ruleset.GetOption("Weapons", "Ranged")) + { return false; + } if (!(weapon is BaseRanged) && !Ruleset.GetOption("Weapons", "Melee")) + { return false; + } if (weapon.PoisonCharges > 0 && weapon.Poison != null && !Ruleset.GetOption("Weapons", "Poisoned")) + { return false; + } if (weapon is BaseWand && !Ruleset.GetOption("Items", "Wands")) + { return false; + } } return true; @@ -306,21 +368,31 @@ namespace Server.Engines.ConPVP public bool AllowSkillUse(Mobile from, SkillName skill) { if (!StartedBeginCountdown) + { return true; + } var pl = Find(from); if (pl?.Eliminated != false) + { return true; + } if (CantDoAnything(from)) + { return false; + } var id = (int)skill; if (id >= 0 && id < SkillInfo.Table.Length) + { if (Ruleset.GetOption("Skills", SkillInfo.Table[id].Name)) + { return true; + } + } from.SendMessage("The dueling ruleset prevents you from using this skill."); return false; @@ -329,16 +401,24 @@ namespace Server.Engines.ConPVP public bool AllowItemUse(Mobile from, Item item) { if (!StartedBeginCountdown) + { return true; + } var pl = Find(from); if (pl?.Eliminated != false) + { return true; + } if (!(item is BaseRefreshPotion)) - if (CantDoAnything(from)) + { + if (CantDoAnything(@from)) + { return false; + } + } string title = null, option = null; @@ -347,21 +427,37 @@ namespace Server.Engines.ConPVP title = "Potions"; if (item is BaseAgilityPotion) + { option = "Agility"; + } else if (item is BaseCurePotion) + { option = "Cure"; + } else if (item is BaseHealPotion) + { option = "Heal"; + } else if (item is NightSightPotion) + { option = "Nightsight"; + } else if (item is BasePoisonPotion) + { option = "Poison"; + } else if (item is BaseStrengthPotion) + { option = "Strength"; + } else if (item is BaseExplosionPotion) + { option = "Explosion"; + } else if (item is BaseRefreshPotion) + { option = "Refresh"; + } } else if (item is Bandage) { @@ -431,7 +527,9 @@ namespace Server.Engines.ConPVP } if (title == null || option == null || Ruleset.GetOption(title, option)) + { return true; + } from.SendMessage("The dueling ruleset prevents you from using this item."); return false; @@ -455,24 +553,36 @@ namespace Server.Engines.ConPVP public void OnLocationChanged(Mobile mob) { if (!Registered || !StartedBeginCountdown || Finished) + { return; + } var arena = Arena; if (arena == null) + { return; + } if (mob.Map == arena.Facet && arena.Bounds.Contains(mob.Location)) + { return; + } var pl = Find(mob); if (pl?.Eliminated != false) + { return; + } if (mob.Map == Map.Internal) + { if (mob.LogoutMap == arena.Facet && arena.Bounds.Contains(mob.LogoutLocation)) + { mob.LogoutLocation = arena.Outside; + } + } pl.Eliminated = true; @@ -487,23 +597,31 @@ namespace Server.Engines.ConPVP var winner = CheckCompletion(); if (winner != null) + { Finish(winner); + } } public void OnDeath(Mobile mob, Container corpse) { if (!Registered || !Started) + { return; + } var pl = Find(mob); if (pl?.Eliminated != false || m_EventGame?.OnDeath(mob, corpse) == false) + { return; + } pl.Eliminated = true; if (mob.Poison != null) + { mob.Poison = null; + } Requip(mob, corpse); DelayBounce(TimeSpan.FromSeconds(4.0), mob, corpse); @@ -528,7 +646,9 @@ namespace Server.Engines.ConPVP var p = Participants[i]; if (p.HasOpenSlot) + { return false; + } } return true; @@ -537,7 +657,9 @@ namespace Server.Engines.ConPVP public void Requip(Mobile from, Container cont) { if (!(cont is Corpse corpse)) + { return; + } var items = new List(corpse.Items); @@ -550,12 +672,18 @@ namespace Server.Engines.ConPVP var item = items[i]; if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable) + { continue; + } if (pack != null) + { pack.DropItem(item); + } else + { didntFit = true; + } } corpse.Carved = true; @@ -571,15 +699,21 @@ namespace Server.Engines.ConPVP var killer = from.FindMostRecentDamager(false); if (killer?.Player == true) - killer.AddToBackpack(new Head(m_Tournament == null ? HeadType.Duel : HeadType.Tournament, from.Name)); + { + killer.AddToBackpack(new Head(m_Tournament == null ? HeadType.Duel : HeadType.Tournament, @from.Name)); + } } from.PlaySound(0x3E3); if (didntFit) - from.SendLocalizedMessage(1062472); // You gather some of your belongings. The rest remain on the corpse. + { + @from.SendLocalizedMessage(1062472); // You gather some of your belongings. The rest remain on the corpse. + } else - from.SendLocalizedMessage(1062471); // You quickly gather all of your belongings. + { + @from.SendLocalizedMessage(1062471); // You quickly gather all of your belongings. + } } public void Refresh(Mobile mob, Container cont) @@ -589,17 +723,23 @@ namespace Server.Engines.ConPVP mob.Resurrect(); if (mob.FindItemOnLayer(Layer.OuterTorso) is DeathRobe robe) + { robe.Delete(); + } if (cont is Corpse corpse) + { for (var i = 0; i < corpse.EquipItems.Count; ++i) { var item = corpse.EquipItems[i]; if (item.Movable && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.IsChildOf(mob.Backpack)) + { mob.EquipItem(item); + } } + } } mob.Hits = mob.HitsMax; @@ -612,7 +752,9 @@ namespace Server.Engines.ConPVP public void SendOutside(Mobile mob) { if (Arena == null) + { return; + } mob.Combatant = null; mob.MoveToWorld(Arena.Outside, Arena.Facet); @@ -621,7 +763,9 @@ namespace Server.Engines.ConPVP public void Finish(Participant winner) { if (Finished) + { return; + } EndAutoTie(); StopSDTimers(); @@ -633,7 +777,9 @@ namespace Server.Engines.ConPVP var pl = winner.Players[i]; if (pl?.Eliminated == false) + { DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null); + } } winner.Broadcast( @@ -664,10 +810,13 @@ namespace Server.Engines.ConPVP ); if (m_Tournament != null) + { loser.TourneyPart?.LostMatch(m_Match); + } } for (var j = 0; j < loser.Players.Length; ++j) + { if (loser.Players[j] != null) { RemoveAggressions(loser.Players[j].Mobile); @@ -675,8 +824,11 @@ namespace Server.Engines.ConPVP loser.Players[j].Mobile.CloseGump(); if (m_Tournament != null) + { loser.Players[j].Mobile.SendEverything(); + } } + } } if (IsOneVsOne) @@ -701,42 +853,60 @@ namespace Server.Engines.ConPVP var ladder = Arena == null ? Ladder.Instance : Arena.AcquireLadder(); if (ladder == null) + { return; + } var ourEntry = ladder.Find(us); var theirEntry = ladder.Find(them); if (ourEntry == null || theirEntry == null) + { return; + } var xpGain = Ladder.GetExperienceGain(ourEntry, theirEntry, won); if (xpGain == 0) + { return; + } if (m_Tournament != null) + { xpGain *= xpGain > 0 ? 5 : 2; + } if (won) + { ++ourEntry.Wins; + } else + { ++ourEntry.Losses; + } var oldLevel = Ladder.GetLevel(ourEntry.Experience); ourEntry.Experience += xpGain; if (ourEntry.Experience < 0) + { ourEntry.Experience = 0; + } ladder.UpdateEntry(ourEntry); var newLevel = Ladder.GetLevel(ourEntry.Experience); if (newLevel > oldLevel) + { us.SendMessage(0x59, "You have achieved level {0}!", newLevel); + } else if (newLevel < oldLevel) + { us.SendMessage(0x22, "You have lost a level. You are now at {0}.", newLevel); + } } public void UnregisterRematch() @@ -754,7 +924,9 @@ namespace Server.Engines.ConPVP DestroyWall(); if (!Registered) + { return; + } Registered = false; @@ -771,17 +943,23 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl == null) + { continue; + } if (pl.Mobile is PlayerMobile mobile) + { mobile.DuelPlayer = null; + } CloseAllGumps(pl); } } if (queryRematch && m_Tournament == null) + { QueryRematch(); + } } public void QueryRematch() @@ -803,7 +981,9 @@ namespace Server.Engines.ConPVP var oldPlayer = oldPart.Players[j]; if (oldPlayer != null) + { newPart.Players[j] = new DuelPlayer(oldPlayer.Mobile, newPart); + } } dc.Participants.Add(newPart); @@ -818,7 +998,9 @@ namespace Server.Engines.ConPVP if (mob is PlayerMobile pm) { if (pm.DuelContext == this) + { return pm.DuelPlayer; + } return null; } @@ -829,7 +1011,9 @@ namespace Server.Engines.ConPVP var pl = p.Find(mob); if (pl != null) + { return pl; + } } return null; @@ -859,7 +1043,9 @@ namespace Server.Engines.ConPVP ++eliminated; if (eliminated == Participants.Count - 1) + { hasWinner = true; + } } else { @@ -890,7 +1076,9 @@ namespace Server.Engines.ConPVP private void Countdown_Callback(int count, CountdownCallback cb) { if (count == 0) + { StopCountdown(); + } cb(count); } @@ -928,7 +1116,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl?.Eliminated != false) + { continue; + } pl.Mobile.SendSound(0x1E1); pl.Mobile.SendMessage(0x22, "Warning! Warning! Warning!"); @@ -957,7 +1147,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl?.Eliminated != false) + { continue; + } pl.Mobile.SendSound(0x1E1); pl.Mobile.SendMessage(0x22, "Warning! Warning! Warning!"); @@ -1000,7 +1192,9 @@ namespace Server.Engines.ConPVP m_AutoTieTimer = null; if (!Started || Finished) + { return; + } Tied = true; Finished = true; @@ -1040,11 +1234,15 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl?.Eliminated == false) + { DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null); + } } if (p.TourneyPart != null) + { remaining.Add(p.TourneyPart); + } } for (var j = 0; j < p.Players.Length; ++j) @@ -1084,12 +1282,16 @@ namespace Server.Engines.ConPVP var ladder = Ladder.Instance; if (ladder == null) + { return; + } var entry = ladder.Find(pm); if (entry != null) - from.SendGump(new PropertiesGump(from, entry)); + { + @from.SendGump(new PropertiesGump(@from, entry)); + } } } @@ -1100,22 +1302,30 @@ namespace Server.Engines.ConPVP private static void EventSink_Login(Mobile m) { if (!(m is PlayerMobile pm)) + { return; + } var dc = pm.DuelContext; if (dc == null) + { return; + } if (dc.ReadyWait && pm.DuelPlayer.Ready && !dc.Started && !dc.StartedBeginCountdown && !dc.Finished) { if (dc.m_Tournament == null) + { pm.SendGump(new ReadyGump(pm, dc, dc.ReadyCount)); + } } else if (dc.ReadyWait && !dc.StartedBeginCountdown && !dc.Started && !dc.Finished) { if (dc.m_Tournament == null) + { pm.SendGump(new ReadyUpGump(pm, dc)); + } } else if (dc.Initiator == pm && !dc.ReadyWait && !dc.StartedBeginCountdown && !dc.Started && !dc.Finished) { @@ -1130,7 +1340,9 @@ namespace Server.Engines.ConPVP var entry = ladder.Find(pm); if (entry == null) + { return; // sanity + } var text = $"{{0}} are ranked {LadderGump.Rank(entry.Index + 1)} at level {Ladder.GetLevel(entry.Experience)}."; @@ -1146,21 +1358,25 @@ namespace Server.Engines.ConPVP else if (obj is Mobile mob) { if (mob.Body.IsHuman) + { mob.PrivateOverheadMessage( MessageType.Regular, mob.SpeechHue, false, "I'm not a duelist, and quite frankly, I resent the implication.", - from.NetState + @from.NetState ); + } else + { mob.PrivateOverheadMessage( MessageType.Regular, 0x3B2, true, "It's probably better than you.", - from.NetState + @from.NetState ); + } } else { @@ -1171,10 +1387,14 @@ namespace Server.Engines.ConPVP private static void EventSink_Speech(SpeechEventArgs e) { if (e.Handled) + { return; + } if (!(e.Mobile is PlayerMobile pm)) + { return; + } if (Insensitive.Contains(e.Speech, "i wish to duel")) { @@ -1194,9 +1414,13 @@ namespace Server.Engines.ConPVP else if (pm.DuelContext != null) { if (pm.DuelContext.Initiator == pm) + { e.Mobile.SendMessage(0x22, "You have already started a duel."); + } else + { e.Mobile.SendMessage(0x22, "You have already been challenged in a duel."); + } } else if (TournamentController.IsActive) { @@ -1243,7 +1467,9 @@ namespace Server.Engines.ConPVP var entry = instance.Find(pm); if (entry == null) + { return; // sanity + } var text = $"{{0}} {{1}} ranked {LadderGump.Rank(entry.Index + 1)} at level {Ladder.GetLevel(entry.Experience)}."; @@ -1309,7 +1535,9 @@ namespace Server.Engines.ConPVP var pl = pm.DuelContext.Find(pm); if (pl == null) + { return; + } var p = pl.Participant; @@ -1329,6 +1557,7 @@ namespace Server.Engines.ConPVP var ns = init.NetState; if (ns != null) + { foreach (var g in ns.Gumps) { if (g is ParticipantGump pg && pg.Participant == p) @@ -1343,6 +1572,7 @@ namespace Server.Engines.ConPVP break; } } + } } } else if (!pm.DuelContext.StartedReadyCountdown) // at ready stage @@ -1386,7 +1616,9 @@ namespace Server.Engines.ConPVP } if (send) + { init.SendGump(new DuelContextGump(init, dc)); + } } } } @@ -1435,7 +1667,9 @@ namespace Server.Engines.ConPVP } if (send) + { init.SendGump(new DuelContextGump(init, dc)); + } } } } @@ -1478,7 +1712,9 @@ namespace Server.Engines.ConPVP var winner = pm.DuelContext.CheckCompletion(); if (winner != null) + { pm.DuelContext.Finish(winner); + } } } } @@ -1512,7 +1748,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl != null) + { CloseAllGumps(pl); + } } } } @@ -1520,7 +1758,9 @@ namespace Server.Engines.ConPVP public void RejectReady(Mobile rejector, string page) { if (StartedReadyCountdown) + { return; // sanity + } for (var i = 0; i < Participants.Count; ++i) { @@ -1531,7 +1771,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl == null) + { continue; + } pl.Ready = false; @@ -1540,14 +1782,20 @@ namespace Server.Engines.ConPVP if (page == null) // yield { if (mob != rejector) + { mob.SendMessage(0x22, "{0} has yielded.", rejector.Name); + } } else { if (mob == rejector) + { mob.SendMessage(0x22, "You have rejected the {0}.", Rematch ? "rematch" : page); + } else + { mob.SendMessage(0x22, "{0} has rejected the {1}.", rejector.Name, Rematch ? "rematch" : page); + } } // Close all of them? @@ -1558,9 +1806,13 @@ namespace Server.Engines.ConPVP } if (Rematch) + { Unregister(); + } else if (!m_Yielding) + { Initiator.SendGump(new DuelContextGump(Initiator, this)); + } ReadyWait = false; ReadyCount = 0; @@ -1600,7 +1852,9 @@ namespace Server.Engines.ConPVP AnimalForm.RemoveContext(mob, true); if (DisguiseTimers.IsDisguised(mob)) + { DisguiseTimers.StopTimer(mob); + } if (!mob.CanBeginAction()) { @@ -1622,7 +1876,9 @@ namespace Server.Engines.ConPVP public static void CancelSpell(Mobile mob) { if (mob.Spell is Spell spell) + { spell.Disturb(DisturbType.Kill); + } Target.Cancel(mob); } @@ -1630,7 +1886,9 @@ namespace Server.Engines.ConPVP public void DestroyWall() { for (var i = 0; i < m_Walls.Count; ++i) + { m_Walls[i].Delete(); + } m_Walls.Clear(); } @@ -1638,7 +1896,9 @@ namespace Server.Engines.ConPVP public void CreateWall() { if (Arena == null) + { return; + } var start = Arena.Points.EdgeWest; var wall = Arena.Wall; @@ -1651,13 +1911,21 @@ namespace Server.Engines.ConPVP bool eastToWest; if (rx >= 0 && ry >= 0) + { eastToWest = false; + } else if (rx >= 0) + { eastToWest = true; + } else if (ry >= 0) + { eastToWest = true; + } else + { eastToWest = false; + } Effects.PlaySound(wall, Arena.Facet, 0x1F6); @@ -1688,12 +1956,15 @@ namespace Server.Engines.ConPVP var dp = p.Players[j]; if (dp == null) + { continue; + } players.Add(dp.Mobile); } if (players.Count > 1) + { for (var leaderIndex = 0; leaderIndex + 1 < players.Count; leaderIndex += Party.Capacity) { var leader = players[leaderIndex]; @@ -1716,7 +1987,9 @@ namespace Server.Engines.ConPVP var existing = Party.Get(player); if (existing == party) + { continue; + } if (party.Members.Count + party.Candidates.Count >= Party.Capacity) { @@ -1739,6 +2012,7 @@ namespace Server.Engines.ConPVP } } } + } } } } @@ -1754,7 +2028,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl == null) + { continue; + } ClearIllegalItems(pl.Mobile); } @@ -1764,20 +2040,28 @@ namespace Server.Engines.ConPVP public void ClearIllegalItems(Mobile mob) { if (mob.StunReady && !AllowSpecialAbility(mob, "Stun", false)) + { mob.StunReady = false; + } if (mob.DisarmReady && !AllowSpecialAbility(mob, "Disarm", false)) + { mob.DisarmReady = false; + } var pack = mob.Backpack; if (pack == null) + { return; + } for (var i = mob.Items.Count - 1; i >= 0; --i) { if (i >= mob.Items.Count) + { continue; // sanity + } var item = mob.Items[i]; @@ -1786,20 +2070,26 @@ namespace Server.Engines.ConPVP pack.DropItem(item); if (item is BaseWeapon) + { mob.SendLocalizedMessage( 1062001, item.Name ?? $"#{item.LabelNumber}" ); // You can no longer wield your ~1_WEAPON~ + } else if (item is BaseArmor && !(item is BaseShield)) + { mob.SendLocalizedMessage( 1062002, item.Name ?? $"#{item.LabelNumber}" ); // You can no longer wear your ~1_ARMOR~ + } else + { mob.SendLocalizedMessage( 1062003, item.Name ?? $"#{item.LabelNumber}" ); // You can no longer equip your ~1_SHIELD~ + } } } @@ -1812,9 +2102,13 @@ namespace Server.Engines.ConPVP var bi = inHand.GetBounce(); if (bi.Parent == mob) + { pack.DropItem(inHand); + } else + { inHand.Bounce(mob); + } inHand.ClearBounce(); } @@ -1822,7 +2116,10 @@ namespace Server.Engines.ConPVP private void MessageRuleset(Mobile mob) { - if (Ruleset == null) return; + if (Ruleset == null) + { + return; + } var ruleset = Ruleset; var basedef = ruleset.Base; @@ -1852,6 +2149,7 @@ namespace Server.Engines.ConPVP var opts = ruleset.Options; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) { var name = ruleset.Layout.FindByIndex(i); @@ -1860,17 +2158,23 @@ namespace Server.Engines.ConPVP { ++changes; - if (changes == 1) mob.SendMessage("Modifications:"); + if (changes == 1) + { + mob.SendMessage("Modifications:"); + } mob.SendMessage("{0}: {1}", name, opts[i] ? "enabled" : "disabled"); } } + } } public void SendBeginGump(int count) { if (!Registered || Finished) + { return; + } if (count == 10) { @@ -1900,7 +2204,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl == null) + { continue; + } var mob = pl.Mobile; @@ -1936,7 +2242,9 @@ namespace Server.Engines.ConPVP var dp = p.Players[j]; if (dp == null || dp.Mobile == mob) + { continue; + } mob.RemoveAggressed(dp.Mobile); mob.RemoveAggressor(dp.Mobile); @@ -1949,7 +2257,9 @@ namespace Server.Engines.ConPVP public void SendReadyUpGump() { if (!Registered) + { return; + } ReadyWait = true; ReadyCount = -1; @@ -1976,7 +2286,9 @@ namespace Server.Engines.ConPVP public string ValidateStart() { if (m_Tournament == null && TournamentController.IsActive) + { return "a tournament is active"; + } for (var i = 0; i < Participants.Count; ++i) { @@ -1987,32 +2299,47 @@ namespace Server.Engines.ConPVP var dp = p.Players[j]; if (dp == null) + { return "a slot is empty"; + } if (dp.Mobile.Region.IsPartOf()) + { return $"{dp.Mobile.Name} is in jail"; + } if (Sigil.ExistsOn(dp.Mobile)) + { return $"{dp.Mobile.Name} is holding a sigil"; + } if (!dp.Mobile.Alive) { if (m_Tournament == null) + { return $"{dp.Mobile.Name} is dead"; + } + dp.Mobile.Resurrect(); } if (m_Tournament == null && CheckCombat(dp.Mobile)) + { return $"{dp.Mobile.Name} is in combat"; + } if (dp.Mobile.Mounted) { var mount = dp.Mobile.Mount; if (m_Tournament != null && mount != null) + { mount.Rider = null; + } else + { return $"{dp.Mobile.Name} is mounted"; + } } } } @@ -2023,10 +2350,14 @@ namespace Server.Engines.ConPVP public void SendReadyGump(int count) { if (!Registered) + { return; + } if (count != -1) + { StartedReadyCountdown = true; + } ReadyCount = count; @@ -2066,7 +2397,9 @@ namespace Server.Engines.ConPVP var dp = p.Players[j]; if (dp != null) + { players.Add(dp.Mobile); + } } } @@ -2130,7 +2463,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl == null) + { continue; + } tp.Register(pl.Mobile); @@ -2187,7 +2522,9 @@ namespace Server.Engines.ConPVP var pl = p.Players[j]; if (pl == null) + { continue; + } var mob = pl.Mobile; @@ -2207,7 +2544,9 @@ namespace Server.Engines.ConPVP } if (count == -1 && isAllReady) + { StartCountdown(3, SendReadyGump); + } } private class InternalWall : Item @@ -2272,7 +2611,9 @@ namespace Server.Engines.ConPVP public void Return() { if (Facet == Map.Internal || Facet == null) + { return; + } if (Mobile.Map == Map.Internal) { @@ -2341,9 +2682,14 @@ namespace Server.Engines.ConPVP var entry = m_Entries[i]; if (entry.Mobile == mob) + { return entry; + } + if (entry.Expired) + { m_Entries.RemoveAt(i--); + } } return null; @@ -2352,7 +2698,9 @@ namespace Server.Engines.ConPVP public override bool OnMoveOver(Mobile m) { if (!base.OnMoveOver(m)) + { return false; + } var entry = Find(m); @@ -2389,7 +2737,9 @@ namespace Server.Engines.ConPVP writer.Write(entry.Facet); if (entry.Expired) + { m_Entries.RemoveAt(i--); + } } } @@ -2452,12 +2802,16 @@ namespace Server.Engines.ConPVP public override void CheckGate(Mobile m, int range) { if (CheckCombat(m)) + { m.SendMessage( 0x22, "You have recently been in combat with another player and cannot use this moongate." ); + } else + { base.CheckGate(m, range); + } } public override void UseGate(Mobile m) @@ -2472,7 +2826,9 @@ namespace Server.Engines.ConPVP else { if (m_Teleporter?.Deleted == false) + { m_Teleporter.Register(m); + } base.UseGate(m); } diff --git a/Projects/UOContent/Engines/ConPVP/DuelTeleporterAddon.cs b/Projects/UOContent/Engines/ConPVP/DuelTeleporterAddon.cs index e7d7d6a15..a8761cd34 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelTeleporterAddon.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelTeleporterAddon.cs @@ -61,14 +61,18 @@ namespace Server.Engines.ConPVP get { if (Components.Count > 0) + { return (DuelTeleporterType)Components[0].ItemID; + } return DuelTeleporterType.Squares; } set { for (var i = 0; i < Components.Count && i < 9; ++i) + { Components[i].ItemID = i + (int)value; + } } } diff --git a/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs b/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs index 34427529d..ccd4493dd 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs @@ -46,10 +46,14 @@ namespace Server.Engines.ConPVP private Mobile FindOwner(IEntity parent) { if (parent is Item item) + { return item.RootParent as Mobile; + } if (parent is Mobile mobile) + { return mobile; + } return null; } @@ -85,7 +89,9 @@ namespace Server.Engines.ConPVP var mob = FindOwner(parent); if (mob != null) + { mob.SolidHueOverride = 0x0499; + } } public override void OnRemoved(IEntity parent) @@ -95,23 +101,33 @@ namespace Server.Engines.ConPVP var mob = FindOwner(parent); if (mob != null && m_Game != null) + { mob.SolidHueOverride = m_Game.GetColor(mob); + } } public void DropTo(Mobile mob, Mobile killer) { if (mob?.Deleted == false) + { MoveToWorld(mob.Location, mob.Map); + } else if (killer?.Deleted == false) + { MoveToWorld(killer.Location, killer.Map); + } else + { m_Game?.ReturnBomb(); + } } public override bool OnMoveOver(Mobile m) { if (m_Flying || !Visible || m_Game == null || m?.Alive != true) + { return true; + } var useTeam = m_Game.GetTeamInfo(m); return useTeam == null || TakeBomb(m, useTeam, "picked up"); @@ -122,7 +138,9 @@ namespace Server.Engines.ConPVP base.OnLocationChange(oldLocation); if (m_Flying || !Visible || m_Game == null || Parent != null) + { return; + } var eable = GetClientsInRange(0); foreach (var ns in eable) @@ -130,11 +148,15 @@ namespace Server.Engines.ConPVP var m = ns.Mobile; if (m?.Player != true || !m.Alive) + { continue; + } var useTeam = m_Game.GetTeamInfo(m); if (useTeam != null) + { TakeBomb(m, useTeam, "got"); + } } } @@ -148,42 +170,62 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick(Mobile m) { if (m_Game == null || !Visible || m?.Alive != true) + { return; + } if (!m_Flying && IsChildOf(m.Backpack)) + { m.Target = new BombTarget(this, m); + } else if (Parent == null) + { if (m.InRange(Location, 1) && m.Location.Z != Z) { var useTeam = m_Game.GetTeamInfo(m); if (useTeam == null) + { return; + } TakeBomb(m, useTeam, "grabbed"); } + } } private bool OnBombTarget(Mobile from, object obj) { if (m_Game == null) + { return true; + } if (!IsChildOf(from.Backpack)) + { return true; + } // don't let them throw it to themselves if (obj == from) + { return false; + } if (!(obj is IPoint3D)) + { return false; + } var pt = new Point3D((IPoint3D)obj); if (obj is Mobile) + { pt.Z += 10; + } else if (obj is Item item) + { pt.Z += item.ItemData.CalcHeight + 1; + } m_Flying = true; Visible = false; @@ -208,10 +250,14 @@ namespace Server.Engines.ConPVP private bool CheckCatch(Mobile m, Point3D myLoc) { if (m?.Alive != true || !m.Player || m_Game == null) + { return false; + } if (m_Game.GetTeamInfo(m) == null) + { return false; + } var zdiff = myLoc.Z - m.Z; @@ -238,22 +284,30 @@ namespace Server.Engines.ConPVP Visible = true; if (m?.Alive != true || !m.Player || m_Game == null) + { return; + } var useTeam = m_Game.GetTeamInfo(m); if (useTeam == null) + { return; + } DoAnim(GetWorldLocation(), m.Location, m.Map); var verb = "caught"; if (Thrower != null && m_Game.GetTeamInfo(Thrower) != useTeam) + { verb = "intercepted"; + } if (!TakeBomb(m, useTeam, verb)) + { MoveToWorld(m.Location, m.Map); + } } private void BeginFlight(Point3D dest) @@ -296,7 +350,9 @@ namespace Server.Engines.ConPVP var p = list[^1]; if (p.X != ix || p.Y != iy || p.Z != iz) + { list.Add(new Point3D(ix, iy, iz)); + } } else { @@ -309,7 +365,9 @@ namespace Server.Engines.ConPVP } if (list.Count > 0 && list[^1] != dest) + { list.Add(dest); + } /*if (dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y )) { @@ -361,7 +419,9 @@ namespace Server.Engines.ConPVP m_Path.Clear(); for (var i = 0; i < list.Count; i++) + { m_Path.Add(list[i]); + } m_PathIdx = 0; @@ -378,12 +438,16 @@ namespace Server.Engines.ConPVP var pathCheckEnd = m_PathIdx + 5; if (m_Path.Count < pathCheckEnd) + { pathCheckEnd = m_Path.Count; + } Visible = false; if (m_PathIdx > 0) // move to the next location + { MoveToWorld(m_Path[m_PathIdx - 1]); + } Point3D pTop = new Point3D(GetWorldLocation()), pBottom = new Point3D(m_Path[pathCheckEnd - 1]); Utility.FixPoints(ref pTop, ref pBottom); @@ -430,9 +494,14 @@ namespace Server.Engines.ConPVP (id.Flags & (TileFlag.Impassable | TileFlag.Wall | TileFlag.NoShoot)) != 0) { if (i > m_PathIdx) + { point = m_Path[i - 1]; + } else + { point = GetWorldLocation(); + } + HitObject(point, t.Z, height); return; } @@ -445,7 +514,9 @@ namespace Server.Engines.ConPVP foreach (var i in area) { if (i == this || i.ItemID >= 0x4000) + { continue; + } if (i is BRGoal) { @@ -459,7 +530,10 @@ namespace Server.Engines.ConPVP { var id = i.ItemData; if ((id.Flags & (TileFlag.Impassable | TileFlag.Wall | TileFlag.NoShoot)) == 0) + { continue; + } + height = id.CalcHeight; } @@ -474,24 +548,35 @@ namespace Server.Engines.ConPVP { found = true; if (j > m_PathIdx) + { point = m_Path[j - 1]; + } else + { point = GetWorldLocation(); + } + break; } } if (!found) + { continue; + } area.Free(); if (i is BRGoal goal) { var oldLoc = new Point3D(GetWorldLocation()); if (CheckScore(goal, Thrower, 3)) + { DoAnim(oldLoc, point, Map); + } else + { HitObject(point, loc.Z, height); + } } else { @@ -509,7 +594,9 @@ namespace Server.Engines.ConPVP var m = ns.Mobile; if (m == null || m == Thrower) + { continue; + } Point3D point; var loc = m.Location; @@ -520,11 +607,15 @@ namespace Server.Engines.ConPVP if (loc.X == point.X && loc.Y == point.Y && loc.Z <= point.Z && loc.Z + 16 >= point.Z) + { found = CheckCatch(m, point); + } } if (!found) + { continue; + } clients.Free(); @@ -539,22 +630,29 @@ namespace Server.Engines.ConPVP m_PathIdx = pathCheckEnd; if (m_PathIdx > 0 && m_PathIdx - 1 < m_Path.Count) + { DoAnim(GetWorldLocation(), m_Path[m_PathIdx - 1], Map); + } Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight); } else { if (m_PathIdx > 0 && m_PathIdx - 1 < m_Path.Count) + { MoveToWorld(m_Path[m_PathIdx - 1]); + } else if (m_Path.Count > 0) + { MoveToWorld(m_Path.Last); + } var myZ = Map?.GetAverageZ(X, Y) ?? 0; var statics = Map?.Tiles?.GetStaticTiles(X, Y, true); if (statics != null) + { for (var j = 0; j < statics.Length; j++) { var t = statics[j]; @@ -563,17 +661,24 @@ namespace Server.Engines.ConPVP height = id.CalcHeight; if (t.Z + height > myZ && t.Z + height <= Z) + { myZ = t.Z + height; + } } + } var eable = GetItemsInRange(0); foreach (var item in eable) + { if (item.Visible && item != this) { height = item.ItemData.CalcHeight; if (item.Z + height > myZ && item.Z + height <= Z) + { myZ = item.Z + height; + } } + } eable.Free(); @@ -589,16 +694,24 @@ namespace Server.Engines.ConPVP public bool CheckScore(BRGoal goal, Mobile m, int points) { if (m_Game == null || m == null || goal == null) + { return false; + } var team = m_Game.GetTeamInfo(m); if (team == null || goal.Team == null || team == goal.Team) + { return false; + } if (points > 3) + { m_Game.Alert("Touchdown {0} ({1})!", team.Name, m.Name); + } else + { m_Game.Alert("Field goal {0} ({1})!", team.Name, m.Name); + } for (var i = m_Helpers.Count - 1; i >= 0; i--) { @@ -608,7 +721,9 @@ namespace Server.Engines.ConPVP if (pi != null) { if (mob == m) + { pi.Captures += points; + } pi.Score += points + 1; @@ -631,7 +746,9 @@ namespace Server.Engines.ConPVP private bool TakeBomb(Mobile m, BRTeamInfo team, string verb) { if (!m.Player || !m.Alive || m.NetState == null) + { return false; + } if (m.PlaceInBackpack(this)) { @@ -643,14 +760,18 @@ namespace Server.Engines.ConPVP m.Target = new BombTarget(this, m); if (m_Helpers.Contains(m)) + { m_Helpers.Remove(m); + } if (m_Helpers.Count > 0) { var last = m_Helpers[0]; if (m_Game.GetTeamInfo(last) != team) + { m_Helpers.Clear(); + } } m_Helpers.Add(m); @@ -678,7 +799,9 @@ namespace Server.Engines.ConPVP if (m_Bomb.Parent == null && m_Bomb.m_Game?.Controller != null) { if (!m_Bomb.m_Flying && m_Bomb.Map != Map.Internal) + { Effects.SendLocationEffect(m_Bomb.GetWorldLocation(), m_Bomb.Map, 0x377A, 16, 10, m_Bomb.Hue, 0); + } if (m_Bomb.Location != m_Bomb.m_Game.Controller.BombHome) { @@ -735,14 +858,18 @@ namespace Server.Engines.ConPVP // has to be delayed in case some other target canceled us... if (m_Resend) + { Timer.DelayCall(ResendBombTarget); + } } private void ResendBombTarget() { // Make sure they still have the bomb, then give them the target back if (m_Bomb?.Deleted == false && m_Mob?.Deleted == false && m_Mob.Alive && m_Bomb.IsChildOf(m_Mob)) + { m_Mob.Target = new BombTarget(m_Bomb, m_Mob); + } } } } @@ -789,9 +916,13 @@ namespace Server.Engines.ConPVP { m_Team = value; if (m_Team != null && m_Team.Color != 0) + { Hue = m_Team.Color; + } else + { Hue = 0x84C; + } } } @@ -896,18 +1027,28 @@ namespace Server.Engines.ConPVP public override bool OnMoveOver(Mobile m) { if (!Visible) + { return true; + } if (m?.Player != true || !m.Alive || m.Backpack == null || m_Team?.Game == null) + { return true; + } if (!base.OnMoveOver(m)) + { return false; + } if (m_Team != null && m_Team.Color != 0) + { Hue = m_Team.Color; + } else + { Hue = 0x84C; + } m.Backpack.FindItemByType()?.CheckScore(this, m, 7); return true; @@ -977,7 +1118,9 @@ namespace Server.Engines.ConPVP var teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; if (teamInfo == null) + { continue; + } entries.Add(teamInfo); } @@ -987,8 +1130,12 @@ namespace Server.Engines.ConPVP else { foreach (var player in section.Players.Values) + { if (player.Score > 0) + { total++; + } + } } entries.Sort(); @@ -996,7 +1143,9 @@ namespace Server.Engines.ConPVP var height = 0; if (section == null) + { height = 73 + entries.Count * 75 + 28; + } Closable = false; @@ -1007,7 +1156,9 @@ namespace Server.Engines.ConPVP AddImageTiled(16, 15, 369, height - 29, 3604); for (var i = 0; i < total; i += 1) + { AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + } AddAlphaRegion(16, 15, 369, height - 29); @@ -1020,6 +1171,7 @@ namespace Server.Engines.ConPVP AddImageTiled(42, 52, 264, 1, 9157); if (section == null) + { for (var i = 0; i < entries.Count; ++i) { var teamInfo = entries[i]; @@ -1098,8 +1250,11 @@ namespace Server.Engines.ConPVP AddBorderedText(235 + 10, 85 + i * 75, 250, 20, "Leader:", 0xFFC000, BlackColor32); if (pl != null) + { AddBorderedText(235 + 15, 105 + i * 75, 250, 20, pl.Player.Name, 0xFFC000, BlackColor32); + } } + } AddButton(314, height - 42, 247, 248, 1); } @@ -1120,9 +1275,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } } @@ -1147,12 +1306,16 @@ namespace Server.Engines.ConPVP { var res = pi.Captures.CompareTo(Captures); if (res != 0) + { return res; + } res = pi.Score.CompareTo(Score); if (res == 0) + { res = pi.Kills.CompareTo(Kills); + } return res; } @@ -1188,7 +1351,9 @@ namespace Server.Engines.ConPVP m_Score = value; if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + { m_TeamInfo.Leader = this; + } } } } @@ -1240,10 +1405,14 @@ namespace Server.Engines.ConPVP get { if (mob == null) + { return null; + } if (!Players.TryGetValue(mob, out var val)) + { Players[mob] = val = new BRPlayerInfo(this, mob); + } return val; } @@ -1263,7 +1432,9 @@ namespace Server.Engines.ConPVP { m_Goal = value; if (m_Goal != null) + { m_Goal.Team = this; + } } } @@ -1275,7 +1446,9 @@ namespace Server.Engines.ConPVP res = ti.Score.CompareTo(Score); if (res == 0) + { res = ti.Kills.CompareTo(Kills); + } } return res; @@ -1300,9 +1473,14 @@ namespace Server.Engines.ConPVP Players.Clear(); if (Board != null) + { Board.m_TeamInfo = this; + } + if (m_Goal != null) + { m_Goal.Team = this; + } } public void Serialize(IGenericWriter op) @@ -1321,7 +1499,10 @@ namespace Server.Engines.ConPVP public override string ToString() { if (TeamName != null) + { return $"({Name}) ..."; + } + return "..."; } } @@ -1341,7 +1522,9 @@ namespace Server.Engines.ConPVP TeamInfo = new BRTeamInfo[4]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new BRTeamInfo(i); + } } public BRController(Serial serial) @@ -1389,7 +1572,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(TeamInfo.Length); for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -1409,7 +1594,9 @@ namespace Server.Engines.ConPVP TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new BRTeamInfo(i, reader); + } break; } @@ -1434,7 +1621,9 @@ namespace Server.Engines.ConPVP get { if (m_Context.Arena != null) + { return m_Context.Arena.Facet; + } return Controller.Map; } @@ -1472,8 +1661,12 @@ namespace Server.Engines.ConPVP var p = m_Context.Participants[i]; for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Mobile.SendMessage(0x35, text); + } + } } } @@ -1487,7 +1680,9 @@ namespace Server.Engines.ConPVP var teamID = GetTeamID(mob); if (teamID >= 0) + { return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + } return null; } @@ -1495,13 +1690,19 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { if (!(mob is PlayerMobile pm)) + { return mob is BaseCreature creature ? creature.Team - 1 : -1; + } if (pm.DuelContext == null || pm.DuelContext != m_Context) + { return -1; + } if (pm.DuelPlayer?.Eliminated != false) + { return -1; + } return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); } @@ -1511,8 +1712,12 @@ namespace Server.Engines.ConPVP private void ApplyHues(Participant p, int hueOverride) { for (var i = 0; i < p.Players.Length; ++i) + { if (p.Players[i] != null) + { p.Players[i].Mobile.SolidHueOverride = hueOverride; + } + } } public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse) @@ -1527,9 +1732,13 @@ namespace Server.Engines.ConPVP m_Context.RemoveAggressions(mob); if (dp?.Eliminated == false) + { mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); + } else + { m_Context.SendOutside(mob); + } m_Context.Refresh(mob, corpse); DuelContext.Debuff(mob); @@ -1576,7 +1785,9 @@ namespace Server.Engines.ConPVP playerInfo.Score += 1; // base frag if (hadBomb) + { playerInfo.Score += 4; // fragged bomb carrier + } } } } @@ -1601,10 +1812,12 @@ namespace Server.Engines.ConPVP } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues( m_Context.Participants[i], Controller.TeamInfo[i % Controller.TeamInfo.Length].Color ); + } m_FinishTimer?.Stop(); @@ -1623,7 +1836,9 @@ namespace Server.Engines.ConPVP var teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; if (teamInfo != null) + { teams.Add(teamInfo); + } } teams.Sort(); @@ -1658,7 +1873,9 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } @@ -1666,7 +1883,9 @@ namespace Server.Engines.ConPVP } if (Controller != null) + { sb.Append(' ').Append(Controller.Title); + } var title = sb.ToString(); @@ -1688,14 +1907,18 @@ namespace Server.Engines.ConPVP var mob = pl.Player; if (mob == null) + { continue; + } sb = new StringBuilder(); sb.Append(title); if (pl == leader) + { sb.Append(" Leader"); + } if (pl.Score > 0) { @@ -1718,12 +1941,16 @@ namespace Server.Engines.ConPVP Item item = new Trophy(sb.ToString(), rank); if (pl == leader) + { item.ItemID = 4810; + } item.Name = $"{item.Name}, {teams[i].Name.ToLower()} team"; if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } var cash = pl.Score * 250; @@ -1732,7 +1959,9 @@ namespace Server.Engines.ConPVP item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } mob.SendMessage( "You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.", @@ -1755,7 +1984,9 @@ namespace Server.Engines.ConPVP var p = m_Context.Participants[i]; if (p?.Players == null) + { continue; + } for (var j = 0; j < p.Players.Length; ++j) { @@ -1769,16 +2000,26 @@ namespace Server.Engines.ConPVP } if (i == winner?.TeamID) + { continue; + } if (p.Players != null) + { for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Eliminated = true; + } + } + } } if (winner != null) + { m_Context.Finish(m_Context.Participants[winner.TeamID]); + } } public override void OnStop() @@ -1788,7 +2029,9 @@ namespace Server.Engines.ConPVP var teamInfo = Controller.TeamInfo[i]; if (teamInfo.Board != null) + { teamInfo.Board.m_TeamInfo = null; + } teamInfo.Game = null; } @@ -1798,7 +2041,9 @@ namespace Server.Engines.ConPVP m_Bomb?.Delete(); for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues(m_Context.Participants[i], -1); + } m_FinishTimer?.Stop(); m_FinishTimer = null; diff --git a/Projects/UOContent/Engines/ConPVP/Games/CTF.cs b/Projects/UOContent/Engines/ConPVP/Games/CTF.cs index 7c9a3c4d4..7f284f085 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/CTF.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/CTF.cs @@ -67,26 +67,38 @@ namespace Server.Engines.ConPVP var entries = new List(); if (section == null) + { for (var i = 0; i < game.Context.Participants.Count; ++i) { var teamInfo = game.Controller.TeamInfo[i % 8]; if (teamInfo?.Flag == null) + { continue; + } entries.Add(teamInfo); } + } else + { foreach (var player in section.Players.Values) + { if (player.Score > 0) + { entries.Add(player); + } + } + } entries.Sort((a, b) => b.Score - a.Score); var height = 0; if (section == null) + { height = 73 + entries.Count * 75 + 28; + } Closable = false; @@ -97,7 +109,9 @@ namespace Server.Engines.ConPVP AddImageTiled(16, 15, 369, height - 29, 3604); for (var i = 0; i < entries.Count; i += 1) + { AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + } AddAlphaRegion(16, 15, 369, height - 29); @@ -110,12 +124,15 @@ namespace Server.Engines.ConPVP AddImageTiled(42, 52, 264, 1, 9157); if (section == null) + { for (var i = 0; i < entries.Count; ++i) { var teamInfo = entries[i] as CTFTeamInfo; if (teamInfo == null) + { continue; + } AddImage(30, 70 + i * 75, 10152); AddImage(30, 85 + i * 75, 10151); @@ -191,8 +208,11 @@ namespace Server.Engines.ConPVP AddBorderedText(235 + 10, 85 + i * 75, 250, 20, "Leader:", 0xFFC000, BlackColor32); if (pl != null) + { AddBorderedText(235 + 15, 105 + i * 75, 250, 20, pl.Player.Name, 0xFFC000, BlackColor32); + } } + } AddButton(314, height - 42, 247, 248, 1); } @@ -213,9 +233,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } } @@ -251,7 +275,9 @@ namespace Server.Engines.ConPVP var useTeam = m_TeamInfo.Game.GetTeamInfo(from); if (ourTeam == null || useTeam == null) + { return; + } if (IsChildOf(from.Backpack)) { @@ -283,7 +309,9 @@ namespace Server.Engines.ConPVP var playerInfo = useTeam[from]; if (playerInfo != null) + { playerInfo.Score += 4; // return + } m_Returner = from; m_ReturnTime = DateTime.UtcNow; @@ -406,10 +434,14 @@ namespace Server.Engines.ConPVP private void Flag_OnTarget(Mobile from, object obj) { if (m_TeamInfo == null) + { return; + } if (!IsChildOf(from.Backpack)) + { return; + } var ourTeam = m_TeamInfo; var useTeam = m_TeamInfo.Game.GetTeamInfo(from); @@ -439,7 +471,9 @@ namespace Server.Engines.ConPVP var assistInfo = useTeam[teamFlag.m_Fragger]; if (assistInfo != null) + { assistInfo.Score += 6; // frag assist + } } if (teamFlag.m_Returner != null && @@ -448,7 +482,9 @@ namespace Server.Engines.ConPVP var assistInfo = useTeam[teamFlag.m_Returner]; if (assistInfo != null) + { assistInfo.Score += 4; // return assist + } } } } @@ -462,16 +498,22 @@ namespace Server.Engines.ConPVP var passTeam = m_TeamInfo.Game.GetTeamInfo(passTo); if (passTo == from) - from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them."); + { + @from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them."); + } else if (passTeam == useTeam && passTo.PlaceInBackpack(this)) + { passTo.LocalOverheadMessage( MessageType.Regular, 0x59, false, - $"{from.Name} has passed you the cookies!" + $"{@from.Name} has passed you the cookies!" ); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them."); + { + @from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them."); + } } } @@ -480,7 +522,9 @@ namespace Server.Engines.ConPVP StopCountdown(); if (m_TeamInfo == null) + { return; + } MoveToWorld(m_TeamInfo.Origin, m_TeamInfo.Game.Facet); } @@ -488,10 +532,14 @@ namespace Server.Engines.ConPVP private Mobile FindOwner(IEntity parent) { if (parent is Item item) + { return item.RootParent as Mobile; + } if (parent is Mobile mobile) + { return mobile; + } return null; } @@ -503,7 +551,9 @@ namespace Server.Engines.ConPVP var mob = FindOwner(parent); if (mob != null) + { mob.SolidHueOverride = 0x4001; + } } public override void OnRemoved(IEntity parent) @@ -513,7 +563,9 @@ namespace Server.Engines.ConPVP var mob = FindOwner(parent); if (mob != null) + { mob.SolidHueOverride = m_TeamInfo?.Game.GetColor(mob) ?? -1; + } } public override void Serialize(IGenericWriter writer) @@ -587,7 +639,9 @@ namespace Server.Engines.ConPVP m_Score = value; if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + { m_TeamInfo.Leader = this; + } } } } @@ -649,10 +703,14 @@ namespace Server.Engines.ConPVP get { if (mob == null) + { return null; + } if (!Players.TryGetValue(mob, out var val)) + { Players[mob] = val = new CTFPlayerInfo(this, mob); + } return val; } @@ -697,7 +755,9 @@ namespace Server.Engines.ConPVP } if (Board != null) + { Board.m_TeamInfo = this; + } } public void Serialize(IGenericWriter op) @@ -730,7 +790,9 @@ namespace Server.Engines.ConPVP TeamInfo = new CTFTeamInfo[8]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new CTFTeamInfo(i); + } } public CTFController(Serial serial) @@ -784,7 +846,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(TeamInfo.Length); for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -806,7 +870,9 @@ namespace Server.Engines.ConPVP TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new CTFTeamInfo(i, reader); + } break; } @@ -815,14 +881,18 @@ namespace Server.Engines.ConPVP TeamInfo = new CTFTeamInfo[8]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new CTFTeamInfo(i); + } break; } } if (version < 2) + { Duration = TimeSpan.FromMinutes(30.0); + } } } @@ -839,7 +909,9 @@ namespace Server.Engines.ConPVP get { if (m_Context.Arena != null) + { return m_Context.Arena.Facet; + } return Controller.Map; } @@ -848,7 +920,9 @@ namespace Server.Engines.ConPVP public static void Initialize() { for (var i = 0x7C9; i <= 0x7D0; ++i) + { TileData.ItemTable[i].Flags |= TileFlag.NoShoot; + } } public void Alert(string text) @@ -860,8 +934,12 @@ namespace Server.Engines.ConPVP var p = m_Context.Participants[i]; for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Mobile.SendMessage(0x35, text); + } + } } } @@ -875,7 +953,9 @@ namespace Server.Engines.ConPVP var teamID = GetTeamID(mob); if (teamID >= 0) + { return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + } return null; } @@ -883,13 +963,19 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { if (!(mob is PlayerMobile pm)) + { return -1; + } if (pm.DuelContext == null || pm.DuelContext != m_Context) + { return -1; + } if (pm.DuelPlayer?.Eliminated != false) + { return -1; + } return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); } @@ -899,7 +985,9 @@ namespace Server.Engines.ConPVP var teamInfo = GetTeamInfo(mob); if (teamInfo != null) + { return teamInfo.Color; + } return -1; } @@ -907,8 +995,12 @@ namespace Server.Engines.ConPVP private void ApplyHues(Participant p, int hueOverride) { for (var i = 0; i < p.Players.Length; ++i) + { if (p.Players[i] != null) + { p.Players[i].Mobile.SolidHueOverride = hueOverride; + } + } } public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse) @@ -923,9 +1015,13 @@ namespace Server.Engines.ConPVP m_Context.RemoveAggressions(mob); if (dp?.Eliminated == false) + { mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); + } else + { m_Context.SendOutside(mob); + } m_Context.Refresh(mob, corpse); DuelContext.Debuff(mob); @@ -972,30 +1068,42 @@ namespace Server.Engines.ConPVP playerInfo.Score += 1; // base frag if (hadFlag) + { playerInfo.Score += 4; // fragged flag carrier + } if (mob.InRange(teamInfo.Origin, 24) && mob.Map == Facet) + { playerInfo.Score += 1; // fragged in base -- guarding + } for (var i = 0; i < Controller.TeamInfo.Length; ++i) { if (Controller.TeamInfo[i] == teamInfo) + { continue; + } Mobile ourFlagCarrier = null; if (Controller.TeamInfo[i].Flag != null) + { ourFlagCarrier = Controller.TeamInfo[i].Flag.RootParent as Mobile; + } if (ourFlagCarrier != null && GetTeamInfo(ourFlagCarrier) == teamInfo) { if (ourFlagCarrier.Aggressors.Any( aggr => aggr.Defender == ourFlagCarrier && aggr.Attacker == mob )) + { playerInfo.Score += 2; // helped defend guy capturing enemy flag + } if (mob.Map == ourFlagCarrier.Map && ourFlagCarrier.InRange(mob, 12)) + { playerInfo.Score += 1; // helped defend guy capturing enemy flag + } } } } @@ -1022,7 +1130,9 @@ namespace Server.Engines.ConPVP } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues(m_Context.Participants[i], Controller.TeamInfo[i % 8].Color); + } m_FinishTimer?.Stop(); @@ -1038,7 +1148,9 @@ namespace Server.Engines.ConPVP var teamInfo = Controller.TeamInfo[i % 8]; if (teamInfo?.Flag == null) + { continue; + } teams.Add(teamInfo); } @@ -1075,7 +1187,9 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } @@ -1083,7 +1197,9 @@ namespace Server.Engines.ConPVP } if (Controller != null) + { sb.Append(' ').Append(Controller.Title); + } var title = sb.ToString(); @@ -1094,9 +1210,13 @@ namespace Server.Engines.ConPVP var rank = TrophyRank.Bronze; if (i == 0) + { rank = TrophyRank.Gold; + } else if (i == 1) + { rank = TrophyRank.Silver; + } var leader = teams[i].Leader; @@ -1105,7 +1225,9 @@ namespace Server.Engines.ConPVP var mob = pl.Player; if (mob == null) + { continue; + } // "Red v Blue CTF Champion" @@ -1114,7 +1236,9 @@ namespace Server.Engines.ConPVP sb.Append(title); if (pl == leader) + { sb.Append(" Leader"); + } if (pl.Score > 0) { @@ -1141,12 +1265,16 @@ namespace Server.Engines.ConPVP Item item = new Trophy(sb.ToString(), rank); if (pl == leader) + { item.ItemID = 4810; + } item.Name = $"{item.Name}, {teams[i].Name.ToLower()} team"; if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } var cash = pl.Score * 250; @@ -1155,7 +1283,9 @@ namespace Server.Engines.ConPVP item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } mob.SendMessage( "You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.", @@ -1189,15 +1319,23 @@ namespace Server.Engines.ConPVP } if (i == winner?.TeamID) + { continue; + } for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Eliminated = true; + } + } } if (winner != null) + { m_Context.Finish(m_Context.Participants[winner.TeamID]); + } } public override void OnStop() @@ -1213,13 +1351,17 @@ namespace Server.Engines.ConPVP } if (teamInfo.Board != null) + { teamInfo.Board.m_TeamInfo = null; + } teamInfo.Game = null; } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues(m_Context.Participants[i], -1); + } m_FinishTimer?.Stop(); diff --git a/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs b/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs index b4f09b62a..7258cb7ff 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs @@ -64,24 +64,36 @@ namespace Server.Engines.ConPVP var entries = new List(); if (section == null) + { for (var i = 0; i < game.Context.Participants.Count; ++i) { var teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; if (teamInfo != null) + { entries.Add(teamInfo); + } } + } else + { foreach (var player in section.Players.Values) + { if (player.Score > 0) + { entries.Add(player); + } + } + } entries.Sort((a, b) => b.Score - a.Score); var height = 0; if (section == null) + { height = 73 + entries.Count * 75 + 28; + } Closable = false; @@ -92,7 +104,9 @@ namespace Server.Engines.ConPVP AddImageTiled(16, 15, 369, height - 29, 3604); for (var i = 0; i < entries.Count; i += 1) + { AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + } AddAlphaRegion(16, 15, 369, height - 29); @@ -105,6 +119,7 @@ namespace Server.Engines.ConPVP AddImageTiled(42, 52, 264, 1, 9157); if (section == null) + { for (var i = 0; i < entries.Count; ++i) { var teamInfo = entries[i] as DDTeamInfo; @@ -183,8 +198,11 @@ namespace Server.Engines.ConPVP AddBorderedText(235 + 10, 85 + i * 75, 250, 20, "Leader:", 0xFFC000, BlackColor32); if (pl != null) + { AddBorderedText(235 + 15, 105 + i * 75, 250, 20, pl.Player.Name, 0xFFC000, BlackColor32); + } } + } AddButton(314, height - 42, 247, 248, 1); } @@ -205,9 +223,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } } @@ -259,7 +281,9 @@ namespace Server.Engines.ConPVP m_Score = value; if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + { m_TeamInfo.Leader = this; + } } } } @@ -309,10 +333,14 @@ namespace Server.Engines.ConPVP get { if (mob == null) + { return null; + } if (!Players.TryGetValue(mob, out var val)) + { Players[mob] = val = new DDPlayerInfo(this, mob); + } return val; } @@ -347,7 +375,9 @@ namespace Server.Engines.ConPVP Players.Clear(); if (Board != null) + { Board.m_TeamInfo = this; + } } public void Serialize(IGenericWriter op) @@ -376,7 +406,9 @@ namespace Server.Engines.ConPVP TeamInfo = new DDTeamInfo[2]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new DDTeamInfo(i); + } } public DDController(Serial serial) @@ -420,7 +452,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(TeamInfo.Length); for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i].Serialize(writer); + } writer.Write(PointA); writer.Write(PointB); @@ -440,7 +474,9 @@ namespace Server.Engines.ConPVP TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new DDTeamInfo(i, reader); + } PointA = reader.ReadItem() as DDWayPoint; PointB = reader.ReadItem() as DDWayPoint; @@ -470,7 +506,9 @@ namespace Server.Engines.ConPVP get { if (m_Context.Arena != null) + { return m_Context.Arena.Facet; + } return Controller.Map; } @@ -485,8 +523,12 @@ namespace Server.Engines.ConPVP var p = m_Context.Participants[i]; for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Mobile.SendMessage(0x35, text); + } + } } } @@ -500,7 +542,9 @@ namespace Server.Engines.ConPVP var teamID = GetTeamID(mob); if (teamID >= 0) + { return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + } return null; } @@ -508,13 +552,19 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { if (!(mob is PlayerMobile pm)) + { return -1; + } if (pm.DuelContext == null || pm.DuelContext != m_Context) + { return -1; + } if (pm.DuelPlayer?.Eliminated != false) + { return -1; + } return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); } @@ -524,8 +574,12 @@ namespace Server.Engines.ConPVP private void ApplyHues(Participant p, int hueOverride) { for (var i = 0; i < p.Players.Length; ++i) + { if (p.Players[i] != null) + { p.Players[i].Mobile.SolidHueOverride = hueOverride; + } + } } public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse) @@ -540,9 +594,13 @@ namespace Server.Engines.ConPVP m_Context.RemoveAggressions(mob); if (dp?.Eliminated == false) + { mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); + } else + { m_Context.SendOutside(mob); + } m_Context.Refresh(mob, corpse); DuelContext.Debuff(mob); @@ -570,17 +628,27 @@ namespace Server.Engines.ConPVP // extra points for killing someone on the waypoint if (Controller.PointA != null) + { if (mob.InRange(Controller.PointA, 2)) + { playerInfo.Score += 1; + } + } if (Controller.PointB != null) + { if (mob.InRange(Controller.PointB, 2)) + { playerInfo.Score += 1; + } + } } playerInfo = victInfo[mob]; if (playerInfo != null) + { playerInfo.Score -= 1; + } } } @@ -618,16 +686,22 @@ namespace Server.Engines.ConPVP } if (Controller.PointA != null) + { Controller.PointA.Game = this; + } if (Controller.PointB != null) + { Controller.PointB.Game = this; + } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues( m_Context.Participants[i], Controller.TeamInfo[i % Controller.TeamInfo.Length].Color ); + } m_FinishTimer?.Stop(); m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); @@ -642,7 +716,9 @@ namespace Server.Engines.ConPVP var teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; if (teamInfo != null) + { teams.Add(teamInfo); + } } teams.Sort((a, b) => b.Score - a.Score); @@ -677,7 +753,9 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } @@ -685,7 +763,9 @@ namespace Server.Engines.ConPVP } if (Controller != null) + { sb.Append(' ').Append(Controller.Title); + } var title = sb.ToString(); @@ -696,9 +776,13 @@ namespace Server.Engines.ConPVP var rank = TrophyRank.Bronze; if (i == 0) + { rank = TrophyRank.Gold; + } else if (i == 1) + { rank = TrophyRank.Silver; + } var leader = teams[i].Leader; @@ -707,7 +791,9 @@ namespace Server.Engines.ConPVP var mob = pl.Player; if (mob == null) + { continue; + } // "Red v Blue DD Champion" @@ -716,7 +802,9 @@ namespace Server.Engines.ConPVP sb.Append(title); if (pl == leader) + { sb.Append(" Leader"); + } if (pl.Score > 0) { @@ -743,12 +831,16 @@ namespace Server.Engines.ConPVP Item item = new Trophy(sb.ToString(), rank); if (pl == leader) + { item.ItemID = 4810; + } item.Name = $"{item.Name}, {teams[i].Name.ToLower()} team"; if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } var cash = pl.Score * 250; @@ -757,7 +849,9 @@ namespace Server.Engines.ConPVP item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } mob.SendMessage( "You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.", @@ -791,11 +885,17 @@ namespace Server.Engines.ConPVP } if (i == winner.TeamID) + { continue; + } for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Eliminated = true; + } + } } m_Context.Finish(m_Context.Participants[winner.TeamID]); @@ -808,16 +908,22 @@ namespace Server.Engines.ConPVP var teamInfo = Controller.TeamInfo[i]; if (teamInfo.Board != null) + { teamInfo.Board.m_TeamInfo = null; + } teamInfo.Game = null; } if (Controller.PointA != null) + { Controller.PointA.Game = null; + } if (Controller.PointB != null) + { Controller.PointB.Game = null; + } m_Capturable = false; @@ -834,7 +940,9 @@ namespace Server.Engines.ConPVP } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues(m_Context.Participants[i], -1); + } m_FinishTimer?.Stop(); m_FinishTimer = null; @@ -843,7 +951,9 @@ namespace Server.Engines.ConPVP public void Dominate(DDWayPoint point, Mobile from, DDTeamInfo team) { if (point == null || from == null || team == null || !m_Capturable) + { return; + } var wasDom = Controller.PointA?.TeamOwner == Controller.PointB?.TeamOwner && Controller.PointA?.TeamOwner != null; @@ -992,9 +1102,13 @@ namespace Server.Engines.ConPVP m_TeamOwner = null; if (m_Game != null) + { SetNonCaptureHue(); + } else + { SetUncapturableHue(); + } } } @@ -1026,33 +1140,50 @@ namespace Server.Engines.ConPVP public void SetUncapturableHue() { for (var i = 0; i < Components.Count; i++) + { Components[i].Hue = UncapturableHue; + } + Hue = UncapturableHue; } public void SetNonCaptureHue() { for (var i = 0; i < Components.Count; i++) + { Components[i].Hue = NonCapturedHue; + } if (m_TeamOwner != null) + { Hue = m_TeamOwner.Color; + } else + { Hue = NonCapturedHue; + } } public void SetCaptureHue(int stage) { if (m_TeamOwner == null) + { return; + } Hue = m_TeamOwner.Color; for (var i = 0; i < Components.Count; i++) + { if (i < stage) + { Components[i].Hue = m_TeamOwner.Color; + } else + { Components[i].Hue = NonCapturedHue; + } + } } public override bool OnMoveOver(Mobile from) @@ -1066,7 +1197,9 @@ namespace Server.Engines.ConPVP var team = m_Game.GetTeamInfo(from); if (team != null && team != TeamOwner) - m_Game.Dominate(this, from, team); + { + m_Game.Dominate(this, @from, team); + } } return true; diff --git a/Projects/UOContent/Engines/ConPVP/Games/EventGame.cs b/Projects/UOContent/Engines/ConPVP/Games/EventGame.cs index 62a086d38..c879a2c68 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/EventGame.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/EventGame.cs @@ -39,7 +39,9 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) - from.SendGump(new PropertiesGump(from, this)); + { + @from.SendGump(new PropertiesGump(@from, this)); + } } } diff --git a/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs b/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs index 6419556b0..dd796fe41 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs @@ -54,7 +54,10 @@ namespace Server.Engines.ConPVP get { if (m_KingTimer != null) + { return m_KingTimer.Captures; + } + return 0; } } @@ -88,15 +91,21 @@ namespace Server.Engines.ConPVP { // Game running? if (m_Game == null) + { return false; + } // Mobile exists and is alive and is a player? if (m?.Deleted != false || !m.Alive || !m.Player) + { return false; + } // Not current king (or they are the current king) if (King != null && King != m) + { return false; + } // They are on a team return m_Game.GetTeamInfo(m) != null; @@ -105,7 +114,9 @@ namespace Server.Engines.ConPVP public override bool OnMoveOver(Mobile m) { if (m_Game == null || m?.Alive != true) + { return base.OnMoveOver(m); + } if (CanBeKing(m)) { @@ -119,7 +130,9 @@ namespace Server.Engines.ConPVP { // Decrease their stam a little so they don't keep pushing someone out of the way if (m.AccessLevel == AccessLevel.Player && m.Stam >= m.StamMax) + { m.Stam -= 5; + } } return false; @@ -130,7 +143,9 @@ namespace Server.Engines.ConPVP if (base.OnMoveOff(m)) { if (King == m) + { DeKingify(); + } return true; } @@ -164,10 +179,14 @@ namespace Server.Engines.ConPVP private void ReKingify(Mobile m) { if (m_Game == null || m == null) + { return; + } if (m_Game.GetTeamInfo(m) == null) + { return; + } King = m; @@ -176,7 +195,9 @@ namespace Server.Engines.ConPVP m_KingTimer.StartHillTicker(); if (King.Name != null) + { PublicOverheadMessage(MessageType.Regular, 0x0481, false, $"Taken by {King.Name}!"); + } } private class KingTimer : Timer @@ -223,7 +244,9 @@ namespace Server.Engines.ConPVP var ti = m_Hill.Game.GetTeamInfo(m_Hill.King); if (ti != null) + { pi = ti[m_Hill.King]; + } if (ti == null || pi == null) { @@ -359,7 +382,9 @@ namespace Server.Engines.ConPVP var teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; if (teamInfo != null) + { entries.Add(teamInfo); + } } entries.Sort(); @@ -380,7 +405,9 @@ namespace Server.Engines.ConPVP AddImageTiled(16, 15, 369, height - 29, 3604); for (var i = 0; i < entries.Count; i += 1) + { AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + } AddAlphaRegion(16, 15, 369, height - 29); @@ -482,9 +509,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } } @@ -508,7 +539,9 @@ namespace Server.Engines.ConPVP { var res = pi.Score.CompareTo(Score); if (res != 0) + { return res; + } res = pi.Captures.CompareTo(Captures); @@ -546,7 +579,9 @@ namespace Server.Engines.ConPVP m_Score = value; if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + { m_TeamInfo.Leader = this; + } } } } @@ -591,10 +626,14 @@ namespace Server.Engines.ConPVP get { if (mob == null) + { return null; + } if (!Players.TryGetValue(mob, out var val)) + { Players[mob] = val = new KHPlayerInfo(this, mob); + } return val; } @@ -610,12 +649,16 @@ namespace Server.Engines.ConPVP { var res = ti.Score.CompareTo(Score); if (res != 0) + { return res; + } res = ti.Captures.CompareTo(Captures); if (res == 0) + { res = ti.Kills.CompareTo(Kills); + } return res; } @@ -668,7 +711,9 @@ namespace Server.Engines.ConPVP TeamInfo = new KHTeamInfo[8]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new KHTeamInfo(i); + } } public KHController(Serial serial) @@ -755,7 +800,9 @@ namespace Server.Engines.ConPVP public void AddBoard(KHBoard b) { if (b != null) + { Boards.Add(b); + } } public override void Serialize(IGenericWriter writer) @@ -771,11 +818,15 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(Hills.Length); for (var i = 0; i < Hills.Length; ++i) + { writer.Write(Hills[i]); + } writer.WriteEncodedInt(TeamInfo.Length); for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -796,11 +847,15 @@ namespace Server.Engines.ConPVP Hills = new HillOfTheKing[reader.ReadEncodedInt()]; for (var i = 0; i < Hills.Length; ++i) + { Hills[i] = reader.ReadItem() as HillOfTheKing; + } TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()]; for (var i = 0; i < TeamInfo.Length; ++i) + { TeamInfo[i] = new KHTeamInfo(i, reader); + } break; } @@ -821,7 +876,9 @@ namespace Server.Engines.ConPVP get { if (m_Context?.Arena != null) + { return m_Context.Arena.Facet; + } return Controller.Map; } @@ -830,9 +887,15 @@ namespace Server.Engines.ConPVP public override bool CantDoAnything(Mobile mob) { if (mob != null && GetTeamInfo(mob) != null && Controller != null) + { for (var i = 0; i < Controller.Hills.Length; i++) + { if (Controller.Hills[i]?.King == mob) + { return true; + } + } + } return false; } @@ -846,8 +909,12 @@ namespace Server.Engines.ConPVP var p = m_Context.Participants[i]; for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Mobile.SendMessage(0x35, text); + } + } } } @@ -861,7 +928,9 @@ namespace Server.Engines.ConPVP var teamID = GetTeamID(mob); if (teamID >= 0) + { return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + } return null; } @@ -869,13 +938,19 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { if (!(mob is PlayerMobile pm)) + { return mob is BaseCreature creature ? creature.Team - 1 : -1; + } if (pm.DuelContext == null || pm.DuelContext != m_Context) + { return -1; + } if (pm.DuelPlayer?.Eliminated != false) + { return -1; + } return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); } @@ -885,8 +960,12 @@ namespace Server.Engines.ConPVP private void ApplyHues(Participant p, int hueOverride) { for (var i = 0; i < p.Players.Length; ++i) + { if (p.Players[i] != null) + { p.Players[i].Mobile.SolidHueOverride = hueOverride; + } + } } public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse) @@ -901,9 +980,13 @@ namespace Server.Engines.ConPVP m_Context.RemoveAggressions(mob); if (dp?.Eliminated == false) + { mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); + } else + { m_Context.SendOutside(mob); + } m_Context.Refresh(mob, corpse); DuelContext.Debuff(mob); @@ -911,7 +994,9 @@ namespace Server.Engines.ConPVP mob.Frozen = false; if (corpse?.Deleted == false) + { Timer.DelayCall(TimeSpan.FromSeconds(30), corpse.Delete); + } } public override bool OnDeath(Mobile mob, Container corpse) @@ -922,12 +1007,16 @@ namespace Server.Engines.ConPVP var bonus = 0; if (killer?.Player == true) + { teamInfo = GetTeamInfo(killer); + } for (var i = 0; i < Controller.Hills.Length; i++) { if (Controller.Hills[i] == null) + { continue; + } if (Controller.Hills[i].King == mob) { @@ -936,7 +1025,9 @@ namespace Server.Engines.ConPVP } if (Controller.Hills[i].King == killer) + { bonus += 2; + } } if (teamInfo != null && teamInfo != victInfo) @@ -970,20 +1061,30 @@ namespace Server.Engines.ConPVP } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues( m_Context.Participants[i], Controller.TeamInfo[i % Controller.TeamInfo.Length].Color ); + } m_FinishTimer?.Stop(); for (var i = 0; i < Controller.Hills.Length; i++) + { if (Controller.Hills[i] != null) + { Controller.Hills[i].Game = this; + } + } foreach (var board in Controller.Boards) + { if (board?.Deleted == false) + { board.m_Game = this; + } + } m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); } @@ -997,7 +1098,9 @@ namespace Server.Engines.ConPVP var teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; if (teamInfo != null) + { teams.Add(teamInfo); + } } teams.Sort(); @@ -1027,7 +1130,9 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } @@ -1035,7 +1140,9 @@ namespace Server.Engines.ConPVP } if (Controller != null) + { sb.Append(' ').Append(Controller.Title); + } var title = sb.ToString(); @@ -1046,9 +1153,13 @@ namespace Server.Engines.ConPVP var rank = TrophyRank.Bronze; if (i == 0) + { rank = TrophyRank.Gold; + } else if (i == 1) + { rank = TrophyRank.Silver; + } var leader = teams[i].Leader; @@ -1057,14 +1168,18 @@ namespace Server.Engines.ConPVP var mob = pl.Player; if (mob == null) + { continue; + } sb = new StringBuilder(); sb.Append(title); if (pl == leader) + { sb.Append(" Leader"); + } if (pl.Score > 0) { @@ -1088,12 +1203,16 @@ namespace Server.Engines.ConPVP Item item = new Trophy(sb.ToString(), rank); if (pl == leader) + { item.ItemID = 4810; + } item.Name = $"{item.Name}, {teams[i].Name.ToLower()}"; if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } var cash = pl.Score * 250; @@ -1102,7 +1221,9 @@ namespace Server.Engines.ConPVP item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } mob.SendMessage( "You have been awarded a {0} trophy and {1:N0}gp for your participation in this game.", @@ -1124,7 +1245,9 @@ namespace Server.Engines.ConPVP { var p = m_Context.Participants[i]; if (p.Players == null) + { continue; + } for (var j = 0; j < p.Players.Length; ++j) { @@ -1138,33 +1261,55 @@ namespace Server.Engines.ConPVP } if (i == winner?.TeamID) + { continue; + } if (p.Players != null) + { for (var j = 0; j < p.Players.Length; ++j) + { if (p.Players[j] != null) + { p.Players[j].Eliminated = true; + } + } + } } if (winner != null) + { m_Context.Finish(m_Context.Participants[winner.TeamID]); + } } public override void OnStop() { for (var i = 0; i < Controller.TeamInfo.Length; ++i) + { Controller.TeamInfo[i].Game = null; + } for (var i = 0; i < Controller.Hills.Length; ++i) + { if (Controller.Hills[i] != null) + { Controller.Hills[i].Game = null; + } + } foreach (var board in Controller.Boards) + { if (board != null) + { board.m_Game = null; + } + } for (var i = 0; i < m_Context.Participants.Count; ++i) + { ApplyHues(m_Context.Participants[i], -1); + } m_FinishTimer?.Stop(); m_FinishTimer = null; diff --git a/Projects/UOContent/Engines/ConPVP/Games/TourneyMatch.cs b/Projects/UOContent/Engines/ConPVP/Games/TourneyMatch.cs index e7eb4dcb8..c38386d23 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/TourneyMatch.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/TourneyMatch.cs @@ -20,21 +20,27 @@ namespace Server.Engines.ConPVP sb.Append("Matched in a duel against "); if (participants.Count > 2) + { sb.AppendFormat( "{0} other {1}: ", participants.Count - 1, part.Players.Count == 1 ? "players" : "teams" ); + } var hasAppended = false; for (var j = 0; j < participants.Count; ++j) { if (i == j) + { continue; + } if (hasAppended) + { sb.Append(", "); + } sb.Append(participants[j].NameList); hasAppended = true; @@ -71,17 +77,25 @@ namespace Server.Engines.ConPVP }; for (var j = 0; j < tourneyPart.Players.Count; ++j) + { duelPart.Add(tourneyPart.Players[j]); + } for (var j = 0; j < duelPart.Players.Length; ++j) + { if (duelPart.Players[j] != null) + { duelPart.Players[j].Ready = true; + } + } dc.Participants.Add(duelPart); } if (tourney.EventController != null) + { dc.m_EventGame = tourney.EventController.Construct(dc); + } dc.m_Tournament = tourney; dc.m_Match = this; @@ -90,7 +104,9 @@ namespace Server.Engines.ConPVP if (tourney.SuddenDeath > TimeSpan.Zero && (tourney.SuddenDeathRounds == 0 || tourney.Pyramid.Levels.Count <= tourney.SuddenDeathRounds)) + { dc.StartSuddenDeath(tourney.SuddenDeath); + } dc.SendReadyGump(0); @@ -107,8 +123,12 @@ namespace Server.Engines.ConPVP var mob = p.Players[j]; foreach (var view in mob.GetMobilesInRange(18)) + { if (!mob.CanSee(view)) + { mob.Send(view.RemovePacket); + } + } mob.LocalOverheadMessage( MessageType.Emote, diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs index 281293dd1..89ecc6415 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs @@ -46,7 +46,9 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (var i = 0; i < ruleset.Flavors.Count; ++i) + { defs.Or(ruleset.Flavors[i].Options); + } height += ruleset.Flavors.Count * 18; } @@ -58,8 +60,12 @@ namespace Server.Engines.ConPVP var opts = ruleset.Options; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) + { ++changes; + } + } height += changes * 22; @@ -101,14 +107,18 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } } if (tourney.EventController != null) + { sb.Append(' ').Append(tourney.EventController.Title); + } sb.Append(" Tournament Invitation"); @@ -160,9 +170,13 @@ namespace Server.Engines.ConPVP sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; if (tourney.SuddenDeathRounds > 0) + { sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; + } else + { sdText = $"{sdText} (all rounds)"; + } } AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32); @@ -177,7 +191,9 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < ruleset.Flavors.Count; ++i, y += 18) + { AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32); + } y += 4; @@ -187,6 +203,7 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) { var name = ruleset.Layout.FindByIndex(i); @@ -199,6 +216,7 @@ namespace Server.Engines.ConPVP y += 22; } + } } else { @@ -245,15 +263,21 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } public void AutoReject() { if (!m_Active) + { return; + } m_Active = false; @@ -286,14 +310,18 @@ namespace Server.Engines.ConPVP var mob = m_Requested; if (info.ButtonID != 1 || !m_Active) + { return; + } m_Active = false; if (info.IsSwitched(1)) { if (!(mob is PlayerMobile pm)) + { return; + } if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed) { @@ -384,7 +412,9 @@ namespace Server.Engines.ConPVP else { if (info.IsSwitched(3)) + { AcceptDuelGump.BeginIgnore(m_Requested, m_From); + } m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ArenaGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ArenaGump.cs index 0f2e2260e..85c5d7e46 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ArenaGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ArenaGump.cs @@ -54,7 +54,9 @@ namespace Server.Engines.ConPVP from.SendGump(new ArenaGump(from, this)); if (!from.Hidden || from.AccessLevel == AccessLevel.Player) - Effects.PlaySound(from.Location, from.Map, 0x20E); + { + Effects.PlaySound(@from.Location, @from.Map, 0x20E); + } return true; } @@ -62,9 +64,13 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 1)) - UseGate(from); + { + UseGate(@from); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that + } } public override bool OnMoveOver(Mobile m) => !m.Player || UseGate(m); @@ -93,7 +99,9 @@ namespace Server.Engines.ConPVP var list = m_Arenas; for (var i = 1; i < list.Count; i += 2) + { AddImageTiled(12, 32 + i * 31, 475 + 40, 30, 0x2430); + } AddAlphaRegion(10, 10, 479 + 40, height - 20); @@ -127,7 +135,9 @@ namespace Server.Engines.ConPVP var ladder = Ladder.Instance; if (ladder == null) + { continue; + } LadderEntry p1 = null, p2 = null, p3 = null, p4 = null; @@ -166,7 +176,9 @@ namespace Server.Engines.ConPVP Append(sb, p4); if (ar.Players.Count > 4) + { sb.Append(", ..."); + } } else { @@ -183,10 +195,14 @@ namespace Server.Engines.ConPVP private void Append(StringBuilder sb, LadderEntry le) { if (le == null) + { return; + } if (sb.Length > 0) + { sb.Append(", "); + } sb.Append(le.Mobile.Name); } @@ -194,17 +210,23 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID != 1) + { return; + } var switches = info.Switches; if (switches.Length == 0) + { return; + } var opt = switches[0]; if (opt < 0 || opt >= m_Arenas.Count) + { return; + } var arena = m_Arenas[opt]; @@ -259,9 +281,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, string text, int color) { if (color == 0) + { AddHtml(x, y, width, 20, text); + } else + { AddHtml(x, y, width, 20, Color(text, color)); + } } private void AddColumnHeader(int width, string name) @@ -270,7 +296,9 @@ namespace Server.Engines.ConPVP AddImageTiled(m_ColumnX + 2, 14, width - 4, 16, 0x2430); if (name != null) + { AddBorderedText(m_ColumnX, 13, width, Center(name), 0xFFFFFF, 0); + } m_ColumnX += width; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs index 2bce20b93..ee1d8dfe8 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs @@ -45,7 +45,9 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (var i = 0; i < ruleset.Flavors.Count; ++i) + { defs.Or(ruleset.Flavors[i].Options); + } height += ruleset.Flavors.Count * 18; } @@ -57,15 +59,21 @@ namespace Server.Engines.ConPVP var opts = ruleset.Options; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) + { ++changes; + } + } height += changes * 22; height += 10 + 22 + 25 + 25; if (tourney.PlayersPerParticipant > 1) + { height += 36 + tourney.PlayersPerParticipant * 20; + } Closable = false; @@ -106,14 +114,18 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } } if (tourney.EventController != null) + { sb.Append(' ').Append(tourney.EventController.Title); + } sb.Append(" Tournament Signup"); @@ -164,9 +176,13 @@ namespace Server.Engines.ConPVP sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; if (tourney.SuddenDeathRounds > 0) + { sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; + } else + { sdText = $"{sdText} (all rounds)"; + } } AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32); @@ -181,7 +197,9 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < ruleset.Flavors.Count; ++i, y += 18) + { AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32); + } y += 4; @@ -191,6 +209,7 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) { var name = ruleset.Layout.FindByIndex(i); @@ -203,6 +222,7 @@ namespace Server.Engines.ConPVP y += 22; } + } } else { @@ -223,9 +243,13 @@ namespace Server.Engines.ConPVP for (var i = 0; i < players.Count; ++i, y += 20) { if (i == 0) + { AddImage(35, y, 0xD2); + } else + { AddGoldenButton(35, y, 1 + i); + } AddBorderedText(60, y, 200, 20, players[i].Name, LabelColor32, BlackColor32); } @@ -233,9 +257,13 @@ namespace Server.Engines.ConPVP for (var i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20) { if (i == 0) + { AddImage(35, y, 0xD2); + } else + { AddGoldenButton(35, y, 1 + i); + } AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32); } @@ -274,9 +302,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } public void AddGoldenButton(int x, int y, int bid) @@ -299,21 +331,25 @@ namespace Server.Engines.ConPVP if (m_Registrar != null) { if (m_Tournament.HasParticipant(from)) + { m_Registrar.PrivateOverheadMessage( MessageType.Regular, 0x35, false, "Excuse me? You are already signed up.", - from.NetState + @from.NetState ); + } else + { m_Registrar.PrivateOverheadMessage( MessageType.Regular, 0x22, false, "The tournament has already begun. You are too late to signup now.", - from.NetState + @from.NetState ); + } } break; @@ -359,21 +395,25 @@ namespace Server.Engines.ConPVP if (m_Registrar != null) { if (mob == from) + { m_Registrar.PrivateOverheadMessage( MessageType.Regular, 0x35, false, "You have not yet proven yourself a worthy dueler.", - from.NetState + @from.NetState ); + } else + { m_Registrar.PrivateOverheadMessage( MessageType.Regular, 0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.", - from.NetState + @from.NetState ); + } } m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); @@ -399,21 +439,25 @@ namespace Server.Engines.ConPVP if (m_Registrar != null) { if (mob == from) + { m_Registrar.PrivateOverheadMessage( MessageType.Regular, 0x35, false, "You have already entered this tournament.", - from.NetState + @from.NetState ); + } else + { m_Registrar.PrivateOverheadMessage( MessageType.Regular, 0x35, false, $"{mob.Name} has already entered this tournament.", - from.NetState + @from.NetState ); + } } m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); @@ -423,21 +467,25 @@ namespace Server.Engines.ConPVP if (mob is PlayerMobile mobile && mobile.DuelContext != null) { if (mob == from) + { m_Registrar?.PrivateOverheadMessage( MessageType.Regular, 0x35, false, "You are already assigned to a duel. You must yield it before joining this tournament.", - from.NetState + @from.NetState ); + } else + { m_Registrar?.PrivateOverheadMessage( MessageType.Regular, 0x35, false, $"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.", - from.NetState + @from.NetState ); + } m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); return; @@ -449,14 +497,20 @@ namespace Server.Engines.ConPVP string fmt; if (tourney.PlayersPerParticipant == 1) + { fmt = "As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}."; + } else if (tourney.PlayersPerParticipant == 2) + { fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your partner."; + } else + { fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team."; + } string timeUntil; var minutesUntil = (int)Math.Round( @@ -465,9 +519,13 @@ namespace Server.Engines.ConPVP ); if (minutesUntil == 0) + { timeUntil = "momentarily"; + } else + { timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}"; + } m_Registrar.PrivateOverheadMessage( MessageType.Regular, @@ -524,9 +582,13 @@ namespace Server.Engines.ConPVP m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); if (mob.Body.IsHuman) - mob.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust. + { + mob.SayTo(@from, 1005443); // Nay, I would rather stay here and watch a nail rust. + } else - mob.SayTo(from, 1005444); // The creature ignores your offer. + { + mob.SayTo(@from, 1005444); // The creature ignores your offer. + } } else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed) { @@ -543,7 +605,9 @@ namespace Server.Engines.ConPVP else { if (!(mob is PlayerMobile pm)) + { return; + } if (pm.DuelContext != null) { diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/DuelContextGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/DuelContextGump.cs index 820f7acee..d36c4305b 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/DuelContextGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/DuelContextGump.cs @@ -17,7 +17,9 @@ namespace Server.Engines.ConPVP var count = context.Participants.Count; if (count < 3) + { count = 3; + } var height = 35 + 10 + 22 + 30 + 22 + 22 + 2 + count * 22 + 2 + 30; @@ -82,7 +84,9 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (!Context.Registered) + { return; + } var index = info.ButtonID; @@ -124,9 +128,13 @@ namespace Server.Engines.ConPVP case 3: // New Participant { if (Context.Participants.Count < 10) + { Context.Participants.Add(new Participant(Context, 1)); + } else + { From.SendMessage("The number of participating parties may not be increased further."); + } From.SendGump(new DuelContextGump(From, Context)); @@ -137,7 +145,9 @@ namespace Server.Engines.ConPVP index -= 4; if (index >= 0 && index < Context.Participants.Count) + { From.SendGump(new ParticipantGump(From, Context, Context.Participants[index])); + } break; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/LadderGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/LadderGump.cs index 8676caee9..13a4430b0 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/LadderGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/LadderGump.cs @@ -86,7 +86,9 @@ namespace Server.Engines.ConPVP var end = start + 15; if (end > lc) + { end = lc; + } var ct = end - start; @@ -95,19 +97,29 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 499, height, 0x2436); for (var i = start + 1; i < end; i += 2) + { AddImageTiled(12, 32 + (i - start) * 20, 475, 20, 0x2430); + } AddAlphaRegion(10, 10, 479, height - 20); if (page > 0) + { AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1); + } else + { AddImage(446, height - 12 - 2 - 16, 0x2626); + } if ((page + 1) * 15 < lc) + { AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2); + } else + { AddImage(466, height - 12 - 2 - 16, 0x2622); + } AddHtml( 16, @@ -156,9 +168,13 @@ namespace Server.Engines.ConPVP var xpOffset = xp - xpBase; if (xpOffset >= xpAdvance) + { width = 109; // level 50 + } else + { width = (109 * xpOffset + xpAdvance / 2) / (xpAdvance - 1); + } // AddImageTiled( 21, y + 6, width, 8, 0x2617 ); AddImageTiled(x + 3, y + 4, width, 11, 0x806); @@ -168,7 +184,9 @@ namespace Server.Engines.ConPVP var mob = entry.Mobile; if (mob.Guild != null) + { AddBorderedText(x, y, 50, Center(mob.Guild.Abbreviation), 0xFFFFFF, 0); + } x += 50; @@ -190,7 +208,9 @@ namespace Server.Engines.ConPVP var numStr = num.ToString("N0"); if (num % 100 > 10 && num % 100 < 20) + { return $"{numStr}th"; + } return (num % 10) switch { @@ -206,9 +226,13 @@ namespace Server.Engines.ConPVP var from = sender.Mobile; if (info.ButtonID == 1 && m_Page > 0) - from.SendGump(new LadderGump(m_Ladder, m_Page - 1)); + { + @from.SendGump(new LadderGump(m_Ladder, m_Page - 1)); + } else if (info.ButtonID == 2 && (m_Page + 1) * 15 < Math.Min(m_List.Count, 150)) - from.SendGump(new LadderGump(m_Ladder, m_Page + 1)); + { + @from.SendGump(new LadderGump(m_Ladder, m_Page + 1)); + } } public string Center(string text) => $"
{text}
"; @@ -229,9 +253,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, string text, int color) { if (color == 0) + { AddHtml(x, y, width, 20, text); + } else + { AddHtml(x, y, width, 20, Color(text, color)); + } } private void AddColumnHeader(int width, string name) diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs index efa9660fa..e99952bfb 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs @@ -20,7 +20,9 @@ namespace Server.Engines.ConPVP var count = p.Players.Length; if (count < 4) + { count = 4; + } AddPage(0); @@ -81,7 +83,9 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (!Context.Registered) + { return; + } var bid = info.ButtonID; @@ -92,18 +96,26 @@ namespace Server.Engines.ConPVP else if (bid == 1) { if (Participant.Count < 8) + { Participant.Resize(Participant.Count + 1); + } else + { From.SendMessage("You may not raise the team size any further."); + } From.SendGump(new ParticipantGump(From, Context, Participant)); } else if (bid == 2) { if (Participant.Count > 1 && Participant.Count > Participant.FilledSlots) + { Participant.Resize(Participant.Count - 1); + } else + { From.SendMessage("You may not lower the team size any further."); + } From.SendGump(new ParticipantGump(From, Context, Participant)); } @@ -166,7 +178,9 @@ namespace Server.Engines.ConPVP Participant.Players[bid].Mobile.SendMessage("You have been removed from the duel."); if (Participant.Players[bid].Mobile is PlayerMobile) + { ((PlayerMobile)Participant.Players[bid].Mobile).DuelPlayer = null; + } Participant.Players[bid] = null; From.SendMessage("They have been removed from the duel."); @@ -192,12 +206,16 @@ namespace Server.Engines.ConPVP protected override void OnTarget(Mobile from, object targeted) { if (!m_Context.Registered) + { return; + } var index = m_Index; if (index < 0 || index >= m_Participant.Players.Length) + { return; + } if (!(targeted is Mobile mob)) { @@ -206,9 +224,13 @@ namespace Server.Engines.ConPVP else if (!mob.Player) { if (mob.Body.IsHuman) - mob.SayTo(from, 1005443); // Nay, I would rather stay here and watch a nail rust. + { + mob.SayTo(@from, 1005443); // Nay, I would rather stay here and watch a nail rust. + } else - mob.SayTo(from, 1005444); // The creature ignores your offer. + { + mob.SayTo(@from, 1005444); // The creature ignores your offer. + } } else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed) { @@ -217,7 +239,9 @@ namespace Server.Engines.ConPVP else { if (!(mob is PlayerMobile pm)) + { return; + } if (pm.DuelContext != null) { diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/PickRulesetGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/PickRulesetGump.cs index 28f5cda58..4d10c2c89 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/PickRulesetGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/PickRulesetGump.cs @@ -37,11 +37,17 @@ namespace Server.Engines.ConPVP AddHtml(35 + 14, y, 176, 20, cur.Title); if (ruleset.Base == cur && !ruleset.Changed) + { AddImage(35, y + 4, 0x939); + } else if (ruleset.Base == cur) + { AddButton(35, y + 4, 0x93A, 0x939, 2 + i); + } else + { AddButton(35, y + 4, 0x938, 0x939, 2 + i); + } y += 22; } @@ -62,9 +68,13 @@ namespace Server.Engines.ConPVP AddHtml(35 + 14, y, 176, 20, cur.Title); if (ruleset.Flavors.Contains(cur)) + { AddButton(35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i); + } else + { AddButton(35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i); + } y += 22; } @@ -75,14 +85,18 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (m_Context?.Registered == false) + { return; + } switch (info.ButtonID) { case 0: // closed { if (m_Context != null) + { m_From.SendGump(new DuelContextGump(m_From, m_Context)); + } break; } @@ -107,9 +121,13 @@ namespace Server.Engines.ConPVP if (idx >= 0 && idx < m_Flavors.Length) { if (m_Ruleset.Flavors.Contains(m_Flavors[idx])) + { m_Ruleset.RemoveFlavor(m_Flavors[idx]); + } else + { m_Ruleset.AddFlavor(m_Flavors[idx]); + } m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset)); } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ReadyGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ReadyGump.cs index 0313723f8..1b4c80645 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ReadyGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ReadyGump.cs @@ -26,7 +26,9 @@ namespace Server.Engines.ConPVP height += 4; if (p.Players.Length > 1) + { height += 22; + } height += p.Players.Length * 22; } @@ -92,7 +94,9 @@ namespace Server.Engines.ConPVP } if (p.Players.Length > 1) + { AddImage(35, yStore + 4, isAllReady ? 0x939 : 0x938); + } } } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs index ad2daaafe..afc9acd46 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs @@ -45,7 +45,9 @@ namespace Server.Engines.ConPVP height += 4; if (p.Players.Length > 1) + { height += 22; + } height += p.Players.Length * 22; } @@ -111,7 +113,9 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (var i = 0; i < ruleset.Flavors.Count; ++i) + { defs.Or(ruleset.Flavors[i].Options); + } height += ruleset.Flavors.Count * 18; } @@ -123,8 +127,12 @@ namespace Server.Engines.ConPVP var opts = ruleset.Options; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) + { ++changes; + } + } height += changes * 22; @@ -140,7 +148,9 @@ namespace Server.Engines.ConPVP y = 70; for (var i = 0; i < ruleset.Flavors.Count; ++i, y += 18) + { AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}"); + } y += 4; @@ -150,6 +160,7 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) { var name = ruleset.Layout.FindByIndex(i); @@ -162,6 +173,7 @@ namespace Server.Engines.ConPVP y += 22; } + } } else { @@ -191,14 +203,18 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (!m_Context.Registered || !m_Context.ReadyWait) + { return; + } switch (info.ButtonID) { case 1: // okay { if (!(m_From is PlayerMobile pm)) + { break; + } pm.DuelPlayer.Ready = true; m_Context.SendReadyGump(); diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/RulesetGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/RulesetGump.cs index 7a6309b07..73729c65b 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/RulesetGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/RulesetGump.cs @@ -30,7 +30,9 @@ namespace Server.Engines.ConPVP var depthCounter = page; while (depthCounter != null) + { depthCounter = depthCounter.Parent; + } var count = page.Children.Length + page.Options.Length; @@ -59,9 +61,13 @@ namespace Server.Engines.ConPVP var enabled = ruleset.Options[page.Offset + i]; if (readOnly) + { AddImage(x, y, enabled ? 0xD3 : 0xD2); + } else + { AddCheck(x, y, 0xD2, 0xD3, enabled, i); + } AddHtml(x + 25, y, 250, 22, page.Options[i]); @@ -80,7 +86,9 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (m_DuelContext?.Registered == false) + { return; + } if (!m_ReadOnly) { @@ -91,15 +99,19 @@ namespace Server.Engines.ConPVP var sid = info.Switches[i]; if (sid >= 0 && sid < m_Page.Options.Length) + { opts[sid] = true; + } } for (var i = 0; i < opts.Length; ++i) + { if (m_Ruleset.Options[m_Page.Offset + i] != opts[i]) { m_Ruleset.Options[m_Page.Offset + i] = opts[i]; m_Ruleset.Changed = true; } + } } var bid = info.ButtonID; @@ -107,16 +119,22 @@ namespace Server.Engines.ConPVP if (bid == 0) { if (m_Page.Parent != null) + { m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Page.Parent, m_DuelContext, m_ReadOnly)); + } else if (!m_ReadOnly) + { m_From.SendGump(new PickRulesetGump(m_From, m_DuelContext, m_Ruleset)); + } } else { bid -= 1; if (bid >= 0 && bid < m_Page.Children.Length) + { m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Page.Children[bid], m_DuelContext, m_ReadOnly)); + } } } } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs index e4aa81b3e..1a02dc0ba 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs @@ -77,14 +77,18 @@ namespace Server.Engines.ConPVP for (var i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(tourney.PlayersPerParticipant); } } if (tourney.EventController != null) + { sb.Append(' ').Append(tourney.EventController.Title); + } sb.Append(" Tournament Bracket"); @@ -105,14 +109,22 @@ namespace Server.Engines.ConPVP secs %= 60; if (mins > 0 && secs > 0) + { text = $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")} and {secs} second{(secs == 1 ? "" : "s")}."; + } else if (mins > 0) + { text = $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")}."; + } else if (secs > 0) + { text = $"The tournament will begin in {secs} second{(secs == 1 ? "" : "s")}."; + } else + { text = "The tournament will begin shortly."; + } } else { @@ -140,7 +152,9 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (var i = 0; i < ruleset.Flavors.Count; ++i) + { defs.Or(ruleset.Flavors[i].Options); + } } else { @@ -152,8 +166,12 @@ namespace Server.Engines.ConPVP var opts = ruleset.Options; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) + { ++changes; + } + } AddPage(0); AddBackground( @@ -204,9 +222,13 @@ namespace Server.Engines.ConPVP sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; if (tourney.SuddenDeathRounds > 0) + { sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; + } else + { sdText = $"{sdText} (all rounds)"; + } } AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}"); @@ -218,7 +240,9 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < ruleset.Flavors.Count; ++i, y += 18) + { AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}"); + } y += 4; @@ -228,6 +252,7 @@ namespace Server.Engines.ConPVP y += 20; for (var i = 0; i < opts.Length; ++i) + { if (defs[i] != opts[i]) { var name = ruleset.Layout.FindByIndex(i); @@ -240,6 +265,7 @@ namespace Server.Engines.ConPVP y += 22; } + } } else { @@ -268,8 +294,12 @@ namespace Server.Engines.ConPVP var name = part.NameList; if (m_Tournament.TourneyType != TourneyType.Standard && part.Players.Count == 1) + { if (part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null) + { name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666); + } + } AddRightArrow(25, y, ToButtonID(2, index + i), name); } @@ -279,7 +309,9 @@ namespace Server.Engines.ConPVP case TourneyBracketGumpType.Participant_Info: { if (!(obj is TourneyParticipant part)) + { break; + } AddPage(0); AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380); @@ -298,8 +330,12 @@ namespace Server.Engines.ConPVP var name = mob.Name; if (m_Tournament.TourneyType != TourneyType.Standard) + { if (mob is PlayerMobile pm && pm.DuelPlayer != null) + { name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666); + } + } AddRightArrow(35, y, ToButtonID(4, i), name); y += 18; @@ -322,13 +358,17 @@ namespace Server.Engines.ConPVP for (var i = 0; i < part.Log.Count; ++i) { if (sb.Length > 0) + { sb.Append("
"); + } sb.Append(part.Log[i]); } if (sb.Length == 0) + { sb.Append("Nothing logged yet."); + } AddHtml(25, y, 250, 150, Color(sb.ToString(), BlackColor32), false, true); @@ -343,7 +383,9 @@ namespace Server.Engines.ConPVP AddHtml(25, 35, 250, 20, Center("Participants")); if (!(obj is Mobile mob)) + { break; + } var ladder = Ladder.Instance; var entry = ladder?.Find(mob); @@ -378,7 +420,9 @@ namespace Server.Engines.ConPVP StartPage(out var index, out var count, out var y, 12); for (var i = 0; i < count; ++i, y += 18) + { AddRightArrow(25, y, ToButtonID(3, index + i), $"Round #{index + i + 1}"); + } break; } @@ -391,7 +435,9 @@ namespace Server.Engines.ConPVP AddHtml(25, 35, 250, 20, Center("Rounds")); if (!(m_Object is PyramidLevel level)) + { break; + } var matchesList = m_List != null ? Utility.CastListCovariant(m_List) @@ -415,36 +461,51 @@ namespace Server.Engines.ConPVP var color = -1; if (match.InProgress) + { color = 0x336666; + } else if (match.Context != null && match.Winner == null) + { color = 0x666666; + } var sb = new StringBuilder(); if (m_Tournament.TourneyType == TourneyType.Standard) + { for (var j = 0; j < match.Participants.Count; ++j) { if (sb.Length > 0) + { sb.Append(" vs "); + } var part = match.Participants[j]; var txt = part.NameList; if (color == -1 && match.Context != null && match.Winner == part) + { txt = Color(txt, 0x336633); + } else if (color == -1 && match.Context != null) + { txt = Color(txt, 0x663333); + } sb.Append(txt); } + } else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam || m_Tournament.TourneyType == TourneyType.RedVsBlue || m_Tournament.TourneyType == TourneyType.Faction) + { for (var j = 0; j < match.Participants.Count; ++j) { if (sb.Length > 0) + { sb.Append(" vs "); + } var part = match.Participants[j]; string txt; @@ -504,18 +565,28 @@ namespace Server.Engines.ConPVP } if (color == -1 && match.Context != null && match.Winner == part) + { txt = Color(txt, 0x336633); + } else if (color == -1 && match.Context != null) + { txt = Color(txt, 0x663333); + } sb.Append(txt); } - else if (m_Tournament.TourneyType == TourneyType.FreeForAll) sb.Append("Free For All"); + } + else if (m_Tournament.TourneyType == TourneyType.FreeForAll) + { + sb.Append("Free For All"); + } var str = sb.ToString(); if (color >= 0) + { str = Color(str, color); + } AddRightArrow(25, y, ToButtonID(5, index + i + 1), str); } @@ -525,7 +596,9 @@ namespace Server.Engines.ConPVP case TourneyBracketGumpType.Match_Info: { if (!(obj is TourneyMatch match)) + { break; + } var ct = m_Tournament.TourneyType == TourneyType.FreeForAll ? 2 : match.Participants.Count; @@ -546,16 +619,19 @@ namespace Server.Engines.ConPVP AddHtml(25, 93, 250, 20, "Participants:"); if (m_Tournament.TourneyType == TourneyType.Standard) + { for (var i = 0; i < match.Participants.Count; ++i) { var part = match.Participants[i]; AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), part.NameList); } + } else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam || m_Tournament.TourneyType == TourneyType.RedVsBlue || m_Tournament.TourneyType == TourneyType.Faction) + { for (var i = 0; i < match.Participants.Count; ++i) { var part = match.Participants[i]; @@ -644,8 +720,11 @@ namespace Server.Engines.ConPVP ); } } + } else if (m_Tournament.TourneyType == TourneyType.FreeForAll) + { AddHtml(25, 113, 250, 20, "Free For All"); + } break; } @@ -668,9 +747,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, int height, string text, int color) { if (color == 0) + { AddHtml(x, y, width, height, text); + } else + { AddHtml(x, y, width, height, Color(text, color)); + } } public void AddRightArrow(int x, int y, int bid, string text) @@ -678,7 +761,9 @@ namespace Server.Engines.ConPVP AddButton(x, y, 0x15E1, 0x15E5, bid); if (text != null) + { AddHtml(x + 20, y - 1, 230, 20, text); + } } public void AddRightArrow(int x, int y, int bid) @@ -691,7 +776,9 @@ namespace Server.Engines.ConPVP AddButton(x, y, 0x15E3, 0x15E7, bid); if (text != null) + { AddHtml(x + 20, y - 1, 230, 20, text); + } } public void AddLeftArrow(int x, int y, int bid) @@ -718,16 +805,22 @@ namespace Server.Engines.ConPVP y = 53 + (12 - perPage) * 18; if (m_Page > 0) + { AddLeftArrow(242, 35, ToButtonID(1, 0)); + } if ((m_Page + 1) * perPage < m_List.Count) + { AddRightArrow(260, 35, ToButtonID(1, 1)); + } } public override void OnResponse(NetState sender, RelayInfo info) { if (!FromButtonID(info.ButtonID, out var type, out var index)) + { return; + } switch (type) { @@ -788,13 +881,16 @@ namespace Server.Engines.ConPVP case 5: { if (!(m_Object is TourneyMatch match)) + { break; + } for (var i = 0; i < m_Tournament.Pyramid.Levels.Count; ++i) { var level = m_Tournament.Pyramid.Levels[i]; if (level.Matches.Contains(match)) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -805,6 +901,7 @@ namespace Server.Engines.ConPVP level ) ); + } } break; @@ -820,6 +917,7 @@ namespace Server.Engines.ConPVP case 0: { if (m_List != null && m_Page > 0) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -830,12 +928,14 @@ namespace Server.Engines.ConPVP m_Object ) ); + } break; } case 1: { if (m_List != null && (m_Page + 1) * m_PerPage < m_List.Count) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -846,6 +946,7 @@ namespace Server.Engines.ConPVP m_Object ) ); + } break; } @@ -856,9 +957,12 @@ namespace Server.Engines.ConPVP case 2: { if (m_Type != TourneyBracketGumpType.Participant_List) + { break; + } if (index >= 0 && index < m_List.Count) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -869,15 +973,19 @@ namespace Server.Engines.ConPVP m_List[index] ) ); + } break; } case 3: { if (m_Type != TourneyBracketGumpType.Round_List) + { break; + } if (index >= 0 && index < m_List.Count) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -888,15 +996,19 @@ namespace Server.Engines.ConPVP m_List[index] ) ); + } break; } case 4: { if (m_Type != TourneyBracketGumpType.Participant_Info) + { break; + } if (m_Object is TourneyParticipant part && index >= 0 && index < part.Players.Count) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -907,20 +1019,26 @@ namespace Server.Engines.ConPVP part.Players[index] ) ); + } break; } case 5: { if (m_Type != TourneyBracketGumpType.Round_Info) + { break; + } if (!(m_Object is PyramidLevel level)) + { break; + } if (index == 0) { if (level.FreeAdvance != null) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -931,10 +1049,13 @@ namespace Server.Engines.ConPVP level.FreeAdvance ) ); + } else + { m_From.SendGump( new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page, m_Object) ); + } } else if (index >= 1 && index <= level.Matches.Count) { @@ -955,9 +1076,12 @@ namespace Server.Engines.ConPVP case 6: { if (m_Type != TourneyBracketGumpType.Match_Info) + { break; + } if (m_Object is TourneyMatch match && index >= 0 && index < match.Participants.Count) + { m_From.SendGump( new TournamentBracketGump( m_From, @@ -968,6 +1092,7 @@ namespace Server.Engines.ConPVP match.Participants[index] ) ); + } break; } diff --git a/Projects/UOContent/Engines/ConPVP/Ladder.cs b/Projects/UOContent/Engines/ConPVP/Ladder.cs index 60bd341bd..529795d14 100644 --- a/Projects/UOContent/Engines/ConPVP/Ladder.cs +++ b/Projects/UOContent/Engines/ConPVP/Ladder.cs @@ -28,7 +28,9 @@ namespace Server.Engines.ConPVP public override void Delete() { if (Ladder.Instance == Ladder) + { Ladder.Instance = null; + } base.Delete(); } @@ -58,7 +60,9 @@ namespace Server.Engines.ConPVP Ladder = new Ladder(reader); if (version < 1 || reader.ReadBool()) + { Ladder.Instance = Ladder; + } break; } @@ -167,9 +171,14 @@ namespace Server.Engines.ConPVP public static int GetLevel(int xp) { if (xp >= 22500) + { return 50; + } + if (xp >= 2500) + { return 10 + (xp - 2500) / 500; + } return m_ShortLevels[Math.Max(xp, 0) / 100]; } @@ -191,7 +200,9 @@ namespace Server.Engines.ConPVP public static int GetLossFactor(int level) { if (level >= 10) + { return 100; + } return m_LossFactors[level - 1]; } @@ -201,7 +212,9 @@ namespace Server.Engines.ConPVP var x = ourLevel - theirLevel; if (x < -6 || x > +6) + { return 0; + } var y = win ? 0 : 1; @@ -211,7 +224,9 @@ namespace Server.Engines.ConPVP public static int GetExperienceGain(LadderEntry us, LadderEntry them, bool weWon) { if (us == null || them == null) + { return 0; + } var ourLevel = GetLevel(us.Experience); var theirLevel = GetLevel(them.Experience); @@ -219,17 +234,23 @@ namespace Server.Engines.ConPVP var scalar = GetOffsetScalar(ourLevel, theirLevel, weWon); if (scalar == 0) + { return 0; + } var xp = 25 * scalar; if (!weWon) + { xp = xp * GetLossFactor(ourLevel) / 100; + } xp /= 100; if (xp <= 0) + { xp = 1; + } return xp * (weWon ? 1 : -1); } @@ -254,10 +275,14 @@ namespace Server.Engines.ConPVP if (index >= 0 && index < Entries.Count) { while (index - 1 >= 0 && entry.CompareTo(Entries[index - 1]) < 0) + { index = Swap(index, index - 1); + } while (index + 1 < Entries.Count && entry.CompareTo(Entries[index + 1]) > 0) + { index = Swap(index, index + 1); + } } } @@ -286,7 +311,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(Entries.Count); for (var i = 0; i < Entries.Count; ++i) + { Entries[i].Serialize(writer); + } } } diff --git a/Projects/UOContent/Engines/ConPVP/Participant.cs b/Projects/UOContent/Engines/ConPVP/Participant.cs index 43f21f712..cff808f60 100644 --- a/Projects/UOContent/Engines/ConPVP/Participant.cs +++ b/Projects/UOContent/Engines/ConPVP/Participant.cs @@ -28,8 +28,12 @@ namespace Server.Engines.ConPVP var count = 0; for (var i = 0; i < Players.Length; ++i) + { if (Players[i] != null) + { ++count; + } + } return count; } @@ -40,8 +44,12 @@ namespace Server.Engines.ConPVP get { for (var i = 0; i < Players.Length; ++i) + { if (Players[i] == null) + { return true; + } + } return false; } @@ -52,8 +60,12 @@ namespace Server.Engines.ConPVP get { for (var i = 0; i < Players.Length; ++i) + { if (Players[i]?.Eliminated == false) + { return false; + } + } return true; } @@ -68,12 +80,16 @@ namespace Server.Engines.ConPVP for (var i = 0; i < Players.Length; ++i) { if (Players[i] == null) + { continue; + } var mob = Players[i].Mobile; if (sb.Length > 0) + { sb.Append(", "); + } sb.Append(mob.Name); } @@ -87,14 +103,20 @@ namespace Server.Engines.ConPVP if (mob is PlayerMobile pm) { if (pm.DuelContext == Context && pm.DuelPlayer.Participant == this) + { return pm.DuelPlayer; + } return null; } for (var i = 0; i < Players.Length; ++i) + { if (Players[i]?.Mobile == mob) + { return Players[i]; + } + } return null; } @@ -104,12 +126,16 @@ namespace Server.Engines.ConPVP public void Broadcast(int hue, string message, string nonLocalOverhead, string localOverhead) { for (var i = 0; i < Players.Length; ++i) + { if (Players[i] != null) { if (message != null) + { Players[i].Mobile.SendMessage(hue, message); + } if (nonLocalOverhead != null) + { Players[i] .Mobile.NonlocalOverheadMessage( MessageType.Regular, @@ -121,21 +147,29 @@ namespace Server.Engines.ConPVP Players[i].Mobile.Female ? "her" : "his" ) ); + } if (localOverhead != null) + { Players[i].Mobile.LocalOverheadMessage(MessageType.Regular, hue, false, localOverhead); + } } + } } public void Nullify(DuelPlayer player) { if (player == null) + { return; + } var index = Array.IndexOf(Players, player); if (index == -1) + { return; + } Players[index] = null; } @@ -143,21 +177,29 @@ namespace Server.Engines.ConPVP public void Remove(DuelPlayer player) { if (player == null) + { return; + } var index = Array.IndexOf(Players, player); if (index == -1) + { return; + } var old = Players; Players = new DuelPlayer[old.Length - 1]; for (var i = 0; i < index; ++i) + { Players[i] = old[i]; + } for (var i = index + 1; i < old.Length; ++i) + { Players[i - 1] = old[i]; + } } public void Remove(Mobile player) @@ -168,14 +210,18 @@ namespace Server.Engines.ConPVP public void Add(Mobile player) { if (Contains(player)) + { return; + } for (var i = 0; i < Players.Length; ++i) + { if (Players[i] == null) { Players[i] = new DuelPlayer(player, this); return; } + } Resize(Players.Length + 1); Players[^1] = new DuelPlayer(player, this); @@ -191,8 +237,12 @@ namespace Server.Engines.ConPVP var ct = 0; for (var i = 0; i < old.Length; ++i) + { if (old[i] != null && ct < count) + { Players[ct++] = old[i]; + } + } } } } @@ -207,7 +257,9 @@ namespace Server.Engines.ConPVP Participant = p; if (mob is PlayerMobile mobile) + { mobile.DuelPlayer = this; + } } public Mobile Mobile { get; } diff --git a/Projects/UOContent/Engines/ConPVP/Preferences.cs b/Projects/UOContent/Engines/ConPVP/Preferences.cs index 081861510..ada665b83 100644 --- a/Projects/UOContent/Engines/ConPVP/Preferences.cs +++ b/Projects/UOContent/Engines/ConPVP/Preferences.cs @@ -15,9 +15,13 @@ namespace Server.Engines.ConPVP Preferences = new Preferences(); if (Preferences.Instance == null) + { Preferences.Instance = Preferences; + } else + { Delete(); + } } public PreferencesController(Serial serial) : base(serial) @@ -32,7 +36,9 @@ namespace Server.Engines.ConPVP public override void Delete() { if (Preferences.Instance != Preferences) + { base.Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -123,7 +129,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(Entries.Count); for (var i = 0; i < Entries.Count; ++i) + { Entries[i].Serialize(writer); + } } } @@ -148,7 +156,9 @@ namespace Server.Engines.ConPVP Disliked = new List(count); for (var i = 0; i < count; ++i) + { Disliked.Add(reader.ReadString()); + } break; } @@ -166,7 +176,9 @@ namespace Server.Engines.ConPVP writer.WriteEncodedInt(Disliked.Count); for (var i = 0; i < Disliked.Count; ++i) + { writer.Write(Disliked[i]); + } } } @@ -180,7 +192,9 @@ namespace Server.Engines.ConPVP m_Entry = prefs.Find(from); if (m_Entry == null) + { return; + } var arenas = Arena.Arenas; @@ -191,7 +205,9 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 499 + 40 - 365, height, 0x2436); for (var i = 1; i < arenas.Count; i += 2) + { AddImageTiled(12, 32 + i * 31, 475 + 40 - 365, 30, 0x2430); + } AddAlphaRegion(10, 10, 479 + 40 - 365, height - 20); @@ -222,10 +238,14 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { if (m_Entry == null) + { return; + } if (info.ButtonID != 1) + { return; + } m_Entry.Disliked.Clear(); @@ -236,7 +256,9 @@ namespace Server.Engines.ConPVP var idx = info.Switches[i]; if (idx >= 0 && idx < arenas.Count) + { m_Entry.Disliked.Add(arenas[idx].Name); + } } } @@ -252,9 +274,13 @@ namespace Server.Engines.ConPVP private void AddColoredText(int x, int y, int width, string text, int color) { if (color == 0) + { AddHtml(x, y, width, 20, text); + } else + { AddHtml(x, y, width, 20, Color(text, color)); + } } private void AddColumnHeader(int width, string name) @@ -263,7 +289,9 @@ namespace Server.Engines.ConPVP AddImageTiled(m_ColumnX + 2, 14, width - 4, 16, 0x2430); if (name != null) + { AddBorderedText(m_ColumnX, 13, width, Center(name), 0xFFFFFF, 0); + } m_ColumnX += width; } diff --git a/Projects/UOContent/Engines/ConPVP/Ruleset.cs b/Projects/UOContent/Engines/ConPVP/Ruleset.cs index 0176cf80d..e5d61011c 100644 --- a/Projects/UOContent/Engines/ConPVP/Ruleset.cs +++ b/Projects/UOContent/Engines/ConPVP/Ruleset.cs @@ -46,7 +46,9 @@ namespace Server.Engines.ConPVP public void AddFlavor(Ruleset flavor) { if (Flavors.Contains(flavor)) + { return; + } Flavors.Add(flavor); Options.Or(flavor.Options); @@ -55,7 +57,9 @@ namespace Server.Engines.ConPVP public void RemoveFlavor(Ruleset flavor) { if (!Flavors.Contains(flavor)) + { return; + } Flavors.Remove(flavor); Options.And(flavor.Options.Not()); @@ -67,10 +71,14 @@ namespace Server.Engines.ConPVP var layout = Layout.FindByTitle(title); if (layout == null) + { return; + } for (var i = 0; i < layout.TotalLength; ++i) + { Options[i + layout.Offset] = value; + } Changed = true; } @@ -81,7 +89,9 @@ namespace Server.Engines.ConPVP var layout = Layout.FindByOption(title, option, ref index); if (layout == null) + { return true; + } return Options[layout.Offset + index]; } @@ -92,7 +102,9 @@ namespace Server.Engines.ConPVP var layout = Layout.FindByOption(title, option, ref index); if (layout == null) + { return; + } Options[layout.Offset + index] = value; diff --git a/Projects/UOContent/Engines/ConPVP/RulesetLayout.cs b/Projects/UOContent/Engines/ConPVP/RulesetLayout.cs index e9fff89e4..600c5cfed 100644 --- a/Projects/UOContent/Engines/ConPVP/RulesetLayout.cs +++ b/Projects/UOContent/Engines/ConPVP/RulesetLayout.cs @@ -50,7 +50,9 @@ namespace Server.Engines.ConPVP Options = options; for (var i = 0; i < children.Length; ++i) + { children[i].Parent = this; + } } public static RulesetLayout Root @@ -58,7 +60,9 @@ namespace Server.Engines.ConPVP get { if (m_Root != null) + { return m_Root; + } var entries = new List { @@ -228,6 +232,7 @@ namespace Server.Engines.ConPVP ); if (Core.ML) + { entries.Add( new RulesetLayout( "Spellweaving", @@ -252,12 +257,14 @@ namespace Server.Engines.ConPVP } ) ); + } } } if (Core.AOS) { if (Core.SE) + { entries.Add( new RulesetLayout( "Combat Abilities", @@ -291,7 +298,9 @@ namespace Server.Engines.ConPVP } ) ); + } else + { entries.Add( new RulesetLayout( "Combat Abilities", @@ -315,6 +324,7 @@ namespace Server.Engines.ConPVP } ) ); + } } else { @@ -409,6 +419,7 @@ namespace Server.Engines.ConPVP } if (Core.SE) + { entries.Add( new RulesetLayout( "Items", @@ -443,7 +454,9 @@ namespace Server.Engines.ConPVP } ) ); + } else + { entries.Add( new RulesetLayout( "Items", @@ -476,6 +489,7 @@ namespace Server.Engines.ConPVP } ) ); + } m_Root = new RulesetLayout("Rules", entries.ToArray()); m_Root.ComputeOffsets(); @@ -794,14 +808,18 @@ namespace Server.Engines.ConPVP public RulesetLayout FindByTitle(string title) { if (Title == title) + { return this; + } for (var i = 0; i < Children.Length; ++i) { var layout = Children[i].FindByTitle(title); if (layout != null) + { return layout; + } } return null; @@ -810,14 +828,18 @@ namespace Server.Engines.ConPVP public string FindByIndex(int index) { if (index >= Offset && index < Offset + Options.Length) + { return $"{Description}: {Options[index - Offset]}"; + } for (var i = 0; i < Children.Length; ++i) { var opt = Children[i].FindByIndex(index); if (opt != null) + { return opt; + } } return null; @@ -830,7 +852,9 @@ namespace Server.Engines.ConPVP index = GetOptionIndex(option); if (index >= 0) + { return this; + } title = null; } @@ -840,7 +864,9 @@ namespace Server.Engines.ConPVP var layout = Children[i].FindByOption(title, option, ref index); if (layout != null) + { return layout; + } } return null; @@ -863,7 +889,9 @@ namespace Server.Engines.ConPVP TotalLength += Options.Length; for (var i = 0; i < Children.Length; ++i) + { TotalLength += Children[i].RecurseComputeOffsets(ref offset); + } return TotalLength; } diff --git a/Projects/UOContent/Engines/ConPVP/SafeZone.cs b/Projects/UOContent/Engines/ConPVP/SafeZone.cs index 9c0dc75cd..ca4b5ac24 100644 --- a/Projects/UOContent/Engines/ConPVP/SafeZone.cs +++ b/Projects/UOContent/Engines/ConPVP/SafeZone.cs @@ -34,7 +34,9 @@ namespace Server.Engines.ConPVP (m is BaseCreature bc && bc.Summoned ? bc.SummonMaster as PlayerMobile : null); if (pm?.DuelContext?.StartedBeginCountdown == true) + { return true; + } if (DuelContext.CheckCombat(m)) { diff --git a/Projects/UOContent/Engines/ConPVP/Tournament.cs b/Projects/UOContent/Engines/ConPVP/Tournament.cs index d35fd90c0..7292e0175 100644 --- a/Projects/UOContent/Engines/ConPVP/Tournament.cs +++ b/Projects/UOContent/Engines/ConPVP/Tournament.cs @@ -88,7 +88,9 @@ namespace Server.Engines.ConPVP case 0: { if (version < 3) + { SuddenDeathRounds = 3; + } m_ParticipantsPerMatch = reader.ReadEncodedInt(); m_PlayersPerParticipant = reader.ReadEncodedInt(); @@ -193,8 +195,12 @@ namespace Server.Engines.ConPVP public bool HasParticipant(Mobile mob) { for (var i = 0; i < Participants.Count; ++i) + { if (Participants[i].Players.Contains(mob)) + { return true; + } + } return false; } @@ -223,10 +229,14 @@ namespace Server.Engines.ConPVP public void HandleTie(Arena arena, TourneyMatch match, List remaining) { if (remaining.Count == 1) + { HandleWon(arena, match, remaining[0]); + } if (remaining.Count < 2) + { return; + } var sb = new StringBuilder(); @@ -247,7 +257,9 @@ namespace Server.Engines.ConPVP if (remaining.Contains(part)) { if (hasAppended) + { sb.Append(", "); + } sb.Append(part.NameList); hasAppended = true; @@ -265,7 +277,9 @@ namespace Server.Engines.ConPVP var tieType = TieType; if (tieType == TieType.FullElimination && remaining.Count >= Undefeated.Count) + { tieType = TieType.FullAdvancement; + } switch (tieType) { @@ -277,7 +291,9 @@ namespace Server.Engines.ConPVP case TieType.FullElimination: { for (var j = 0; j < remaining.Count; ++j) + { Undefeated.Remove(remaining[j]); + } sb.AppendFormat("In accordance with the rules, {0} parties are eliminated.", whole); break; @@ -287,15 +303,21 @@ namespace Server.Engines.ConPVP var advanced = remaining.RandomElement(); for (var i = 0; i < remaining.Count; ++i) + { if (remaining[i] != advanced) + { Undefeated.Remove(remaining[i]); + } + } if (advanced != null) + { sb.AppendFormat( "In accordance with the rules, {0} {1} advanced.", advanced.NameList, advanced.Players.Count == 1 ? "is" : "are" ); + } break; } @@ -308,19 +330,27 @@ namespace Server.Engines.ConPVP var part = remaining[i]; if (advanced == null || part.TotalLadderXP > advanced.TotalLadderXP) + { advanced = part; + } } for (var i = 0; i < remaining.Count; ++i) + { if (remaining[i] != advanced) + { Undefeated.Remove(remaining[i]); + } + } if (advanced != null) + { sb.AppendFormat( "In accordance with the rules, {0} {1} advanced.", advanced.NameList, advanced.Players.Count == 1 ? "is" : "are" ); + } break; } @@ -333,19 +363,27 @@ namespace Server.Engines.ConPVP var part = remaining[i]; if (advanced == null || part.TotalLadderXP < advanced.TotalLadderXP) + { advanced = part; + } } for (var i = 0; i < remaining.Count; ++i) + { if (remaining[i] != advanced) + { Undefeated.Remove(remaining[i]); + } + } if (advanced != null) + { sb.AppendFormat( "In accordance with the rules, {0} {1} advanced.", advanced.NameList, advanced.Players.Count == 1 ? "is" : "are" ); + } break; } @@ -359,25 +397,37 @@ namespace Server.Engines.ConPVP var part = player.Participant; if (!part.Eliminated) + { return; + } if (TourneyType == TourneyType.FreeForAll) { var rem = 0; for (var i = 0; i < part.Context.Participants.Count; ++i) + { if (part.Context.Participants[i]?.Eliminated == false) + { ++rem; + } + } var tp = part.TourneyPart; if (tp == null) + { return; + } if (rem == 1) + { GiveAwards(tp.Players, TrophyRank.Silver, ComputeCashAward() / 2); + } else if (rem == 2) + { GiveAwards(tp.Players, TrophyRank.Bronze, ComputeCashAward() / 4); + } } } @@ -389,16 +439,22 @@ namespace Server.Engines.ConPVP sb.Append(winner.NameList); if (winner.Players.Count > 1) + { sb.Append(" have bested "); + } else + { sb.Append(" has bested "); + } if (match.Participants.Count > 2) + { sb.AppendFormat( "{0} other {1}: ", match.Participants.Count - 1, winner.Players.Count == 1 ? "players" : "teams" ); + } var hasAppended = false; @@ -407,12 +463,16 @@ namespace Server.Engines.ConPVP var part = match.Participants[j]; if (part == winner) + { continue; + } Undefeated.Remove(part); if (hasAppended) + { sb.Append(", "); + } sb.Append(part.NameList); hasAppended = true; @@ -421,7 +481,9 @@ namespace Server.Engines.ConPVP sb.Append("."); if (TourneyType == TourneyType.Standard) + { Alert(arena, sb.ToString()); + } } private int ComputeCashAward() => Participants.Count * m_PlayersPerParticipant * 2500; @@ -433,30 +495,40 @@ namespace Server.Engines.ConPVP case TourneyType.FreeForAll: { if (Pyramid.Levels.Count < 1) + { break; + } var top = Pyramid.Levels[^1]; if (top.FreeAdvance != null || top.Matches.Count != 1) + { break; + } var match = top.Matches[0]; var winner = match.Winner; if (winner != null) + { GiveAwards(winner.Players, TrophyRank.Gold, ComputeCashAward()); + } break; } case TourneyType.Standard: { if (Pyramid.Levels.Count < 2) + { break; + } var top = Pyramid.Levels[^1]; if (top.FreeAdvance != null || top.Matches.Count != 1) + { break; + } var cash = ComputeCashAward(); @@ -468,15 +540,21 @@ namespace Server.Engines.ConPVP var part = match.Participants[i]; if (part == winner) + { GiveAwards(part.Players, TrophyRank.Gold, cash); + } else + { GiveAwards(part.Players, TrophyRank.Silver, cash / 2); + } } var next = Pyramid.Levels[^2]; if (next.Matches.Count > 2) + { break; + } for (var i = 0; i < next.Matches.Count; ++i) { @@ -488,7 +566,9 @@ namespace Server.Engines.ConPVP var part = match.Participants[j]; if (part != winner) + { GiveAwards(part.Players, TrophyRank.Bronze, cash / 4); + } } } @@ -500,10 +580,14 @@ namespace Server.Engines.ConPVP private void GiveAwards(List players, TrophyRank rank, int cash) { if (players.Count == 0) + { return; + } if (players.Count > 1) + { cash /= players.Count - 1; + } cash += 500; cash /= 1000; @@ -535,14 +619,18 @@ namespace Server.Engines.ConPVP for (var i = 0; i < m_ParticipantsPerMatch; ++i) { if (sb.Length > 0) + { sb.Append('v'); + } sb.Append(m_PlayersPerParticipant); } } if (EventController != null) + { sb.Append(' ').Append(EventController.Title); + } sb.Append(" Champion"); @@ -553,19 +641,25 @@ namespace Server.Engines.ConPVP var mob = players[i]; if (mob?.Deleted != false) + { continue; + } Item item = new Trophy(title, rank); if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } if (cash > 0) { item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) + { mob.BankBox.DropItem(item); + } mob.SendMessage( "You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.", @@ -611,7 +705,9 @@ namespace Server.Engines.ConPVP if (bad) { for (var j = 0; j < part.Players.Count; ++j) + { part.Players[j].SendMessage("You have been disqualified from the tournament."); + } Participants.RemoveAt(i); } @@ -629,7 +725,9 @@ namespace Server.Engines.ConPVP var level = Pyramid.Levels[0]; if (level.FreeAdvance != null) + { Undefeated.Add(level.FreeAdvance); + } for (var i = 0; i < level.Matches.Count; ++i) { @@ -772,6 +870,7 @@ namespace Server.Engines.ConPVP stillGoing = true; if (!match.InProgress) + { for (var j = 0; j < Arenas.Count; ++j) { var arena = Arenas[j]; @@ -782,6 +881,7 @@ namespace Server.Engines.ConPVP break; } } + } } } @@ -805,10 +905,14 @@ namespace Server.Engines.ConPVP } if (!bad) + { continue; + } for (var j = 0; j < part.Players.Count; ++j) + { part.Players[j].SendMessage("You have been disqualified from the tournament."); + } Undefeated.RemoveAt(i); @@ -910,7 +1014,9 @@ namespace Server.Engines.ConPVP } if (Undefeated.Count > 1) + { Pyramid.AddLevel(m_ParticipantsPerMatch, Undefeated, GroupType, TourneyType); + } } } } @@ -919,12 +1025,15 @@ namespace Server.Engines.ConPVP public void Alert(params string[] alerts) { for (var i = 0; i < Arenas.Count; ++i) + { Alert(Arenas[i], alerts); + } } public void Alert(Arena arena, params string[] alerts) { if (arena?.Announcer != null) + { for (var j = 0; j < alerts.Length; ++j) { var alert = alerts[j]; @@ -933,6 +1042,7 @@ namespace Server.Engines.ConPVP () => arena.Announcer.PublicOverheadMessage(MessageType.Regular, 0x35, false, alert) ); } + } } } } diff --git a/Projects/UOContent/Engines/ConPVP/TournamentController.cs b/Projects/UOContent/Engines/ConPVP/TournamentController.cs index 5454f0182..66a7cb274 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentController.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentController.cs @@ -36,7 +36,9 @@ namespace Server.Engines.ConPVP if (controller?.Deleted == false && controller.Tournament != null && controller.Tournament.Stage != TournamentStage.Inactive) + { return true; + } } return false; @@ -54,7 +56,9 @@ namespace Server.Engines.ConPVP list.Add(new EditEntry(Tournament)); if (Tournament.CurrentStage == TournamentStage.Inactive) + { list.Add(new StartEntry(Tournament)); + } } } diff --git a/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs b/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs index 8c8059cfd..fc43596b7 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs @@ -17,7 +17,9 @@ namespace Server.Engines.ConPVP var copy = new List(participants); if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow) + { copy.Sort(); + } var level = new PyramidLevel(); @@ -28,7 +30,9 @@ namespace Server.Engines.ConPVP var parts = new TourneyParticipant[2]; for (var i = 0; i < parts.Length; ++i) + { parts[i] = new TourneyParticipant(new List()); + } for (var i = 0; i < copy.Count; ++i) { @@ -39,9 +43,13 @@ namespace Server.Engines.ConPVP var mob = players[j]; if (mob.Kills >= 5) + { parts[0].Players.Add(mob); + } else + { parts[1].Players.Add(mob); + } } } @@ -53,7 +61,9 @@ namespace Server.Engines.ConPVP var parts = new TourneyParticipant[partsPerMatch]; for (var i = 0; i < parts.Length; ++i) + { parts[i] = new TourneyParticipant(new List()); + } for (var i = 0; i < copy.Count; ++i) { @@ -70,16 +80,26 @@ namespace Server.Engines.ConPVP var fac = Faction.Find(mob); if (fac != null) + { index = fac.Definition.Sort; + } } else if (partsPerMatch == 2) { if (Ethic.Evil.IsEligible(mob)) + { index = 0; - else if (Ethic.Hero.IsEligible(mob)) index = 1; + } + else if (Ethic.Hero.IsEligible(mob)) + { + index = 1; + } } - if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch; + if (index < 0 || index >= partsPerMatch) + { + index = i % partsPerMatch; + } parts[index].Players.Add(mob); } @@ -93,10 +113,14 @@ namespace Server.Engines.ConPVP var parts = new TourneyParticipant[partsPerMatch]; for (var i = 0; i < partsPerMatch; ++i) + { parts[i] = new TourneyParticipant(new List()); + } for (var i = 0; i < copy.Count; ++i) + { parts[i % parts.Length].Players.AddRange(copy[i].Players); + } level.Matches.Add(new TourneyMatch(new List(parts))); break; @@ -117,7 +141,9 @@ namespace Server.Engines.ConPVP var p = participants[i]; if (p.FreeAdvances < lowAdvances) + { lowAdvances = p.FreeAdvances; + } } var toAdvance = new List(); @@ -127,11 +153,15 @@ namespace Server.Engines.ConPVP var p = participants[i]; if (p.FreeAdvances == lowAdvances) + { toAdvance.Add(p); + } } if (toAdvance.Count == 0) + { toAdvance = copy; // sanity + } var random = toAdvance.RandomElement(); @@ -165,7 +195,9 @@ namespace Server.Engines.ConPVP } if (copy.Count > 1) + { level.Matches.Add(new TourneyMatch(copy)); + } break; } diff --git a/Projects/UOContent/Engines/ConPVP/TournamentRegistrar.cs b/Projects/UOContent/Engines/ConPVP/TournamentRegistrar.cs index 4f8e42d44..5f9cf9b9f 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentRegistrar.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentRegistrar.cs @@ -25,12 +25,14 @@ namespace Server.Engines.ConPVP var tourney = Tournament?.Tournament; if (tourney?.Stage == TournamentStage.Signup) + { PublicOverheadMessage( MessageType.Regular, 0x35, false, "Come one, come all! Do you aspire to be a fighter of great renown? Join this tournament and show the world your abilities." ); + } } public override void OnMovement(Mobile m, Point3D oldLocation) @@ -47,12 +49,19 @@ namespace Server.Engines.ConPVP var entry = ladder?.Find(m); if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) + { return; + } - if (tourney.IsFactionRestricted && Faction.Find(m) == null) return; + if (tourney.IsFactionRestricted && Faction.Find(m) == null) + { + return; + } if (tourney.HasParticipant(m)) + { return; + } PrivateOverheadMessage( MessageType.Regular, diff --git a/Projects/UOContent/Engines/ConPVP/TournamentSignupItem.cs b/Projects/UOContent/Engines/ConPVP/TournamentSignupItem.cs index 988e4d39a..9385ccc88 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentSignupItem.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentSignupItem.cs @@ -33,10 +33,14 @@ namespace Server.Engines.ConPVP var tourney = Tournament?.Tournament; if (tourney == null) + { return; + } if (Registrar != null) + { Registrar.Direction = Registrar.GetDirectionTo(this); + } switch (tourney.Stage) { @@ -45,21 +49,25 @@ namespace Server.Engines.ConPVP if (Registrar != null) { if (tourney.HasParticipant(from)) + { Registrar.PrivateOverheadMessage( MessageType.Regular, 0x35, false, "Excuse me? You are already signed up.", - from.NetState + @from.NetState ); + } else + { Registrar.PrivateOverheadMessage( MessageType.Regular, 0x22, false, "The tournament has already begun. You are too late to signup now.", - from.NetState + @from.NetState ); + } } break; diff --git a/Projects/UOContent/Engines/ConPVP/TourneyParticipant.cs b/Projects/UOContent/Engines/ConPVP/TourneyParticipant.cs index dba66f17c..c8733e3e2 100644 --- a/Projects/UOContent/Engines/ConPVP/TourneyParticipant.cs +++ b/Projects/UOContent/Engines/ConPVP/TourneyParticipant.cs @@ -31,7 +31,9 @@ namespace Server.Engines.ConPVP var ladder = Ladder.Instance; if (ladder == null) + { return 0; + } var total = 0; @@ -41,7 +43,9 @@ namespace Server.Engines.ConPVP var entry = ladder.Find(mob); if (entry != null) + { total += entry.Experience; + } } return total; @@ -57,18 +61,26 @@ namespace Server.Engines.ConPVP for (var i = 0; i < Players.Count; ++i) { if (Players[i] == null) + { continue; + } var mob = Players[i]; if (sb.Length > 0) { if (Players.Count == 2) + { sb.Append(" and "); + } else if (i + 1 < Players.Count) + { sb.Append(", "); + } else + { sb.Append(", and "); + } } sb.Append(mob.Name); diff --git a/Projects/UOContent/Engines/ConPVP/Trophy.cs b/Projects/UOContent/Engines/ConPVP/Trophy.cs index f6e39dd14..ab2c6d2d6 100644 --- a/Projects/UOContent/Engines/ConPVP/Trophy.cs +++ b/Projects/UOContent/Engines/ConPVP/Trophy.cs @@ -74,7 +74,9 @@ namespace Server.Items Date = reader.ReadDateTime(); if (version == 0) + { LootType = LootType.Blessed; + } } public override void OnAdded(IEntity parent) @@ -89,12 +91,18 @@ namespace Server.Items base.OnSingleClick(from); if (Owner != null) - LabelTo(from, "{0} -- {1}", Title, Owner.RawName); + { + LabelTo(@from, "{0} -- {1}", Title, Owner.RawName); + } else if (Title != null) - LabelTo(from, Title); + { + LabelTo(@from, Title); + } if (Date != DateTime.MinValue) - LabelTo(from, Date.ToString("d")); + { + LabelTo(@from, Date.ToString("d")); + } } public void UpdateStyle() diff --git a/Projects/UOContent/Engines/Craft/Core/CraftCollectionExtensions.cs b/Projects/UOContent/Engines/Craft/Core/CraftCollectionExtensions.cs index 8f8ba61fc..268451d40 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftCollectionExtensions.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftCollectionExtensions.cs @@ -16,7 +16,9 @@ namespace Server.Engines.Craft if (nameNumber != 0 && nameNumber == groupName.Number || nameString != null && nameString == groupName.String) + { return i; + } } return -1; @@ -29,7 +31,9 @@ namespace Server.Engines.Craft var craftItem = list[i]; if (craftItem.ItemType == type || type.IsSubclassOf(craftItem.ItemType)) + { return craftItem; + } } return null; @@ -40,7 +44,10 @@ namespace Server.Engines.Craft for (var i = 0; i < list.Count; i++) { var craftItem = list[i]; - if (craftItem.ItemType == type) return craftItem; + if (craftItem.ItemType == type) + { + return craftItem; + } } return null; diff --git a/Projects/UOContent/Engines/Craft/Core/CraftContext.cs b/Projects/UOContent/Engines/Craft/Core/CraftContext.cs index dcaf0a8ce..a0877fa6e 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftContext.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftContext.cs @@ -36,7 +36,9 @@ namespace Server.Engines.Craft get { if (Items.Count > 0) + { return Items[0]; + } return null; } @@ -47,7 +49,9 @@ namespace Server.Engines.Craft Items.Remove(item); if (Items.Count == 10) + { Items.RemoveAt(9); + } Items.Insert(0, item); } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftGump.cs b/Projects/UOContent/Engines/Craft/Core/CraftGump.cs index 675b7a4f1..b00632384 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftGump.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftGump.cs @@ -49,9 +49,13 @@ namespace Server.Engines.Craft AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitleNumber > 0) + { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor); + } else + { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString); + } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor); //
CATEGORIES
AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor); //
SELECTIONS
@@ -103,9 +107,13 @@ namespace Server.Engines.Craft // **************************************** if (notice is int noticeInt && noticeInt > 0) + { AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor); + } else if (notice is string) + { AddHtml(170, 295, 350, 40, $"{notice}"); + } // If the system has more than one resource if (craftSystem.CraftSubRes.Init) @@ -133,15 +141,21 @@ namespace Server.Engines.Craft var items = from.Backpack.FindItemsByType(resourceType); for (var i = 0; i < items.Length; ++i) + { resourceCount += items[i].Amount; + } } AddButton(15, 362, 4005, 4007, GetButtonID(6, 0)); if (nameNumber > 0) + { AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor); + } else + { AddLabel(50, 362, LabelHue, $"{nameString} ({resourceCount} Available)"); + } } // **************************************** @@ -171,26 +185,38 @@ namespace Server.Engines.Craft var items = from.Backpack.FindItemsByType(resourceType); for (var i = 0; i < items.Length; ++i) + { resourceCount += items[i].Amount; + } } AddButton(15, 382, 4005, 4007, GetButtonID(6, 7)); if (nameNumber > 0) + { AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor); + } else + { AddLabel(50, 385, LabelHue, $"{nameString} ({resourceCount} Available)"); + } } // **************************************** CreateGroupList(); if (page == CraftPage.PickResource) - CreateResList(false, from); + { + CreateResList(false, @from); + } else if (page == CraftPage.PickResource2) - CreateResList(true, from); + { + CreateResList(true, @from); + } else if (context?.LastGroupIndex > -1) + { CreateItemList(context.LastGroupIndex); + } } public void CreateResList(bool opt, Mobile from) @@ -206,12 +232,16 @@ namespace Server.Engines.Craft if (index == 0) { if (i > 0) + { AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1); + } AddPage(i / 10 + 1); if (i > 0) + { AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); + } var context = m_CraftSystem.GetContext(m_From); @@ -233,12 +263,15 @@ namespace Server.Engines.Craft var items = from.Backpack.FindItemsByType(subResource.ItemType); for (var j = 0; j < items.Length; ++j) + { resourceCount += items[j].Amount; + } } AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i)); if (subResource.NameNumber > 0) + { AddHtmlLocalized( 255, 63 + index * 20, @@ -248,8 +281,11 @@ namespace Server.Engines.Craft resourceCount.ToString(), LabelColor ); + } else + { AddLabel(255, 60 + index * 20, LabelHue, $"{subResource.NameString} ({resourceCount})"); + } } } @@ -258,11 +294,14 @@ namespace Server.Engines.Craft var context = m_CraftSystem.GetContext(m_From); if (context == null) + { return; + } var items = context.Items; if (items.Count > 0) + { for (var i = 0; i < items.Count; ++i) { var index = i % 10; @@ -289,14 +328,21 @@ namespace Server.Engines.Craft AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(3, i)); if (craftItem.NameNumber > 0) + { AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor); + } else + { AddLabel(255, 60 + index * 20, LabelHue, craftItem.NameString); + } AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(4, i)); } + } else + { AddHtmlLocalized(230, 62, 200, 22, 1044165, LabelColor); // You haven't made anything yet. + } } public void CreateItemList(int selectedGroup) @@ -336,9 +382,13 @@ namespace Server.Engines.Craft AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(1, i)); if (craftItem.NameNumber > 0) + { AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor); + } else + { AddLabel(255, 60 + index * 20, LabelHue, craftItem.NameString); + } AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(2, i)); } @@ -358,9 +408,13 @@ namespace Server.Engines.Craft AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i)); if (craftGroup.NameNumber > 0) + { AddHtmlLocalized(50, 83 + i * 20, 150, 18, craftGroup.NameNumber, LabelColor); + } else + { AddLabel(50, 80 + i * 20, LabelHue, craftGroup.NameString); + } } return craftGroupCol.Count; @@ -388,7 +442,9 @@ namespace Server.Engines.Craft var resIndex = item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex; if (resIndex >= 0 && resIndex < res.Count) + { type = res.GetAt(resIndex).ItemType; + } } m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item); @@ -398,7 +454,9 @@ namespace Server.Engines.Craft public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID <= 0) + { return; // Canceled + } var buttonID = info.ButtonID - 1; var type = buttonID % 7; @@ -413,7 +471,9 @@ namespace Server.Engines.Craft case 0: // Show group { if (context == null) + { break; + } if (index >= 0 && index < groups.Count) { @@ -426,7 +486,9 @@ namespace Server.Engines.Craft case 1: // Create item { if (context == null) + { break; + } var groupIndex = context.LastGroupIndex; @@ -435,7 +497,9 @@ namespace Server.Engines.Craft var group = groups[groupIndex]; if (index >= 0 && index < group.CraftItems.Count) - CraftItem(group.CraftItems[index]); + { + CraftItem(@group.CraftItems[index]); + } } break; @@ -443,7 +507,9 @@ namespace Server.Engines.Craft case 2: // Item details { if (context == null) + { break; + } var groupIndex = context.LastGroupIndex; @@ -452,7 +518,9 @@ namespace Server.Engines.Craft var group = groups[groupIndex]; if (index >= 0 && index < group.CraftItems.Count) - m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems[index], m_Tool)); + { + m_From.SendGump(new CraftGumpItem(m_From, system, @group.CraftItems[index], m_Tool)); + } } break; @@ -460,24 +528,32 @@ namespace Server.Engines.Craft case 3: // Create item (last 10) { if (context == null) + { break; + } var lastTen = context.Items; if (index >= 0 && index < lastTen.Count) + { CraftItem(lastTen[index]); + } break; } case 4: // Item details (last 10) { if (context == null) + { break; + } var lastTen = context.Items; if (index >= 0 && index < lastTen.Count) + { m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool)); + } break; } @@ -494,7 +570,9 @@ namespace Server.Engines.Craft else { if (context != null) + { context.LastResourceIndex = index; + } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } @@ -510,7 +588,9 @@ namespace Server.Engines.Craft else { if (context != null) + { context.LastResourceIndex2 = index; + } m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); } @@ -525,27 +605,36 @@ namespace Server.Engines.Craft case 0: // Resource selection { if (system.CraftSubRes.Init) + { m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource)); + } break; } case 1: // Smelt item { if (system.Resmelt) + { Resmelt.Do(m_From, system, m_Tool); + } break; } case 2: // Make last { if (context == null) + { break; + } var item = context.LastMade; if (item != null) + { CraftItem(item); + } else + { m_From.SendGump( new CraftGump( m_From, @@ -555,13 +644,16 @@ namespace Server.Engines.Craft m_Page ) ); // You haven't made anything yet. + } break; } case 3: // Last 10 { if (context == null) + { break; + } context.LastGroupIndex = 501; m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); @@ -571,7 +663,9 @@ namespace Server.Engines.Craft case 4: // Toggle use resource hue { if (context == null) + { break; + } context.DoNotColor = !context.DoNotColor; @@ -582,14 +676,18 @@ namespace Server.Engines.Craft case 5: // Repair item { if (system.Repair) + { Repair.Do(m_From, system, m_Tool); + } break; } case 6: // Toggle mark option { if (context == null || !system.MarkOption) + { break; + } context.MarkOption = context.MarkOption switch { @@ -606,16 +704,20 @@ namespace Server.Engines.Craft case 7: // Resource selection 2 { if (system.CraftSubRes2.Init) + { m_From.SendGump( new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2) ); + } break; } case 8: // Enhance item { if (system.CanEnhance) + { Enhance.BeginTarget(m_From, system, m_Tool); + } break; } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs b/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs index e7d7f40e9..c26a58aff 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftGumpItem.cs @@ -59,9 +59,13 @@ namespace Server.Engines.Craft AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor); //
OTHER
if (craftSystem.GumpTitleNumber > 0) + { AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor); + } else + { AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString); + } AddButton(15, 387, 4014, 4016, 0); AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor); // BACK @@ -81,11 +85,16 @@ namespace Server.Engines.Craft } if (craftItem.NameNumber > 0) + { AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor); + } else + { AddLabel(330, 40, LabelHue, craftItem.NameString); + } if (craftItem.UseAllRes) + { AddHtmlLocalized( 170, 302 + m_OtherCount++ * 20, @@ -94,6 +103,7 @@ namespace Server.Engines.Craft 1048176, LabelColor ); // Makes as many as possible at once + } DrawItem(); DrawSkill(); @@ -122,6 +132,7 @@ namespace Server.Engines.Craft } if (needsRecipe) + { AddHtmlLocalized( 170, 302 + m_OtherCount++ * 20, @@ -130,6 +141,7 @@ namespace Server.Engines.Craft 1073620, RedLabelColor ); // You have not learned this recipe. + } } private TextDefinition RequiredExpansionMessage(Expansion expansion) @@ -179,7 +191,9 @@ namespace Server.Engines.Craft var context = m_CraftSystem.GetContext(m_From); if (context != null) + { resIndex = m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex; + } var chance = m_CraftItem.GetSuccessChance( m_From, @@ -211,7 +225,9 @@ namespace Server.Engines.Craft var resIndex = -1; if (context != null) + { resIndex = m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex; + } var cropScroll = m_CraftItem.Resources.Count > 1 && m_CraftItem.Resources[^1].ItemType == typeofBlankScroll @@ -240,7 +256,9 @@ namespace Server.Engines.Craft nameNumber = subResource.GenericNameNumber; if (nameNumber <= 0) + { nameNumber = subResource.NameNumber; + } } // ****************** @@ -259,9 +277,13 @@ namespace Server.Engines.Craft } if (nameNumber > 0) + { AddHtmlLocalized(170, 219 + i * 20, 310, 18, nameNumber, LabelColor); + } else + { AddLabel(170, 219 + i * 20, LabelHue, nameString); + } AddLabel(430, 219 + i * 20, LabelHue, craftResource.Amount.ToString()); } @@ -273,6 +295,7 @@ namespace Server.Engines.Craft } if (cropScroll) + { AddHtmlLocalized( 170, 302 + m_OtherCount++ * 20, @@ -281,6 +304,7 @@ namespace Server.Engines.Craft 1044379, LabelColor ); // Inscribing scrolls also requires a blank scroll and mana. + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -311,7 +335,9 @@ namespace Server.Engines.Craft var resIndex = m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex; if (resIndex > -1) + { type = res.GetAt(resIndex).ItemType; + } } m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem); diff --git a/Projects/UOContent/Engines/Craft/Core/CraftItem.cs b/Projects/UOContent/Engines/Craft/Core/CraftItem.cs index 15ed5cc98..55fa6b00d 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftItem.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftItem.cs @@ -192,9 +192,13 @@ namespace Server.Engines.Craft var number = ItemIDOf(type); if (number >= 0x4000) + { number += 1078872; + } else + { number += 1020000; + } return number; } @@ -202,15 +206,26 @@ namespace Server.Engines.Craft public static int ItemIDOf(Type type) { if (_itemIds.TryGetValue(type, out var 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; + } + else if (type == typeof(FactionSpikeTrap)) + { + itemId = 4517; + } if (itemId == 0) { @@ -296,13 +311,19 @@ namespace Server.Engines.Craft consumStam = consume; if (consumMana) - from.Mana -= Mana; + { + @from.Mana -= Mana; + } if (consumHits) - from.Hits -= Hits; + { + @from.Hits -= Hits; + } if (consumStam) - from.Stam -= Stam; + { + @from.Stam -= Stam; + } return true; } @@ -310,11 +331,17 @@ namespace Server.Engines.Craft public bool IsMarkable(Type type) { if (ForceNonExceptional) // Don't even display the stuff for marking if it can't ever be exceptional. + { return false; + } for (var i = 0; i < m_MarkableTable.Length; ++i) + { if (type == m_MarkableTable[i] || type.IsSubclassOf(m_MarkableTable[i])) + { return true; + } + } return false; } @@ -324,15 +351,21 @@ namespace Server.Engines.Craft var neverColor = false; for (var i = 0; !neverColor && i < m_NeverColorTable.Length; ++i) + { neverColor = type == m_NeverColorTable[i] || type.IsSubclassOf(m_NeverColorTable[i]); + } if (neverColor) + { return false; + } var inItemTable = false; for (var i = 0; !inItemTable && i < m_ColoredItemTable.Length; ++i) + { inItemTable = type == m_ColoredItemTable[i] || type.IsSubclassOf(m_ColoredItemTable[i]); + } return inItemTable; } @@ -340,17 +373,23 @@ namespace Server.Engines.Craft public bool RetainsColorFrom(CraftSystem system, Type type) { if (system.RetainsColorFrom(this, type)) + { return true; + } var inItemTable = RetainsColor(ItemType); if (!inItemTable) + { return false; + } var inResourceTable = false; for (var i = 0; !inResourceTable && i < m_ColoredResourceTable.Length; ++i) + { inResourceTable = type == m_ColoredResourceTable[i] || type.IsSubclassOf(m_ColoredResourceTable[i]); + } return inResourceTable; } @@ -360,20 +399,25 @@ namespace Server.Engines.Craft var map = from.Map; if (map == null) + { return false; + } var eable = map.GetItemsInRange(from.Location, 2); var found = eable.Any(item => item.Z + 16 > item.Z && item.Z + 16 > item.Z && Find(item.ItemID, itemIDs)); eable.Free(); if (found) + { return true; + } for (var x = -2; x <= 2; ++x) + { for (var y = -2; y <= 2; ++y) { - var vx = from.X + x; - var vy = from.Y + y; + var vx = @from.X + x; + var vy = @from.Y + y; var tiles = map.Tiles.GetStaticTiles(vx, vy, true); @@ -382,10 +426,13 @@ namespace Server.Engines.Craft var z = tiles[i].Z; var id = tiles[i].ID; - if (z + 16 > from.Z && from.Z + 16 > z && Find(id, itemIDs)) + if (z + 16 > @from.Z && @from.Z + 16 > z && Find(id, itemIDs)) + { return true; + } } } + } return false; } @@ -395,7 +442,9 @@ namespace Server.Engines.Craft var contains = false; for (var i = 0; !contains && i < itemIDs.Length; i += 2) + { contains = itemID >= itemIDs[i] && itemID <= itemIDs[i + 1]; + } return contains; } @@ -406,7 +455,9 @@ namespace Server.Engines.Craft public int ConsumeQuantity(Container cont, Type[][] types, int[] amounts) { if (types.Length != amounts.Length) + { throw new ArgumentException(); + } var items = new Item[types.Length][]; var totals = new int[types.Length]; @@ -416,6 +467,7 @@ namespace Server.Engines.Craft items[i] = cont.FindItemsByType(types[i]); for (var j = 0; j < items[i].Length; ++j) + { if (!(items[i][j] is IHasQuantity hq)) { totals[i] += items[i][j].Amount; @@ -423,13 +475,18 @@ namespace Server.Engines.Craft else { if (hq is BaseBeverage beverage && beverage.Content != RequiredBeverage) + { continue; + } totals[i] += hq.Quantity; } + } if (totals[i] < amounts[i]) + { return i; + } } for (var i = 0; i < types.Length; ++i) @@ -458,7 +515,9 @@ namespace Server.Engines.Craft else { if (hq is BaseBeverage beverage && beverage.Content != RequiredBeverage) + { continue; + } var theirAmount = hq.Quantity; @@ -486,6 +545,7 @@ namespace Server.Engines.Craft var amount = 0; for (var i = 0; i < items.Length; ++i) + { if (!(items[i] is IHasQuantity hq)) { amount += items[i].Amount; @@ -493,10 +553,13 @@ namespace Server.Engines.Craft else { if (hq is BaseBeverage beverage && beverage.Content != RequiredBeverage) + { continue; + } amount += hq.Quantity; } + } return amount; } @@ -515,7 +578,9 @@ namespace Server.Engines.Craft var ourPack = from.Backpack; if (ourPack == null) + { return false; + } if (NeedHeat && !Find(from, m_HeatSources)) { @@ -564,11 +629,17 @@ namespace Server.Engines.Craft // ****************** for (var j = 0; types[i] == null && j < m_TypesTable.Length; ++j) + { if (m_TypesTable[j][0] == baseType) + { types[i] = m_TypesTable[j]; + } + } if (types[i] == null) + { types[i] = new[] { baseType }; + } amounts[i] = craftRes.Amount; @@ -586,11 +657,17 @@ namespace Server.Engines.Craft res = Resources[i]; if (res.MessageNumber > 0) + { message = res.MessageNumber; + } else if (!string.IsNullOrEmpty(res.MessageString)) + { message = res.MessageString; + } else + { message = 502925; // You don't have the resources required to make that item. + } return false; } @@ -599,15 +676,23 @@ namespace Server.Engines.Craft // **************************** if (isFailure && !craftSystem.ConsumeOnFailure(from, types[i][0], this)) + { amounts[i] = 0; + } } // We adjust the amount of each resource to consume the max possible if (UseAllRes) + { for (var i = 0; i < amounts.Length; ++i) + { amounts[i] *= maxAmount; + } + } else + { maxAmount = -1; + } RecallRune consumeExtra = null; @@ -633,9 +718,13 @@ namespace Server.Engines.Craft m_System = craftSystem; if (IsQuantityType(types)) + { index = ConsumeQuantity(ourPack, types, amounts); + } else + { index = ourPack.ConsumeTotalGrouped(types, amounts, true, OnResourceConsumed, CheckHueGrouping); + } resHue = m_ResHue; } @@ -647,7 +736,9 @@ namespace Server.Engines.Craft amounts[i] /= 2; if (amounts[i] < 1) + { amounts[i] = 1; + } } m_ResHue = 0; @@ -655,9 +746,13 @@ namespace Server.Engines.Craft m_System = craftSystem; if (IsQuantityType(types)) + { index = ConsumeQuantity(ourPack, types, amounts); + } else + { index = ourPack.ConsumeTotalGrouped(types, amounts, true, OnResourceConsumed, CheckHueGrouping); + } resHue = m_ResHue; } @@ -667,7 +762,9 @@ namespace Server.Engines.Craft // TODO: Optimize this if (IsQuantityType(types)) + { for (var i = 0; i < types.Length; i++) + { if (GetQuantity(ourPack, types[i]) < amounts[i]) { index = i; @@ -676,18 +773,24 @@ namespace Server.Engines.Craft else { for (var j = 0; j < types.Length; j++) + { if (ourPack.GetBestGroupAmount(types[j], true, CheckHueGrouping) < amounts[j]) { index = j; break; } + } } + } + } } if (index == -1) { if (consumeType != ConsumeType.None) + { consumeExtra?.Delete(); + } return true; } @@ -695,11 +798,17 @@ namespace Server.Engines.Craft res = Resources[index]; if (res.MessageNumber > 0) + { message = res.MessageNumber; + } else if (!string.IsNullOrEmpty(res.MessageString)) + { message = res.MessageString; + } else + { message = 502925; // You don't have the resources required to make that item. + } return false; } @@ -707,7 +816,9 @@ namespace Server.Engines.Craft private void OnResourceConsumed(Item item, int amount) { if (!RetainsColorFrom(m_System, item.GetType())) + { return; + } if (amount >= m_ResAmount) { @@ -721,7 +832,9 @@ namespace Server.Engines.Craft public double GetExceptionalChance(CraftSystem system, double chance, Mobile from) { if (ForceNonExceptional) + { return 0.0; + } var bonus = 0.0; @@ -761,7 +874,9 @@ namespace Server.Engines.Craft var chance = GetSuccessChance(from, typeRes, craftSystem, gainSkills, out allRequiredSkills); if (GetExceptionalChance(craftSystem, chance, from) > Utility.RandomDouble()) + { quality = 2; + } return chance > Utility.RandomDouble(); } @@ -786,7 +901,9 @@ namespace Server.Engines.Craft var valSkill = from.Skills[craftSkill.SkillToMake].Value; if (valSkill < minSkill) + { allRequiredSkills = false; + } if (craftSkill.SkillToMake == craftSystem.MainSkill) { @@ -796,22 +913,32 @@ namespace Server.Engines.Craft } if (gainSkills) // This is a passive check. Success chance is entirely dependant on the main skill - from.CheckSkill(craftSkill.SkillToMake, minSkill, maxSkill); + { + @from.CheckSkill(craftSkill.SkillToMake, minSkill, maxSkill); + } } double chance; if (allRequiredSkills) + { chance = craftSystem.GetChanceAtMin(this) + (valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) * (1.0 - craftSystem.GetChanceAtMin(this)); + } else + { chance = 0.0; + } if (allRequiredSkills && from.Talisman is BaseTalisman talisman && talisman.Skill == craftSystem.MainSkill) + { chance += talisman.SuccessBonus / 100.0; + } if (allRequiredSkills && valMainSkill == maxMainSkill) + { chance = 1.0; + } return chance; } @@ -946,9 +1073,13 @@ namespace Server.Engines.Craft if (badCraft > 0) { if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, badCraft)); + } else - from.SendLocalizedMessage(badCraft); + { + @from.SendLocalizedMessage(badCraft); + } return; } @@ -969,11 +1100,17 @@ namespace Server.Engines.Craft && ConsumeAttributes(from, ref checkMessage, false))) { if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, checkMessage)); + } else if (checkMessage is int messageInt && messageInt > 0) - from.SendLocalizedMessage(messageInt); + { + @from.SendLocalizedMessage(messageInt); + } else - from.SendMessage(checkMessage.ToString()); + { + @from.SendMessage(checkMessage.ToString()); + } return; } @@ -998,11 +1135,17 @@ namespace Server.Engines.Craft && ConsumeAttributes(from, ref message, true))) { if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, message)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, message)); + } else if (message is int messageIn && messageIn > 0) - from.SendLocalizedMessage(messageIn); + { + @from.SendLocalizedMessage(messageIn); + } else - from.SendMessage(message.ToString()); + { + @from.SendMessage(message.ToString()); + } return; } @@ -1010,18 +1153,26 @@ namespace Server.Engines.Craft tool.UsesRemaining--; if (craftSystem is DefBlacksmithy) - if (from.FindItemOnLayer(Layer.OneHanded) is AncientSmithyHammer hammer && hammer != tool) + { + if (@from.FindItemOnLayer(Layer.OneHanded) is AncientSmithyHammer hammer && hammer != tool) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) + { hammer.Delete(); + } } + } if (tool.UsesRemaining < 1 && tool.BreakOnDepletion) + { toolBroken = true; + } if (toolBroken) + { tool.Delete(); + } var num = 0; @@ -1043,33 +1194,45 @@ namespace Server.Engines.Craft if (item != null) { if (item is ICraftable craftable) - endquality = craftable.OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue); + { + endquality = craftable.OnCraft(quality, makersMark, @from, craftSystem, typeRes, tool, this, resHue); + } else if (item.Hue == 0) + { item.Hue = resHue; + } if (maxAmount > 0) { if (!item.Stackable && item is IUsesRemaining remaining) + { remaining.UsesRemaining *= maxAmount; + } else + { item.Amount = maxAmount; + } } from.AddToBackpack(item); if (from.AccessLevel > AccessLevel.Player) + { CommandLogging.WriteLine( - from, + @from, "Crafting {0} with craft system {1}", CommandLogging.Format(item), craftSystem.GetType().Name ); + } // from.PlaySound( 0x57 ); } if (num == 0) - num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this); + { + num = craftSystem.PlayEndingEffect(@from, false, true, toolBroken, endquality, makersMark, this); + } var queryFactionImbue = false; var availableSilver = 0; @@ -1097,7 +1260,9 @@ namespace Server.Engines.Craft availableSilver = pack.GetAmount(typeof(Silver)); if (availableSilver >= def.SilverCost) - queryFactionImbue = Faction.IsNearType(from, def.VendorType, 12); + { + queryFactionImbue = Faction.IsNearType(@from, def.VendorType, 12); + } } } } @@ -1107,11 +1272,12 @@ namespace Server.Engines.Craft // TODO: Scroll imbuing if (queryFactionImbue) - from.SendGump( + { + @from.SendGump( new FactionImbueGump( quality, item, - from, + @from, craftSystem, tool, num, @@ -1120,17 +1286,26 @@ namespace Server.Engines.Craft def ) ); + } else if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, num)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, num)); + } else if (num > 0) - from.SendLocalizedMessage(num); + { + @from.SendLocalizedMessage(num); + } } else if (!allRequiredSkills) { if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, 1044153)); + } else - from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item. + { + @from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item. + } } else { @@ -1144,11 +1319,17 @@ namespace Server.Engines.Craft if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true)) { if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, message)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, message)); + } else if (message is int messageInt && messageInt > 0) - from.SendLocalizedMessage(messageInt); + { + @from.SendLocalizedMessage(messageInt); + } else - from.SendMessage(message.ToString()); + { + @from.SendMessage(message.ToString()); + } return; } @@ -1156,18 +1337,26 @@ namespace Server.Engines.Craft tool.UsesRemaining--; if (tool.UsesRemaining < 1 && tool.BreakOnDepletion) + { toolBroken = true; + } if (toolBroken) + { tool.Delete(); + } // SkillCheck failed. var num = craftSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this); if (!tool.Deleted && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, craftSystem, tool, num)); + { + @from.SendGump(new CraftGump(@from, craftSystem, tool, num)); + } else if (num > 0) - from.SendLocalizedMessage(num); + { + @from.SendLocalizedMessage(num); + } } } @@ -1214,9 +1403,13 @@ namespace Server.Engines.Craft if (badCraft > 0) { if (m_Tool?.Deleted == false && m_Tool.UsesRemaining > 0) + { m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft)); + } else + { m_From.SendLocalizedMessage(badCraft); + } return; } @@ -1229,7 +1422,9 @@ namespace Server.Engines.Craft var context = m_CraftSystem.GetContext(m_From); if (context == null) + { return; + } if (typeof(CustomCraft).IsAssignableFrom(m_CraftItem.ItemType)) { @@ -1260,7 +1455,9 @@ namespace Server.Engines.Craft var makersMark = false; if (quality == 2 && m_From.Skills[m_CraftSystem.MainSkill].Base >= 100.0) + { makersMark = m_CraftItem.IsMarkable(m_CraftItem.ItemType); + } if (makersMark && context.MarkOption == CraftMarkOption.PromptForMark) { @@ -1278,7 +1475,9 @@ namespace Server.Engines.Craft else { if (context.MarkOption == CraftMarkOption.DoNotMark) + { makersMark = false; + } m_CraftItem.CompleteCraft(quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null); } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftRes.cs b/Projects/UOContent/Engines/Craft/Core/CraftRes.cs index 9d681c6ee..9f87dbb84 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftRes.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftRes.cs @@ -31,11 +31,17 @@ namespace Server.Engines.Craft public void SendMessage(Mobile from) { if (MessageNumber > 0) - from.SendLocalizedMessage(MessageNumber); + { + @from.SendLocalizedMessage(MessageNumber); + } else if (!string.IsNullOrEmpty(MessageString)) - from.SendMessage(MessageString); + { + @from.SendMessage(MessageString); + } else - from.SendLocalizedMessage(502925); // You don't have the resources required to make that item. + { + @from.SendLocalizedMessage(502925); // You don't have the resources required to make that item. + } } } } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftSubResCol.cs b/Projects/UOContent/Engines/Craft/Core/CraftSubResCol.cs index ff0d931d9..2079f9e0b 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftSubResCol.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftSubResCol.cs @@ -22,7 +22,10 @@ namespace Server.Engines.Craft for (var i = 0; i < Count; i++) { var craftSubRes = this[i]; - if (craftSubRes.ItemType == type) return craftSubRes; + if (craftSubRes.ItemType == type) + { + return craftSubRes; + } } return null; diff --git a/Projects/UOContent/Engines/Craft/Core/CraftSystem.cs b/Projects/UOContent/Engines/Craft/Core/CraftSystem.cs index 87132e6f9..22a7cbae7 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftSystem.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftSystem.cs @@ -70,7 +70,9 @@ namespace Server.Engines.Craft public CraftContext GetContext(Mobile m) { if (m == null) + { return null; + } if (m.Deleted) { @@ -79,7 +81,9 @@ namespace Server.Engines.Craft } if (!m_ContextTable.TryGetValue(m, out var c)) + { m_ContextTable[m] = c = new CraftContext(); + } return c; } @@ -95,13 +99,17 @@ namespace Server.Engines.Craft { // Verify if the type is in the list of the craftable item if (CraftItems.SearchFor(type) != null) - realCraftItem.Craft(from, this, typeRes, tool); + { + realCraftItem.Craft(@from, this, typeRes, tool); + } } public int RandomRecipe() { if (m_Recipes.Count == 0) + { return -1; + } return m_Recipes.RandomElement(); } @@ -109,7 +117,9 @@ namespace Server.Engines.Craft public int RandomRareRecipe() { if (m_RareRecipes.Count == 0) + { return -1; + } return m_RareRecipes.RandomElement(); } diff --git a/Projects/UOContent/Engines/Craft/Core/Enhance.cs b/Projects/UOContent/Engines/Craft/Core/Enhance.cs index 238fff02b..c04c4b29c 100644 --- a/Projects/UOContent/Engines/Craft/Core/Enhance.cs +++ b/Projects/UOContent/Engines/Craft/Core/Enhance.cs @@ -26,19 +26,29 @@ namespace Server.Engines.Craft ) { if (item == null) + { return EnhanceResult.BadItem; + } if (!item.IsChildOf(from.Backpack)) + { return EnhanceResult.NotInBackpack; + } if (!(item is BaseArmor) && !(item is BaseWeapon)) + { return EnhanceResult.BadItem; + } if (item is IArcaneEquip eq && eq.IsArcane) + { return EnhanceResult.BadItem; + } if (CraftResources.IsStandard(resource)) + { return EnhanceResult.BadResource; + } var num = craftSystem.CanCraft(from, tool, item.GetType()); @@ -51,20 +61,28 @@ namespace Server.Engines.Craft var craftItem = craftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) + { return EnhanceResult.BadItem; + } if (craftItem.GetSuccessChance(from, resType, craftSystem, false, out _) <= 0.0) + { return EnhanceResult.NoSkill; + } var info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) + { return EnhanceResult.BadResource; + } var attributes = info.AttributeInfo; if (attributes == null) + { return EnhanceResult.BadResource; + } int resHue = 0, maxAmount = 0; @@ -77,15 +95,21 @@ namespace Server.Engines.Craft ConsumeType.None, ref resMessage )) + { return EnhanceResult.NoResources; + } if (craftSystem is DefBlacksmithy) - if (from.FindItemOnLayer(Layer.OneHanded) is AncientSmithyHammer hammer) + { + if (@from.FindItemOnLayer(Layer.OneHanded) is AncientSmithyHammer hammer) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) + { hammer.Delete(); + } } + } int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0; int dura, luck, lreq, dinc = 0; @@ -104,7 +128,9 @@ namespace Server.Engines.Craft if (item is BaseWeapon weapon) { if (!CraftResources.IsStandard(weapon.Resource)) + { return EnhanceResult.AlreadyEnhanced; + } baseChance = 20; @@ -128,7 +154,9 @@ namespace Server.Engines.Craft var armor = (BaseArmor)item; if (!CraftResources.IsStandard(armor.Resource)) + { return EnhanceResult.AlreadyEnhanced; + } baseChance = 20; @@ -157,36 +185,56 @@ namespace Server.Engines.Craft var skill = from.Skills[craftSystem.MainSkill].Fixed / 10; if (skill >= 100) + { baseChance -= (skill - 90) / 10; + } var res = EnhanceResult.Success; if (physBonus) + { CheckResult(ref res, baseChance + phys); + } if (fireBonus) + { CheckResult(ref res, baseChance + fire); + } if (coldBonus) + { CheckResult(ref res, baseChance + cold); + } if (nrgyBonus) + { CheckResult(ref res, baseChance + nrgy); + } if (poisBonus) + { CheckResult(ref res, baseChance + pois); + } if (duraBonus) + { CheckResult(ref res, baseChance + dura / 40); + } if (luckBonus) + { CheckResult(ref res, baseChance + 10 + luck / 2); + } if (lreqBonus) + { CheckResult(ref res, baseChance + lreq / 4); + } if (dincBonus) + { CheckResult(ref res, baseChance + dinc / 4); + } switch (res) { @@ -201,7 +249,9 @@ namespace Server.Engines.Craft ConsumeType.Half, ref resMessage )) + { return EnhanceResult.NoResources; + } item.Delete(); break; @@ -217,7 +267,9 @@ namespace Server.Engines.Craft ConsumeType.All, ref resMessage )) + { return EnhanceResult.NoResources; + } if (item is BaseWeapon w) { @@ -225,7 +277,9 @@ namespace Server.Engines.Craft var hue = w.GetElementalDamageHue(); if (hue > 0) + { w.Hue = hue; + } } else { @@ -245,7 +299,9 @@ namespace Server.Engines.Craft ConsumeType.Half, ref resMessage )) + { return EnhanceResult.NoResources; + } break; } @@ -257,14 +313,20 @@ namespace Server.Engines.Craft public static void CheckResult(ref EnhanceResult res, int chance) { if (res != EnhanceResult.Success) + { return; // we've already failed.. + } var random = Utility.Random(100); if (random < 10) + { res = EnhanceResult.Failure; + } else if (chance > random) + { res = EnhanceResult.Broken; + } } public static void BeginTarget(Mobile from, CraftSystem craftSystem, BaseTool tool) @@ -272,7 +334,9 @@ namespace Server.Engines.Craft var context = craftSystem.GetContext(from); if (context == null) + { return; + } var lastRes = context.LastResourceIndex; var subRes = craftSystem.CraftSubRes; diff --git a/Projects/UOContent/Engines/Craft/Core/QueryMakersMarkGump.cs b/Projects/UOContent/Engines/Craft/Core/QueryMakersMarkGump.cs index af36d136d..19313edac 100644 --- a/Projects/UOContent/Engines/Craft/Core/QueryMakersMarkGump.cs +++ b/Projects/UOContent/Engines/Craft/Core/QueryMakersMarkGump.cs @@ -47,9 +47,13 @@ namespace Server.Engines.Craft var makersMark = info.ButtonID == 1; if (makersMark) + { m_From.SendLocalizedMessage(501808); // You mark the item. + } else + { m_From.SendLocalizedMessage(501809); // Cancelled mark. + } m_CraftItem.CompleteCraft(m_Quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null); } diff --git a/Projects/UOContent/Engines/Craft/Core/Recipes.cs b/Projects/UOContent/Engines/Craft/Core/Recipes.cs index 77c5874d5..2bde31ec4 100644 --- a/Projects/UOContent/Engines/Craft/Core/Recipes.cs +++ b/Projects/UOContent/Engines/Craft/Core/Recipes.cs @@ -59,7 +59,9 @@ namespace Server.Engines.Craft if (targeted is PlayerMobile mobile) { foreach (var kvp in Recipes) + { mobile.AcquireRecipe(kvp.Key); + } from.SendMessage("You teach them all of the recipes."); } diff --git a/Projects/UOContent/Engines/Craft/Core/Repair.cs b/Projects/UOContent/Engines/Craft/Core/Repair.cs index 0a01ed422..8944d3a92 100644 --- a/Projects/UOContent/Engines/Craft/Core/Repair.cs +++ b/Projects/UOContent/Engines/Craft/Core/Repair.cs @@ -57,9 +57,14 @@ namespace Server.Engines.Craft var maxSkill = difficulty + 25; if (value < minSkill) + { return false; // Too difficult + } + if (value >= maxSkill) + { return true; // No challenge + } var chance = (value - minSkill) / (maxSkill - minSkill); @@ -71,7 +76,10 @@ namespace Server.Engines.Craft private bool CheckDeed(Mobile from) { - if (m_Deed != null) return m_Deed.Check(from); + if (m_Deed != null) + { + return m_Deed.Check(@from); + } return true; } @@ -81,11 +89,13 @@ namespace Server.Engines.Craft // Clothing repairable but not craftable if (m_CraftSystem is DefTailoring) + { return clothing is BearMask || clothing is DeerMask || clothing is TheMostKnowledgePerson || clothing is TheRobeOfBritanniaAri || clothing is EmbroideredOakLeafCloak; + } return false; } @@ -95,21 +105,26 @@ namespace Server.Engines.Craft // Weapons repairable but not craftable if (m_CraftSystem is DefTinkering) + { return weapon is Cleaver || weapon is Hatchet || weapon is Pickaxe || weapon is ButcherKnife || weapon is SkinningKnife; + } if (m_CraftSystem is DefCarpentry) + { return weapon is Club || weapon is BlackStaff || weapon is MagicWand // TODO: Make these items craftable || weapon is WildStaff; + } if (m_CraftSystem is DefBlacksmithy) + { return weapon is Pitchfork // TODO: Make these items craftable @@ -122,11 +137,14 @@ namespace Server.Engines.Craft || weapon is ElvenMachete || weapon is OrnateAxe || weapon is DiamondMace; + } // TODO: Make these items craftable if (m_CraftSystem is DefBowFletching) + { return weapon is ElvenCompositeLongbow || weapon is MagicalShortbow; + } return false; } @@ -137,6 +155,7 @@ namespace Server.Engines.Craft // TODO: Make these items craftable if (m_CraftSystem is DefTailoring) + { return armor is LeafTonlet || armor is LeafArms || armor is LeafChest @@ -148,8 +167,10 @@ namespace Server.Engines.Craft || armor is HideGorget || armor is HidePants || armor is HidePauldrons; + } if (m_CraftSystem is DefCarpentry) + { return armor is WingedHelm || armor is RavenHelm || armor is VultureHelm @@ -158,10 +179,14 @@ namespace Server.Engines.Craft || armor is WoodlandGloves || armor is WoodlandGorget || armor is WoodlandLegs; + } + if (m_CraftSystem is DefBlacksmithy) + { return armor is Circlet || armor is RoyalCirclet || armor is GemmedCirclet; + } return false; } @@ -171,7 +196,9 @@ namespace Server.Engines.Craft int number; if (!CheckDeed(from)) + { return; + } var usingDeed = m_Deed != null; var toDelete = false; @@ -210,12 +237,16 @@ namespace Server.Engines.Craft else { if (damage > (int)(skillValue * 0.3)) + { damage = (int)(skillValue * 0.3); + } damage += 30; if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0)) + { damage /= 2; + } var pack = from.Backpack; @@ -259,11 +290,17 @@ namespace Server.Engines.Craft var skillLevel = usingDeed ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) + { toWeaken = 1; + } else if (skillLevel >= 70.0) + { toWeaken = 2; + } else + { toWeaken = 3; + } } if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon)) @@ -327,11 +364,17 @@ namespace Server.Engines.Craft var skillLevel = usingDeed ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) + { toWeaken = 1; + } else if (skillLevel >= 70.0) + { toWeaken = 2; + } else + { toWeaken = 3; + } } if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !IsSpecialArmor(armor)) @@ -391,11 +434,17 @@ namespace Server.Engines.Craft var skillLevel = usingDeed ? m_Deed.SkillLevel : from.Skills[skill].Base; if (skillLevel >= 90.0) + { toWeaken = 1; + } else if (skillLevel >= 70.0) + { toWeaken = 2; + } else + { toWeaken = 3; + } } if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && @@ -484,7 +533,9 @@ namespace Server.Engines.Craft from.SendLocalizedMessage(number); if (toDelete) + { m_Deed.Delete(); + } } } } diff --git a/Projects/UOContent/Engines/Craft/Core/Resmelt.cs b/Projects/UOContent/Engines/Craft/Core/Resmelt.cs index dde4b3703..b62d0c53b 100644 --- a/Projects/UOContent/Engines/Craft/Core/Resmelt.cs +++ b/Projects/UOContent/Engines/Craft/Core/Resmelt.cs @@ -45,25 +45,35 @@ namespace Server.Engines.Craft try { if (Ethic.IsImbued(item)) + { return SmeltResult.Invalid; + } if (CraftResources.GetType(resource) != CraftResourceType.Metal) + { return SmeltResult.Invalid; + } var info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) + { return SmeltResult.Invalid; + } var craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) + { return SmeltResult.Invalid; + } var craftResource = craftItem.Resources[0]; if (craftResource.Amount < 2) + { return SmeltResult.Invalid; // Not enough metal to resmelt + } var difficulty = resource switch { @@ -79,7 +89,9 @@ namespace Server.Engines.Craft }; if (difficulty > from.Skills.Mining.Value) + { return SmeltResult.NoSkill; + } var resourceType = info.ResourceTypes[0]; var ingot = (Item)ActivatorUtil.CreateInstance(resourceType); @@ -87,9 +99,13 @@ namespace Server.Engines.Craft if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed || item is BaseWeapon weapon && weapon.PlayerConstructed || item is BaseClothing clothing && clothing.PlayerConstructed) + { ingot.Amount = craftResource.Amount / 2; + } else + { ingot.Amount = 1; + } item.Delete(); from.AddToBackpack(ingot); @@ -117,9 +133,13 @@ namespace Server.Engines.Craft DefBlacksmithy.CheckAnvilAndForge(from, 2, out var anvil, out var forge); if (!anvil) + { num = 1044266; // You must be near an anvil + } else if (!forge) + { num = 1044265; // You must be near a forge. + } } from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, num)); diff --git a/Projects/UOContent/Engines/Craft/DefAlchemy.cs b/Projects/UOContent/Engines/Craft/DefAlchemy.cs index 69e076be7..b27eaf254 100644 --- a/Projects/UOContent/Engines/Craft/DefAlchemy.cs +++ b/Projects/UOContent/Engines/Craft/DefAlchemy.cs @@ -24,10 +24,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -45,7 +49,9 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { @@ -63,7 +69,10 @@ namespace Server.Engines.Craft if (IsPotion(item.ItemType)) { if (quality == -1) + { return 1048136; // You create the potion and pour it into a keg. + } + return 500279; // You pour the potion into a bottle... } diff --git a/Projects/UOContent/Engines/Craft/DefBlacksmithy.cs b/Projects/UOContent/Engines/Craft/DefBlacksmithy.cs index 0e3a6f3c7..3dd1c5d61 100644 --- a/Projects/UOContent/Engines/Craft/DefBlacksmithy.cs +++ b/Projects/UOContent/Engines/Craft/DefBlacksmithy.cs @@ -44,7 +44,9 @@ namespace Server.Engines.Craft var map = from.Map; if (map == null) + { return; + } var eable = map.GetItemsInRange(from.Location, range); @@ -60,22 +62,27 @@ namespace Server.Engines.Craft if (isAnvil || isForge) { if (from.Z + 16 < item.Z || item.Z + 16 < from.Z || !from.InLOS(item)) + { continue; + } anvil = anvil || isAnvil; forge = forge || isForge; if (anvil && forge) + { break; + } } } eable.Free(); for (var x = -range; (!anvil || !forge) && x <= range; ++x) + { for (var y = -range; (!anvil || !forge) && y <= range; ++y) { - var tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true); + var tiles = map.Tiles.GetStaticTiles(@from.X + x, @from.Y + y, true); for (var i = 0; (!anvil || !forge) && i < tiles.Length; ++i) { @@ -86,30 +93,43 @@ namespace Server.Engines.Craft if (isAnvil || isForge) { - if (from.Z + 16 < tiles[i].Z || tiles[i].Z + 16 < from.Z || - !from.InLOS(new Point3D(from.X + x, from.Y + y, tiles[i].Z + tiles[i].Height / 2 + 1))) + if (@from.Z + 16 < tiles[i].Z || tiles[i].Z + 16 < @from.Z || + !@from.InLOS(new Point3D(@from.X + x, @from.Y + y, tiles[i].Z + tiles[i].Height / 2 + 1))) + { continue; + } anvil = anvil || isAnvil; forge = forge || isForge; } } } + } } public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckTool(tool, from)) + { return 1048146; // If you have a tool equipped, you must use that tool. + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } CheckAnvilAndForge(from, 2, out var anvil, out var forge); if (anvil && forge) + { return 0; + } return 1044267; // You must be near an anvil and a forge to smith items. } @@ -130,21 +150,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } @@ -187,7 +221,9 @@ namespace Server.Engines.Craft AddCraft(typeof(FemalePlateChest), 1011078, 1046430, 44.1, 94.1, typeof(IronIngot), 1044036, 20, 1044037); if (Core.AOS) // exact pre-aos functionality unknown + { AddCraft(typeof(DragonBardingDeed), 1011078, 1053012, 72.5, 122.5, typeof(IronIngot), 1044036, 750, 1044037); + } if (Core.SE) { @@ -409,12 +445,16 @@ namespace Server.Engines.Craft } if (Core.AOS) + { AddCraft(typeof(BoneHarvester), 1011081, 1029915, 33.0, 83.0, typeof(IronIngot), 1044036, 10, 1044037); + } AddCraft(typeof(Broadsword), 1011081, 1023934, 35.4, 85.4, typeof(IronIngot), 1044036, 10, 1044037); if (Core.AOS) + { AddCraft(typeof(CrescentBlade), 1011081, 1029921, 45.0, 95.0, typeof(IronIngot), 1044036, 14, 1044037); + } AddCraft(typeof(Cutlass), 1011081, 1025185, 24.3, 74.3, typeof(IronIngot), 1044036, 8, 1044037); AddCraft(typeof(Dagger), 1011081, 1023921, -0.4, 49.6, typeof(IronIngot), 1044036, 3, 1044037); @@ -1114,23 +1154,33 @@ namespace Server.Engines.Craft AddCraft(typeof(Bardiche), 1011083, 1023917, 31.7, 81.7, typeof(IronIngot), 1044036, 18, 1044037); if (Core.AOS) + { AddCraft(typeof(BladedStaff), 1011083, 1029917, 40.0, 90.0, typeof(IronIngot), 1044036, 12, 1044037); + } if (Core.AOS) + { AddCraft(typeof(DoubleBladedStaff), 1011083, 1029919, 45.0, 95.0, typeof(IronIngot), 1044036, 16, 1044037); + } AddCraft(typeof(Halberd), 1011083, 1025183, 39.1, 89.1, typeof(IronIngot), 1044036, 20, 1044037); if (Core.AOS) + { AddCraft(typeof(Lance), 1011083, 1029920, 48.0, 98.0, typeof(IronIngot), 1044036, 20, 1044037); + } if (Core.AOS) + { AddCraft(typeof(Pike), 1011083, 1029918, 47.0, 97.0, typeof(IronIngot), 1044036, 12, 1044037); + } AddCraft(typeof(ShortSpear), 1011083, 1025123, 45.3, 95.3, typeof(IronIngot), 1044036, 6, 1044037); if (Core.AOS) + { AddCraft(typeof(Scythe), 1011083, 1029914, 39.0, 89.0, typeof(IronIngot), 1044036, 14, 1044037); + } AddCraft(typeof(Spear), 1011083, 1023938, 49.0, 99.0, typeof(IronIngot), 1044036, 12, 1044037); AddCraft(typeof(WarFork), 1011083, 1025125, 42.9, 92.9, typeof(IronIngot), 1044036, 12, 1044037); @@ -1143,7 +1193,9 @@ namespace Server.Engines.Craft AddCraft(typeof(Maul), 1011084, 1025179, 19.4, 69.4, typeof(IronIngot), 1044036, 10, 1044037); if (Core.AOS) + { AddCraft(typeof(Scepter), 1011084, 1029916, 21.4, 71.4, typeof(IronIngot), 1044036, 10, 1044037); + } AddCraft(typeof(WarMace), 1011084, 1025127, 28.0, 78.0, typeof(IronIngot), 1044036, 14, 1044037); AddCraft(typeof(WarHammer), 1011084, 1025177, 34.2, 84.2, typeof(IronIngot), 1044036, 16, 1044037); diff --git a/Projects/UOContent/Engines/Craft/DefBowFletching.cs b/Projects/UOContent/Engines/Craft/DefBowFletching.cs index a662ebc7b..0ce48898c 100644 --- a/Projects/UOContent/Engines/Craft/DefBowFletching.cs +++ b/Projects/UOContent/Engines/Craft/DefBowFletching.cs @@ -24,9 +24,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -46,21 +51,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } diff --git a/Projects/UOContent/Engines/Craft/DefCarpentry.cs b/Projects/UOContent/Engines/Craft/DefCarpentry.cs index 6c918d785..fa8e45ff6 100644 --- a/Projects/UOContent/Engines/Craft/DefCarpentry.cs +++ b/Projects/UOContent/Engines/Craft/DefCarpentry.cs @@ -22,9 +22,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -44,21 +49,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } diff --git a/Projects/UOContent/Engines/Craft/DefCartography.cs b/Projects/UOContent/Engines/Craft/DefCartography.cs index 7d5bba0ed..af007e101 100644 --- a/Projects/UOContent/Engines/Craft/DefCartography.cs +++ b/Projects/UOContent/Engines/Craft/DefCartography.cs @@ -22,9 +22,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -40,21 +45,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } diff --git a/Projects/UOContent/Engines/Craft/DefCooking.cs b/Projects/UOContent/Engines/Craft/DefCooking.cs index 4864fd1dd..1d8d785c0 100644 --- a/Projects/UOContent/Engines/Craft/DefCooking.cs +++ b/Projects/UOContent/Engines/Craft/DefCooking.cs @@ -24,10 +24,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -42,21 +46,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } diff --git a/Projects/UOContent/Engines/Craft/DefGlassblowing.cs b/Projects/UOContent/Engines/Craft/DefGlassblowing.cs index 1320d0a6e..7217eca84 100644 --- a/Projects/UOContent/Engines/Craft/DefGlassblowing.cs +++ b/Projects/UOContent/Engines/Craft/DefGlassblowing.cs @@ -23,13 +23,24 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckTool(tool, from)) + { return 1048146; // If you have a tool equipped, you must use that tool. + } + if (!(from is PlayerMobile mobile && mobile.Glassblowing && mobile.Skills.Alchemy.Base >= 100.0)) + { return 1044634; // You havent learned glassblowing. + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } DefBlacksmithy.CheckAnvilAndForge(from, 2, out _, out var forge); @@ -52,23 +63,37 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } from.PlaySound(0x41); // glass breaking if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } diff --git a/Projects/UOContent/Engines/Craft/DefInscription.cs b/Projects/UOContent/Engines/Craft/DefInscription.cs index 8694e5dc5..e941d01dc 100644 --- a/Projects/UOContent/Engines/Craft/DefInscription.cs +++ b/Projects/UOContent/Engines/Craft/DefInscription.cs @@ -44,9 +44,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type typeItem) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } if (typeItem != null) { @@ -61,7 +66,10 @@ namespace Server.Engines.Craft return hasSpell ? 0 : 1042404; // null : You don't have that spell! } - if (o is Item item) item.Delete(); + if (o is Item item) + { + item.Delete(); + } } return 0; @@ -78,28 +86,45 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (!typeofSpellScroll.IsAssignableFrom(item.ItemType)) // not a scroll { if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } if (failed) + { return 501630; // You fail to inscribe the scroll, and the scroll is ruined. + } + return 501629; // You inscribe the spell and put the scroll in your backpack. } @@ -156,7 +181,9 @@ namespace Server.Engines.Craft ); for (var i = 1; i < regs.Length; ++i) + { AddRes(index, m_RegTypes[(int)regs[i]], 1044353 + (int)regs[i], 1, 1044361 + (int)regs[i]); + } AddRes(index, typeof(BlankScroll), 1044377, 1, 1044378); @@ -178,7 +205,9 @@ namespace Server.Engines.Craft ); // Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI. for (var i = 1; i < regs.Length; ++i) + { AddRes(index, regs[i], CraftItem.LabelNumber(regs[0]), 1, 501627); + } AddRes(index, typeof(BlankScroll), 1044377, 1, 1044378); SetManaReq(index, mana); @@ -199,7 +228,9 @@ namespace Server.Engines.Craft ); for (var i = 1; i < regs.Length; ++i) + { AddRes(index, regs[i], CraftItem.LabelNumber(regs[i]), 1, 501627); + } AddRes(index, typeof(BlankScroll), 1044377, 1, 1044378); SetManaReq(index, mana); @@ -391,9 +422,14 @@ namespace Server.Engines.Craft AddRes(index, typeof(GateTravelScroll), 1044446, 1, 1044253); if (Core.AOS) + { AddCraft(typeof(BulkOrderBook), 1044294, 1028793, 65.0, 115.0, typeof(BlankScroll), 1044377, 10, 1044378); + } - if (Core.SE) AddCraft(typeof(Spellbook), 1044294, 1023834, 50.0, 126, typeof(BlankScroll), 1044377, 10, 1044378); + if (Core.SE) + { + AddCraft(typeof(Spellbook), 1044294, 1023834, 50.0, 126, typeof(BlankScroll), 1044377, 10, 1044378); + } /* TODO if (Core.ML) diff --git a/Projects/UOContent/Engines/Craft/DefMasonry.cs b/Projects/UOContent/Engines/Craft/DefMasonry.cs index dc73c8b5b..4ebddaaad 100644 --- a/Projects/UOContent/Engines/Craft/DefMasonry.cs +++ b/Projects/UOContent/Engines/Craft/DefMasonry.cs @@ -25,13 +25,24 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckTool(tool, from)) + { return 1048146; // If you have a tool equipped, you must use that tool. + } + if (!(from is PlayerMobile mobile && mobile.Masonry && mobile.Skills.Carpentry.Base >= 100.0)) + { return 1044633; // You havent learned stonecraft. + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -50,21 +61,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } diff --git a/Projects/UOContent/Engines/Craft/DefTailoring.cs b/Projects/UOContent/Engines/Craft/DefTailoring.cs index cb864936f..5786938d5 100644 --- a/Projects/UOContent/Engines/Craft/DefTailoring.cs +++ b/Projects/UOContent/Engines/Craft/DefTailoring.cs @@ -32,10 +32,14 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } return 0; } @@ -43,14 +47,18 @@ namespace Server.Engines.Craft public override bool RetainsColorFrom(CraftItem item, Type type) { if (type != typeof(Cloth) && type != typeof(UncutCloth)) + { return false; + } type = item.ItemType; var contains = false; for (var i = 0; !contains && i < m_TailorColorables.Length; ++i) + { contains = m_TailorColorables[i] == type; + } return contains; } @@ -66,21 +74,35 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } @@ -102,7 +124,9 @@ namespace Server.Engines.Craft AddCraft(typeof(JesterHat), 1011375, 1025916, 7.2, 32.2, typeof(Cloth), 1044286, 15, 1044287); if (Core.AOS) + { AddCraft(typeof(FlowerGarland), 1011375, 1028965, 10.0, 35.0, typeof(Cloth), 1044286, 5, 1044287); + } if (Core.SE) { @@ -163,7 +187,9 @@ namespace Server.Engines.Craft AddCraft(typeof(Skirt), 1015279, 1025398, 29.0, 54.0, typeof(Cloth), 1044286, 10, 1044287); if (Core.AOS) + { AddCraft(typeof(FurSarong), 1015279, 1028971, 35.0, 60.0, typeof(Cloth), 1044286, 12, 1044287); + } if (Core.SE) { @@ -323,7 +349,9 @@ namespace Server.Engines.Craft } if (Core.AOS) + { AddCraft(typeof(FurBoots), 1015288, 1028967, 50.0, 75.0, typeof(Cloth), 1044286, 12, 1044287); + } if (Core.SE) { diff --git a/Projects/UOContent/Engines/Craft/DefTinkering.cs b/Projects/UOContent/Engines/Craft/DefTinkering.cs index c7bc8e4fe..142a38b89 100644 --- a/Projects/UOContent/Engines/Craft/DefTinkering.cs +++ b/Projects/UOContent/Engines/Craft/DefTinkering.cs @@ -36,7 +36,9 @@ namespace Server.Engines.Craft public override double GetChanceAtMin(CraftItem item) { if (item.NameNumber == 1044258 || item.NameNumber == 1046445) // potion keg and faction trap removal kit - return 0.5; // 50% + { + return 0.5; // 50% + } return 0.0; // 0% } @@ -44,13 +46,21 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { if (tool?.Deleted != false || tool.UsesRemaining < 0) + { return 1044038; // You have worn out your tool! + } + if (!BaseTool.CheckAccessible(tool, from)) + { return 1044263; // The tool must be on your person to use. + } + if (itemType != null && (itemType.IsSubclassOf(typeof(BaseFactionTrapDeed)) || itemType == typeof(FactionTrapRemovalKit)) && Faction.Find(from) == null) + { return 1044573; // You have to be in a faction to do that. + } return 0; } @@ -58,14 +68,18 @@ namespace Server.Engines.Craft public override bool RetainsColorFrom(CraftItem item, Type type) { if (!type.IsSubclassOf(typeof(BaseIngot))) + { return false; + } type = item.ItemType; var contains = false; for (var i = 0; !contains && i < m_TinkerColorables.Length; ++i) + { contains = m_TinkerColorables[i] == type; + } return contains; } @@ -82,28 +96,44 @@ namespace Server.Engines.Craft ) { if (toolBroken) - from.SendLocalizedMessage(1044038); // You have worn out your tool + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool + } if (failed) { if (lostMaterial) + { return 1044043; // You failed to create the item, and some of your materials are lost. + } + return 1044157; // You failed to create the item, but no materials were lost. } if (quality == 0) + { return 502785; // You were barely able to make this item. It's quality is below average. + } + if (makersMark && quality == 2) + { return 1044156; // You create an exceptional quality item and affix your maker's mark. + } + if (quality == 2) + { return 1044155; // You create an exceptional quality item. + } + return 1044154; // You create the item. } public override bool ConsumeOnFailure(Mobile from, Type resourceType, CraftItem craftItem) { if (resourceType == typeof(Silver)) + { return false; + } return base.ConsumeOnFailure(from, resourceType, craftItem); } @@ -567,17 +597,34 @@ namespace Server.Engines.Craft private int Verify(LockableContainer container) { if (container == null || container.KeyValue == 0) + { return 1005638; // You can only trap lockable chests. + } + if (From.Map != container.Map || !From.InRange(container.GetWorldLocation(), 2)) + { return 500446; // That is too far away. + } + if (!container.Movable) + { return 502944; // You cannot trap this item because it is locked down. + } + if (!container.IsAccessibleTo(From)) + { return 502946; // That belongs to someone else. + } + if (container.Locked) + { return 502943; // You can only trap an unlocked object. + } + if (container.TrapType != TrapType.None) + { return 502945; // You can only place one trap on an object at a time. + } return 0; } @@ -588,7 +635,10 @@ namespace Server.Engines.Craft message = Verify(container); - if (message > 0) return false; + if (message > 0) + { + return false; + } Container = container; return true; @@ -628,6 +678,7 @@ namespace Server.Engines.Craft protected override void OnTarget(Mobile from, object targeted) { if (m_TrapCraft.Acquire(targeted, out var message)) + { m_TrapCraft.CraftItem.CompleteCraft( m_TrapCraft.Quality, false, @@ -637,14 +688,19 @@ namespace Server.Engines.Craft m_TrapCraft.Tool, m_TrapCraft ); + } else + { Failure(message); + } } protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { if (cancelType == TargetCancelType.Canceled) + { Failure(0); + } } private void Failure(int message) @@ -653,9 +709,13 @@ namespace Server.Engines.Craft var tool = m_TrapCraft.Tool; if (tool?.Deleted == false && tool.UsesRemaining > 0) - from.SendGump(new CraftGump(from, m_TrapCraft.CraftSystem, tool, message)); + { + @from.SendGump(new CraftGump(@from, m_TrapCraft.CraftSystem, tool, message)); + } else if (message > 0) - from.SendLocalizedMessage(message); + { + @from.SendLocalizedMessage(message); + } } } } diff --git a/Projects/UOContent/Engines/Doom/GauntletSpawner.cs b/Projects/UOContent/Engines/Doom/GauntletSpawner.cs index 6fa9e2c39..3b6729fce 100644 --- a/Projects/UOContent/Engines/Doom/GauntletSpawner.cs +++ b/Projects/UOContent/Engines/Doom/GauntletSpawner.cs @@ -59,14 +59,18 @@ namespace Server.Engines.Doom get { if (Creatures.Count == 0) + { return false; + } for (var i = 0; i < Creatures.Count; ++i) { var mob = Creatures[i]; if (!mob.Deleted) + { return false; + } } return true; @@ -83,7 +87,9 @@ namespace Server.Engines.Doom set { if (m_State == value) + { return; + } m_State = value; @@ -123,7 +129,9 @@ namespace Server.Engines.Doom } if (Addon != null) + { Addon.Hue = hue; + } if (m_State == GauntletSpawnerState.InProgress) { @@ -156,12 +164,16 @@ namespace Server.Engines.Doom public virtual void CreateRegion() { if (Region != null) + { return; + } var map = Map; if (map == null || map == Map.Internal) + { return; + } Region = new GauntletRegion(this, map); } @@ -183,7 +195,9 @@ namespace Server.Engines.Doom public virtual void ClearTraps() { for (var i = 0; i < Traps.Count; ++i) + { Traps[i].Delete(); + } Traps.Clear(); } @@ -193,25 +207,39 @@ namespace Server.Engines.Doom var map = Map; if (map == null) + { return; + } BaseTrap trap; var random = Utility.Random(100); if (random < 22) + { trap = new SawTrap(Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor); + } else if (random < 44) + { trap = new SpikeTrap(Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor); + } else if (random < 66) + { trap = new GasTrap(Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall); + } else if (random < 88) + { trap = new FireColumnTrap(); + } else + { trap = new MushroomTrap(); + } if (trap is FireColumnTrap || trap is MushroomTrap) + { trap.Hue = 0x451; + } // try 10 times to find a valid location for (var i = 0; i < 10; ++i) @@ -221,10 +249,14 @@ namespace Server.Engines.Doom var z = Z; if (!map.CanFit(x, y, z, 16, false, false)) + { z = map.GetAverageZ(x, y); + } if (!map.CanFit(x, y, z, 16, false, false)) + { continue; + } trap.MoveToWorld(new Point3D(x, y, z), map); Traps.Add(trap); @@ -248,11 +280,15 @@ namespace Server.Engines.Doom var reg = Region.Find(loc, map).GetRegion("Doom Gauntlet"); if (reg != null) + { playerCount = reg.GetPlayerCount(); + } } if (playerCount == 0 && Region != null) + { playerCount = Region.GetPlayerCount(); + } return Math.Max((playerCount + PlayersPerSpawn - 1) / PlayersPerSpawn, 1); } @@ -260,7 +296,9 @@ namespace Server.Engines.Doom public virtual void ClearCreatures() { for (var i = 0; i < Creatures.Count; ++i) + { Creatures[i].Delete(); + } Creatures.Clear(); } @@ -272,14 +310,18 @@ namespace Server.Engines.Doom var count = ComputeSpawnCount(); for (var i = 0; i < count; ++i) + { Spawn(); + } ClearTraps(); count = ComputeTrapCount(); for (var i = 0; i < count; ++i) + { SpawnTrap(); + } } public virtual void Spawn() @@ -287,12 +329,16 @@ namespace Server.Engines.Doom try { if (TypeName == null) + { return; + } var type = AssemblyHandler.FindFirstTypeForName(TypeName, true); if (type == null) + { return; + } var obj = ActivatorUtil.CreateInstance(type); @@ -320,19 +366,25 @@ namespace Server.Engines.Doom State = GauntletSpawnerState.InSequence; if (Sequence?.Deleted == false) + { Sequence.RecurseReset(); + } } } public virtual void Slice() { if (m_State != GauntletSpawnerState.InProgress) + { return; + } var count = ComputeSpawnCount(); for (var i = Creatures.Count; i < count; ++i) + { Spawn(); + } if (HasCompleted) { @@ -341,7 +393,9 @@ namespace Server.Engines.Doom if (Sequence?.Deleted == false) { if (Sequence.State == GauntletSpawnerState.Completed) + { RecurseReset(); + } Sequence.State = GauntletSpawnerState.InProgress; } @@ -455,7 +509,9 @@ namespace Server.Engines.Doom spawner.MoveToWorld(new Point3D(xSpawner, ySpawner, -1), Map.Malas); if (xDoor > 0 && yDoor > 0) + { spawner.Door = CreateDoorSet(xDoor, yDoor, doorEastToWest, 0); + } spawner.RegionBounds = new Rectangle2D(xStart, yStart, xWidth, yHeight); @@ -508,7 +564,9 @@ namespace Server.Engines.Doom var item = items[i]; if (item.Layer != Layer.ShopBuy && item.Layer != Layer.ShopResale && item.Layer != Layer.ShopSell) + { item.Delete(); + } } dealer.HairItemID = 0x2049; // Pig Tails @@ -556,6 +614,7 @@ namespace Server.Engines.Doom CreateVarietyDealer(492, 369); for (var x = 434; x <= 478; ++x) + { for (var y = 371; y <= 372; ++y) { var item = new Static(0x524); @@ -563,6 +622,7 @@ namespace Server.Engines.Doom item.Hue = 1; item.MoveToWorld(new Point3D(x, y, -1), Map.Malas); } + } /* End supply room */ /* Begin gauntlet cycle */ diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs index c90d79d79..72ef3e4b0 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs @@ -117,24 +117,36 @@ namespace Server.Engines.Doom m_Levers = new List(); /* codes are 0x1 shifted left x # of bits, easily handled here */ for (; i < 4; i++) + { m_Levers.Add(AddLeverPuzzlePart(TA[i], new LeverPuzzleLever((ushort)(1 << i), this))); + } m_Tiles = new List(); for (; i < 9; i++) + { m_Tiles.Add(new LeverPuzzleRegion(this, TA[i])); + } m_Teles = new List(); for (; i < 15; i++) + { m_Teles.Add(AddLeverPuzzlePart(TA[i], new LampRoomTeleporter(TA[++i]))); + } m_Statues = new List(); for (; i < 19; i++) + { m_Statues.Add(AddLeverPuzzlePart(TA[i], new LeverPuzzleStatue(TA[++i], this))); + } if (!installed) + { Delete(); + } else + { Enabled = true; + } m_Box = (LampRoomBox)AddLeverPuzzlePart(TA[i], new LampRoomBox(this)); m_LampRoom = new LampRoomRegion(this); @@ -161,8 +173,13 @@ namespace Server.Engines.Doom get /* OSI: all 5 must be occupied */ { for (var i = 0; i < 5; i++) + { if (GetOccupant(i) == null) + { return false; + } + } + return true; } } @@ -186,17 +203,25 @@ namespace Server.Engines.Doom new LeverPuzzleController().MoveToWorld(lp_Center, Map.Malas); if (!installed) + { e.Mobile.SendMessage("There was a problem generating the puzzle."); + } else + { e.Mobile.SendMessage("Lamp room puzzle successfully generated."); + } } public static Item AddLeverPuzzlePart(int[] loc, Item newitem) { if (newitem?.Deleted != false) + { installed = false; + } else + { newitem.MoveToWorld(new Point3D(loc[0], loc[1], loc[2]), Map.Malas); + } return newitem; } @@ -215,25 +240,42 @@ namespace Server.Engines.Doom m_LampRoom?.Unregister(); if (m_Tiles != null) + { foreach (var region in m_Tiles) + { region.Unregister(); + } + } + if (m_Box?.Deleted == false) + { m_Box.Delete(); + } } public static void NukeItemList(List list) { if (list?.Count > 0) + { foreach (var item in list) + { if (item?.Deleted == false) + { item.Delete(); + } + } + } } public virtual PlayerMobile GetOccupant(int index) { var region = m_Tiles[index]; - if (region?.Occupant?.Alive == true) return (PlayerMobile)region.Occupant; + if (region?.Occupant?.Alive == true) + { + return (PlayerMobile)region.Occupant; + } + return null; } @@ -256,7 +298,9 @@ namespace Server.Engines.Doom { Item s; if ((s = GetStatue(i)) != null) + { s.PublicOverheadMessage(MessageType.Regular, 0x3B2, message, fstring); + } } } @@ -283,8 +327,15 @@ namespace Server.Engines.Doom public virtual void KillTimers() { - if (l_Timer?.Running == true) l_Timer.Stop(); - if (m_Timer?.Running == true) m_Timer.Stop(); + if (l_Timer?.Running == true) + { + l_Timer.Stop(); + } + + if (m_Timer?.Running == true) + { + m_Timer.Stop(); + } } public virtual void RemoveSuccessful() @@ -332,14 +383,22 @@ namespace Server.Engines.Doom else { for (var i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */ + { if (((MyKey >> i) & 1) == 1 && ((TheirKey >> i) & 1) == 1) + { correct++; + } + } PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null); for (var i = 0; i < 5; i++) + { if ((player = GetOccupant(i)) != null) + { new RockTimer(player, this).Start(); + } + } } } @@ -351,7 +410,10 @@ namespace Server.Engines.Doom Span ca = stackalloc ushort[] { 1, 2, 4, 8 }; ca.Shuffle(); - for (var i = 0; i < 4; i++) MyKey = (ushort)(ca[i] | (MyKey <<= 4)); + for (var i = 0; i < 4; i++) + { + MyKey = (ushort)(ca[i] | (MyKey <<= 4)); + } } private static bool IsValidDamagable(Mobile m) => @@ -364,7 +426,9 @@ namespace Server.Engines.Doom if (m != null) { if (m is PlayerMobile && !m.Alive && m.Corpse?.Deleted == false) + { m.Corpse.MoveToWorld(lr_Exit, Map.Malas); + } BaseCreature.TeleportPets(m, lr_Exit, Map.Malas); m.Location = lr_Exit; @@ -407,7 +471,9 @@ namespace Server.Engines.Doom public static void PlaySounds(Point3D location, int[] sounds) { foreach (var soundid in sounds) + { Effects.PlaySound(location, Map.Malas, soundid); + } } public static void PlayEffect(IEntity from, IEntity to, int itemid, int speed, bool explodes) @@ -449,7 +515,9 @@ namespace Server.Engines.Doom ); p.Acquire(); foreach (var state in from.Map.GetClientsInRange(from.Location)) + { state.Send(p); + } Packet.Release(p); } @@ -478,7 +546,9 @@ namespace Server.Engines.Doom m_Tiles = new List(); for (var i = 4; i < 9; i++) + { m_Tiles.Add(new LeverPuzzleRegion(this, TA[i])); + } m_LampRoom = new LampRoomRegion(this); Enabled = true; @@ -528,7 +598,10 @@ namespace Server.Engines.Doom PlaySounds(m_Player.Location, exp); PlayerSendASCII(m_Player, 1); // A speeding rock ... - if (AniSafe(m_Player)) m_Player.Animate(21, 10, 1, true, true, 0); + if (AniSafe(m_Player)) + { + m_Player.Animate(21, 10, 1, true, true, 0); + } } else if (Count == 3) { @@ -546,13 +619,18 @@ namespace Server.Engines.Doom var mobiles = m_IEntity.Map.GetMobilesInRange(m_IEntity.Location, 2).ToList(); for (var k = 0; k < mobiles.Count; k++) + { if (IsValidDamagable(mobiles[k]) && mobiles[k] != m_Player) { PlayEffect(m_Player, mobiles[k], Rock(), 8, true); DoDamage(mobiles[k], 25, 30, false); - if (mobiles[k].Player) POHMessage(mobiles[k], 2); // OUCH! + if (mobiles[k].Player) + { + POHMessage(mobiles[k], 2); // OUCH! + } } + } PlayEffect(m_Player, m_IEntity, Rock(), 8, false); } @@ -597,15 +675,25 @@ namespace Server.Engines.Doom if (ticks >= 71 || m_Controller.m_LampRoom.GetPlayerCount() == 0) { foreach (var mobile in mobiles) + { if (mobile?.Deleted == false && !mobile.IsDeadBondedPet) + { mobile.Kill(); + } + } + m_Controller.Enabled = true; Stop(); } else { - if (ticks % 12 == 0) level++; + if (ticks % 12 == 0) + { + level++; + } + foreach (var mobile in mobiles) + { if (IsValidDamagable(mobile)) { if (ticks % 2 == 0 && level == 5) @@ -613,20 +701,31 @@ namespace Server.Engines.Doom if (mobile.Player) { mobile.Say(1062092); - if (AniSafe(mobile)) mobile.Animate(32, 5, 1, true, false, 0); + if (AniSafe(mobile)) + { + mobile.Animate(32, 5, 1, true, false, 0); + } } DoDamage(mobile, 15, 20, true); } if (Utility.Random((int)(level & ~0xfffffffc), 3) == 3) + { mobile.ApplyPoison(mobile, PA2[level]); + } + if (ticks % 12 == 0 && level > 0 && mobile.Player) + { mobile.SendLocalizedMessage(PA[level][0], null, PA[level][1]); + } } + } for (var i = 0; i <= level; i++) + { SendLocationEffect(RandomPointIn(lr_Rect, -1), 0x36B0, Utility.Random(150, 200), 0, PA[level][2]); + } } } } diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs index 5865ba98d..3058073af 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs @@ -24,9 +24,14 @@ namespace Server.Engines.Doom public override void OnDoubleClick(Mobile m) { if (!m.InRange(GetWorldLocation(), 3)) + { return; + } + if (m_Controller.Enabled) + { return; + } if (m_Wanderer?.Alive != true) { @@ -45,7 +50,9 @@ namespace Server.Engines.Doom public override void OnAfterDelete() { if (m_Controller?.Deleted == false) + { m_Controller.Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -81,7 +88,9 @@ namespace Server.Engines.Doom public override void OnAfterDelete() { if (m_Controller?.Deleted == false) + { m_Controller.Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -135,7 +144,9 @@ namespace Server.Engines.Doom public override void OnAfterDelete() { if (m_Controller?.Deleted == false) + { m_Controller.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs index 8c2810923..3e1077f6d 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -32,16 +32,23 @@ namespace Server.Engines.Doom public override void OnEnter(Mobile m) { if (m == null || m is WandererOfTheVoid) + { return; + } if (m.AccessLevel > AccessLevel.Player) + { return; + } if (m_Controller.Successful != null) { if (m is PlayerMobile) { - if (m == m_Controller.Successful) return; + if (m == m_Controller.Successful) + { + return; + } } else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == m_Controller.Successful || bc.Summoned)) @@ -57,13 +64,18 @@ namespace Server.Engines.Doom public override void OnExit(Mobile m) { if (m != null && m == m_Controller.Successful) + { m_Controller.RemoveSuccessful(); + } } public override void OnDeath(Mobile m) { if (m?.Deleted != false || m is WandererOfTheVoid) + { return; + } + Timer kick = new LeverPuzzleController.LampRoomKickTimer(m); kick.Start(); } @@ -88,13 +100,17 @@ namespace Server.Engines.Doom public override void OnEnter(Mobile m) { if (m != null && m_Occupant == null && m is PlayerMobile && m.Alive) + { m_Occupant = m; + } } public override void OnExit(Mobile m) { if (m != null && m == m_Occupant) + { m_Occupant = null; + } } } } diff --git a/Projects/UOContent/Engines/Ethics/Core/Persistance.cs b/Projects/UOContent/Engines/Ethics/Core/Persistance.cs index f3c819c30..ad5032ba8 100644 --- a/Projects/UOContent/Engines/Ethics/Core/Persistance.cs +++ b/Projects/UOContent/Engines/Ethics/Core/Persistance.cs @@ -9,9 +9,13 @@ namespace Server.Ethics Movable = false; if (Instance?.Deleted != false) + { Instance = this; + } else + { base.Delete(); + } } public EthicsPersistance(Serial serial) @@ -29,7 +33,9 @@ namespace Server.Ethics writer.Write(0); // version for (var i = 0; i < Ethic.Ethics.Length; ++i) + { Ethic.Ethics[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -43,7 +49,9 @@ namespace Server.Ethics case 0: { for (var i = 0; i < Ethic.Ethics.Length; ++i) + { Ethic.Ethics[i].Deserialize(reader); + } break; } diff --git a/Projects/UOContent/Engines/Ethics/Core/Player.cs b/Projects/UOContent/Engines/Ethics/Core/Player.cs index 2eded0130..7aaf35538 100644 --- a/Projects/UOContent/Engines/Ethics/Core/Player.cs +++ b/Projects/UOContent/Engines/Ethics/Core/Player.cs @@ -69,10 +69,14 @@ namespace Server.Ethics get { if (m_Shield == DateTime.MinValue) + { return false; + } if (DateTime.UtcNow < m_Shield + TimeSpan.FromHours(1.0)) + { return true; + } FinishShield(); return false; @@ -90,19 +94,27 @@ namespace Server.Ethics if (inherit && mob is BaseCreature bc) { if (bc.Controlled) + { pm = bc.ControlMaster as PlayerMobile; + } else if (bc.Summoned) + { pm = bc.SummonMaster as PlayerMobile; + } } if (pm == null) + { return null; + } } var pl = pm.EthicPlayer; if (pl?.Ethic.IsEligible(pl.Mobile) == false) + { pm.EthicPlayer = pl = null; + } return pl; } @@ -120,13 +132,17 @@ namespace Server.Ethics public void CheckAttach() { if (Ethic.IsEligible(Mobile)) + { Attach(); + } } public void Attach() { if (Mobile is PlayerMobile mobile) + { mobile.EthicPlayer = this; + } Ethic.Players.Add(this); } @@ -134,7 +150,9 @@ namespace Server.Ethics public void Detach() { if (Mobile is PlayerMobile mobile) + { mobile.EthicPlayer = null; + } Ethic.Players.Remove(this); } diff --git a/Projects/UOContent/Engines/Ethics/Core/Power.cs b/Projects/UOContent/Engines/Ethics/Core/Power.cs index 8282ffaa6..afc4cc13b 100644 --- a/Projects/UOContent/Engines/Ethics/Core/Power.cs +++ b/Projects/UOContent/Engines/Ethics/Core/Power.cs @@ -11,7 +11,9 @@ namespace Server.Ethics public virtual bool CheckInvoke(Player from) { if (!from.Mobile.CheckAlive()) + { return false; + } if (from.Power < m_Definition.Power) { diff --git a/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs b/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs index 6db604873..91d82e580 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs @@ -59,9 +59,13 @@ namespace Server.Mobiles public override string ApplyNameSuffix(string suffix) { if (suffix.Length == 0) + { suffix = Ethic.Evil.Definition.Adjunct.String; + } else + { suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}"; + } return base.ApplyNameSuffix(suffix); } diff --git a/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholySteed.cs b/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholySteed.cs index d3d4e820d..53618887b 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholySteed.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Mobiles/UnholySteed.cs @@ -56,9 +56,13 @@ namespace Server.Mobiles public override string ApplyNameSuffix(string suffix) { if (suffix.Length == 0) + { suffix = Ethic.Evil.Definition.Adjunct.String; + } else + { suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}"; + } return base.ApplyNameSuffix(suffix); } @@ -66,9 +70,13 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (Ethic.Find(from) != Ethic.Evil) - from.SendMessage("You may not ride this steed."); + { + @from.SendMessage("You may not ride this steed."); + } else - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs index b916eb0ee..1050e74f3 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs @@ -24,10 +24,14 @@ namespace Server.Ethics.Evil private void Power_OnTarget(Mobile fromMobile, object obj, Player from) { if (!(obj is IPoint3D p)) + { return; + } if (!CheckInvoke(from)) + { return; + } var powerFunctioned = false; @@ -36,13 +40,19 @@ namespace Server.Ethics.Evil foreach (var mob in from.Mobile.GetMobilesInRange(6)) { if (mob == from.Mobile || !SpellHelper.ValidIndirectTarget(from.Mobile, mob)) + { continue; + } if (mob.GetStatMod("Holy Curse") != null) + { continue; + } if (!from.Mobile.CanBeHarmful(mob, false)) + { continue; + } from.Mobile.DoHarmful(mob, true); diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/SummonFamiliar.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/SummonFamiliar.cs index 972384619..1195910ec 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/SummonFamiliar.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/SummonFamiliar.cs @@ -17,7 +17,9 @@ namespace Server.Ethics.Evil public override void BeginInvoke(Player from) { if (from.Familiar?.Deleted == true) - from.Familiar = null; + { + @from.Familiar = null; + } if (from.Familiar != null) { diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs index 2b06ede51..59259b19e 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs @@ -51,7 +51,9 @@ namespace Server.Ethics.Evil if (canImbue) { if (!CheckInvoke(from)) + { return; + } item.Hue = Ethic.Evil.Definition.PrimaryHue; item.SavedFlags |= 0x200; diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySense.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySense.cs index dfbe5924a..736358d5d 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySense.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySense.cs @@ -29,13 +29,19 @@ namespace Server.Ethics.Evil var mob = pl.Mobile; if (mob == null || mob.Map != from.Mobile.Map || !mob.Alive) + { continue; + } if (!mob.InRange(from.Mobile, Math.Max(18, maxRange - pl.Power))) + { continue; + } if (primary == null || pl.Power > primary.Power) + { primary = pl; + } ++enemyCount; } diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySteed.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySteed.cs index 770d6b95e..f2fc51914 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySteed.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySteed.cs @@ -17,7 +17,9 @@ namespace Server.Ethics.Evil public override void BeginInvoke(Player from) { if (from.Steed?.Deleted == true) - from.Steed = null; + { + @from.Steed = null; + } if (from.Steed != null) { diff --git a/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs b/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs index 74d8906cf..0a8275be5 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs @@ -28,7 +28,9 @@ namespace Server.Ethics.Hero public override bool IsEligible(Mobile mob) { if (mob.Kills >= 5) + { return false; + } var fac = Faction.Find(mob); diff --git a/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs b/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs index 9beb71215..b07570a89 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs @@ -60,9 +60,13 @@ namespace Server.Mobiles public override string ApplyNameSuffix(string suffix) { if (suffix.Length == 0) + { suffix = Ethic.Hero.Definition.Adjunct.String; + } else + { suffix = $"{suffix} {Ethic.Hero.Definition.Adjunct.String}"; + } return base.ApplyNameSuffix(suffix); } diff --git a/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolySteed.cs b/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolySteed.cs index 30669520b..ff9d5735a 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolySteed.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Mobiles/HolySteed.cs @@ -56,9 +56,13 @@ namespace Server.Mobiles public override string ApplyNameSuffix(string suffix) { if (suffix.Length == 0) + { suffix = Ethic.Hero.Definition.Adjunct.String; + } else + { suffix = $"{suffix} {Ethic.Hero.Definition.Adjunct.String}"; + } return base.ApplyNameSuffix(suffix); } @@ -66,9 +70,13 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (Ethic.Find(from) != Ethic.Hero) - from.SendMessage("You may not ride this steed."); + { + @from.SendMessage("You may not ride this steed."); + } else - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs index 5d59ac64c..2ba2f04e7 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs @@ -24,10 +24,14 @@ namespace Server.Ethics.Hero private void Power_OnTarget(Mobile fromMobile, object obj, Player from) { if (!(obj is IPoint3D p)) + { return; + } if (!CheckInvoke(from)) + { return; + } var powerFunctioned = false; @@ -36,13 +40,19 @@ namespace Server.Ethics.Hero foreach (var mob in from.Mobile.GetMobilesInRange(6)) { if (mob != from.Mobile && SpellHelper.ValidIndirectTarget(from.Mobile, mob)) + { continue; + } if (mob.GetStatMod("Holy Bless") != null) + { continue; + } if (!from.Mobile.CanBeBeneficial(mob, false)) + { continue; + } from.Mobile.DoBeneficial(mob); diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs index b4e2a3f7f..9e85c4444 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs @@ -51,7 +51,9 @@ namespace Server.Ethics.Hero if (canImbue) { if (!CheckInvoke(from)) + { return; + } item.Hue = Ethic.Hero.Definition.PrimaryHue; item.SavedFlags |= 0x100; diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySense.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySense.cs index b0782ed15..1b51c9fb8 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySense.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySense.cs @@ -29,13 +29,19 @@ namespace Server.Ethics.Hero var mob = pl.Mobile; if (mob == null || mob.Map != from.Mobile.Map || !mob.Alive) + { continue; + } if (!mob.InRange(from.Mobile, Math.Max(18, maxRange - pl.Power))) + { continue; + } if (primary == null || pl.Power > primary.Power) + { primary = pl; + } ++enemyCount; } diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySteed.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySteed.cs index 386f71a9a..1c2c5a373 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySteed.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolySteed.cs @@ -17,7 +17,9 @@ namespace Server.Ethics.Hero public override void BeginInvoke(Player from) { if (from.Steed?.Deleted == true) - from.Steed = null; + { + @from.Steed = null; + } if (from.Steed != null) { diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/SummonFamiliar.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/SummonFamiliar.cs index f52741c00..1206dfe47 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/SummonFamiliar.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/SummonFamiliar.cs @@ -17,7 +17,9 @@ namespace Server.Ethics.Hero public override void BeginInvoke(Player from) { if (from.Familiar?.Deleted == true) - from.Familiar = null; + { + @from.Familiar = null; + } if (from.Familiar != null) { diff --git a/Projects/UOContent/Engines/Events/EventScheduler.cs b/Projects/UOContent/Engines/Events/EventScheduler.cs index 8c6e4551f..3a5d13fb5 100644 --- a/Projects/UOContent/Engines/Events/EventScheduler.cs +++ b/Projects/UOContent/Engines/Events/EventScheduler.cs @@ -62,7 +62,9 @@ namespace Server.Engines.Events var firstRun = new DateTime(now.Year, now.Month, now.Day, hour, min, 0); while (now > firstRun) + { firstRun += interval; + } ScheduleEvent( new EventScheduleEntry(e, firstRun, interval, TimeSpan.FromHours(hour) + TimeSpan.FromMinutes(min)) @@ -82,8 +84,12 @@ namespace Server.Engines.Events protected override void OnTick() { foreach (var entry in _schedule) + { if (entry.NextOccurrence <= DateTime.UtcNow) + { entry.Occur(); + } + } } } } diff --git a/Projects/UOContent/Engines/Factions/Core/Election.cs b/Projects/UOContent/Engines/Factions/Core/Election.cs index c61d4dd1d..fab0bec02 100644 --- a/Projects/UOContent/Engines/Factions/Core/Election.cs +++ b/Projects/UOContent/Engines/Factions/Core/Election.cs @@ -45,7 +45,9 @@ namespace Server.Factions var cd = new Candidate(reader); if (cd.Mobile != null) + { Candidates.Add(cd); + } } break; @@ -90,7 +92,9 @@ namespace Server.Factions var until = LastStateTime + period - DateTime.UtcNow; if (until < TimeSpan.Zero) + { until = TimeSpan.Zero; + } return until; } @@ -125,13 +129,17 @@ namespace Server.Factions writer.WriteEncodedInt(Candidates.Count); for (var i = 0; i < Candidates.Count; ++i) + { Candidates[i].Serialize(writer); + } } public void AddCandidate(Mobile mob) { if (IsCandidate(mob)) + { return; + } Candidates.Add(new Candidate(mob)); mob.SendLocalizedMessage(1010117); // You are now running for office. @@ -140,6 +148,7 @@ namespace Server.Factions public void RemoveVoter(Mobile mob) { if (CurrentState == ElectionState.Election) + { for (var i = 0; i < Candidates.Count; ++i) { var voters = Candidates[i].Voters; @@ -149,9 +158,12 @@ namespace Server.Factions var voter = voters[j]; if (voter.From == mob) + { voters.RemoveAt(j--); + } } } + } } public void RemoveCandidate(Mobile mob) @@ -159,7 +171,9 @@ namespace Server.Factions var cd = FindCandidate(mob); if (cd == null) + { return; + } Candidates.Remove(cd); mob.SendLocalizedMessage(1038031); @@ -211,8 +225,12 @@ namespace Server.Factions public Candidate FindCandidate(Mobile mob) { for (var i = 0; i < Candidates.Count; ++i) + { if (Candidates[i].Mobile == mob) + { return Candidates[i]; + } + } return null; } @@ -228,7 +246,9 @@ namespace Server.Factions var voter = voters[j]; if (voter.From == mob) + { return Candidates[i]; + } } } @@ -238,13 +258,19 @@ namespace Server.Factions public bool CanBeCandidate(Mobile mob) { if (IsCandidate(mob)) + { return false; + } if (Candidates.Count >= MaxCandidates) + { return false; + } if (CurrentState != ElectionState.Campaign) + { return false; // sanity.. + } var pl = PlayerState.Find(mob); @@ -267,7 +293,9 @@ namespace Server.Factions case ElectionState.Pending: { if (LastStateTime + PendingPeriod > DateTime.UtcNow) + { break; + } Faction.Broadcast(1038023); // Campaigning for the Faction Commander election has begun. @@ -279,7 +307,9 @@ namespace Server.Factions case ElectionState.Campaign: { if (LastStateTime + CampaignPeriod > DateTime.UtcNow) + { break; + } if (Candidates.Count == 0) { @@ -319,7 +349,9 @@ namespace Server.Factions case ElectionState.Election: { if (LastStateTime + VotingPeriod > DateTime.UtcNow) + { break; + } Faction.Broadcast(1038024); // The results for the Faction Commander election are in @@ -332,12 +364,16 @@ namespace Server.Factions var pl = PlayerState.Find(cd.Mobile); if (pl == null || pl.Faction != Faction) + { continue; + } // cd.CleanMuleVotes(); if (winner == null || cd.Votes > winner.Votes) + { winner = cd; + } } if (winner == null) @@ -371,9 +407,13 @@ namespace Server.Factions Candidate = candidate; if (From.NetState != null) + { Address = From.NetState.Address; + } else + { Address = IPAddress.None; + } Time = DateTime.UtcNow; } @@ -410,14 +450,18 @@ namespace Server.Factions var gameTime = TimeSpan.Zero; if (From is PlayerMobile mobile) + { gameTime = mobile.GameTime; + } var kp = 0; var pl = PlayerState.Find(From); if (pl != null) + { kp = pl.KillPoints; + } var sk = From.Skills.Total; @@ -466,7 +510,9 @@ namespace Server.Factions var voter = new Voter(reader, Mobile); if (voter.From != null) + { Voters.Add(voter); + } } break; @@ -479,7 +525,9 @@ namespace Server.Factions Voters = new List(mobs.Count); for (var i = 0; i < mobs.Count; ++i) + { Voters.Add(new Voter(mobs[i], Mobile)); + } break; } @@ -499,7 +547,9 @@ namespace Server.Factions var voter = Voters[i]; if ((int)voter.AcquireFields()[3] < 90) + { Voters.RemoveAt(i--); + } } } @@ -512,7 +562,9 @@ namespace Server.Factions writer.WriteEncodedInt(Voters.Count); for (var i = 0; i < Voters.Count; ++i) + { Voters[i].Serialize(writer); + } } } diff --git a/Projects/UOContent/Engines/Factions/Core/Faction.cs b/Projects/UOContent/Engines/Factions/Core/Faction.cs index 9f94b1411..e60f03a1a 100644 --- a/Projects/UOContent/Engines/Factions/Core/Faction.cs +++ b/Projects/UOContent/Engines/Factions/Core/Faction.cs @@ -102,7 +102,9 @@ namespace Server.Factions var members = Members; for (var i = 0; i < members.Count; ++i) + { members[i].Mobile.SendMessage(hue, text); + } } public void Broadcast(int number) @@ -110,7 +112,9 @@ namespace Server.Factions var members = Members; for (var i = 0; i < members.Count; ++i) + { members[i].Mobile.SendLocalizedMessage(number); + } } public void Broadcast(string format, params object[] args) @@ -132,7 +136,9 @@ namespace Server.Factions public void EndBroadcast(Mobile from, string text) { if (from.AccessLevel == AccessLevel.Player) + { State.RegisterBroadcast(); + } Broadcast(Definition.HueBroadcast, "{0} [Commander] {1} : {2}", from.Name, Definition.FriendlyName, text); } @@ -140,26 +146,42 @@ namespace Server.Factions public static void HandleAtrophy() { foreach (var f in Factions) + { if (!f.State.IsAtrophyReady) + { return; + } + } var activePlayers = new List(); foreach (var f in Factions) + { foreach (var ps in f.Members) + { if (ps.KillPoints > 0 && ps.IsActive) + { activePlayers.Add(ps); + } + } + } var distrib = 0; foreach (var f in Factions) + { distrib += f.State.CheckAtrophy(); + } if (activePlayers.Count == 0) + { return; + } for (var i = 0; i < distrib; ++i) + { activePlayers.RandomElement().KillPoints++; + } } public static void DistributePoints(int distrib) @@ -167,13 +189,23 @@ namespace Server.Factions var activePlayers = new List(); foreach (var f in Factions) + { foreach (var ps in f.Members) + { if (ps.KillPoints > 0 && ps.IsActive) + { activePlayers.Add(ps); + } + } + } if (activePlayers.Count > 0) + { for (var i = 0; i < distrib; ++i) + { activePlayers.RandomElement().KillPoints++; + } + } } public void BeginHonorLeadership(Mobile from) @@ -190,7 +222,9 @@ namespace Server.Factions var recvState = PlayerState.Find(recv); if (giveState == null) + { return; + } if (recvState == null || recvState.Faction != giveState.Faction) { @@ -236,7 +270,9 @@ namespace Server.Factions var items = type.IsSubclassOf(typeof(Item)); if (!(items || mobs)) + { return false; + } var eable = mob.Map.GetObjectsInRange(mob.Location, range, items, mobs); var isInstance = eable.Any(type.IsInstanceOfType); @@ -256,7 +292,9 @@ namespace Server.Factions public void RemovePlayerState(PlayerState pl) { if (pl == null || !Members.Contains(pl)) + { return; + } var killPoints = pl.KillPoints; @@ -278,7 +316,9 @@ namespace Server.Factions var pm = (PlayerMobile)pl.Mobile; if (pm == null) + { return; + } var mob = pl.Mobile; if (pm.FactionPlayerState == pl) @@ -289,24 +329,34 @@ namespace Server.Factions mob.Delta(MobileDelta.Noto); if (Election.IsCandidate(mob)) + { Election.RemoveCandidate(mob); + } if (pl.Finance != null) + { pl.Finance.Finance = null; + } if (pl.Sheriff != null) + { pl.Sheriff.Sheriff = null; + } Election.RemoveVoter(mob); if (Commander == mob) + { Commander = null; + } pm.ValidateEquipment(); } if (killPoints > 0) + { DistributePoints(killPoints); + } } public void RemoveMember(Mobile mob) @@ -314,7 +364,9 @@ namespace Server.Factions var pl = PlayerState.Find(mob); if (pl == null || !Members.Contains(pl)) + { return; + } var killPoints = pl.KillPoints; @@ -339,30 +391,44 @@ namespace Server.Factions Members.Remove(pl); if (mob is PlayerMobile mobile) + { mobile.FactionPlayerState = null; + } mob.InvalidateProperties(); mob.Delta(MobileDelta.Noto); if (Election.IsCandidate(mob)) + { Election.RemoveCandidate(mob); + } Election.RemoveVoter(mob); if (pl.Finance != null) + { pl.Finance.Finance = null; + } if (pl.Sheriff != null) + { pl.Sheriff.Sheriff = null; + } if (Commander == mob) + { Commander = null; + } if (mob is PlayerMobile playerMobile) + { playerMobile.ValidateEquipment(); + } if (killPoints > 0) + { DistributePoints(killPoints); + } } public void JoinGuilded(PlayerMobile mob, Guild guild) @@ -400,13 +466,17 @@ namespace Server.Factions private bool AlreadyHasCharInFaction(Mobile mob) { if (mob.Account is Account acct) + { for (var i = 0; i < acct.Length; ++i) { var c = acct[i]; if (Find(c) != null) + { return true; + } } + } return false; } @@ -414,7 +484,9 @@ namespace Server.Factions public static bool IsFactionBanned(Mobile mob) { if (!(mob.Account is Account acct)) + { return false; + } return acct.GetTag("FactionBanned") != null; } @@ -422,7 +494,9 @@ namespace Server.Factions public void OnJoinAccepted(Mobile mob) { if (!(mob is PlayerMobile pm)) + { return; // sanity + } var pl = PlayerState.Find(pm); @@ -485,7 +559,9 @@ namespace Server.Factions for (var i = 0; i < members.Count; ++i) { if (!(members[i] is PlayerMobile member)) + { continue; + } JoinGuilded(member, guild); } @@ -506,7 +582,9 @@ namespace Server.Factions public bool IsCommander(Mobile mob) { if (mob == null) + { return false; + } return mob.AccessLevel >= AccessLevel.GameMaster || mob == Commander; } @@ -518,10 +596,14 @@ namespace Server.Factions var pl = PlayerState.Find(mob); if (pl?.IsLeaving != true) + { return false; + } if (pl.Leaving + LeavePeriod >= DateTime.UtcNow) + { return false; + } mob.SendLocalizedMessage(1005163); // You have now quit your faction @@ -551,7 +633,9 @@ namespace Server.Factions var monoliths = BaseMonolith.Monoliths; for (var i = 0; i < monoliths.Count; ++i) + { monoliths[i].Sigil = null; + } var towns = Town.Towns; @@ -591,9 +675,13 @@ namespace Server.Factions var fi = list[j]; if (fi.Expiration == DateTime.MinValue) + { fi.Item.Delete(); + } else + { fi.Detach(); + } } } } @@ -603,7 +691,9 @@ namespace Server.Factions var monoliths = BaseMonolith.Monoliths; for (var i = 0; i < monoliths.Count; ++i) + { monoliths[i].Sigil = null; + } var towns = Town.Towns; @@ -639,7 +729,9 @@ namespace Server.Factions var playerStateList = new List(f.Members); for (var j = 0; j < playerStateList.Count; ++j) + { f.RemoveMember(playerStateList[j].Mobile); + } var factionItemList = new List(f.State.FactionItems); @@ -648,15 +740,21 @@ namespace Server.Factions var fi = factionItemList[j]; if (fi.Expiration == DateTime.MinValue) + { fi.Item.Delete(); + } else + { fi.Detach(); + } } var factionTrapList = new List(f.Traps); for (var j = 0; j < factionTrapList.Count; ++j) + { factionTrapList[j].Delete(); + } } } @@ -665,8 +763,12 @@ namespace Server.Factions var items = new List(); foreach (var item in World.Items.Values) + { if (item is IFactionItem && !(item is HoodedShroudOfShadows)) + { items.Add(item); + } + } var hues = new int[Factions.Count * 2]; @@ -684,16 +786,20 @@ namespace Server.Factions var fci = (IFactionItem)item; if (fci.FactionItemState != null || item.LootType != LootType.Blessed) + { continue; + } var isHued = false; for (var j = 0; j < hues.Length; ++j) + { if (item.Hue == hues[j]) { isHued = true; break; } + } if (isHued) { @@ -747,10 +853,14 @@ namespace Server.Factions var faction = stone.Faction; if (faction != null) - from.SendGump(new ElectionManagementGump(faction.Election)); + { + @from.SendGump(new ElectionManagementGump(faction.Election)); + } // from.SendGump( new Gumps.PropertiesGump( from, faction.Election ) ); else - from.SendMessage("That stone has no faction assigned."); + { + @from.SendMessage("That stone has no faction assigned."); + } } else { @@ -817,7 +927,9 @@ namespace Server.Factions if (sigil.LastMonolith?.Sigil == null) { if (sigil.LastStolen + Sigil.ReturnPeriod < DateTime.UtcNow) + { sigil.ReturnHome(); + } } else { @@ -848,7 +960,9 @@ namespace Server.Factions public int AwardSilver(Mobile mob, int silver) { if (silver <= 0) + { return 0; + } var tithed = silver * Tithe / 100; @@ -857,7 +971,9 @@ namespace Server.Factions silver = silver - tithed; if (silver > 0) + { mob.AddToBackpack(new Silver(silver)); + } return silver; } @@ -872,7 +988,9 @@ namespace Server.Factions var faction = factions[i]; if (smallest == null || faction.Members.Count < smallest.Members.Count) + { smallest = faction; + } } return smallest; @@ -887,7 +1005,9 @@ namespace Server.Factions var faction = factions[i]; if (faction.Members.Count > StabilityActivation) + { return true; + } } return false; @@ -896,15 +1016,21 @@ namespace Server.Factions public bool CanHandleInflux(int influx) { if (!StabilityActive()) + { return true; + } var smallest = FindSmallestFaction(); if (smallest == null) + { return true; // sanity + } if ((Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count) + { return false; + } return true; } @@ -946,7 +1072,9 @@ namespace Server.Factions ); if (killerState == null) + { return; + } if (victim is BaseCreature bc) { @@ -957,10 +1085,12 @@ namespace Server.Factions var silver = killerState.Faction.AwardSilver(killer, bc.FactionSilverWorth); if (silver > 0) + { killer?.SendLocalizedMessage( 1042748, silver.ToString("N0") ); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature. + } } if (bc.Map == Facet && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) @@ -980,13 +1110,19 @@ namespace Server.Factions var victimState = PlayerState.Find(victim); if (victimState == null) + { return; + } if (victim.Region.IsPartOf()) + { return; + } if (killer == victim || killerState.Faction != victimState.Faction) + { ApplySkillLoss(victim); + } if (killerState.Faction != victimState.Faction) { @@ -1002,7 +1138,9 @@ namespace Server.Factions var powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > 100 - killerEPL.Power) + { powerTransfer = 100 - killerEPL.Power; + } if (powerTransfer > 0) { @@ -1020,7 +1158,9 @@ namespace Server.Factions var award = Math.Max(victimState.KillPoints / 10, 1); if (award > 40) + { award = 40; + } if (victimState.CanGiveSilverTo(killer)) { @@ -1031,15 +1171,19 @@ namespace Server.Factions victimState.IsActive = true; if (Utility.Random(3) < 1) + { killerState.IsActive = true; + } var silver = killerState.Faction.AwardSilver(killer, award * 40); if (silver > 0) + { killer?.SendLocalizedMessage( 1042736, $"{silver:N0} silver\t{victim.Name}" ); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~! + } } victimState.KillPoints -= award; @@ -1066,7 +1210,9 @@ namespace Server.Factions var powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > 100 - killerEPL.Power) + { powerTransfer = 100 - killerEPL.Power; + } if (powerTransfer > 0) { @@ -1115,18 +1261,31 @@ namespace Server.Factions var pl = PlayerState.Find(mob); if (pl != null) + { return pl.Faction; + } if (inherit && mob is BaseCreature bc) { if (bc.Controlled) + { return Find(bc.ControlMaster); + } + if (bc.Summoned) + { return Find(bc.SummonMaster); + } + if (creatureAllegiances && bc is BaseFactionGuard guard) + { return guard.Faction; + } + if (creatureAllegiances) + { return bc.FactionAllegiance; + } } return null; @@ -1141,7 +1300,9 @@ namespace Server.Factions var faction = factions[i]; if (Insensitive.Equals(faction.Definition.FriendlyName, name)) + { return faction; + } } return null; @@ -1152,7 +1313,9 @@ namespace Server.Factions public static void ApplySkillLoss(Mobile mob) { if (InSkillLoss(mob)) + { return; + } var context = new SkillLossContext(); m_SkillLoss[mob] = context; @@ -1181,14 +1344,18 @@ namespace Server.Factions public static bool ClearSkillLoss(Mobile mob) { if (!m_SkillLoss.TryGetValue(mob, out var context)) + { return false; + } m_SkillLoss.Remove(mob); var mods = context.m_Mods; for (var i = 0; i < mods.Count; ++i) + { mob.RemoveSkillMod(mods[i]); + } context.m_Timer.Stop(); diff --git a/Projects/UOContent/Engines/Factions/Core/FactionItem.cs b/Projects/UOContent/Engines/Factions/Core/FactionItem.cs index 17eb4f68b..e8f9df85e 100644 --- a/Projects/UOContent/Engines/Factions/Core/FactionItem.cs +++ b/Projects/UOContent/Engines/Factions/Core/FactionItem.cs @@ -45,7 +45,9 @@ namespace Server.Factions get { if (Item?.Deleted != false) + { return true; + } return Expiration != DateTime.MinValue && DateTime.UtcNow >= Expiration; } @@ -59,15 +61,21 @@ namespace Server.Factions public void CheckAttach() { if (!HasExpired) + { Attach(); + } else + { Detach(); + } } public void Attach() { if (Item is IFactionItem item) + { item.FactionItemState = this; + } Faction?.State.FactionItems.Add(this); } @@ -75,10 +83,14 @@ namespace Server.Factions public void Detach() { if (Item is IFactionItem item) + { item.FactionItemState = null; + } if (Faction?.State.FactionItems.Contains(this) == true) + { Faction.State.FactionItems.Remove(this); + } } public void Serialize(IGenericWriter writer) @@ -118,7 +130,9 @@ namespace Server.Factions public static Item Imbue(Item item, Faction faction, bool expire, int hue) { if (!(item is IFactionItem)) + { return item; + } var state = Find(item); @@ -129,7 +143,9 @@ namespace Server.Factions } if (expire) + { state.StartExpiration(); + } item.Hue = hue; return item; diff --git a/Projects/UOContent/Engines/Factions/Core/FactionState.cs b/Projects/UOContent/Engines/Factions/Core/FactionState.cs index 73e958f66..64ce14176 100644 --- a/Projects/UOContent/Engines/Factions/Core/FactionState.cs +++ b/Projects/UOContent/Engines/Factions/Core/FactionState.cs @@ -42,7 +42,9 @@ namespace Server.Factions var time = reader.ReadDateTime(); if (i < m_LastBroadcasts.Length) + { m_LastBroadcasts[i] = time; + } } goto case 3; @@ -62,14 +64,18 @@ namespace Server.Factions m_Commander = reader.ReadMobile(); if (version < 5) + { LastAtrophy = DateTime.UtcNow; + } if (version < 4) { var time = reader.ReadDateTime(); if (m_LastBroadcasts.Length > 0) + { m_LastBroadcasts[0] = time; + } } Tithe = reader.ReadEncodedInt(); @@ -84,7 +90,9 @@ namespace Server.Factions var pl = new PlayerState(reader, m_Faction, Members); if (pl.Mobile != null) + { Members.Add(pl); + } } m_Faction.State = this; @@ -97,9 +105,13 @@ namespace Server.Factions var player = Members[i]; if (player.KillPoints <= 0) + { m_Faction.ZeroRankOffset = i; + } else + { player.RankIndex = i; + } } FactionItems = new List(); @@ -123,8 +135,12 @@ namespace Server.Factions var factionTrapCount = reader.ReadEncodedInt(); for (var i = 0; i < factionTrapCount; ++i) + { if (reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay()) + { Traps.Add(trap); + } + } } break; @@ -132,7 +148,9 @@ namespace Server.Factions } if (version < 1) + { Election = new Election(m_Faction); + } } public DateTime LastAtrophy { get; set; } @@ -142,8 +160,12 @@ namespace Server.Factions get { for (var i = 0; i < m_LastBroadcasts.Length; ++i) + { if (DateTime.UtcNow >= m_LastBroadcasts[i] + BroadcastPeriod) + { return true; + } + } return false; } @@ -175,10 +197,14 @@ namespace Server.Factions var pl = PlayerState.Find(m_Commander); if (pl?.Finance != null) + { pl.Finance.Finance = null; + } if (pl?.Sheriff != null) + { pl.Sheriff.Sheriff = null; + } } } } @@ -192,7 +218,9 @@ namespace Server.Factions public int CheckAtrophy() { if (DateTime.UtcNow < LastAtrophy + TimeSpan.FromHours(47.0)) + { return 0; + } var distrib = 0; LastAtrophy = DateTime.UtcNow; @@ -223,11 +251,13 @@ namespace Server.Factions public void RegisterBroadcast() { for (var i = 0; i < m_LastBroadcasts.Length; ++i) + { if (DateTime.UtcNow >= m_LastBroadcasts[i] + BroadcastPeriod) { m_LastBroadcasts[i] = DateTime.UtcNow; break; } + } } public void Serialize(IGenericWriter writer) @@ -239,7 +269,9 @@ namespace Server.Factions writer.WriteEncodedInt(m_LastBroadcasts.Length); for (var i = 0; i < m_LastBroadcasts.Length; ++i) + { writer.Write(m_LastBroadcasts[i]); + } Election.Serialize(writer); @@ -262,12 +294,16 @@ namespace Server.Factions writer.WriteEncodedInt(FactionItems.Count); for (var i = 0; i < FactionItems.Count; ++i) + { FactionItems[i].Serialize(writer); + } writer.WriteEncodedInt(Traps.Count); for (var i = 0; i < Traps.Count; ++i) + { writer.Write(Traps[i]); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Core/Generator.cs b/Projects/UOContent/Engines/Factions/Core/Generator.cs index cb637ddc5..839e1b1a5 100644 --- a/Projects/UOContent/Engines/Factions/Core/Generator.cs +++ b/Projects/UOContent/Engines/Factions/Core/Generator.cs @@ -17,12 +17,16 @@ namespace Server.Factions var factions = Faction.Factions; foreach (var faction in factions) + { Generate(faction); + } var towns = Town.Towns; foreach (var town in towns) + { Generate(town); + } } public static void Generate(Town town) @@ -39,7 +43,9 @@ namespace Server.Factions } if (!CheckExistance(def.TownStone, facet, typeof(TownStone))) + { new TownStone(town).MoveToWorld(def.TownStone, facet); + } } public static void Generate(Faction faction) @@ -51,17 +57,23 @@ namespace Server.Factions var stronghold = faction.Definition.Stronghold; if (!CheckExistance(stronghold.JoinStone, facet, typeof(JoinStone))) + { new JoinStone(faction).MoveToWorld(stronghold.JoinStone, facet); + } if (!CheckExistance(stronghold.FactionStone, facet, typeof(FactionStone))) + { new FactionStone(faction).MoveToWorld(stronghold.FactionStone, facet); + } for (var i = 0; i < stronghold.Monoliths.Length; ++i) { var monolith = stronghold.Monoliths[i]; if (!CheckExistance(monolith, facet, typeof(StrongholdMonolith))) + { new StrongholdMonolith(towns[i], faction).MoveToWorld(monolith, facet); + } } } diff --git a/Projects/UOContent/Engines/Factions/Core/Keywords.cs b/Projects/UOContent/Engines/Factions/Core/Keywords.cs index 21a6fb1c1..bb4988b94 100644 --- a/Projects/UOContent/Engines/Factions/Core/Keywords.cs +++ b/Projects/UOContent/Engines/Factions/Core/Keywords.cs @@ -27,138 +27,172 @@ namespace Server.Factions var keywords = e.Keywords; for (var i = 0; i < keywords.Length; ++i) + { switch (keywords[i]) { case 0x00E4: // *i wish to access the city treasury* { - var town = Town.FromRegion(from.Region); + var town = Town.FromRegion(@from.Region); - if (town?.IsFinance(from) != true || !from.Alive) + if (town?.IsFinance(@from) != true || !@from.Alive) + { break; + } - if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. - else if (town.Owner != null && from is PlayerMobile mobile) + if (FactionGump.Exists(@from)) + { + @from.SendLocalizedMessage(1042160); // You already have a faction menu open. + } + else if (town.Owner != null && @from is PlayerMobile mobile) + { mobile.SendGump(new FinanceGump(mobile, town.Owner, town)); + } break; } case 0x0ED: // *i am sheriff* { - var town = Town.FromRegion(from.Region); + var town = Town.FromRegion(@from.Region); - if (town?.IsSheriff(from) != true || !from.Alive) + if (town?.IsSheriff(@from) != true || !@from.Alive) + { break; + } - if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. + if (FactionGump.Exists(@from)) + { + @from.SendLocalizedMessage(1042160); // You already have a faction menu open. + } else if (town.Owner != null) - from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town)); + { + @from.SendGump(new SheriffGump((PlayerMobile)@from, town.Owner, town)); + } break; } case 0x00EF: // *you are fired* { - var town = Town.FromRegion(from.Region); + var town = Town.FromRegion(@from.Region); if (town == null) + { break; + } - if (town.IsFinance(from) || town.IsSheriff(from)) - town.BeginOrderFiring(from); + if (town.IsFinance(@from) || town.IsSheriff(@from)) + { + town.BeginOrderFiring(@from); + } break; } case 0x00E5: // *i wish to resign as finance minister* { - var pl = PlayerState.Find(from); + var pl = PlayerState.Find(@from); if (pl?.Finance != null) { pl.Finance.Finance = null; - from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister + @from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister } break; } case 0x00EE: // *i wish to resign as sheriff* { - var pl = PlayerState.Find(from); + var pl = PlayerState.Find(@from); if (pl?.Sheriff != null) { pl.Sheriff.Sheriff = null; - from.SendLocalizedMessage(1010270); // You have been fired as Sheriff + @from.SendLocalizedMessage(1010270); // You have been fired as Sheriff } break; } case 0x00E9: // *what is my faction term status* { - var pl = PlayerState.Find(from); + var pl = PlayerState.Find(@from); if (pl?.IsLeaving == true) { - if (Faction.CheckLeaveTimer(from)) + if (Faction.CheckLeaveTimer(@from)) + { break; + } var remaining = pl.Leaving + Faction.LeavePeriod - DateTime.UtcNow; if (remaining.TotalDays >= 1) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1042743, remaining.TotalDays .ToString("N0") ); // Your term of service will come to an end in ~1_DAYS~ days. + } else if (remaining.TotalHours >= 1) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1042741, remaining.TotalHours .ToString("N0") ); // Your term of service will come to an end in ~1_HOURS~ hours. + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1042742 ); // Your term of service will come to an end in less than one hour. + } } else if (pl != null) { - from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction. + @from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction. } break; } case 0x00EA: // *message faction* { - var faction = Faction.Find(from); + var faction = Faction.Find(@from); - if (faction?.IsCommander(from) != true) + if (faction?.IsCommander(@from) != true) + { break; + } - if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) - from.SendLocalizedMessage( + if (@from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) + { + @from.SendLocalizedMessage( 1010264 ); // The required time has not yet passed since the last message was sent + } else - faction.BeginBroadcast(from); + { + faction.BeginBroadcast(@from); + } break; } case 0x00EC: // *showscore* { - var pl = PlayerState.Find(from); + var pl = PlayerState.Find(@from); if (pl != null) + { Timer.DelayCall(ShowScore_Sandbox, pl); + } break; } case 0x0178: // i honor your leadership { - Faction.Find(from)?.BeginHonorLeadership(from); + Faction.Find(@from)?.BeginHonorLeadership(@from); break; } } + } } } } diff --git a/Projects/UOContent/Engines/Factions/Core/MerchantTitles.cs b/Projects/UOContent/Engines/Factions/Core/MerchantTitles.cs index f39e74ad7..51518d7b4 100644 --- a/Projects/UOContent/Engines/Factions/Core/MerchantTitles.cs +++ b/Projects/UOContent/Engines/Factions/Core/MerchantTitles.cs @@ -88,7 +88,9 @@ namespace Server.Factions var idx = (int)title - 1; if (idx >= 0 && idx < Info.Length) + { return Info[idx]; + } return null; } @@ -96,8 +98,12 @@ namespace Server.Factions public static bool HasMerchantQualifications(Mobile mob) { for (var i = 0; i < Info.Length; ++i) + { if (IsQualified(mob, Info[i])) + { return true; + } + } return false; } @@ -107,7 +113,9 @@ namespace Server.Factions public static bool IsQualified(Mobile mob, MerchantTitleInfo info) { if (mob == null || info == null) + { return false; + } return mob.Skills[info.Skill].Value >= info.Requirement; } diff --git a/Projects/UOContent/Engines/Factions/Core/Persistance.cs b/Projects/UOContent/Engines/Factions/Core/Persistance.cs index fd3c5b728..882ac72d0 100644 --- a/Projects/UOContent/Engines/Factions/Core/Persistance.cs +++ b/Projects/UOContent/Engines/Factions/Core/Persistance.cs @@ -7,9 +7,13 @@ namespace Server.Factions Movable = false; if (Instance?.Deleted == true) + { Instance = this; + } else + { base.Delete(); + } } public FactionPersistance(Serial serial) : base(serial) => Instance = this; @@ -56,6 +60,7 @@ namespace Server.Factions PersistedType type; while ((type = (PersistedType)reader.ReadEncodedInt()) != PersistedType.Terminator) + { switch (type) { case PersistedType.Faction: @@ -65,6 +70,7 @@ namespace Server.Factions new TownState(reader); break; } + } break; } diff --git a/Projects/UOContent/Engines/Factions/Core/PlayerState.cs b/Projects/UOContent/Engines/Factions/Core/PlayerState.cs index 04578c4a1..32fe5f820 100644 --- a/Projects/UOContent/Engines/Factions/Core/PlayerState.cs +++ b/Projects/UOContent/Engines/Factions/Core/PlayerState.cs @@ -208,11 +208,17 @@ namespace Server.Factions int percent; if (Owner.Count == 1) + { percent = 1000; + } else if (m_RankIndex == -1) + { percent = 0; + } else + { percent = (Faction.ZeroRankOffset - m_RankIndex) * 1000 / Faction.ZeroRankOffset; + } for (var i = 0; i < ranks.Length; i++) { @@ -250,9 +256,13 @@ namespace Server.Factions var sge = SilverGiven[i]; if (sge.IsExpired) + { SilverGiven.RemoveAt(i--); + } else if (sge.GivenTo == mob) + { return false; + } } return true; @@ -273,7 +283,9 @@ namespace Server.Factions public void Attach() { if (Mobile is PlayerMobile mobile) + { mobile.FactionPlayerState = this; + } } public void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Factions/Core/Reflector.cs b/Projects/UOContent/Engines/Factions/Core/Reflector.cs index 90e25cf74..2e298b4e2 100644 --- a/Projects/UOContent/Engines/Factions/Core/Reflector.cs +++ b/Projects/UOContent/Engines/Factions/Core/Reflector.cs @@ -16,7 +16,9 @@ namespace Server.Factions get { if (m_Towns == null) + { ProcessTypes(); + } return m_Towns; } @@ -27,7 +29,9 @@ namespace Server.Factions get { if (m_Factions == null) + { ProcessTypes(); + } return m_Factions; } @@ -65,12 +69,16 @@ namespace Server.Factions if (type.IsSubclassOf(typeof(Faction))) { if (Construct(type) is Faction faction) + { Faction.Factions.Add(faction); + } } else if (type.IsSubclassOf(typeof(Town))) { if (Construct(type) is Town town) + { Town.Towns.Add(town); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Core/StrongholdRegion.cs b/Projects/UOContent/Engines/Factions/Core/StrongholdRegion.cs index 9eafcfc73..f6a7374b6 100644 --- a/Projects/UOContent/Engines/Factions/Core/StrongholdRegion.cs +++ b/Projects/UOContent/Engines/Factions/Core/StrongholdRegion.cs @@ -22,10 +22,14 @@ namespace Server.Factions public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) { if (!base.OnMoveInto(m, d, newLocation, oldLocation)) + { return false; + } if (m.AccessLevel >= AccessLevel.Counselor || Contains(oldLocation)) + { return true; + } if (m is PlayerMobile pm && pm.DuelContext != null) { diff --git a/Projects/UOContent/Engines/Factions/Core/Town.cs b/Projects/UOContent/Engines/Factions/Core/Town.cs index 97a0abae5..78aa5933f 100644 --- a/Projects/UOContent/Engines/Factions/Core/Town.cs +++ b/Projects/UOContent/Engines/Factions/Core/Town.cs @@ -81,7 +81,9 @@ namespace Server.Factions var upkeep = 0; for (var i = 0; i < vendorLists.Count; ++i) + { upkeep += vendorLists[i].Vendors.Count * vendorLists[i].Definition.Upkeep; + } return upkeep; } @@ -95,7 +97,9 @@ namespace Server.Factions var upkeep = 0; for (var i = 0; i < guardLists.Count; ++i) + { upkeep += guardLists[i].Guards.Count * guardLists[i].Definition.Upkeep; + } return upkeep; } @@ -112,8 +116,12 @@ namespace Server.Factions var monoliths = BaseMonolith.Monoliths; foreach (var monolith in monoliths) + { if (monolith is TownMonolith townMonolith && townMonolith.Town == this) + { return townMonolith; + } + } return null; } @@ -136,7 +144,9 @@ namespace Server.Factions public static Town FromRegion(Region reg) { if (reg.Map != Faction.Facet) + { return null; + } var towns = Towns; @@ -145,7 +155,9 @@ namespace Server.Factions var town = towns[i]; if (reg.IsPartOf(town.Definition.Region)) + { return town; + } } return null; @@ -159,11 +171,17 @@ namespace Server.Factions // NOTE: Messages not OSI-accurate, intentional if (isFinance && isSheriff) // GM only + { type = "vendor or guard"; + } else if (isFinance) + { type = "vendor"; + } else if (isSheriff) + { type = "guard"; + } from.SendMessage("Target the {0} you wish to dismiss.", type); from.BeginTarget(12, false, TargetFlags.None, EndOrderFiring); @@ -176,18 +194,30 @@ namespace Server.Factions string type = null; if (isFinance && isSheriff) // GM only + { type = "vendor or guard"; + } else if (isFinance) + { type = "vendor"; + } else if (isSheriff) + { type = "guard"; + } if (obj is BaseFactionVendor vendor && vendor.Town == this && isFinance) + { vendor.Delete(); + } else if (obj is BaseFactionGuard guard && guard.Town == this && isSheriff) + { guard.Delete(); + } else - from.SendMessage("That is not a {0}!", type); + { + @from.SendMessage("That is not a {0}!", type); + } } public void StartIncomeTimer() @@ -207,7 +237,9 @@ namespace Server.Factions public void CheckIncome() { if (LastIncome + IncomePeriod > DateTime.UtcNow || Owner == null) + { return; + } ProcessIncome(); } @@ -240,10 +272,14 @@ namespace Server.Factions var list = new List(); for (var i = 0; i < VendorLists.Count; ++i) + { list.AddRange(VendorLists[i].Vendors); + } for (var i = 0; i < GuardLists.Count; ++i) + { list.AddRange(GuardLists[i].Guards); + } return list; } @@ -255,7 +291,9 @@ namespace Server.Factions GuardLists = new List(); for (var i = 0; i < defs.Length; ++i) + { GuardLists.Add(new GuardList(defs[i])); + } } public GuardList FindGuardList(Type type) @@ -267,7 +305,9 @@ namespace Server.Factions var guardList = guardLists[i]; if (guardList.Definition.Type == type) + { return guardList; + } } return null; @@ -280,7 +320,9 @@ namespace Server.Factions VendorLists = new List(); for (var i = 0; i < defs.Length; ++i) + { VendorLists.Add(new VendorList(defs[i])); + } } public VendorList FindVendorList(Type type) @@ -292,7 +334,9 @@ namespace Server.Factions var vendorList = vendorLists[i]; if (vendorList.Definition.Type == type) + { return vendorList; + } } return null; @@ -301,12 +345,16 @@ namespace Server.Factions public bool RegisterGuard(BaseFactionGuard guard) { if (guard == null) + { return false; + } var guardList = FindGuardList(guard.GetType()); if (guardList == null) + { return false; + } guardList.Guards.Add(guard); return true; @@ -315,15 +363,21 @@ namespace Server.Factions public bool UnregisterGuard(BaseFactionGuard guard) { if (guard == null) + { return false; + } var guardList = FindGuardList(guard.GetType()); if (guardList == null) + { return false; + } if (!guardList.Guards.Contains(guard)) + { return false; + } guardList.Guards.Remove(guard); return true; @@ -332,12 +386,16 @@ namespace Server.Factions public bool RegisterVendor(BaseFactionVendor vendor) { if (vendor == null) + { return false; + } var vendorList = FindVendorList(vendor.GetType()); if (vendorList == null) + { return false; + } vendorList.Vendors.Add(vendor); return true; @@ -346,15 +404,21 @@ namespace Server.Factions public bool UnregisterVendor(BaseFactionVendor vendor) { if (vendor == null) + { return false; + } var vendorList = FindVendorList(vendor.GetType()); if (vendorList == null) + { return false; + } if (!vendorList.Vendors.Contains(vendor)) + { return false; + } vendorList.Vendors.Remove(vendor); return true; @@ -384,7 +448,9 @@ namespace Server.Factions public void Capture(Faction f) { if (m_State.Owner == f) + { return; + } if (m_State.Owner == null) // going from unowned to owned { @@ -408,7 +474,9 @@ namespace Server.Factions var monolith = Monolith; if (monolith != null) + { monolith.Faction = f; + } var vendorLists = VendorLists; @@ -418,7 +486,9 @@ namespace Server.Factions var vendors = vendorList.Vendors; for (var j = vendors.Count - 1; j >= 0; --j) + { vendors[j].Delete(); + } } var guardLists = GuardLists; @@ -429,7 +499,9 @@ namespace Server.Factions var guards = guardList.Guards; for (var j = guards.Count - 1; j >= 0; --j) + { guards[j].Delete(); + } } ConstructGuardLists(); @@ -449,7 +521,9 @@ namespace Server.Factions var idx = reader.ReadEncodedInt() - 1; if (idx >= 0 && idx < Towns.Count) + { return Towns[idx]; + } return null; } @@ -463,7 +537,9 @@ namespace Server.Factions var town = towns[i]; if (Insensitive.Equals(town.Definition.FriendlyName, name)) + { return town; + } } return null; diff --git a/Projects/UOContent/Engines/Factions/Core/TownState.cs b/Projects/UOContent/Engines/Factions/Core/TownState.cs index 128a2db3a..540b51281 100644 --- a/Projects/UOContent/Engines/Factions/Core/TownState.cs +++ b/Projects/UOContent/Engines/Factions/Core/TownState.cs @@ -63,7 +63,9 @@ namespace Server.Factions var pl = PlayerState.Find(m_Sheriff); if (pl != null) + { pl.Sheriff = null; + } } m_Sheriff = value; @@ -73,7 +75,9 @@ namespace Server.Factions var pl = PlayerState.Find(m_Sheriff); if (pl != null) + { pl.Sheriff = Town; + } } } } @@ -88,7 +92,9 @@ namespace Server.Factions var pl = PlayerState.Find(m_Finance); if (pl != null) + { pl.Finance = null; + } } m_Finance = value; @@ -98,7 +104,9 @@ namespace Server.Factions var pl = PlayerState.Find(m_Finance); if (pl != null) + { pl.Finance = Town; + } } } } diff --git a/Projects/UOContent/Engines/Factions/Definitions/FactionItemDefinition.cs b/Projects/UOContent/Engines/Factions/Definitions/FactionItemDefinition.cs index 402dc2c9d..ba3399008 100644 --- a/Projects/UOContent/Engines/Factions/Definitions/FactionItemDefinition.cs +++ b/Projects/UOContent/Engines/Factions/Definitions/FactionItemDefinition.cs @@ -28,19 +28,32 @@ namespace Server.Factions if (item is BaseArmor armor) { if (CraftResources.GetType(armor.Resource) == CraftResourceType.Leather) + { return m_LeatherArmor; + } return m_MetalArmor; } if (item is BaseRanged) + { return m_RangedWeapon; + } + if (item is BaseWeapon) + { return m_Weapon; + } + if (item is BaseClothing) + { return m_Clothing; + } + if (item is SpellScroll) + { return m_Scroll; + } return null; } diff --git a/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs b/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs index f1045ec38..9e55b0b57 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/ElectionGump.cs @@ -72,7 +72,9 @@ namespace Server.Factions var pl = PlayerState.Find(m_From); if (pl == null || pl.Rank.Rank < Election.CandidateRank) + { AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office + } } break; @@ -110,14 +112,18 @@ namespace Server.Factions case 1: // vote { if (m_Election.State == ElectionState.Election) + { m_From.SendGump(new VoteGump(m_From, m_Election)); + } break; } case 2: // campaign { if (m_Election.CanBeCandidate(m_From)) + { m_Election.AddCandidate(m_From); + } break; } diff --git a/Projects/UOContent/Engines/Factions/Gumps/ElectionManagementGump.cs b/Projects/UOContent/Engines/Factions/Gumps/ElectionManagementGump.cs index 4a25cde0c..6d37be412 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/ElectionManagementGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/ElectionManagementGump.cs @@ -44,14 +44,22 @@ namespace Server.Factions AddHtml(14, 100, 420, 20, Color(Center("Voters"), LabelColor)); if (page > 0) + { AddButton(397, 104, 0x15E3, 0x15E7, 2); + } else + { AddImage(397, 104, 0x25EA); + } if ((page + 1) * 10 < candidate.Voters.Count) + { AddButton(414, 104, 0x15E1, 0x15E5, 3); + } else + { AddImage(414, 104, 0x25E6); + } AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor)); AddHtml(47, 120, 150, 20, Color("Name", LabelColor)); @@ -133,7 +141,9 @@ namespace Server.Factions var mob = cd.Mobile; if (mob == null) + { continue; + } AddButton(13, 118 + i * 20, 4005, 4007, 2 + i); AddHtml(47, 120 + i * 20, 150, 20, Color(mob.Name, LabelColor)); @@ -169,7 +179,9 @@ namespace Server.Factions bid -= 2; if (bid >= 0 && bid < m_Election.Candidates.Count) - from.SendGump(new ElectionManagementGump(m_Election, m_Election.Candidates[bid])); + { + @from.SendGump(new ElectionManagementGump(m_Election, m_Election.Candidates[bid])); + } } } else diff --git a/Projects/UOContent/Engines/Factions/Gumps/FactionGump.cs b/Projects/UOContent/Engines/Factions/Gumps/FactionGump.cs index f8266e5a1..f3e773b12 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/FactionGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/FactionGump.cs @@ -32,9 +32,13 @@ namespace Server.Factions public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll) { if (text?.Number > 0) + { AddHtmlLocalized(x, y, width, height, text.Number, back, scroll); + } else if (text?.String != null) + { AddHtml(x, y, width, height, text.String, back, scroll); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Gumps/FactionImbueGump.cs b/Projects/UOContent/Engines/Factions/Gumps/FactionImbueGump.cs index 10631f165..3f9c5df00 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/FactionImbueGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/FactionImbueGump.cs @@ -73,11 +73,17 @@ namespace Server.Factions int hue; if (m_Item is SpellScroll) + { hue = 0; + } else if (info.IsSwitched(1)) + { hue = m_Faction.Definition.HuePrimary; + } else + { hue = m_Faction.Definition.HueSecondary; + } FactionItem.Imbue(m_Item, m_Faction, true, hue); } @@ -89,11 +95,17 @@ namespace Server.Factions } if (m_Tool?.Deleted == false && m_Tool.UsesRemaining > 0) + { m_Mobile.SendGump(new CraftGump(m_Mobile, m_CraftSystem, m_Tool, m_Notice)); + } else if (m_Notice is string s) + { m_Mobile.SendMessage(s); + } else if (m_Notice is int i && i > 0) + { m_Mobile.SendLocalizedMessage(i); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Gumps/FactionStoneGump.cs b/Projects/UOContent/Engines/Factions/Gumps/FactionStoneGump.cs index 70bdceb93..7467c5e07 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/FactionStoneGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/FactionStoneGump.cs @@ -28,9 +28,13 @@ namespace Server.Factions AddHtmlLocalized(20, 80, 100, 20, 1011457); // Tithe rate : if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0) + { AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10); + } else + { AddHtml(125, 80, 350, 20, $"{faction.Tithe}%"); + } AddHtmlLocalized(20, 100, 100, 20, 1011458); // Traps placed : AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString()); @@ -66,9 +70,13 @@ namespace Server.Factions AddHtmlLocalized(55, 250, 300, 20, 1011461); // COMMANDER OPTIONS if (faction.IsCommander(from)) + { AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 6); + } else + { AddImage(20, 250, 4020); + } AddHtmlLocalized(55, 275, 300, 20, 1011426); // LEAVE THIS FACTION AddButton(20, 275, 4005, 4007, ToButtonID(0, 1)); @@ -142,9 +150,13 @@ namespace Server.Factions var info = infos[i]; if (MerchantTitles.IsQualified(from, info)) + { AddButton(20, 100 + i * 30, 4005, 4007, ToButtonID(1, i + 1)); + } else + { AddImage(20, 100 + i * 30, 4020); + } AddHtmlText(55, 100 + i * 30, 200, 20, info.Label, false, false); } @@ -161,9 +173,13 @@ namespace Server.Factions AddHtmlLocalized(20, 70, 120, 20, 1011457); // Tithe rate : if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0) + { AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10); + } else + { AddHtml(140, 70, 250, 20, $"{faction.Tithe}%"); + } AddHtmlLocalized(20, 100, 120, 20, 1011474); // Silver available : AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0")); // NOTE: Added 'N0' formatting @@ -173,9 +189,13 @@ namespace Server.Factions AddHtmlLocalized(55, 160, 200, 20, 1018301); // TRANSFER SILVER if (faction.Silver >= 10000) + { AddButton(20, 160, 4005, 4007, 0, GumpButtonType.Page, 7); + } else + { AddImage(20, 160, 4020); + } AddHtmlLocalized(55, 310, 100, 20, 1011447); // BACK AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); @@ -195,9 +215,13 @@ namespace Server.Factions AddHtmlText(55, 75 + i * 30, 200, 20, town.Definition.TownName, false, false); if (town.Owner == faction) + { AddButton(20, 75 + i * 30, 4005, 4007, ToButtonID(2, i)); + } else + { AddImage(20, 75 + i * 30, 4020); + } } AddHtmlLocalized(55, 310, 100, 20, 1011447); // BACK @@ -213,7 +237,9 @@ namespace Server.Factions for (var i = 0; i <= 10; ++i) { if (i == 5) + { y += 5; + } AddHtmlLocalized(55, y, 300, 20, 1011480 + i); AddButton(20, y, 4005, 4007, ToButtonID(3, i)); @@ -221,7 +247,9 @@ namespace Server.Factions y += 20; if (i == 5) + { y += 5; + } } AddHtmlLocalized(55, 310, 300, 20, 1011447); // BACK @@ -234,7 +262,9 @@ namespace Server.Factions public override void OnResponse(NetState sender, RelayInfo info) { if (!FromButtonID(info.ButtonID, out var type, out var index)) + { return; + } switch (type) { @@ -270,14 +300,18 @@ namespace Server.Factions m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed if (pl != null) + { pl.MerchantTitle = newTitle; + } } else if (MerchantTitles.IsQualified(m_From, mti)) { m_From.SendLocalizedMessage(mti.Assigned); if (pl != null) + { pl.MerchantTitle = newTitle; + } } } @@ -286,7 +320,9 @@ namespace Server.Factions case 2: // transfer silver { if (!m_Faction.IsCommander(m_From)) + { return; + } var towns = Town.Towns; @@ -295,6 +331,7 @@ namespace Server.Factions var town = towns[index]; if (town.Owner == m_Faction) + { if (m_Faction.Silver >= 10000) { m_Faction.Silver -= 10000; @@ -303,6 +340,7 @@ namespace Server.Factions // 10k in silver has been received by: m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}"); } + } } break; @@ -310,10 +348,14 @@ namespace Server.Factions case 3: // change tithe { if (!m_Faction.IsCommander(m_From)) + { return; + } if (index >= 0 && index <= 10) + { m_Faction.Tithe = index * 10; + } break; } diff --git a/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs b/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs index 44fc8fea4..ed6dc81f6 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/FinanceGump.cs @@ -59,9 +59,13 @@ namespace Server.Factions AddRadio(x, y, 208, 209, town.Tax == ofs, i + 1); if (ofs < 0) + { AddLabel(x + 35, y, 0x26, $"- {-ofs}%"); + } else + { AddLabel(x + 35, y, 0x12A, $"+ {ofs}%"); + } } AddRadio(20, 270, 208, 209, town.Tax == 0, 0); @@ -147,9 +151,13 @@ namespace Server.Factions AddHtmlText(55, 300, 200, 25, vendorList.Definition.Label, false, false); if (town.Silver >= vendorList.Definition.Price) + { AddButton(20, 300, 4005, 4007, ToButtonID(1, i)); + } else + { AddImage(20, 300, 4020); + } AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3); @@ -167,7 +175,9 @@ namespace Server.Factions } if (!FromButtonID(info.ButtonID, out var type, out var index)) + { return; + } switch (type) { @@ -180,48 +190,66 @@ namespace Server.Factions var switches = info.Switches; if (switches.Length == 0) + { break; + } var opt = switches[0]; var newTax = 0; if (opt >= 1 && opt <= m_PriceOffsets.Length) + { newTax = m_PriceOffsets[opt - 1]; + } if (m_Town.Tax == newTax) + { break; + } if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady) { var remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod); if (remaining.TotalMinutes < 4) + { m_From.SendLocalizedMessage( 1042165 ); // You must wait a short while before changing prices again. + } else if (remaining.TotalMinutes < 10) + { m_From.SendLocalizedMessage( 1042166 ); // You must wait several minutes before changing prices again. + } else if (remaining.TotalHours < 1) + { m_From.SendLocalizedMessage( 1042167 ); // You must wait up to an hour before changing prices again. + } else if (remaining.TotalHours < 4) + { m_From.SendLocalizedMessage( 1042168 ); // You must wait a few hours before changing prices again. + } else + { m_From.SendLocalizedMessage( 1042169 ); // You must wait several hours before changing prices again. + } } else { m_Town.Tax = newTax; if (m_From.AccessLevel == AccessLevel.Player) + { m_Town.LastTaxChange = DateTime.UtcNow; + } } break; diff --git a/Projects/UOContent/Engines/Factions/Gumps/HorseBreederGump.cs b/Projects/UOContent/Engines/Factions/Gumps/HorseBreederGump.cs index d8ca466a2..36e28c38f 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/HorseBreederGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/HorseBreederGump.cs @@ -41,15 +41,21 @@ namespace Server.Factions public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID != 1) + { return; + } if (Faction.Find(m_From) != m_Faction) + { return; + } var pack = m_From.Backpack; if (pack == null) + { return; + } var horse = new FactionWarHorse(m_Faction); diff --git a/Projects/UOContent/Engines/Factions/Gumps/JoinStoneGump.cs b/Projects/UOContent/Engines/Factions/Gumps/JoinStoneGump.cs index 2dd24856b..b3580fec9 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/JoinStoneGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/JoinStoneGump.cs @@ -27,9 +27,13 @@ namespace Server.Factions AddHtmlLocalized(20, 80, 100, 20, 1011457); // Tithe rate : if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0) + { AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10); + } else + { AddHtml(125, 80, 350, 20, $"{faction.Tithe}%"); + } AddButton(20, 400, 4005, 4007, 1); AddHtmlLocalized(55, 400, 200, 20, 1011425); // JOIN THIS FACTION @@ -41,7 +45,9 @@ namespace Server.Factions public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_Faction.OnJoinAccepted(m_From); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs b/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs index 969299faa..1824047e6 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs @@ -20,6 +20,7 @@ namespace Server.Factions AddBackground(10, 10, 250, 100, 3000); if (from.Guild is Guild guild && guild.Leader == from) + { AddHtmlLocalized( 20, 15, @@ -29,8 +30,11 @@ namespace Server.Factions true, true ); // Are you sure you want your entire guild to leave this faction? + } else + { AddHtmlLocalized(20, 15, 230, 60, 1018063, true, true); // Are you sure you want to leave this faction? + } AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE AddButton(20, 80, 4005, 4007, 1); @@ -54,12 +58,16 @@ namespace Server.Factions pl.Leaving = DateTime.UtcNow; if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod) + { m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days + } else + { m_From.SendMessage( "You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays ); + } } } else if (guild.Leader != m_From) @@ -82,12 +90,16 @@ namespace Server.Factions pl.Leaving = DateTime.UtcNow; if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod) + { mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days + } else + { mob.SendMessage( "Your guild will quit the faction in {0} days.", Faction.LeavePeriod.TotalDays ); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Gumps/VoteGump.cs b/Projects/UOContent/Engines/Factions/Gumps/VoteGump.cs index 8ecbaebd9..c69676c08 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/VoteGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/VoteGump.cs @@ -24,16 +24,22 @@ namespace Server.Factions AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false); if (canVote) + { AddHtmlLocalized(20, 60, 380, 20, 1011428); // VOTE FOR LEADERSHIP + } else + { AddHtmlLocalized(20, 60, 380, 20, 1038032); // You have already voted in this election. + } for (var i = 0; i < election.Candidates.Count; ++i) { var cd = election.Candidates[i]; if (canVote) + { AddButton(20, 100 + i * 20, 4005, 4007, i + 1); + } AddLabel(55, 100 + i * 20, 0, cd.Mobile.Name); AddLabel(300, 100 + i * 20, 0, cd.Votes.ToString()); @@ -52,12 +58,16 @@ namespace Server.Factions else { if (!m_Election.CanVote(m_From)) + { return; + } var index = info.ButtonID - 1; if (index >= 0 && index < m_Election.Candidates.Count) + { m_Election.Candidates[index].Voters.Add(new Voter(m_From, m_Election.Candidates[index].Mobile)); + } m_From.SendGump(new VoteGump(m_From, m_Election)); } diff --git a/Projects/UOContent/Engines/Factions/Items/BaseMonolith.cs b/Projects/UOContent/Engines/Factions/Items/BaseMonolith.cs index 13117bc90..b239d769b 100644 --- a/Projects/UOContent/Engines/Factions/Items/BaseMonolith.cs +++ b/Projects/UOContent/Engines/Factions/Items/BaseMonolith.cs @@ -28,15 +28,21 @@ namespace Server.Factions set { if (m_Sigil == value) + { return; + } m_Sigil = value; if (m_Sigil?.LastMonolith != null && m_Sigil.LastMonolith != this && m_Sigil.LastMonolith.Sigil == m_Sigil) + { m_Sigil.LastMonolith.Sigil = null; + } if (m_Sigil != null) + { m_Sigil.LastMonolith = this; + } UpdateSigil(); } @@ -81,7 +87,9 @@ namespace Server.Factions public virtual void UpdateSigil() { if (m_Sigil?.Deleted != false) + { return; + } m_Sigil.MoveToWorld(new Point3D(X, Y, Z + 18), Map); } diff --git a/Projects/UOContent/Engines/Factions/Items/BaseSystemController.cs b/Projects/UOContent/Engines/Factions/Items/BaseSystemController.cs index 854fa8839..e7bba10a3 100644 --- a/Projects/UOContent/Engines/Factions/Items/BaseSystemController.cs +++ b/Projects/UOContent/Engines/Factions/Items/BaseSystemController.cs @@ -20,7 +20,9 @@ namespace Server.Factions get { if (m_LabelNumber > 0) + { return m_LabelNumber; + } return DefaultLabelNumber; } diff --git a/Projects/UOContent/Engines/Factions/Items/FactionStone.cs b/Projects/UOContent/Engines/Factions/Items/FactionStone.cs index 147cf1147..f8efc8e16 100644 --- a/Projects/UOContent/Engines/Factions/Items/FactionStone.cs +++ b/Projects/UOContent/Engines/Factions/Items/FactionStone.cs @@ -35,7 +35,9 @@ namespace Server.Factions public override void OnDoubleClick(Mobile from) { if (m_Faction == null) + { return; + } if (!from.InRange(GetWorldLocation(), 2)) { @@ -54,11 +56,15 @@ namespace Server.Factions var pl = PlayerState.Find(mobile); if (pl?.IsLeaving == true) + { mobile.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction + } else + { mobile.SendGump(new FactionStoneGump(mobile, m_Faction)); + } } else if (existingFaction != null) { diff --git a/Projects/UOContent/Engines/Factions/Items/JoinStone.cs b/Projects/UOContent/Engines/Factions/Items/JoinStone.cs index b97f6b935..1c7faae0c 100644 --- a/Projects/UOContent/Engines/Factions/Items/JoinStone.cs +++ b/Projects/UOContent/Engines/Factions/Items/JoinStone.cs @@ -36,14 +36,22 @@ namespace Server.Factions public override void OnDoubleClick(Mobile from) { if (m_Faction == null) + { return; + } if (!from.InRange(GetWorldLocation(), 2)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. + { + @from.SendLocalizedMessage(1042160); // You already have a faction menu open. + } else if (Faction.Find(from) == null && from is PlayerMobile mobile) + { mobile.SendGump(new JoinStoneGump(mobile, m_Faction)); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/BloodRose.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/BloodRose.cs index 2c1d4b834..03757ed88 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/BloodRose.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/BloodRose.cs @@ -21,7 +21,10 @@ namespace Server { from.PlaySound(Utility.Random(0x3A, 3)); - if (from.Body.IsHuman && !from.Mounted) from.Animate(34, 5, 1, true, false, 0); + if (from.Body.IsHuman && !from.Mounted) + { + @from.Animate(34, 5, 1, true, false, 0); + } var amount = Utility.Dice(3, 3, 3); var time = Utility.RandomMinMax(5, 30); diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs index f43563b77..2d1f7e084 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs @@ -24,7 +24,10 @@ namespace Server from.PlaySound(0x2D6); - if (from.Body.IsHuman) from.Animate(34, 5, 1, true, false, 0); + if (from.Body.IsHuman) + { + @from.Animate(34, 5, 1, true, false, 0); + } from.FixedParticles(0x375A, 10, 15, 5011, EffectLayer.Head); from.PlaySound(0x1EB); diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs index 12f7db779..f4350ff83 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs @@ -44,7 +44,10 @@ namespace Server { var weight = 0; - foreach (var item in _items) weight += item.Weight; + foreach (var item in _items) + { + weight += item.Weight; + } weight = Utility.Random(weight); diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs index 0e5e63f99..71c96b54d 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs @@ -21,7 +21,10 @@ namespace Server public override bool Use(Mobile user) { - if (!Movable) return false; + if (!Movable) + { + return false; + } user.BeginTarget( 12, @@ -29,7 +32,10 @@ namespace Server TargetFlags.None, (from, obj, stormsEye) => { - if (!stormsEye.Movable || stormsEye.Deleted || !(obj is IPoint3D pt)) return; + if (!stormsEye.Movable || stormsEye.Deleted || !(obj is IPoint3D pt)) + { + return; + } SpellHelper.GetSurfaceTop(ref pt); @@ -37,7 +43,9 @@ namespace Server var facet = from.Map; if (facet?.CanFit(pt.X, pt.Y, pt.Z, 16, false, false) != true) + { return; + } stormsEye.Movable = false; @@ -95,9 +103,13 @@ namespace Server var damage = mob.Hits * 6 / 10; if (!mob.Player && damage < 10) + { damage = 10; + } else if (damage > 75) + { damage = 75; + } Effects.SendMovingEffect( new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs index 4397233f8..acf2e31a7 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs @@ -26,20 +26,25 @@ namespace Server var used = false; foreach (var mob in from.GetMobilesInRange(8)) - if (mob.Player && !mob.Alive && from.InLOS(mob)) + { + if (mob.Player && !mob.Alive && @from.InLOS(mob)) { - if (Faction.Find(mob) != ourFaction) continue; + if (Faction.Find(mob) != ourFaction) + { + continue; + } var house = BaseHouse.FindHouseAt(mob); - if (house?.IsFriend(from) != false || house.IsFriend(mob)) + if (house?.IsFriend(@from) != false || house.IsFriend(mob)) { Faction.ClearSkillLoss(mob); - mob.SendGump(new ResurrectGump(mob, from)); + mob.SendGump(new ResurrectGump(mob, @from)); used = true; } } + } if (used) { diff --git a/Projects/UOContent/Engines/Factions/Items/Sigil.cs b/Projects/UOContent/Engines/Factions/Items/Sigil.cs index 5e4c9e5b6..9fbf12b21 100644 --- a/Projects/UOContent/Engines/Factions/Items/Sigil.cs +++ b/Projects/UOContent/Engines/Factions/Items/Sigil.cs @@ -106,12 +106,16 @@ namespace Server.Factions get { if (!IsBeingCorrupted) + { return TimeSpan.Zero; + } var ts = CorruptionStart + CorruptionPeriod - DateTime.UtcNow; if (ts < TimeSpan.Zero) + { ts = TimeSpan.Zero; + } return ts; } @@ -124,11 +128,17 @@ namespace Server.Factions ItemID = m_Town?.Definition.SigilID ?? 0x1869; if (m_Town == null) + { AssignName(null); + } else if (IsCorrupted || IsPurifying) + { AssignName(m_Town.Definition.CorruptedSigilName); + } else + { AssignName(m_Town.Definition.SigilName); + } InvalidateProperties(); } @@ -138,16 +148,26 @@ namespace Server.Factions base.GetProperties(list); if (IsCorrupted) + { TextDefinition.AddTo(list, m_Corrupted.Definition.SigilControl); + } else + { list.Add(1042256); // This sigil is not corrupted. + } if (IsCorrupting) + { list.Add(1042257); // This sigil is in the process of being corrupted. + } else if (IsPurifying) + { list.Add(1042258); // This sigil has recently been corrupted, and is undergoing purification. + } else + { list.Add(1042259); // This sigil is not in the process of being corrupted. + } } public override void OnSingleClick(Mobile from) @@ -157,9 +177,13 @@ namespace Server.Factions if (IsCorrupted) { if (m_Corrupted.Definition.SigilControl.Number > 0) - LabelTo(from, m_Corrupted.Definition.SigilControl.Number); + { + LabelTo(@from, m_Corrupted.Definition.SigilControl.Number); + } else if (m_Corrupted.Definition.SigilControl.String != null) - LabelTo(from, m_Corrupted.Definition.SigilControl.String); + { + LabelTo(@from, m_Corrupted.Definition.SigilControl.String); + } } else { @@ -167,11 +191,17 @@ namespace Server.Factions } if (IsCorrupting) - LabelTo(from, 1042257); // This sigil is in the process of being corrupted. + { + LabelTo(@from, 1042257); // This sigil is in the process of being corrupted. + } else if (IsPurifying) - LabelTo(from, 1042258); // This sigil has been recently corrupted, and is undergoing purification. + { + LabelTo(@from, 1042258); // This sigil has been recently corrupted, and is undergoing purification. + } else - LabelTo(from, 1042259); // This sigil is not in the process of being corrupted. + { + LabelTo(@from, 1042259); // This sigil is not in the process of being corrupted. + } } public override bool CheckLift(Mobile from, Item item, ref LRReason reject) @@ -183,10 +213,14 @@ namespace Server.Factions private Mobile FindOwner(IEntity parent) { if (parent is Item item) + { return item.RootParent as Mobile; + } if (parent is Mobile mobile) + { return mobile; + } return null; } @@ -198,7 +232,9 @@ namespace Server.Factions var mob = FindOwner(parent); if (mob != null) + { mob.SolidHueOverride = OwnershipHue; + } } public override void OnRemoved(IEntity parent) @@ -208,7 +244,9 @@ namespace Server.Factions var mob = FindOwner(parent); if (mob != null) + { mob.SolidHueOverride = -1; + } } public override void OnDoubleClick(Mobile from) @@ -237,7 +275,9 @@ namespace Server.Factions private void Sigil_OnTarget(Mobile from, object obj) { if (Deleted || !IsChildOf(from.Backpack)) + { return; + } if (obj is Mobile) { @@ -296,14 +336,20 @@ namespace Server.Factions if (oldController == null) { if (m_Corrupted != newController) + { BeginCorrupting(newController); + } } else if (GraceStart > DateTime.MinValue && GraceStart + CorruptionGrace < DateTime.UtcNow) { if (m_Corrupted != newController) + { BeginCorrupting(newController); // grace time over, reset period + } else + { ClearCorrupting(); + } GraceStart = DateTime.MinValue; } @@ -394,7 +440,9 @@ namespace Server.Factions Update(); if (RootParent is Mobile mob) + { mob.SolidHueOverride = OwnershipHue; + } break; } @@ -406,10 +454,14 @@ namespace Server.Factions var monolith = LastMonolith; if (monolith == null && m_Town != null) + { monolith = m_Town.Monolith; + } if (monolith?.Deleted == false) + { monolith.Sigil = this; + } return monolith?.Deleted == false; } @@ -431,7 +483,9 @@ namespace Server.Factions public override void Delete() { if (ReturnHome()) + { return; + } base.Delete(); } diff --git a/Projects/UOContent/Engines/Factions/Items/Silver.cs b/Projects/UOContent/Engines/Factions/Items/Silver.cs index 684242207..e55388305 100644 --- a/Projects/UOContent/Engines/Factions/Items/Silver.cs +++ b/Projects/UOContent/Engines/Factions/Items/Silver.cs @@ -28,9 +28,15 @@ namespace Server.Factions public override int GetDropSound() { if (Amount <= 1) + { return 0x2E4; + } + if (Amount <= 5) + { return 0x2E5; + } + return 0x2E6; } diff --git a/Projects/UOContent/Engines/Factions/Items/TownStone.cs b/Projects/UOContent/Engines/Factions/Items/TownStone.cs index 222153116..59ee2489a 100644 --- a/Projects/UOContent/Engines/Factions/Items/TownStone.cs +++ b/Projects/UOContent/Engines/Factions/Items/TownStone.cs @@ -34,21 +34,33 @@ namespace Server.Factions public override void OnDoubleClick(Mobile from) { if (m_Town == null) + { return; + } var faction = Faction.Find(from); if (faction == null && from.AccessLevel < AccessLevel.GameMaster) + { return; // TODO: Message? + } if (m_Town.Owner == null || from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner) - from.SendLocalizedMessage(1010332); // Your faction does not control this town + { + @from.SendLocalizedMessage(1010332); // Your faction does not control this town + } else if (!m_Town.Owner.IsCommander(from)) - from.SendLocalizedMessage(1005242); // Only faction Leaders can use townstones + { + @from.SendLocalizedMessage(1005242); // Only faction Leaders can use townstones + } else if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. + { + @from.SendLocalizedMessage(1042160); // You already have a faction menu open. + } else if (from is PlayerMobile mobile) + { mobile.SendGump(new TownStoneGump(mobile, m_Town.Owner, m_Town)); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs b/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs index 7ad03e92b..bfa9bec01 100644 --- a/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs +++ b/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrap.cs @@ -57,7 +57,9 @@ namespace Server.Factions get { if (Core.AOS) + { return TimeSpan.FromDays(1.0); + } return TimeSpan.MaxValue; // no decay } @@ -66,7 +68,9 @@ namespace Server.Factions public override void OnTrigger(Mobile from) { if (!IsEnemy(from)) + { return; + } Conceal(); @@ -88,16 +92,20 @@ namespace Server.Factions { // TODO: Get real message if (from.Alive) + { Placer.SendMessage( "You have earned {0} silver pieces because {1} fell for your trap.", silverGiven, - from.Name + @from.Name ); + } else + { Placer.SendLocalizedMessage( 1042736, - $"{silverGiven} silver\t{from.Name}" + $"{silverGiven} silver\t{@from.Name}" ); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~! + } } victimState.OnGivenSilverTo(Placer); @@ -115,12 +123,20 @@ namespace Server.Factions public virtual int IsValidLocation(Point3D p, Map m) { if (m == null) + { return 502956; // You cannot place a trap on that. + } if (Core.ML) + { foreach (var item in m.GetItemsInRange(p, 0)) + { if (item is BaseFactionTrap trap && trap.Faction == Faction) + { return 1075263; // There is already a trap belonging to your faction at this location.; + } + } + } switch (AllowedPlacing) { @@ -129,7 +145,9 @@ namespace Server.Factions var region = Region.Find(p, m).GetRegion(); if (region != null && region.Faction == Faction) + { return 0; + } return 1010355; // This trap can only be placed in your stronghold } @@ -138,7 +156,9 @@ namespace Server.Factions var town = Town.FromRegion(Region.Find(p, m)); if (town != null) + { return 0; + } return 1010356; // This trap can only be placed in a faction town } @@ -147,7 +167,9 @@ namespace Server.Factions var town = Town.FromRegion(Region.Find(p, m)); if (town != null && town.Owner == Faction) + { return 0; + } return 1010357; // This trap can only be placed in a town your faction controls } @@ -161,9 +183,13 @@ namespace Server.Factions base.OnMovement(m, oldLocation); if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6)) + { if (Faction.Find(m) != null && (m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble()) + { PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap] + } + } } public void PrivateOverheadLocalizedMessage(Mobile to, int number, int hue, string name, string args) @@ -178,7 +204,9 @@ namespace Server.Factions var decayPeriod = DecayPeriod; if (decayPeriod == TimeSpan.MaxValue) + { return false; + } if (TimeOfPlacement + decayPeriod < DateTime.UtcNow) { @@ -203,7 +231,9 @@ namespace Server.Factions m_Concealing = null; if (!Deleted) + { Visible = false; + } } public override void Serialize(IGenericWriter writer) @@ -217,7 +247,9 @@ namespace Server.Factions writer.Write(TimeOfPlacement); if (Visible) + { BeginConceal(); + } } public override void Deserialize(IGenericReader reader) @@ -231,7 +263,9 @@ namespace Server.Factions TimeOfPlacement = reader.ReadDateTime(); if (Visible) + { BeginConceal(); + } CheckDecay(); } @@ -239,7 +273,9 @@ namespace Server.Factions public override void OnDelete() { if (Faction?.Traps.Contains(this) == true) + { Faction.Traps.Remove(this); + } base.OnDelete(); } @@ -247,18 +283,26 @@ namespace Server.Factions public virtual bool IsEnemy(Mobile mob) { if (mob.Hidden && mob.AccessLevel > AccessLevel.Player) + { return false; + } if (!mob.Alive || mob.IsDeadBondedPet) + { return false; + } var faction = Faction.Find(mob, true); if (faction == null && mob is BaseFactionGuard guard) + { faction = guard.Faction; + } if (faction == null) + { return false; + } return faction != Faction; } diff --git a/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs b/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs index df030b988..1617e7a95 100644 --- a/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs +++ b/Projects/UOContent/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs @@ -30,7 +30,9 @@ namespace Server.Factions m_Faction = value; if (m_Faction != null) + { Hue = m_Faction.Definition.HuePrimary; + } } } @@ -78,7 +80,9 @@ namespace Server.Factions var trap = Construct(from); if (trap == null) + { return; + } var message = trap.IsValidLocation(from.Location, from.Map); diff --git a/Projects/UOContent/Engines/Factions/Mobiles/FactionWarHorse.cs b/Projects/UOContent/Engines/Factions/Mobiles/FactionWarHorse.cs index d32319ada..e718b64bb 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/FactionWarHorse.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/FactionWarHorse.cs @@ -70,15 +70,23 @@ namespace Server.Factions var pl = PlayerState.Find(from); if (pl == null) - from.SendLocalizedMessage(1010366); // You cannot mount a faction war horse! + { + @from.SendLocalizedMessage(1010366); // You cannot mount a faction war horse! + } else if (pl.Faction != Faction) - from.SendLocalizedMessage(1010367); // You cannot ride an opposing faction's war horse! + { + @from.SendLocalizedMessage(1010367); // You cannot ride an opposing faction's war horse! + } else if (pl.Rank.Rank < 2) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1010368 ); // You must achieve a faction rank of at least two before riding a war horse! + } else - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs index 9ae3e89e8..42188bcff 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs @@ -86,7 +86,9 @@ namespace Server.Factions public void Register() { if (m_Town != null && m_Faction != null) + { m_Town.RegisterGuard(this); + } } public void Unregister() @@ -100,14 +102,18 @@ namespace Server.Factions var theirFaction = Faction.Find(m); if (theirFaction == null && m is BaseFactionGuard guard) + { theirFaction = guard.Faction; + } if (ourFaction != null && theirFaction != null && ourFaction != theirFaction) { var reactionType = Orders.GetReaction(theirFaction).Type; if (reactionType == ReactionType.Attack) + { return true; + } var list = m.Aggressed; @@ -116,7 +122,9 @@ namespace Server.Factions var ai = list[i]; if (ai.Defender is BaseFactionGuard bf && bf.Faction == ourFaction) + { return true; + } } } @@ -149,7 +157,9 @@ namespace Server.Factions public override bool HandlesOnSpeech(Mobile from) { if (InRange(from, ListenRange)) + { return true; + } return base.HandlesOnSpeech(from); } @@ -179,9 +189,13 @@ namespace Server.Factions }; if (def != null && def.Number > 0) + { Say(def.Number); + } else if (def?.String != null) + { Say(def.String); + } } Orders.SetReaction(faction, type); @@ -217,7 +231,9 @@ namespace Server.Factions else if (DateTime.UtcNow < m_OrdersEnd) { if (m_Town?.IsSheriff(from) != true || Town.FromRegion(Region) != m_Town) + { return; + } m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); @@ -225,13 +241,21 @@ namespace Server.Factions ReactionType newType = 0; if (Insensitive.Contains(e.Speech, "attack")) + { newType = ReactionType.Attack; + } else if (Insensitive.Contains(e.Speech, "warn")) + { newType = ReactionType.Warn; + } else if (Insensitive.Contains(e.Speech, "ignore")) + { newType = ReactionType.Ignore; + } else + { understood = false; + } if (understood) { @@ -277,7 +301,9 @@ namespace Server.Factions } if (!understood) + { Say(1042183); // I'm sorry, I don't understand your orders... + } } } } @@ -287,7 +313,9 @@ namespace Server.Factions base.GetProperties(list); if (m_Faction != null && Map == Faction.Facet) + { list.Add(1060846, m_Faction.Definition.PropName); // Guard: ~1_val~ + } } public override void OnSingleClick(Mobile from) @@ -318,7 +346,9 @@ namespace Server.Factions public void PackStrongPotions(int count) { for (var i = 0; i < count; ++i) + { PackStrongPotion(); + } } public void PackStrongPotion() @@ -334,7 +364,9 @@ namespace Server.Factions public void PackWeakPotions(int count) { for (var i = 0; i < count; ++i) + { PackWeakPotion(); + } } public void PackWeakPotion() @@ -409,7 +441,9 @@ namespace Server.Factions } if (randomHair) + { GenerateRandomHair(); + } } public override void Serialize(IGenericWriter writer) @@ -491,7 +525,9 @@ namespace Server.Factions Rider = reader.ReadMobile(); if (Rider == null) + { Delete(); + } } } } diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs index f40998be0..13bb028df 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -84,7 +84,9 @@ namespace Server.Factions var entry = combo.Entries[index]; if (entry.Spell == typeof(PoisonSpell) && targ.Poisoned) + { continue; + } if (entry.Chance > Utility.Random(100)) { @@ -122,10 +124,14 @@ namespace Server.Factions get { if (m_Bandage != null && m_Bandage.Timer == null) + { m_Bandage = null; + } if (m_Bandage == null) + { return TimeSpan.MaxValue; + } var ts = m_BandageStart + m_Bandage.Timer.Delay - DateTime.UtcNow; @@ -136,7 +142,9 @@ namespace Server.Factions } if (ts < TimeSpan.Zero) + { ts = TimeSpan.Zero; + } return ts; } @@ -149,7 +157,9 @@ namespace Server.Factions var pack = m_Guard.Backpack; if (pack == null) + { return false; + } if (m_Guard.Weapon is Item weapon && weapon.Parent == m_Guard && !(weapon is Fists)) { @@ -172,7 +182,9 @@ namespace Server.Factions m_Bandage = null; if (m_Guard.Backpack?.FindItemByType() == null) + { return false; + } m_Bandage = BandageContext.BeginHeal(m_Guard, m_Guard); m_BandageStart = DateTime.UtcNow; @@ -186,14 +198,18 @@ namespace Server.Factions var item = pack?.FindItemByType(type); if (item == null) + { return false; + } var requip = DequipWeapon(); item.OnDoubleClick(m_Guard); if (requip) + { EquipWeapon(); + } return true; } @@ -203,7 +219,9 @@ namespace Server.Factions var mod = mob.GetStatMod($"[Magic] {type} Offset"); if (mod == null) + { return 0; + } return mod.Offset; } @@ -233,7 +251,9 @@ namespace Server.Factions public Mobile FindDispelTarget(bool activeOnly) { if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel) + { return null; + } if (activeOnly) { @@ -252,7 +272,9 @@ namespace Server.Factions activePrio = m_Mobile.GetDistanceToSqrt(comb); if (activePrio <= 2) + { return active; + } } for (var i = 0; i < aggressed.Count; ++i) @@ -270,7 +292,9 @@ namespace Server.Factions activePrio = prio; if (activePrio <= 2) + { return active; + } } } } @@ -290,7 +314,9 @@ namespace Server.Factions activePrio = prio; if (activePrio <= 2) + { return active; + } } } } @@ -314,6 +340,7 @@ namespace Server.Factions } foreach (var m in m_Mobile.GetMobilesInRange(12)) + { if (m != m_Mobile && CanDispel(m)) { var prio = m_Mobile.GetDistanceToSqrt(m); @@ -330,6 +357,7 @@ namespace Server.Factions actPrio = prio; } } + } return active ?? inactive; } @@ -355,7 +383,9 @@ namespace Server.Factions if (!m_Mobile.InRange(m, m_Mobile.RangeFight)) { if (!MoveTo(m, true, 1)) + { OnFailedMove(); + } } else if (m_Mobile.InRange(m, m_Mobile.RangeFight - 1)) { @@ -385,7 +415,9 @@ namespace Server.Factions if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("My move is blocked, so I am going to attack {0}", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; @@ -400,18 +432,24 @@ namespace Server.Factions { if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen || m_Mobile.DisallowAllMoves) + { return; + } m_Mobile.Direction = d | Direction.Running; if (!DoMove(m_Mobile.Direction, true)) + { OnFailedMove(); + } } public override bool Think() { if (m_Mobile.Deleted) + { return false; + } var combatant = m_Guard.Combatant; @@ -448,7 +486,9 @@ namespace Server.Factions var dispelTarget = FindDispelTarget(true); if (m_Guard.Target != null && m_ReleaseTarget == DateTime.MinValue) + { m_ReleaseTarget = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + } if (m_Guard.Target != null && DateTime.UtcNow > m_ReleaseTarget) { @@ -460,9 +500,13 @@ namespace Server.Factions { if (m_Guard.Map == toHarm.Map && (targ.Range < 0 || m_Guard.InRange(toHarm, targ.Range)) && m_Guard.CanSee(toHarm) && m_Guard.InLOS(toHarm)) + { targ.Invoke(m_Guard, toHarm); + } else if ((targ as ISpellTarget)?.Spell is DispelSpell) + { targ.Cancel(m_Guard, TargetCancelType.Canceled); + } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { @@ -479,7 +523,9 @@ namespace Server.Factions if (dispelTarget != null) { if (Action != ActionType.Combat) + { Action = ActionType.Combat; + } m_Guard.Warmode = true; @@ -488,7 +534,9 @@ namespace Server.Factions else if (combatant != null) { if (Action != ActionType.Combat) + { Action = ActionType.Combat; + } m_Guard.Warmode = true; @@ -499,17 +547,23 @@ namespace Server.Factions Mobile toFollow = null; if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow) + { toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff; + } if (toFollow != null && toFollow.Map == m_Guard.Map && toFollow.InRange(m_Guard, m_Guard.RangePerception * 3) && Town.FromRegion(toFollow.Region) == m_Guard.Town) { if (Action != ActionType.Combat) + { Action = ActionType.Combat; + } if (m_Mobile.CurrentSpeed != m_Mobile.ActiveSpeed) + { m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed; + } m_Guard.Warmode = true; @@ -518,10 +572,14 @@ namespace Server.Factions else { if (Action != ActionType.Wander) + { Action = ActionType.Wander; + } if (m_Mobile.CurrentSpeed != m_Mobile.PassiveSpeed) + { m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed; + } m_Guard.Warmode = false; @@ -531,7 +589,9 @@ namespace Server.Factions else { if (Action != ActionType.Wander) + { Action = ActionType.Wander; + } m_Guard.Warmode = false; } @@ -541,7 +601,9 @@ namespace Server.Factions var ts = TimeUntilBandage; if (ts == TimeSpan.MaxValue) + { StartBandage(); + } } var spell = m_Mobile.Spell as Spell; @@ -560,9 +622,13 @@ namespace Server.Factions m_Guard.HitsMax - m_Guard.Hits > Utility.Random(250)) { if (IsAllowed(GuardAI.Bless)) + { spell = new CureSpell(m_Guard); + } else + { UseItemByType(typeof(BaseCurePotion)); + } } } else if (IsDamaged && m_Guard.HitsMax - m_Guard.Hits > Utility.Random(200)) @@ -579,10 +645,14 @@ namespace Server.Factions else if (IsAllowed(GuardAI.Bless)) { if (m_Guard.Mana >= 11 && m_Guard.Hits + 30 < m_Guard.HitsMax) + { spell = new GreaterHealSpell(m_Guard); + } else if (m_Guard.Hits + 10 < m_Guard.HitsMax && (m_Guard.Mana < 11 || m_Guard.NextCombatTime - Core.TickCount > 2000)) + { spell = new HealSpell(m_Guard); + } } else if (m_Guard.CanBeginAction()) { @@ -593,9 +663,13 @@ namespace Server.Factions (IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse))) { if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && Utility.Random(100) < 40) + { spell = new ParalyzeSpell(m_Guard); + } else + { spell = new DispelSpell(m_Guard); + } } if (combatant != null) @@ -628,7 +702,9 @@ namespace Server.Factions m_Combo = null; if (m_Guard.Mana >= ManaReserve + 40) + { spell = RandomOffenseSpell(); + } } } else if (m_Guard.Mana >= ManaReserve + 40) @@ -646,27 +722,41 @@ namespace Server.Factions var types = new List(); if (strMod <= 0) + { types.Add(typeof(StrengthSpell)); + } if (dexMod <= 0 && IsAllowed(GuardAI.Melee)) + { types.Add(typeof(AgilitySpell)); + } if (intMod <= 0 && IsAllowed(GuardAI.Magic)) + { types.Add(typeof(CunningSpell)); + } if (IsAllowed(GuardAI.Bless)) { if (types.Count > 1) + { spell = new BlessSpell(m_Guard); + } else if (types.Count == 1) + { spell = ActivatorUtil.CreateInstance(types[0], m_Guard, null) as Spell; + } } else if (types.Count > 0) { if (types[0] == typeof(StrengthSpell)) + { UseItemByType(typeof(BaseStrengthPotion)); + } else if (types[0] == typeof(AgilitySpell)) + { UseItemByType(typeof(BaseAgilityPotion)); + } } } @@ -686,18 +776,28 @@ namespace Server.Factions var types = new List(); if (strMod >= 0) + { types.Add(typeof(WeakenSpell)); + } if (dexMod >= 0 && IsAllowed(GuardAI.Melee)) + { types.Add(typeof(ClumsySpell)); + } if (intMod >= 0 && IsAllowed(GuardAI.Magic)) + { types.Add(typeof(FeeblemindSpell)); + } if (types.Count > 1) + { spell = new CurseSpell(m_Guard); + } else if (types.Count == 1) + { spell = (Spell)ActivatorUtil.CreateInstance(types[0], m_Guard, null); + } } } } @@ -707,23 +807,35 @@ namespace Server.Factions Type type = null; if (spell is GreaterHealSpell) + { type = typeof(BaseHealPotion); + } else if (spell is CureSpell) + { type = typeof(BaseCurePotion); + } else if (spell is StrengthSpell) + { type = typeof(BaseStrengthPotion); + } else if (spell is AgilitySpell) + { type = typeof(BaseAgilityPotion); + } if (type == typeof(BaseHealPotion) && !m_Guard.CanBeginAction(type)) + { type = null; + } if (type != null && m_Guard.Target == null && UseItemByType(type)) { if (spell is GreaterHealSpell) { if (m_Guard.Hits + 30 > m_Guard.HitsMax && m_Guard.Hits + 10 < m_Guard.HitsMax) + { spell = new HealSpell(m_Guard); + } } else { @@ -737,7 +849,9 @@ namespace Server.Factions } if (spell?.Cast() != true) + { EquipWeapon(); + } } else if (spell?.State == SpellState.Sequencing) { diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/Orders.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/Orders.cs index 0cd0c4051..423f7b1a5 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/Orders.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/Orders.cs @@ -83,7 +83,9 @@ namespace Server.Factions.AI m_Reactions = new List(count); for (var i = 0; i < count; ++i) + { m_Reactions.Add(new Reaction(reader)); + } Movement = (MovementType)reader.ReadEncodedInt(); @@ -107,7 +109,9 @@ namespace Server.Factions.AI reaction = m_Reactions[i]; if (reaction.Faction == faction) + { return reaction; + } } reaction = new Reaction( @@ -135,7 +139,9 @@ namespace Server.Factions.AI writer.WriteEncodedInt(m_Reactions.Count); for (var i = 0; i < m_Reactions.Count; ++i) + { m_Reactions[i].Serialize(writer); + } writer.WriteEncodedInt((int)Movement); } diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs index 37d47264b..fcf15abd8 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs @@ -56,13 +56,17 @@ namespace Server.Factions public void Register() { if (m_Town != null && m_Faction != null) + { m_Town.RegisterVendor(this); + } } public override bool OnMoveOver(Mobile m) { if (Core.ML) + { return true; + } return base.OnMoveOver(m); } diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs index 9af80bffe..8a86fca55 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs @@ -55,7 +55,9 @@ namespace Server.Factions public InternalBuyInfo() { for (var i = 0; i < 5; ++i) + { Add(new GenericBuyInfo(typeof(Board), 3, 20, 0x1BD7, 0)); + } } } diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs index 4dcb68b14..df7944311 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs @@ -56,7 +56,9 @@ namespace Server.Factions public InternalBuyInfo() { for (var i = 0; i < 5; ++i) + { Add(new GenericBuyInfo(typeof(Bottle), 5, 20, 0xF0E, 0)); + } } } diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs index feae0c653..15ea35068 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs @@ -36,16 +36,22 @@ namespace Server.Factions public override void VendorBuy(Mobile from) { if (Faction == null || Faction.Find(from, true) != Faction) + { PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1042201, - from.NetState + @from.NetState ); // You are not in my faction, I cannot sell you a horse! + } else if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. + { + @from.SendLocalizedMessage(1042160); // You already have a faction menu open. + } else if (from is PlayerMobile mobile) + { mobile.SendGump(new HorseBreederGump(mobile, Faction)); + } } public override void VendorSell(Mobile from) diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs index b2ffd9dd2..8f87055b0 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs @@ -57,7 +57,9 @@ namespace Server.Factions public InternalBuyInfo() { for (var i = 0; i < 5; ++i) + { Add(new GenericBuyInfo(typeof(IronOre), 16, 20, 0x19B8, 0, m_FixedSizeArgs)); + } } } diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs index 1583c8955..8b9f517d8 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestBank.cs @@ -52,11 +52,16 @@ namespace Server.Engines.Harvest public void CheckRespawn() { if (m_Current == m_Maximum || m_NextRespawn > DateTime.UtcNow) + { return; + } m_Current = m_Maximum; - if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.Random(Definition.VeinWeights)); + if (Definition.RandomizeVeins) + { + m_DefaultVein = Definition.GetVeinFrom(Utility.Random(Definition.VeinWeights)); + } m_Vein = m_DefaultVein; } @@ -75,7 +80,9 @@ namespace Server.Engines.Harvest var minutes = min + rnd * (max - min); if (Definition.RaceBonus && from.Race == Race.Elf) // def.RaceBonus = Core.ML - minutes *= .75; // 25% off the time. + { + minutes *= .75; // 25% off the time. + } m_NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(minutes); } @@ -85,7 +92,9 @@ namespace Server.Engines.Harvest } if (m_Current < 0) + { m_Current = 0; + } } } } diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestDefinition.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestDefinition.cs index bfe635d88..ce5760a06 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestDefinition.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestDefinition.cs @@ -84,26 +84,36 @@ namespace Server.Engines.Harvest public void SendMessageTo(Mobile from, TextDefinition message) { if (message.Number > 0) - from.SendLocalizedMessage(message.Number); + { + @from.SendLocalizedMessage(message.Number); + } else - from.SendMessage(message); + { + @from.SendMessage(message); + } } public HarvestBank GetBank(Map map, int x, int y) { if (map == null || map == Map.Internal) + { return null; + } x /= BankWidth; y /= BankHeight; if (!Banks.TryGetValue(map, out var banks)) + { Banks[map] = banks = new Dictionary(); + } var key = new Point2D(x, y); if (!banks.TryGetValue(key, out var bank)) + { banks[key] = bank = new HarvestBank(this, GetVeinAt(map, x, y)); + } return bank; } @@ -111,9 +121,14 @@ namespace Server.Engines.Harvest public HarvestVein GetVeinAt(Map map, int x, int y) { if (Veins.Length == 1) + { return Veins[0]; + } - if (RandomizeVeins) return GetVeinFrom(Utility.Random(1000u)); + if (RandomizeVeins) + { + return GetVeinFrom(Utility.Random(1000u)); + } // TODO: Introduce pulling primes from a config and writing them if they don't exist to the config var random = new Xoshiro256PlusPlus((ulong)(x * 17 + y * 11 + map.MapID * 3)); @@ -123,12 +138,16 @@ namespace Server.Engines.Harvest public HarvestVein GetVeinFrom(uint randomValue) { if (Veins.Length == 1) + { return Veins[0]; + } for (var i = 0; i < Veins.Length; ++i) { if (randomValue <= Veins[i].VeinChance) + { return Veins[i]; + } randomValue -= Veins[i].VeinChance; } @@ -139,14 +158,18 @@ namespace Server.Engines.Harvest public BonusHarvestResource GetBonusResource() { if (BonusResources == null) + { return null; + } var randomValue = Utility.RandomDouble() * 100; for (var i = 0; i < BonusResources.Length; ++i) { if (randomValue <= BonusResources[i].Chance) + { return BonusResources[i]; + } randomValue -= BonusResources[i].Chance; } @@ -161,7 +184,9 @@ namespace Server.Engines.Harvest var contains = false; for (var i = 0; !contains && i < Tiles.Length; i += 2) + { contains = tileID >= Tiles[i] && tileID <= Tiles[i + 1]; + } return contains; } @@ -169,7 +194,9 @@ namespace Server.Engines.Harvest var dist = -1; for (var i = 0; dist < 0 && i < Tiles.Length; ++i) + { dist = Tiles[i] - tileID; + } return dist == 0; } diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestResource.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestResource.cs index 96f5ef480..4fdb5b1b4 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestResource.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestResource.cs @@ -26,9 +26,13 @@ namespace Server.Engines.Harvest public void SendSuccessTo(Mobile m) { if (SuccessMessage is int messageInt) + { m.SendLocalizedMessage(messageInt); + } else + { m.SendMessage(SuccessMessage.ToString()); + } } } } diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestSoundTimer.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestSoundTimer.cs index 64806f72d..c9fa4fa29 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestSoundTimer.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestSoundTimer.cs @@ -29,7 +29,9 @@ namespace Server.Engines.Harvest m_System.DoHarvestingSound(m_From, m_Tool, m_Definition, m_ToHarvest); if (m_Last) + { m_System.FinishHarvesting(m_From, m_Tool, m_Definition, m_ToHarvest, m_Locked); + } } } } diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestSystem.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestSystem.cs index 0dc2c1337..5c16103ac 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestSystem.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestSystem.cs @@ -18,7 +18,9 @@ namespace Server.Engines.Harvest var wornOut = tool?.Deleted != false || (tool as IUsesRemaining)?.UsesRemaining <= 0; if (wornOut) - from.SendLocalizedMessage(1044038); // You have worn out your tool! + { + @from.SendLocalizedMessage(1044038); // You have worn out your tool! + } return !wornOut; } @@ -33,7 +35,9 @@ namespace Server.Engines.Harvest var inRange = from.Map == map && from.InRange(loc, def.MaxRange); if (!inRange) - def.SendMessageTo(from, timed ? def.TimedOutOfRangeMessage : def.OutOfRangeMessage); + { + def.SendMessageTo(@from, timed ? def.TimedOutOfRangeMessage : def.OutOfRangeMessage); + } return inRange; } @@ -44,7 +48,9 @@ namespace Server.Engines.Harvest var available = bank?.Current >= def.ConsumedPerHarvest; if (!available) - def.SendMessageTo(from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage); + { + def.SendMessageTo(@from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage); + } return available; } @@ -66,7 +72,9 @@ namespace Server.Engines.Harvest public virtual bool BeginHarvesting(Mobile from, Item tool) { if (!CheckHarvest(from, tool)) + { return false; + } from.Target = new HarvestTarget(tool, this); return true; @@ -77,7 +85,9 @@ namespace Server.Engines.Harvest from.EndAction(locked); if (!CheckHarvest(from, tool)) + { return; + } if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc)) { @@ -92,27 +102,43 @@ namespace Server.Engines.Harvest } if (!CheckRange(from, tool, def, map, loc, true)) + { return; + } + if (!CheckResources(from, tool, def, map, loc, true)) + { return; + } + if (!CheckHarvest(from, tool, def, toHarvest)) + { return; + } if (SpecialHarvest(from, tool, def, map, loc)) + { return; + } var bank = def.GetBank(map, loc.X, loc.Y); if (bank == null) + { return; + } var vein = bank.Vein; if (vein != null) - vein = MutateVein(from, tool, def, bank, toHarvest, vein); + { + vein = MutateVein(@from, tool, def, bank, toHarvest, vein); + } if (vein == null) + { return; + } var primary = vein.PrimaryResource; var fallback = vein.FallbackResource; @@ -128,7 +154,9 @@ namespace Server.Engines.Harvest type = GetResourceType(from, tool, def, map, loc, resource); if (type != null) - type = MutateType(type, from, tool, def, map, loc, resource); + { + type = MutateType(type, @from, tool, def, map, loc, resource); + } if (type != null) { @@ -154,13 +182,21 @@ namespace Server.Engines.Harvest if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && Utility.RandomDouble() < 0.1) + { item.Amount = feluccaRacialAmount; + } else if (inFelucca && bank.Current >= feluccaAmount) + { item.Amount = feluccaAmount; + } else if (eligableForRacialBonus && bank.Current >= racialAmount && Utility.RandomDouble() < 0.1) + { item.Amount = racialAmount; + } else + { item.Amount = amount; + } } bank.Consume(item.Amount, from); @@ -183,9 +219,13 @@ namespace Server.Engines.Harvest if (Give(from, bonusItem, true) ) // Bonuses always allow placing at feet, even if pack is full irregrdless of def - bonus.SendSuccessTo(from); + { + bonus.SendSuccessTo(@from); + } else + { item.Delete(); + } } if (tool is IUsesRemaining toolWithUses) @@ -193,7 +233,9 @@ namespace Server.Engines.Harvest toolWithUses.ShowUsesRemaining = true; if (toolWithUses.UsesRemaining > 0) + { --toolWithUses.UsesRemaining; + } if (toolWithUses.UsesRemaining < 1) { @@ -206,7 +248,9 @@ namespace Server.Engines.Harvest } if (type == null) - def.SendMessageTo(from, def.FailMessage); + { + def.SendMessageTo(@from, def.FailMessage); + } OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest); } @@ -251,18 +295,26 @@ namespace Server.Engines.Harvest public virtual bool Give(Mobile m, Item item, bool placeAtFeet) { if (m.PlaceInBackpack(item)) + { return true; + } if (!placeAtFeet) + { return false; + } var map = m.Map; if (map == null) + { return false; + } if (m.GetItemsInRange(0).Any(t => t.StackWith(m, item, false))) + { return true; + } item.MoveToWorld(m.Location, map); return true; @@ -287,12 +339,16 @@ namespace Server.Engines.Harvest var racialBonus = def.RaceBonus && from.Race == Race.Elf; if (vein.ChanceToFallback > Utility.RandomDouble() + (racialBonus ? .20 : 0)) + { return fallback; + } var skillValue = from.Skills[def.Skill].Value; if (fallback != null && (skillValue < primary.ReqSkill || skillValue < primary.MinSkill)) + { return fallback; + } return primary; } @@ -357,7 +413,9 @@ namespace Server.Engines.Harvest from.Direction = from.GetDirectionTo(loc); if (!from.Mounted) - from.Animate(def.EffectActions.RandomElement(), 5, 1, true, false, 0); + { + @from.Animate(def.EffectActions.RandomElement(), 5, 1, true, false, 0); + } } public virtual HarvestDefinition GetDefinition() => Definitions.First(); @@ -368,7 +426,9 @@ namespace Server.Engines.Harvest public virtual void StartHarvesting(Mobile from, Item tool, object toHarvest) { if (!CheckHarvest(from, tool)) + { return; + } if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc)) { @@ -385,11 +445,19 @@ namespace Server.Engines.Harvest } if (!CheckRange(from, tool, def, map, loc, false)) + { return; + } + if (!CheckResources(from, tool, def, map, loc, false)) + { return; + } + if (!CheckHarvest(from, tool, def, toHarvest)) + { return; + } var toLock = GetLock(from, tool, def, toHarvest); diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs index 0004e0612..31fc694e3 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs @@ -27,11 +27,14 @@ namespace Server.Engines.Harvest // grave if (itemID == 0xED3 || itemID == 0xEDF || itemID == 0xEE0 || itemID == 0xEE1 || itemID == 0xEE2 || itemID == 0xEE8) - if (from is PlayerMobile player) + { + if (@from is PlayerMobile player) { var qs = player.Quest; if (!(qs is WitchApprenticeQuest)) + { return; + } var obj = qs.FindObjective(); @@ -45,6 +48,7 @@ namespace Server.Engines.Harvest return; } } + } } if (m_System is Lumberjacking && targeted is IChoppable chopable) @@ -56,9 +60,13 @@ namespace Server.Engines.Harvest var item = (Item)obj; if (!item.IsChildOf(from.Backpack)) - from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used. + { + @from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used. + } else if (obj.Axe(from, axe)) - from.PlaySound(0x13E); + { + @from.PlaySound(0x13E); + } } else if (m_System is Lumberjacking && targeted is ICarvable carvable) { @@ -98,7 +106,9 @@ namespace Server.Engines.Harvest if (item is Container container) { if (container is TrappableContainer trappableContainer) - trappableContainer.ExecuteTrap(from); + { + trappableContainer.ExecuteTrap(@from); + } container.Destroy(); } diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestTimer.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestTimer.cs index 98ddf577a..f44fb1048 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestTimer.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestTimer.cs @@ -30,7 +30,9 @@ namespace Server.Engines.Harvest protected override void OnTick() { if (!m_System.OnHarvesting(m_From, m_Tool, m_Definition, m_ToHarvest, m_Locked, ++m_Index == m_Count)) + { Stop(); + } } } } diff --git a/Projects/UOContent/Engines/Harvest/Fishing.cs b/Projects/UOContent/Engines/Harvest/Fishing.cs index b5f63ffd7..04fb315a7 100644 --- a/Projects/UOContent/Engines/Harvest/Fishing.cs +++ b/Projects/UOContent/Engines/Harvest/Fishing.cs @@ -85,11 +85,13 @@ namespace Server.Engines.Harvest fish.Veins = veins; if (Core.ML) + { fish.BonusResources = new[] { new BonusHarvestResource(0, 99.4, null, null), // set to same chance as mining ml gems new BonusHarvestResource(80.0, .6, 1072597, typeof(WhitePearl)) }; + } Definitions.Add(fish); } @@ -155,14 +157,18 @@ namespace Server.Engines.Harvest var entry = m_MutateTable[i]; if (!deepWater && entry.m_DeepWater) + { continue; + } if (skillBase >= entry.m_ReqSkill) { var chance = (skillValue - entry.m_MinSkill) / (entry.m_MaxSkill - entry.m_MinSkill); if (chance > Utility.RandomDouble()) + { return entry.m_Types.RandomElement(); + } } } @@ -188,15 +194,21 @@ namespace Server.Engines.Harvest int level; if (from is PlayerMobile mobile && mobile.Young && mobile.Map == Map.Trammel && TreasureMap.IsInHavenIsland(from)) + { level = 0; + } else + { level = 1; + } return new TreasureMap(level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel); } if (type == typeof(MessageInABottle)) - return new MessageInABottle(from.Map == Map.Felucca ? Map.Felucca : Map.Trammel); + { + return new MessageInABottle(@from.Map == Map.Felucca ? Map.Felucca : Map.Trammel); + } var pack = from.Backpack; @@ -257,9 +269,13 @@ namespace Server.Engines.Harvest case 5: // Hats { if (Utility.RandomBool()) + { preLoot = new SkullCap(); + } else + { preLoot = new TricorneHat(); + } break; } @@ -275,9 +291,13 @@ namespace Server.Engines.Harvest }; if (Utility.Random(list.Length + 1) == 0) + { preLoot = new Candelabra(); + } else + { preLoot = new ShipwreckedItem(list.RandomElement()); + } break; } @@ -292,12 +312,18 @@ namespace Server.Engines.Harvest LockableContainer chest; if (Utility.RandomBool()) + { chest = new MetalGoldenChest(); + } else + { chest = new WoodenChest(); + } if (sos.IsAncient) + { chest.Hue = 0x481; + } TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(4, sos.Level))); @@ -326,9 +352,13 @@ namespace Server.Engines.Harvest BaseCreature serp; if (Utility.RandomDouble() < 0.25) + { serp = new DeepSeaSerpent(); + } else + { serp = new SeaSerpent(); + } int x = m.X, y = m.Y; @@ -416,22 +446,34 @@ namespace Server.Engines.Harvest number = 1043297; if ((item.ItemData.Flags & TileFlag.ArticleA) != 0) + { name = $"a {item.ItemData.Name}"; + } else if ((item.ItemData.Flags & TileFlag.ArticleAn) != 0) + { name = $"an {item.ItemData.Name}"; + } else + { name = item.ItemData.Name; + } } var ns = from.NetState; if (ns == null) + { return; + } if (number == 1043297 || ns.HighSeas) - from.SendLocalizedMessage(number, name); + { + @from.SendLocalizedMessage(number, name); + } else - from.SendLocalizedMessage(number, true, name); + { + @from.SendLocalizedMessage(number, true, name); + } } } @@ -440,17 +482,21 @@ namespace Server.Engines.Harvest base.OnHarvestStarted(from, tool, def, toHarvest); if (GetHarvestDetails(from, tool, toHarvest, out _, out var map, out var loc)) + { Timer.DelayCall( TimeSpan.FromSeconds(1.5), () => { if (Core.ML) - from.RevealingAction(); + { + @from.RevealingAction(); + } Effects.SendLocationEffect(loc, map, 0x352D, 16, 4); Effects.PlaySound(loc, map, 0x364); } ); + } } public override void OnHarvestFinished( @@ -461,7 +507,9 @@ namespace Server.Engines.Harvest base.OnHarvestFinished(from, tool, def, vein, bank, resource, harvested); if (Core.ML) - from.RevealingAction(); + { + @from.RevealingAction(); + } } public override object GetLock(Mobile from, Item tool, HarvestDefinition def, object toHarvest) => this; @@ -469,7 +517,9 @@ namespace Server.Engines.Harvest public override bool BeginHarvesting(Mobile from, Item tool) { if (!base.BeginHarvesting(from, tool)) + { return false; + } from.SendLocalizedMessage(500974); // What water do you want to fish in? return true; @@ -478,7 +528,9 @@ namespace Server.Engines.Harvest public override bool CheckHarvest(Mobile from, Item tool) { if (!base.CheckHarvest(from, tool)) + { return false; + } if (from.Mounted) { @@ -492,7 +544,9 @@ namespace Server.Engines.Harvest public override bool CheckHarvest(Mobile from, Item tool, HarvestDefinition def, object toHarvest) { if (!base.CheckHarvest(from, tool, def, toHarvest)) + { return false; + } if (from.Mounted) { diff --git a/Projects/UOContent/Engines/Harvest/Lumberjacking.cs b/Projects/UOContent/Engines/Harvest/Lumberjacking.cs index 1f98d9db8..bcc3206aa 100644 --- a/Projects/UOContent/Engines/Harvest/Lumberjacking.cs +++ b/Projects/UOContent/Engines/Harvest/Lumberjacking.cs @@ -125,7 +125,9 @@ namespace Server.Engines.Harvest public override bool CheckHarvest(Mobile from, Item tool) { if (!base.CheckHarvest(from, tool)) + { return false; + } if (tool.Parent != from) { @@ -139,7 +141,9 @@ namespace Server.Engines.Harvest public override bool CheckHarvest(Mobile from, Item tool, HarvestDefinition def, object toHarvest) { if (!base.CheckHarvest(from, tool, def, toHarvest)) + { return false; + } if (tool.Parent != from) { @@ -153,18 +157,26 @@ namespace Server.Engines.Harvest public override void OnBadHarvestTarget(Mobile from, Item tool, object toHarvest) { if (toHarvest is Mobile mobile) + { mobile.PrivateOverheadMessage( MessageType.Regular, 0x3B2, 500450, - from.NetState + @from.NetState ); // You can only skin dead creatures. + } else if (toHarvest is Item item) - item.LabelTo(from, 500464); // Use this on corpses to carve away meat and hide + { + item.LabelTo(@from, 500464); // Use this on corpses to carve away meat and hide + } else if (toHarvest is StaticTarget || toHarvest is LandTarget) - from.SendLocalizedMessage(500489); // You can't use an axe on that. + { + @from.SendLocalizedMessage(500489); // You can't use an axe on that. + } else - from.SendLocalizedMessage(1005213); // You can't do that + { + @from.SendLocalizedMessage(1005213); // You can't do that + } } public override void OnHarvestStarted(Mobile from, Item tool, HarvestDefinition def, object toHarvest) @@ -172,7 +184,9 @@ namespace Server.Engines.Harvest base.OnHarvestStarted(from, tool, def, toHarvest); if (Core.ML) - from.RevealingAction(); + { + @from.RevealingAction(); + } } public static void Initialize() diff --git a/Projects/UOContent/Engines/Harvest/Mining.cs b/Projects/UOContent/Engines/Harvest/Mining.cs index 679b3de97..235364a30 100644 --- a/Projects/UOContent/Engines/Harvest/Mining.cs +++ b/Projects/UOContent/Engines/Harvest/Mining.cs @@ -209,6 +209,7 @@ namespace Server.Engines.Harvest OreAndStone.Veins = veins; if (Core.ML) + { OreAndStone.BonusResources = new[] { new BonusHarvestResource(0, 99.4, null, null), // Nothing @@ -219,6 +220,7 @@ namespace Server.Engines.Harvest new BonusHarvestResource(100, .1, 1072566, typeof(PerfectEmerald)), new BonusHarvestResource(100, .1, 1072568, typeof(Turquoise)) }; + } OreAndStone.RaceBonus = Core.ML; OreAndStone.RandomizeVeins = Core.ML; @@ -280,11 +282,15 @@ namespace Server.Engines.Harvest ) { if (def != OreAndStone) - return base.GetResourceType(from, tool, def, map, loc, resource); + { + return base.GetResourceType(@from, tool, def, map, loc, resource); + } if (from.Skills.Mining.Base >= 100.0 && from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone && Utility.RandomDouble() < 0.1) + { return resource.Types[1]; + } return resource.Types[0]; } @@ -292,7 +298,9 @@ namespace Server.Engines.Harvest public override bool CheckHarvest(Mobile from, Item tool) { if (!base.CheckHarvest(from, tool)) + { return false; + } if (from.Mounted) { @@ -312,15 +320,21 @@ namespace Server.Engines.Harvest public override void SendSuccessTo(Mobile from, Item item, HarvestResource resource) { if (item is BaseGranite) - from.SendLocalizedMessage(1044606); // You carefully extract some workable stone from the ore vein! + { + @from.SendLocalizedMessage(1044606); // You carefully extract some workable stone from the ore vein! + } else - base.SendSuccessTo(from, item, resource); + { + base.SendSuccessTo(@from, item, resource); + } } public override bool CheckHarvest(Mobile from, Item tool, HarvestDefinition def, object toHarvest) { if (!base.CheckHarvest(from, tool, def, toHarvest)) + { return false; + } if (def == Sand && !(from is PlayerMobile mobile && mobile.Skills.Mining.Base >= 100.0 && mobile.SandMining)) @@ -354,7 +368,9 @@ namespace Server.Engines.Harvest var veinIndex = Array.IndexOf(def.Veins, vein); if (veinIndex >= 0 && veinIndex < def.Veins.Length - 1) + { return def.Veins[veinIndex + 1]; + } } return base.MutateVein(from, tool, def, bank, toHarvest, vein); @@ -370,12 +386,15 @@ namespace Server.Engines.Harvest var res = vein.PrimaryResource; if (res == resource && res.Types.Length >= 3) + { try { - var map = from.Map; + var map = @from.Map; if (map == null) + { return; + } if (ActivatorUtil.CreateInstance(res.Types[2], 25) is BaseCreature spawned) { @@ -383,44 +402,47 @@ namespace Server.Engines.Harvest for (var i = 0; i < m_Offsets.Length; i += 2) { - var x = from.X + m_Offsets[(offset + i) % m_Offsets.Length]; - var y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; + var x = @from.X + m_Offsets[(offset + i) % m_Offsets.Length]; + var y = @from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; - if (map.CanSpawnMobile(x, y, from.Z)) + if (map.CanSpawnMobile(x, y, @from.Z)) { - spawned.OnBeforeSpawn(new Point3D(x, y, from.Z), map); - spawned.MoveToWorld(new Point3D(x, y, from.Z), map); - spawned.Combatant = from; + spawned.OnBeforeSpawn(new Point3D(x, y, @from.Z), map); + spawned.MoveToWorld(new Point3D(x, y, @from.Z), map); + spawned.Combatant = @from; return; } var z = map.GetAverageZ(x, y); - if (Math.Abs(z - from.Z) < 10 && map.CanSpawnMobile(x, y, z)) + if (Math.Abs(z - @from.Z) < 10 && map.CanSpawnMobile(x, y, z)) { spawned.OnBeforeSpawn(new Point3D(x, y, z), map); spawned.MoveToWorld(new Point3D(x, y, z), map); - spawned.Combatant = from; + spawned.Combatant = @from; return; } } - spawned.OnBeforeSpawn(from.Location, from.Map); - spawned.MoveToWorld(from.Location, from.Map); - spawned.Combatant = from; + spawned.OnBeforeSpawn(@from.Location, @from.Map); + spawned.MoveToWorld(@from.Location, @from.Map); + spawned.Combatant = @from; } } catch { // ignored } + } } } public override bool BeginHarvesting(Mobile from, Item tool) { if (!base.BeginHarvesting(from, tool)) + { return false; + } from.SendLocalizedMessage(503033); // Where do you wish to dig? return true; @@ -431,15 +453,21 @@ namespace Server.Engines.Harvest base.OnHarvestStarted(from, tool, def, toHarvest); if (Core.ML) - from.RevealingAction(); + { + @from.RevealingAction(); + } } public override void OnBadHarvestTarget(Mobile from, Item tool, object toHarvest) { if (toHarvest is LandTarget) - from.SendLocalizedMessage(501862); // You can't mine there. + { + @from.SendLocalizedMessage(501862); // You can't mine there. + } else - from.SendLocalizedMessage(501863); // You can't mine that. + { + @from.SendLocalizedMessage(501863); // You can't mine that. + } } } } diff --git a/Projects/UOContent/Engines/Help/HelpGump.cs b/Projects/UOContent/Engines/Help/HelpGump.cs index 8edd7da4c..9025baa55 100644 --- a/Projects/UOContent/Engines/Help/HelpGump.cs +++ b/Projects/UOContent/Engines/Help/HelpGump.cs @@ -294,15 +294,24 @@ namespace Server.Engines.Help private static void EventSink_HelpRequest(Mobile m) { - if (m.NetState.Gumps.OfType().Any()) return; + if (m.NetState.Gumps.OfType().Any()) + { + return; + } if (!PageQueue.CheckAllowedToPage(m)) + { return; + } if (PageQueue.Contains(m)) + { m.SendMenu(new ContainedMenu(m)); + } else + { m.SendGump(new HelpGump(m)); + } } private static bool IsYoung(Mobile m) => m is PlayerMobile mobile && mobile.Young; @@ -314,7 +323,9 @@ namespace Server.Engines.Help var info = m.Aggressed[i]; if (DateTime.UtcNow - info.LastCombatTime < TimeSpan.FromSeconds(30.0)) + { return true; + } } return false; @@ -407,15 +418,21 @@ namespace Server.Engines.Help if (IsYoung(from)) { if (from.Region.IsPartOf()) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1114345, "", 0x35 ); // You'll need a better jailbreak plan than that! + } else if (from.Region.IsPartOf("Haven Island")) - from.SendLocalizedMessage(1041529); // You're already in Haven + { + @from.SendLocalizedMessage(1041529); // You're already in Haven + } else - from.MoveToWorld(new Point3D(3503, 2574, 14), Map.Trammel); + { + @from.MoveToWorld(new Point3D(3503, 2574, 14), Map.Trammel); + } } break; @@ -423,7 +440,9 @@ namespace Server.Engines.Help } if (type != (PageType)(-1) && PageQueue.CheckAllowedToPage(from)) - from.SendGump(new PagePromptGump(from, type)); + { + @from.SendGump(new PagePromptGump(@from, type)); + } } } } diff --git a/Projects/UOContent/Engines/Help/PageQueue.cs b/Projects/UOContent/Engines/Help/PageQueue.cs index 3a075e43b..fa188aecb 100644 --- a/Projects/UOContent/Engines/Help/PageQueue.cs +++ b/Projects/UOContent/Engines/Help/PageQueue.cs @@ -40,7 +40,9 @@ namespace Server.Engines.Help PageMap = sender.Map; if (sender is PlayerMobile pm && pm.SpeechLog != null && Array.IndexOf(SpeechLogAttachment, type) >= 0) + { SpeechLog = new List(pm.SpeechLog); + } m_Timer = new InternalTimer(this); m_Timer.Start(); @@ -101,14 +103,19 @@ namespace Server.Engines.Help 1008084 ); // You can reference our website at www.uo.com or contact us at support@uo.com. To cancel your page, please select the help button again and select cancel. - if (m_Entry.Handler != null && m_Entry.Handler.NetState == null) m_Entry.Handler = null; + if (m_Entry.Handler != null && m_Entry.Handler.NetState == null) + { + m_Entry.Handler = null; + } } else { if (index != -1) // m_Entry.AddResponse(m_Entry.Sender, "[Logout]"); + { PageQueue.Remove(m_Entry); + } } } } @@ -129,7 +136,9 @@ namespace Server.Engines.Help public static bool CheckAllowedToPage(Mobile from) { if (!(from is PlayerMobile pm)) + { return true; + } if (pm.DesignContext != null) { @@ -151,19 +160,29 @@ namespace Server.Engines.Help public static string GetPageTypeName(PageType type) { if (type == PageType.VerbalHarassment) + { return "Verbal Harassment"; + } + if (type == PageType.PhysicalHarassment) + { return "Physical Harassment"; + } + return type.ToString(); } public static void OnHandlerChanged(Mobile old, Mobile value, PageEntry entry) { if (old != null) + { m_KeyedByHandler.Remove(old); + } if (value != null) + { m_KeyedByHandler[value] = entry; + } } [Usage("Pages")] @@ -171,11 +190,17 @@ namespace Server.Engines.Help private static void Pages_OnCommand(CommandEventArgs e) { if (m_KeyedByHandler.TryGetValue(e.Mobile, out var entry)) + { e.Mobile.SendGump(new PageEntryGump(e.Mobile, entry)); + } else if (List.Count > 0) + { e.Mobile.SendGump(new PageQueueGump()); + } else + { e.Mobile.SendMessage("The page queue is empty."); + } } public static bool IsHandling(Mobile check) => m_KeyedByHandler.ContainsKey(check); @@ -187,7 +212,9 @@ namespace Server.Engines.Help public static void Remove(PageEntry e) { if (e == null) + { return; + } e.Stop(); @@ -195,7 +222,9 @@ namespace Server.Engines.Help m_KeyedBySender.Remove(e.Sender); if (e.Handler != null) + { m_KeyedByHandler.Remove(e.Handler); + } } public static PageEntry GetEntry(Mobile sender) @@ -221,20 +250,28 @@ namespace Server.Engines.Help var m = ns.Mobile; if (m?.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m)) + { m.SendMessage("A new page has been placed in the queue."); + } if (m?.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && Core.TickCount - m.LastMoveTime < 600000) + { isStaffOnline = true; + } } if (!isStaffOnline) + { entry.Sender.SendMessage( "We are sorry, but no staff members are currently available to assist you. Your page will remain in the queue until one becomes available, or until you cancel it manually." ); + } if (entry.SpeechLog != null) + { Email.SendQueueEmail(entry, GetPageTypeName(entry.Type)); + } } } } diff --git a/Projects/UOContent/Engines/Help/PageQueueGump.cs b/Projects/UOContent/Engines/Help/PageQueueGump.cs index 113817169..2323137c7 100644 --- a/Projects/UOContent/Engines/Help/PageQueueGump.cs +++ b/Projects/UOContent/Engines/Help/PageQueueGump.cs @@ -63,9 +63,13 @@ namespace Server.Engines.Help if (e.Sender.Deleted || e.Sender.NetState == null) // e.AddResponse(e.Sender, "[Logout]"); + { PageQueue.Remove(e); + } else + { ++i; + } } m_List = list.ToArray(); @@ -171,7 +175,9 @@ namespace Server.Engines.Help var path = Path.Combine(Core.BaseDirectory, "Data/pageresponse.cfg"); if (!File.Exists(path)) + { return new List(); + } var list = new List(); @@ -183,12 +189,16 @@ namespace Server.Engines.Help while ((line = ip.ReadLine()?.Trim()) != null) { if (line.Length == 0 || line.StartsWith("#")) + { continue; + } var split = line.Split('\t'); if (split.Length == 2) + { list.Add(new PredefinedResponse(split[0], split[1])); + } } } catch (Exception e) @@ -253,14 +263,22 @@ namespace Server.Engines.Help AddButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, 2 + i * 3); if (i > 0) + { AddButton(377, 44 + i % 5 * 80 + 2, 0x15E0, 0x15E4, 3 + i * 3); + } else + { AddImage(377, 44 + i % 5 * 80 + 2, 0x25E4); + } if (i < list.Count - 1) + { AddButton(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + i * 3); + } else + { AddImage(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x25E8); + } } } @@ -313,7 +331,9 @@ namespace Server.Engines.Help public override void OnResponse(NetState sender, RelayInfo info) { if (m_From.AccessLevel < AccessLevel.Administrator) + { return; + } if (m_Response == null) { @@ -397,7 +417,9 @@ namespace Server.Engines.Help var te = info.GetTextEntry(0); if (te != null) + { m_Response.Title = te.Text; + } PredefinedResponse.Save(); m_From.SendGump(new PredefGump(m_From, m_Response)); @@ -409,7 +431,9 @@ namespace Server.Engines.Help var te = info.GetTextEntry(1); if (te != null) + { m_Response.Message = te.Text; + } PredefinedResponse.Save(); m_From.SendGump(new PredefGump(m_From, m_Response)); @@ -745,7 +769,9 @@ namespace Server.Engines.Help if (text != null) // m_Entry.AddResponse(state.Mobile, "[Response] " + text.Text); + { m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, text.Text)); + } // m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name ); // m_Entry.Sender.SendMessage( 0x482, text.Text ); @@ -765,7 +791,9 @@ namespace Server.Engines.Help Resend(state); if (m_Entry.SpeechLog != null) + { state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog)); + } break; } @@ -776,6 +804,7 @@ namespace Server.Engines.Help if (index >= 0 && index < preresp.Count) // m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title); + { m_Entry.Sender.SendGump( new MessageSentGump( m_Entry.Sender, @@ -783,6 +812,7 @@ namespace Server.Engines.Help preresp[index].Message ) ); + } Resend(state); diff --git a/Projects/UOContent/Engines/Help/PageResponseGump.cs b/Projects/UOContent/Engines/Help/PageResponseGump.cs index 255e06c82..75e770f9d 100644 --- a/Projects/UOContent/Engines/Help/PageResponseGump.cs +++ b/Projects/UOContent/Engines/Help/PageResponseGump.cs @@ -38,7 +38,9 @@ namespace Server.Engines.Help public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID != 1) + { m_From.SendGump(new MessageSentGump(m_From, m_Name, m_Text)); + } } } } diff --git a/Projects/UOContent/Engines/Help/SpeechLog.cs b/Projects/UOContent/Engines/Help/SpeechLog.cs index 8dd0d1d12..d12f295af 100644 --- a/Projects/UOContent/Engines/Help/SpeechLog.cs +++ b/Projects/UOContent/Engines/Help/SpeechLog.cs @@ -52,7 +52,9 @@ namespace Server.Engines.Help public void Add(SpeechLogEntry entry) { if (MaxLength > 0 && m_Queue.Count >= MaxLength) + { m_Queue.Dequeue(); + } Clean(); @@ -66,9 +68,13 @@ namespace Server.Engines.Help var entry = m_Queue.Peek(); if (DateTime.UtcNow - entry.Created > EntryDuration) + { m_Queue.Dequeue(); + } else + { break; + } } } diff --git a/Projects/UOContent/Engines/Help/SpeechLogGump.cs b/Projects/UOContent/Engines/Help/SpeechLogGump.cs index 7ef0e32ff..1feeb925f 100644 --- a/Projects/UOContent/Engines/Help/SpeechLogGump.cs +++ b/Projects/UOContent/Engines/Help/SpeechLogGump.cs @@ -75,7 +75,9 @@ namespace Server.Engines.Help var speech = entry.Speech; if (i != min) + { builder.Append("
"); + } builder.AppendFormat( "{0} ({1}): {2}", @@ -91,12 +93,16 @@ namespace Server.Engines.Help AddHtml(10, 40, 280, 350, sLog, false, true); if (page > 0) + { AddButton(10, 395, 0xFAE, 0xFB0, 1); // Previous page + } AddLabel(45, 395, 0x481, $"Current page: {page + 1}/{lastPage + 1}"); if (page < lastPage) + { AddButton(261, 395, 0xFA5, 0xFA7, 2); // Next page + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -108,14 +114,18 @@ namespace Server.Engines.Help case 1: // Previous page { if (m_Page - 1 >= 0) - from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page - 1)); + { + @from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page - 1)); + } break; } case 2: // Next page { if ((m_Page + 1) * MaxEntriesPerPage < m_Log.Count) - from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page + 1)); + { + @from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page + 1)); + } break; } diff --git a/Projects/UOContent/Engines/Help/StuckMenu.cs b/Projects/UOContent/Engines/Help/StuckMenu.cs index a3ec4f1bb..ed9f671fd 100644 --- a/Projects/UOContent/Engines/Help/StuckMenu.cs +++ b/Projects/UOContent/Engines/Help/StuckMenu.cs @@ -198,7 +198,9 @@ namespace Server.Menus.Questions else if (info.ButtonID == 0) { if (m_Mobile == m_Sender) + { m_Mobile.SendLocalizedMessage(1010588); // You choose not to go to any city. + } } else { @@ -206,7 +208,9 @@ namespace Server.Menus.Questions var entries = IsInSecondAgeArea(m_Mobile) ? m_T2AEntries : m_Entries; if (index >= 0 && index < entries.Length) + { Teleport(entries[index]); + } } } @@ -219,7 +223,9 @@ namespace Server.Menus.Questions new TeleportTimer(m_Mobile, entry, TimeSpan.FromSeconds(10.0 + Utility.RandomDouble() * 110.0)).Start(); if (m_Mobile is PlayerMobile mobile) + { mobile.UsedStuckMenu(); + } } else { @@ -293,11 +299,17 @@ namespace Server.Menus.Questions Map destMap; if (m_Mobile.Map == Map.Trammel) + { destMap = Map.Trammel; + } else if (m_Mobile.Map == Map.Felucca) + { destMap = Map.Felucca; + } else + { destMap = m_Mobile.Kills >= 5 ? Map.Felucca : Map.Trammel; + } BaseCreature.TeleportPets(m_Mobile, dest, destMap); m_Mobile.MoveToWorld(dest, destMap); diff --git a/Projects/UOContent/Engines/Khaldun/KhaldunGen.cs b/Projects/UOContent/Engines/Khaldun/KhaldunGen.cs index b49ca87af..169b7272a 100644 --- a/Projects/UOContent/Engines/Khaldun/KhaldunGen.cs +++ b/Projects/UOContent/Engines/Khaldun/KhaldunGen.cs @@ -55,7 +55,9 @@ namespace Server.Commands public static void CreateMorphItem(int x, int y, int z, int inactiveItemID, int activeItemID, int range) { if (FindMorphItem(x, y, z, inactiveItemID, activeItemID)) + { return; + } var item = new MorphItem(inactiveItemID, activeItemID, range, 3); @@ -66,7 +68,9 @@ namespace Server.Commands public static void CreateApproachLight(int x, int y, int z, int off, int on, LightType light) { if (FindMorphItem(x, y, z, off, on)) + { return; + } var item = new MorphItem(off, on, 2, 3); item.Light = light; @@ -78,7 +82,9 @@ namespace Server.Commands public static void CreateSoundEffect(int x, int y, int z, int sound, int range) { if (FindEffectController(x, y, z)) + { return; + } var item = new EffectController(); item.SoundID = sound; @@ -92,7 +98,9 @@ namespace Server.Commands public static void CreateBigTeleporterItem(int x, int y, bool reverse) { if (FindMorphItem(x, y, 0, reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC)) + { return; + } var item = new MorphItem(reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC, 1, 3); diff --git a/Projects/UOContent/Engines/Khaldun/KhaldunPitTeleporter.cs b/Projects/UOContent/Engines/Khaldun/KhaldunPitTeleporter.cs index 7dc130e43..bd0457308 100644 --- a/Projects/UOContent/Engines/Khaldun/KhaldunPitTeleporter.cs +++ b/Projects/UOContent/Engines/Khaldun/KhaldunPitTeleporter.cs @@ -39,17 +39,23 @@ namespace Server.Items public override void OnDoubleClick(Mobile m) { if (!Active) + { return; + } var map = MapDest; if (map == null || map == Map.Internal) + { map = m.Map; + } var p = PointDest; if (p == Point3D.Zero) + { p = m.Location; + } if (m.InRange(this, 3)) { diff --git a/Projects/UOContent/Engines/Khaldun/Mobiles/GrimmochDrummel.cs b/Projects/UOContent/Engines/Khaldun/Mobiles/GrimmochDrummel.cs index b442e0fd4..7adde3926 100644 --- a/Projects/UOContent/Engines/Khaldun/Mobiles/GrimmochDrummel.cs +++ b/Projects/UOContent/Engines/Khaldun/Mobiles/GrimmochDrummel.cs @@ -60,10 +60,14 @@ namespace Server.Mobiles PackItem(new Arrow(40)); if (Utility.Random(100) < 3) + { PackItem(new FireHorn()); + } if (Utility.Random(3) < 1) + { PackItem(Loot.RandomGrimmochJournal()); + } } public GrimmochDrummel(Serial serial) : base(serial) diff --git a/Projects/UOContent/Engines/Khaldun/Mobiles/LysanderGathenwale.cs b/Projects/UOContent/Engines/Khaldun/Mobiles/LysanderGathenwale.cs index 5d56335b5..c35736293 100644 --- a/Projects/UOContent/Engines/Khaldun/Mobiles/LysanderGathenwale.cs +++ b/Projects/UOContent/Engines/Khaldun/Mobiles/LysanderGathenwale.cs @@ -87,7 +87,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } Backpack?.Destroy(); diff --git a/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs b/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs index 553e57d4b..8ca972ecd 100644 --- a/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs +++ b/Projects/UOContent/Engines/Khaldun/PuzzleChest.cs @@ -24,7 +24,10 @@ namespace Server.Items public PuzzleChestSolution() { - for (var i = 0; i < Cylinders.Length; i++) Cylinders[i] = RandomCylinder(); + for (var i = 0; i < Cylinders.Length; i++) + { + Cylinders[i] = RandomCylinder(); + } } public PuzzleChestSolution( @@ -41,7 +44,10 @@ namespace Server.Items public PuzzleChestSolution(PuzzleChestSolution solution) { - for (var i = 0; i < Cylinders.Length; i++) Cylinders[i] = solution.Cylinders[i]; + for (var i = 0; i < Cylinders.Length; i++) + { + Cylinders[i] = solution.Cylinders[i]; + } } public PuzzleChestSolution(IGenericReader reader) @@ -50,12 +56,15 @@ namespace Server.Items var length = reader.ReadEncodedInt(); for (var i = 0;; i++) + { if (i < length) { var cylinder = (PuzzleChestCylinder)reader.ReadInt(); if (i < Cylinders.Length) + { Cylinders[i] = cylinder; + } } else if (i < Cylinders.Length) { @@ -65,6 +74,7 @@ namespace Server.Items { break; } + } } public PuzzleChestCylinder[] Cylinders { get; } = new PuzzleChestCylinder[Length]; @@ -123,6 +133,7 @@ namespace Server.Items var matchesDst = new bool[solution.Cylinders.Length]; for (var i = 0; i < Cylinders.Length; i++) + { if (Cylinders[i] == solution.Cylinders[i]) { cylinders++; @@ -130,16 +141,23 @@ namespace Server.Items matchesSrc[i] = true; matchesDst[i] = true; } + } for (var i = 0; i < Cylinders.Length; i++) + { if (!matchesSrc[i]) + { for (var j = 0; j < solution.Cylinders.Length; j++) + { if (Cylinders[i] == solution.Cylinders[j] && !matchesDst[j]) { colors++; matchesDst[j] = true; } + } + } + } return cylinders == Cylinders.Length; } @@ -149,7 +167,10 @@ namespace Server.Items writer.WriteEncodedInt(0); // version writer.WriteEncodedInt(Cylinders.Length); - for (var i = 0; i < Cylinders.Length; i++) writer.Write((int)Cylinders[i]); + for (var i = 0; i < Cylinders.Length; i++) + { + writer.Write((int)Cylinders[i]); + } } } @@ -230,7 +251,9 @@ namespace Server.Items { var list = new List(Solution.Cylinders.Length - 1); for (var i = 1; i < Solution.Cylinders.Length; i++) + { list.Add(Solution.Cylinders[i]); + } Hints = new PuzzleChestCylinder[HintsCount]; @@ -253,8 +276,11 @@ namespace Server.Items { PuzzleChestSolution solution = GetLastGuess(from); if (solution != null) + { solution = new PuzzleChestSolution(solution); + } else + { solution = new PuzzleChestSolution( PuzzleChestCylinder.None, PuzzleChestCylinder.None, @@ -262,6 +288,7 @@ namespace Server.Items PuzzleChestCylinder.None, PuzzleChestCylinder.None ); + } from.CloseGump(); from.CloseGump(); @@ -400,31 +427,43 @@ namespace Server.Items var gemType = gem.GetType(); foreach (var listGem in gems) + { if (listGem.GetType() == gemType) { listGem.Amount++; gem.Delete(); break; } + } if (!gem.Deleted) + { gems.Add(gem); + } } foreach (var gem in gems) + { DropItem(gem); + } if (Utility.RandomDouble() < 0.2) + { DropItem(new BagOfReagents()); + } for (var i = 0; i < 2; i++) { Item item; if (Core.AOS) + { item = Loot.RandomArmorOrShieldOrWeaponOrJewelry(); + } else + { item = Loot.RandomArmorOrShieldOrWeapon(); + } if (item is BaseWeapon weapon) { @@ -488,11 +527,17 @@ namespace Server.Items var toDelete = new List(); foreach (var kvp in m_Guesses) + { if (DateTime.UtcNow - kvp.Value.When > CleanupTime) + { toDelete.Add(kvp.Key); + } + } foreach (var m in toDelete) + { m_Guesses.Remove(m); + } } public override void Serialize(IGenericWriter writer) @@ -506,7 +551,10 @@ namespace Server.Items m_Solution.Serialize(writer); writer.WriteEncodedInt(Hints.Length); - for (var i = 0; i < Hints.Length; i++) writer.Write((int)Hints[i]); + for (var i = 0; i < Hints.Length; i++) + { + writer.Write((int)Hints[i]); + } writer.WriteEncodedInt(m_Guesses.Count); foreach (var kvp in m_Guesses) @@ -530,11 +578,15 @@ namespace Server.Items var cylinder = (PuzzleChestCylinder)reader.ReadInt(); if (length == Hints.Length) + { Hints[i] = cylinder; + } } if (length != Hints.Length) + { InitHints(); + } var guesses = reader.ReadEncodedInt(); for (var i = 0; i < guesses; i++) @@ -597,10 +649,14 @@ namespace Server.Items AddCylinder(350, 200, chest.FirstHint); if (lockpicking >= 90.0) + { AddCylinder(350, 212, chest.SecondHint); + } if (lockpicking >= 100.0) + { AddCylinder(350, 224, chest.ThirdHint); + } } else { @@ -608,7 +664,9 @@ namespace Server.Items AddCylinder(350, 160, chest.FirstHint); if (lockpicking >= 70.0) + { AddCylinder(350, 172, chest.SecondHint); + } } } @@ -672,15 +730,21 @@ namespace Server.Items private void AddCylinder(int x, int y, PuzzleChestCylinder cylinder) { if (cylinder != PuzzleChestCylinder.None) + { AddItem(x, y, (int)cylinder); + } else + { AddItem(x + 9, y, (int)cylinder); + } } public override void OnResponse(NetState sender, RelayInfo info) { if (m_Chest.Deleted || info.ButtonID == 0 || !m_From.CheckAlive()) + { return; + } if (m_From.AccessLevel == AccessLevel.Player && (m_From.Map != m_Chest.Map || !m_From.InRange(m_Chest.GetWorldLocation(), 2))) @@ -696,11 +760,15 @@ namespace Server.Items else { if (info.Switches.Length == 0) + { return; + } var pedestal = info.Switches[0]; if (pedestal < 0 || pedestal >= m_Solution.Cylinders.Length) + { return; + } PuzzleChestCylinder cylinder; switch (info.ButtonID) diff --git a/Projects/UOContent/Engines/Khaldun/RaisableItem.cs b/Projects/UOContent/Engines/Khaldun/RaisableItem.cs index 72ab86502..1ca63b457 100644 --- a/Projects/UOContent/Engines/Khaldun/RaisableItem.cs +++ b/Projects/UOContent/Engines/Khaldun/RaisableItem.cs @@ -46,11 +46,17 @@ namespace Server.Items set { if (value <= 0) + { m_MaxElevation = 0; + } else if (value >= 60) + { m_MaxElevation = 60; + } else + { m_MaxElevation = value; + } } } @@ -68,7 +74,9 @@ namespace Server.Items public void Raise() { if (!IsRaisable) + { return; + } m_RaiseTimer = new RaiseTimer(this); m_RaiseTimer.Start(); @@ -138,7 +146,9 @@ namespace Server.Items Stop(); if (m_Item.StopSound >= 0) + { Effects.PlaySound(m_Item.Location, m_Item.Map, m_Item.StopSound); + } m_Up = false; m_Step = 0; @@ -158,7 +168,9 @@ namespace Server.Items Stop(); if (m_Item.StopSound >= 0) + { Effects.PlaySound(m_Item.Location, m_Item.Map, m_Item.StopSound); + } m_Item.m_RaiseTimer = null; @@ -168,7 +180,9 @@ namespace Server.Items } if (m_Item.MoveSound >= 0) + { Effects.PlaySound(m_Item.Location, m_Item.Map, m_Item.MoveSound); + } } } } diff --git a/Projects/UOContent/Engines/Khaldun/RaiseSwitch.cs b/Projects/UOContent/Engines/Khaldun/RaiseSwitch.cs index d4b9aab14..d25b1c288 100644 --- a/Projects/UOContent/Engines/Khaldun/RaiseSwitch.cs +++ b/Projects/UOContent/Engines/Khaldun/RaiseSwitch.cs @@ -27,12 +27,16 @@ namespace Server.Items } if (RaisableItem?.Deleted == true) + { RaisableItem = null; + } Flip(); if (RaisableItem == null) + { return; + } if (RaisableItem.IsRaisable) { @@ -95,7 +99,9 @@ namespace Server.Items protected virtual void Reset() { if (ItemID != 0x1093) + { Flip(); + } } public override void Serialize(IGenericWriter writer) @@ -132,7 +138,9 @@ namespace Server.Items protected override void OnTick() { if (m_RaiseSwitch.Deleted) + { return; + } m_RaiseSwitch.m_ResetTimer = null; @@ -167,19 +175,25 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (Utility.InRange(m.Location, Location, CurrentRange) || Utility.InRange(oldLocation, Location, CurrentRange)) + { Refresh(); + } } public override void OnMapChange() { if (!Deleted) + { Refresh(); + } } public override void OnLocationChange(Point3D oldLoc) { if (!Deleted) + { Refresh(); + } } public void Refresh() @@ -190,7 +204,9 @@ namespace Server.Items public override void Serialize(IGenericWriter writer) { if (RaisableItem?.Deleted == true) + { RaisableItem = null; + } base.Serialize(writer); diff --git a/Projects/UOContent/Engines/MLQuests/Definitions/BaseEscort.cs b/Projects/UOContent/Engines/MLQuests/Definitions/BaseEscort.cs index 733150718..761d63da0 100644 --- a/Projects/UOContent/Engines/MLQuests/Definitions/BaseEscort.cs +++ b/Projects/UOContent/Engines/MLQuests/Definitions/BaseEscort.cs @@ -10,7 +10,9 @@ public override void GetRewards(MLQuestInstance instance) { if (AwardHumanInNeed) + { HumanInNeed.AwardTo(instance.Player); + } base.GetRewards(instance); } diff --git a/Projects/UOContent/Engines/MLQuests/Definitions/BlightedGrove.cs b/Projects/UOContent/Engines/MLQuests/Definitions/BlightedGrove.cs index d34999582..fcf36e901 100644 --- a/Projects/UOContent/Engines/MLQuests/Definitions/BlightedGrove.cs +++ b/Projects/UOContent/Engines/MLQuests/Definitions/BlightedGrove.cs @@ -148,11 +148,15 @@ namespace Server.Engines.MLQuests.Definitions pm.AcquireRecipe(32); if (pm.Skills.Blacksmith.Base < 45.0) // TODO: Verify threshold + { pm.SendLocalizedMessage( 1075005 ); // You observe carefully but you can't grasp the complexities of smithing a bone handled machete. + } else + { pm.SendLocalizedMessage(1075006); // You have learned how to smith a bone handled machete! + } } base.GetRewards(instance); diff --git a/Projects/UOContent/Engines/MLQuests/Definitions/Britannia.cs b/Projects/UOContent/Engines/MLQuests/Definitions/Britannia.cs index 551fc14e4..41081f19a 100644 --- a/Projects/UOContent/Engines/MLQuests/Definitions/Britannia.cs +++ b/Projects/UOContent/Engines/MLQuests/Definitions/Britannia.cs @@ -141,9 +141,13 @@ namespace Server.Engines.MLQuests.Definitions AddItem(new Sandals(Utility.RandomPinkHue())); if (Utility.RandomBool()) + { AddItem(new Kilt(Utility.RandomPinkHue())); + } else + { AddItem(new Skirt(Utility.RandomPinkHue())); + } AddItem(new FancyShirt(Utility.RandomRedHue())); } diff --git a/Projects/UOContent/Engines/MLQuests/Definitions/Heartwood.cs b/Projects/UOContent/Engines/MLQuests/Definitions/Heartwood.cs index 6b58c50d6..a17da9876 100644 --- a/Projects/UOContent/Engines/MLQuests/Definitions/Heartwood.cs +++ b/Projects/UOContent/Engines/MLQuests/Definitions/Heartwood.cs @@ -2320,9 +2320,13 @@ namespace Server.Engines.MLQuests.Definitions AddItem(new Cloak(Utility.RandomBrightHue())); if (Utility.RandomBool()) + { AddItem(new Kilt(0x387)); + } else + { AddItem(new Skirt(0x387)); + } } public Alejaha(Serial serial) @@ -2443,9 +2447,13 @@ namespace Server.Engines.MLQuests.Definitions AddItem(new RoyalCirclet()); if (Utility.RandomBool()) + { AddItem(new Boots(Utility.RandomYellowHue())); + } else + { AddItem(new ThighBoots(Utility.RandomYellowHue())); + } } public Ciala(Serial serial) diff --git a/Projects/UOContent/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs b/Projects/UOContent/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs index 1b42bd86a..2ab2b472a 100644 --- a/Projects/UOContent/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs +++ b/Projects/UOContent/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs @@ -722,7 +722,9 @@ namespace Server.Engines.MLQuests.Definitions var item = base.CreateItem(); if (item is Spellbook book) + { book.Content = (1ul << book.BookCount) - 1; + } return item; } diff --git a/Projects/UOContent/Engines/MLQuests/Definitions/Spellweaving.cs b/Projects/UOContent/Engines/MLQuests/Definitions/Spellweaving.cs index 732ac5720..6fb4371ed 100644 --- a/Projects/UOContent/Engines/MLQuests/Definitions/Spellweaving.cs +++ b/Projects/UOContent/Engines/MLQuests/Definitions/Spellweaving.cs @@ -12,7 +12,9 @@ namespace Server.Engines.MLQuests.Definitions public static void AwardTo(PlayerMobile pm) { if (pm == null) + { return; + } var context = MLQuestSystem.GetOrCreateContext(pm); diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/BaseQuestGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/BaseQuestGump.cs index 1dda2b787..cdc3c794e 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/BaseQuestGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/BaseQuestGump.cs @@ -74,6 +74,7 @@ namespace Server.Engines.MLQuests.Gumps AddPage(++m_Page); if (m_Page > 1) + { AddButton( 130, 430, @@ -83,8 +84,10 @@ namespace Server.Engines.MLQuests.Gumps GumpButtonType.Page, m_Page - 1 ); + } if (m_Page < m_MaxPages) + { AddButton( 275, 430, @@ -94,8 +97,10 @@ namespace Server.Engines.MLQuests.Gumps GumpButtonType.Page, m_Page + 1 ); + } foreach (var button in m_Buttons) + { AddButton( button.Position == ButtonPosition.Left ? 95 : 313, 455, @@ -103,9 +108,12 @@ namespace Server.Engines.MLQuests.Gumps (int)button.Graphic + 2, button.ButtonID ); + } if (m_Title != null) + { AddHtmlLocalized(130, 68, 220, 48, 1114513, m_Title, 0x2710); //
~1_TOKEN~
+ } } public void SetPageCount(int maxPages) @@ -116,9 +124,13 @@ namespace Server.Engines.MLQuests.Gumps public void SetTitle(TextDefinition def) { if (def.Number > 0) + { m_Title = $"#{def.Number}"; // OSI does "@@#{0}" instead, why? KR client related? + } else + { m_Title = def.String; + } } public void RegisterButton(ButtonPosition position, ButtonGraphic graphic, int buttonID) @@ -160,7 +172,9 @@ namespace Server.Engines.MLQuests.Gumps if (objective.IsTimed) { if (objective is CollectObjective) + { y -= 16; + } BaseObjectiveInstance.WriteTimeRemaining(this, ref y, objective.Duration); } @@ -184,7 +198,9 @@ namespace Server.Engines.MLQuests.Gumps var y = 172; foreach (var objInstance in instance.Objectives) + { objInstance.WriteToGump(this, ref y); + } } public void AddRewardsPage(MLQuest quest) // For the quest log/offer gumps diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs index 45414f0e8..f90a8ac57 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs @@ -15,7 +15,9 @@ namespace Server.Engines.MLQuests.Gumps m_CloseGumps = closeGumps; if (closeGumps) + { BaseQuestGump.CloseOtherGumps(instance.Player); + } AddPage(0); @@ -77,16 +79,22 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Instance.Removed) + { return; + } switch (info.ButtonID) { case 7: // Okay { if (info.IsSwitched(2)) + { m_Instance.Cancel(true); + } else if (info.IsSwitched(1)) + { m_Instance.Cancel(false); + } sender.Mobile.SendGump(new QuestLogGump(m_Instance.Player, m_CloseGumps)); break; diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs index f78c92556..1ef2c7331 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs @@ -33,7 +33,9 @@ namespace Server.Engines.MLQuests.Gumps AddDescription(quest); if (instance.Failed) // only displayed on the first page + { AddHtmlLocalized(160, 80, 250, 16, 500039, 0x3C00); // Failed! + } BuildPage(); AddObjectivesProgress(instance); @@ -45,7 +47,9 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Instance.Removed) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogGump.cs index 5826cd2ee..f12b7f46b 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/QuestLogGump.cs @@ -67,18 +67,24 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID < 6) + { return; + } var context = MLQuestSystem.GetContext(m_Owner); if (context == null) + { return; + } var instances = context.QuestInstances; var index = info.ButtonID - 6; if (index >= instances.Count) + { return; + } sender.Mobile.SendGump(new QuestLogDetailedGump(instances[index], m_CloseGumps)); } diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/QuestOfferGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/QuestOfferGump.cs index f39a4f5fb..45ade8384 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/QuestOfferGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/QuestOfferGump.cs @@ -37,7 +37,9 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm)) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/QuestReportBackGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/QuestReportBackGump.cs index 773256dfa..e8592ab8d 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/QuestReportBackGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/QuestReportBackGump.cs @@ -31,7 +31,9 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 4) + { m_Instance.ContinueReportBack(true); + } } } } diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/QuestRewardGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/QuestRewardGump.cs index d1fee0e51..646cc0664 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/QuestRewardGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/QuestRewardGump.cs @@ -29,7 +29,9 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_Instance.ClaimRewards(); + } } } } diff --git a/Projects/UOContent/Engines/MLQuests/Gumps/RaceChangeGump.cs b/Projects/UOContent/Engines/MLQuests/Gumps/RaceChangeGump.cs index 77d9a11f8..19a564ff8 100644 --- a/Projects/UOContent/Engines/MLQuests/Gumps/RaceChangeGump.cs +++ b/Projects/UOContent/Engines/MLQuests/Gumps/RaceChangeGump.cs @@ -38,11 +38,17 @@ namespace Server.Engines.MLQuests.Gumps AddBackground(0, 0, 240, 135, 0x2422); if (targetRace == Race.Human) + { AddHtmlLocalized(15, 15, 210, 75, 1073643, 0); // Are you sure you wish to embrace your humanity? + } else if (targetRace == Race.Elf) + { AddHtmlLocalized(15, 15, 210, 75, 1073642, 0); // Are you sure you want to follow the elven ways? + } else + { AddHtml(15, 15, 210, 75, $"Are you sure you want to change your race to {targetRace.Name}?"); + } AddButton(160, 95, 0xF7, 0xF8, 1); AddButton(90, 95, 0xF2, 0xF1, 0); @@ -61,7 +67,9 @@ namespace Server.Engines.MLQuests.Gumps case 1: // Okay { if (m_Owner?.CheckComplete(m_From) != false) + { Offer(m_Owner, m_From, m_Race); + } break; } @@ -82,7 +90,9 @@ namespace Server.Engines.MLQuests.Gumps var ns = from.NetState; if (ns == null || !CanChange(from, targetRace)) + { return; + } CloseCurrent(ns); @@ -113,6 +123,7 @@ namespace Server.Engines.MLQuests.Gumps public static bool IsWearingEquipment(Mobile from) { foreach (var item in from.Items) + { switch (item.Layer) { case Layer.Hair: @@ -128,6 +139,7 @@ namespace Server.Engines.MLQuests.Gumps return true; } } + } return false; } @@ -135,28 +147,48 @@ namespace Server.Engines.MLQuests.Gumps private static bool CanChange(PlayerMobile from, Race targetRace) { if (from.Deleted) + { return false; + } if (from.Race == targetRace) - from.SendLocalizedMessage(1111918); // You are already that race. + { + @from.SendLocalizedMessage(1111918); // You are already that race. + } else if (!MondainsLegacy.CheckML(from, false)) - from.SendLocalizedMessage(1073651); // You must have Mondain's Legacy before proceeding... + { + @from.SendLocalizedMessage(1073651); // You must have Mondain's Legacy before proceeding... + } else if (!from.Alive) - from.SendLocalizedMessage(1073646); // Only the living may proceed... + { + @from.SendLocalizedMessage(1073646); // Only the living may proceed... + } else if (from.Mounted) - from.SendLocalizedMessage(1073647); // You may not continue while mounted... + { + @from.SendLocalizedMessage(1073647); // You may not continue while mounted... + } else if (!from.CanBeginAction() || DisguiseTimers.IsDisguised(from) || AnimalForm.UnderTransformation(from) || !from.CanBeginAction() || from.IsBodyMod) // TODO: Does this cover everything? - from.SendLocalizedMessage(1073648); // You may only proceed while in your original state... + { + @from.SendLocalizedMessage(1073648); // You may only proceed while in your original state... + } else if (from.Spell?.IsCasting == true) - from.SendLocalizedMessage(1073649); // One may not proceed while embracing magic... + { + @from.SendLocalizedMessage(1073649); // One may not proceed while embracing magic... + } else if (from.Poisoned) - from.SendLocalizedMessage(1073652); // You must be healthy to proceed... + { + @from.SendLocalizedMessage(1073652); // You must be healthy to proceed... + } else if (IsWearingEquipment(from)) - from.SendLocalizedMessage(1073650); // To proceed you must be unburdened by equipment... + { + @from.SendLocalizedMessage(1073650); // To proceed you must be unburdened by equipment... + } else + { return true; + } return false; } @@ -164,12 +196,16 @@ namespace Server.Engines.MLQuests.Gumps private static void RaceChangeReply(NetState state, PacketReader pvSrc) { if (!m_Pending.TryGetValue(state, out var raceChangeState)) + { return; + } CloseCurrent(state); if (!(state.Mobile is PlayerMobile pm)) + { return; + } var owner = raceChangeState.m_Owner; var targetRace = raceChangeState.m_TargetRace; @@ -182,7 +218,9 @@ namespace Server.Engines.MLQuests.Gumps } if (!CanChange(pm, targetRace) || owner?.CheckComplete(pm) == false) + { return; + } int hue = pvSrc.ReadUInt16(); int hairItemId = pvSrc.ReadUInt16(); @@ -214,11 +252,17 @@ namespace Server.Engines.MLQuests.Gumps } if (targetRace == Race.Human) + { pm.SendLocalizedMessage(1073654); // You are now fully human. + } else if (targetRace == Race.Elf) + { pm.SendLocalizedMessage(1073653); // You are now fully initiated into the Elven culture. + } else + { pm.SendMessage("You have fully changed your race to {0}.", targetRace.Name); + } owner?.ConsumeNeeded(pm); } @@ -285,7 +329,9 @@ namespace Server.Engines.MLQuests.Gumps public bool CheckComplete(PlayerMobile pm) { if (Deleted) + { return false; + } if (!IsChildOf(pm.Backpack)) { @@ -308,10 +354,14 @@ namespace Server.Engines.MLQuests.Gumps public override void OnDoubleClick(Mobile from) { if (!(from is PlayerMobile pm)) + { return; + } if (CheckComplete(pm)) + { pm.SendGump(new RaceChangeConfirmGump(this, pm, pm.Race == Race.Human ? Race.Elf : Race.Human)); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/MLQuests/Items/CraftmansSatchel.cs b/Projects/UOContent/Engines/MLQuests/Items/CraftmansSatchel.cs index bb4c81ae0..a88fe40e4 100644 --- a/Projects/UOContent/Engines/MLQuests/Items/CraftmansSatchel.cs +++ b/Projects/UOContent/Engines/MLQuests/Items/CraftmansSatchel.cs @@ -20,7 +20,9 @@ namespace Server.Engines.MLQuests.Items var loot = Loot.Construct(lootSets.RandomElement()); if (loot == null) + { return; + } RewardBag.Enhance(loot); DropItem(loot); @@ -32,7 +34,9 @@ namespace Server.Engines.MLQuests.Items var recipeID = system.RandomRecipe(); if (recipeID != -1) + { DropItem(new RecipeScroll(recipeID)); + } } public override void Serialize(IGenericWriter writer) @@ -58,7 +62,9 @@ namespace Server.Engines.MLQuests.Items AddBaseLoot(Loot.MLArmorTypes, Loot.JewelryTypes, m_TalismanType); if (Utility.RandomDouble() < 0.50) + { AddRecipe(DefTailoring.CraftSystem); + } } public TailorSatchel(Serial serial) @@ -89,7 +95,9 @@ namespace Server.Engines.MLQuests.Items AddBaseLoot(Loot.MLWeaponTypes, Loot.JewelryTypes, m_TalismanType); if (Utility.RandomDouble() < 0.50) + { AddRecipe(DefBlacksmithy.CraftSystem); + } } public BlacksmithSatchel(Serial serial) @@ -120,6 +128,7 @@ namespace Server.Engines.MLQuests.Items AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); if (Utility.RandomDouble() < 0.50) + { switch (Utility.Random(6)) { case 0: @@ -134,6 +143,7 @@ namespace Server.Engines.MLQuests.Items // case 4: AddNonArtifactRecipe( DefCarpentry.CraftSystem ); break; // case 5: AddNonArtifactRecipe( DefBowFletching.CraftSystem ); break; } + } } public TinkerSatchel(Serial serial) @@ -164,7 +174,9 @@ namespace Server.Engines.MLQuests.Items AddBaseLoot(Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); if (Utility.RandomDouble() < 0.50) + { AddRecipe(DefBowFletching.CraftSystem); + } // TODO: runic fletching kit } @@ -197,7 +209,9 @@ namespace Server.Engines.MLQuests.Items AddBaseLoot(Loot.MLArmorTypes, Loot.MLWeaponTypes, Loot.MLRangedWeaponTypes, Loot.JewelryTypes, m_TalismanType); if (Utility.RandomDouble() < 0.50) + { AddRecipe(DefCarpentry.CraftSystem); + } // TODO: Add runic dovetail saw } diff --git a/Projects/UOContent/Engines/MLQuests/Items/PrismaticAmber.cs b/Projects/UOContent/Engines/MLQuests/Items/PrismaticAmber.cs index e4e2fc468..08e7d9f01 100644 --- a/Projects/UOContent/Engines/MLQuests/Items/PrismaticAmber.cs +++ b/Projects/UOContent/Engines/MLQuests/Items/PrismaticAmber.cs @@ -25,7 +25,9 @@ namespace Server.Items var ret = base.DropToWorld(from, p); if (ret) - DestroyItem(from); + { + DestroyItem(@from); + } return ret; } @@ -35,7 +37,9 @@ namespace Server.Items var ret = base.DropToMobile(from, target, p); if (ret) - DestroyItem(from); + { + DestroyItem(@from); + } return ret; } @@ -45,7 +49,9 @@ namespace Server.Items var ret = base.DropToItem(from, target, p); if (ret && Parent != from.Backpack) - DestroyItem(from); + { + DestroyItem(@from); + } return ret; } diff --git a/Projects/UOContent/Engines/MLQuests/Items/PrismaticCrystal.cs b/Projects/UOContent/Engines/MLQuests/Items/PrismaticCrystal.cs index f23750f98..791eb6dcf 100644 --- a/Projects/UOContent/Engines/MLQuests/Items/PrismaticCrystal.cs +++ b/Projects/UOContent/Engines/MLQuests/Items/PrismaticCrystal.cs @@ -23,7 +23,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!(from is PlayerMobile pm) || pm.Backpack == null) + { return; + } if (pm.InRange(GetWorldLocation(), 2)) { diff --git a/Projects/UOContent/Engines/MLQuests/Items/QuestGiverItem.cs b/Projects/UOContent/Engines/MLQuests/Items/QuestGiverItem.cs index 2b0bc9bd0..ad6121aa8 100644 --- a/Projects/UOContent/Engines/MLQuests/Items/QuestGiverItem.cs +++ b/Projects/UOContent/Engines/MLQuests/Items/QuestGiverItem.cs @@ -34,17 +34,25 @@ namespace Server.Engines.MLQuests.Items AddQuestItemProperty(list); if (CanGiveMLQuest) + { list.Add(1072269); // Quest Giver + } } public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (!IsChildOf(from.Backpack)) - from.SendLocalizedMessage(1042593); // That is not in your backpack. + { + @from.SendLocalizedMessage(1042593); // That is not in your backpack. + } else if (MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile) + { MLQuestSystem.OnDoubleClick(this, mobile); + } } public override void OnAfterDelete() @@ -52,7 +60,9 @@ namespace Server.Engines.MLQuests.Items base.OnAfterDelete(); if (MLQuestSystem.Enabled) + { MLQuestSystem.HandleDeletion(this); + } } public override void Serialize(IGenericWriter writer) @@ -102,17 +112,25 @@ namespace Server.Engines.MLQuests.Items AddQuestItemProperty(list); if (CanGiveMLQuest) + { list.Add(1072269); // Quest Giver + } } public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (!IsChildOf(from.Backpack)) - from.SendLocalizedMessage(1042593); // That is not in your backpack. + { + @from.SendLocalizedMessage(1042593); // That is not in your backpack. + } else if (MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile) + { MLQuestSystem.OnDoubleClick(this, mobile); + } } public override void OnAfterDelete() @@ -120,7 +138,9 @@ namespace Server.Engines.MLQuests.Items base.OnAfterDelete(); if (MLQuestSystem.Enabled) + { MLQuestSystem.HandleDeletion(this); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/MLQuests/Items/RewardBags.cs b/Projects/UOContent/Engines/MLQuests/Items/RewardBags.cs index c1cff5005..d078eda18 100644 --- a/Projects/UOContent/Engines/MLQuests/Items/RewardBags.cs +++ b/Projects/UOContent/Engines/MLQuests/Items/RewardBags.cs @@ -28,7 +28,9 @@ namespace Server.Engines.MLQuests.Items }; if (loot == null) + { continue; + } Enhance(loot); c.DropItem(loot); @@ -43,9 +45,15 @@ namespace Server.Engines.MLQuests.Items return; } - if (loot is BaseArmor armor) BaseRunicTool.ApplyAttributesTo(armor, Utility.RandomMinMax(1, 5), 10, 80); + if (loot is BaseArmor armor) + { + BaseRunicTool.ApplyAttributesTo(armor, Utility.RandomMinMax(1, 5), 10, 80); + } - if (loot is BaseJewel jewel) BaseRunicTool.ApplyAttributesTo(jewel, Utility.RandomMinMax(1, 5), 10, 80); + if (loot is BaseJewel jewel) + { + BaseRunicTool.ApplyAttributesTo(jewel, Utility.RandomMinMax(1, 5), 10, 80); + } } } diff --git a/Projects/UOContent/Engines/MLQuests/Items/Teleporters.cs b/Projects/UOContent/Engines/MLQuests/Items/Teleporters.cs index 143eb306c..6402b040e 100644 --- a/Projects/UOContent/Engines/MLQuests/Items/Teleporters.cs +++ b/Projects/UOContent/Engines/MLQuests/Items/Teleporters.cs @@ -46,17 +46,26 @@ namespace Server.Engines.MLQuests.Items public override bool CanTeleport(Mobile m) { if (!base.CanTeleport(m)) + { return false; + } if (m_QuestType == null) + { return true; + } + if (!(m is PlayerMobile pm)) + { return false; + } var context = MLQuestSystem.GetContext(pm); if (context?.IsDoingQuest(m_QuestType) == true || context?.HasDoneQuest(m_QuestType) == true) + { return true; + } TextDefinition.SendMessageTo(m, Message); return false; @@ -67,7 +76,9 @@ namespace Server.Engines.MLQuests.Items base.GetProperties(list); if (m_QuestType != null) + { list.Add($"Required quest: {m_QuestType.Name}"); + } } public override void Serialize(IGenericWriter writer) @@ -89,7 +100,9 @@ namespace Server.Engines.MLQuests.Items var typeName = reader.ReadString(); if (typeName != null) + { m_QuestType = AssemblyHandler.FindFirstTypeForName(typeName); + } Message = TextDefinition.Deserialize(reader); } @@ -142,10 +155,14 @@ namespace Server.Engines.MLQuests.Items public override bool CanTeleport(Mobile m) { if (!base.CanTeleport(m)) + { return false; + } if (m_TicketType == null) + { return true; + } var pack = m.Backpack; var ticket = pack?.FindItemByType(m_TicketType, false) ?? @@ -167,7 +184,9 @@ namespace Server.Engines.MLQuests.Items base.GetProperties(list); if (m_TicketType != null) + { list.Add($"Required ticket: {m_TicketType.Name}"); + } } public override void Serialize(IGenericWriter writer) @@ -189,7 +208,9 @@ namespace Server.Engines.MLQuests.Items var typeName = reader.ReadString(); if (typeName != null) + { m_TicketType = AssemblyHandler.FindFirstTypeForName(typeName); + } Message = TextDefinition.Deserialize(reader); } diff --git a/Projects/UOContent/Engines/MLQuests/MLQuest.cs b/Projects/UOContent/Engines/MLQuests/MLQuest.cs index ef982cba2..259c164c7 100644 --- a/Projects/UOContent/Engines/MLQuests/MLQuest.cs +++ b/Projects/UOContent/Engines/MLQuests/MLQuest.cs @@ -90,8 +90,12 @@ namespace Server.Engines.MLQuests public bool HasObjective() where T : BaseObjective { foreach (var obj in Objectives) + { if (obj is T) + { return true; + } + } return false; } @@ -99,7 +103,9 @@ namespace Server.Engines.MLQuests public virtual void Generate() { if (MLQuestSystem.Debug) + { Console.WriteLine("INFO: Generating quest: {0}", GetType()); + } } public MLQuestInstance CreateInstance(IQuestGiver quester, PlayerMobile pm) => @@ -111,14 +117,18 @@ namespace Server.Engines.MLQuests public virtual bool CanOffer(IQuestGiver quester, PlayerMobile pm, MLQuestContext context, bool message) { if (!Activated || quester.Deleted) + { return false; + } if (context != null) { if (context.IsFull) { if (message) + { MLQuestSystem.Tell(quester, pm, 1080107); // I'm sorry, I have nothing for you at this time. + } return false; } @@ -132,7 +142,9 @@ namespace Server.Engines.MLQuests if (checkQuest.OneTimeOnly) { if (message) + { MLQuestSystem.Tell(quester, pm, 1075454); // I cannot offer you the quest again. + } return false; } @@ -140,26 +152,34 @@ namespace Server.Engines.MLQuests if (nextAvailable > DateTime.UtcNow) { if (message) + { MLQuestSystem.Tell( quester, pm, 1075575 ); // I'm sorry, but I don't have anything else for you right now. Could you check back with me in a few minutes? + } return false; } } if (checkQuest.NextQuest == null) + { break; + } checkQuest = MLQuestSystem.FindQuest(checkQuest.NextQuest); } } foreach (var obj in Objectives) + { if (!obj.CanOffer(quester, pm, message)) + { return false; + } + } return true; } @@ -172,7 +192,9 @@ namespace Server.Engines.MLQuests public virtual void OnAccept(IQuestGiver quester, PlayerMobile pm) { if (!CanOffer(quester, pm, true)) + { return; + } var instance = CreateInstance(quester, pm); @@ -182,7 +204,9 @@ namespace Server.Engines.MLQuests OnAccepted(instance); foreach (var obj in instance.Objectives) + { obj.OnQuestAccepted(); + } } public virtual void OnAccepted(MLQuestInstance instance) @@ -229,7 +253,9 @@ namespace Server.Engines.MLQuests var oldVersion = reader.ReadInt(); if (quest == null) + { return; // not saved or no longer exists + } quest.Refresh(oldVersion); quest.Deserialized = true; @@ -246,7 +272,9 @@ namespace Server.Engines.MLQuests var toDelete = map.GetItemsInRange(loc, 0).Where(item => item is Spawner && item.Name == name); foreach (var item in toDelete) + { item.Delete(); + } s.Name = name; s.MoveToWorld(loc, map); @@ -258,7 +286,9 @@ namespace Server.Engines.MLQuests var toDelete = map.GetItemsInRange(loc, 0).Where(item => item.ItemID == deco.ItemID && item.Z == loc.Z); foreach (var item in toDelete) + { item.Delete(); + } deco.MoveToWorld(loc, map); } diff --git a/Projects/UOContent/Engines/MLQuests/MLQuestContext.cs b/Projects/UOContent/Engines/MLQuests/MLQuestContext.cs index 50c113ea4..44c85e464 100644 --- a/Projects/UOContent/Engines/MLQuests/MLQuestContext.cs +++ b/Projects/UOContent/Engines/MLQuests/MLQuestContext.cs @@ -43,7 +43,9 @@ namespace Server.Engines.MLQuests var instance = MLQuestInstance.Deserialize(reader, version, Owner); if (instance != null) + { QuestInstances.Add(instance); + } } var doneQuests = reader.ReadInt(); @@ -53,7 +55,9 @@ namespace Server.Engines.MLQuests var info = MLDoneQuestInfo.Deserialize(reader, version); if (info != null) + { m_DoneQuests.Add(info); + } } var chainOffers = reader.ReadInt(); @@ -63,7 +67,9 @@ namespace Server.Engines.MLQuests var quest = MLQuestSystem.ReadQuestRef(reader); if (quest?.IsChainTriggered == true) + { ChainOffers.Add(quest); + } } m_Flags = (MLQuestFlag)reader.ReadEncodedInt(); @@ -116,8 +122,12 @@ namespace Server.Engines.MLQuests public bool HasDoneQuest(MLQuest quest) { foreach (var info in m_DoneQuests) + { if (info.m_Quest == quest) + { return true; + } + } return false; } @@ -127,11 +137,13 @@ namespace Server.Engines.MLQuests nextAvailable = DateTime.MinValue; foreach (var info in m_DoneQuests) + { if (info.m_Quest == quest) { nextAvailable = info.m_NextAvailable; return true; } + } return false; } @@ -144,11 +156,13 @@ namespace Server.Engines.MLQuests public void SetDoneQuest(MLQuest quest, DateTime nextAvailable) { foreach (var info in m_DoneQuests) + { if (info.m_Quest == quest) { info.m_NextAvailable = nextAvailable; return; } + } m_DoneQuests.Add(new MLDoneQuestInfo(quest, nextAvailable)); } @@ -160,20 +174,26 @@ namespace Server.Engines.MLQuests var info = m_DoneQuests[i]; if (info.m_Quest == quest) + { m_DoneQuests.RemoveAt(i); + } } } public void HandleDeath() { for (var i = QuestInstances.Count - 1; i >= 0; --i) + { QuestInstances[i].OnPlayerDeath(); + } } public void HandleDeletion() { for (var i = QuestInstances.Count - 1; i >= 0; --i) + { QuestInstances[i].Remove(); + } } public MLQuestInstance FindInstance(Type questType) @@ -181,7 +201,9 @@ namespace Server.Engines.MLQuests var quest = MLQuestSystem.FindQuest(questType); if (quest == null) + { return null; + } return FindInstance(quest); } @@ -189,8 +211,12 @@ namespace Server.Engines.MLQuests public MLQuestInstance FindInstance(MLQuest quest) { foreach (var instance in QuestInstances) + { if (instance.Quest == quest) + { return instance; + } + } return null; } @@ -212,17 +238,23 @@ namespace Server.Engines.MLQuests writer.Write(QuestInstances.Count); foreach (var instance in QuestInstances) + { instance.Serialize(writer); + } writer.Write(m_DoneQuests.Count); foreach (var info in m_DoneQuests) + { info.Serialize(writer); + } writer.Write(ChainOffers.Count); foreach (var quest in ChainOffers) + { MLQuestSystem.WriteQuestRef(writer, quest); + } writer.WriteEncodedInt((int)m_Flags); } @@ -232,9 +264,13 @@ namespace Server.Engines.MLQuests public void SetFlag(MLQuestFlag flag, bool value) { if (value) + { m_Flags |= flag; + } else + { m_Flags &= ~flag; + } } private class MLDoneQuestInfo @@ -260,7 +296,9 @@ namespace Server.Engines.MLQuests var nextAvailable = reader.ReadDateTime(); if (quest?.RecordCompletion != true) + { return null; // forget about this record + } return new MLDoneQuestInfo(quest, nextAvailable); } diff --git a/Projects/UOContent/Engines/MLQuests/MLQuestEntry.cs b/Projects/UOContent/Engines/MLQuests/MLQuestEntry.cs index f5ae7d632..f4adcb5fb 100644 --- a/Projects/UOContent/Engines/MLQuests/MLQuestEntry.cs +++ b/Projects/UOContent/Engines/MLQuests/MLQuestEntry.cs @@ -43,13 +43,17 @@ namespace Server.Engines.MLQuests Objectives[i] = obj = quest.Objectives[i].CreateInstance(this); if (obj.IsTimed) + { timed = true; + } } Register(); if (timed) + { m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), Slice); + } } public MLQuest Quest { get; set; } @@ -99,7 +103,9 @@ namespace Server.Engines.MLQuests Quest?.Instances?.Add(this); if (Player != null) + { PlayerContext.QuestInstances.Add(this); + } } private void Unregister() @@ -107,7 +113,9 @@ namespace Server.Engines.MLQuests Quest?.Instances?.Remove(this); if (Player != null) + { PlayerContext.QuestInstances.Remove(this); + } Removed = true; } @@ -115,8 +123,12 @@ namespace Server.Engines.MLQuests public bool AllowsQuestItem(Item item, Type type) { foreach (var objective in Objectives) + { if (!objective.Expired && objective.AllowsQuestItem(item, type)) + { return true; + } + } return false; } @@ -130,9 +142,14 @@ namespace Server.Engines.MLQuests var complete = obj.IsCompleted(); if (complete && !requiresAll) + { return true; + } + if (!complete && requiresAll) + { return false; + } } return requiresAll; @@ -145,7 +162,9 @@ namespace Server.Engines.MLQuests Player.PlaySound(0x5B5); // public sound foreach (var obj in Objectives) + { obj.OnQuestCompleted(); + } TextDefinition.SendMessageTo(Player, Quest.CompletionNotice, 0x23); @@ -159,7 +178,9 @@ namespace Server.Engines.MLQuests */ if (!Removed && SkipReportBack && !Quest.RequiresCollection ) // An OnQuestCompleted can potentially have removed this instance already + { ContinueReportBack(false); + } } } @@ -180,6 +201,7 @@ namespace Server.Engines.MLQuests var hasAnyLeft = false; foreach (var obj in Objectives) + { if (!obj.Expired) { if (obj.IsTimed && obj.EndTime <= DateTime.UtcNow) @@ -196,12 +218,17 @@ namespace Server.Engines.MLQuests hasAnyLeft = true; } } + } if (Quest.ObjectiveType == ObjectiveType.All && hasAnyFails || !hasAnyLeft) + { Fail(); + } if (!hasAnyLeft) + { StopTimer(); + } } public void SendProgressGump() @@ -239,9 +266,13 @@ namespace Server.Engines.MLQuests public void SendReportBackGump() { if (SkipReportBack) + { ContinueReportBack(true); // skip ahead + } else + { Player.SendGump(new QuestReportBackGump(this)); + } } public void ContinueReportBack(bool sendRewardGump) @@ -252,15 +283,25 @@ namespace Server.Engines.MLQuests { // TODO: 1115877 - You no longer have the required items to complete this quest. foreach (var objective in Objectives) + { if (!objective.IsCompleted()) + { return; + } + } foreach (var objective in Objectives) + { if (!objective.OnBeforeClaimReward()) + { return; + } + } foreach (var objective in Objectives) + { objective.OnClaimReward(); + } } else { @@ -271,6 +312,7 @@ namespace Server.Engines.MLQuests var complete = false; foreach (var objective in Objectives) + { if (objective.IsCompleted()) { if (objective.OnBeforeClaimReward()) @@ -281,33 +323,46 @@ namespace Server.Engines.MLQuests break; } + } if (!complete) + { return; + } } ClaimReward = true; if (Quest.HasRestartDelay) + { PlayerContext.SetDoneQuest(Quest, DateTime.UtcNow + Quest.GetRestartDelay()); + } // This is correct for ObjectiveType.Any as well foreach (var objective in Objectives) + { objective.OnAfterClaimReward(); + } if (sendRewardGump) + { SendRewardOffer(); + } } public void ClaimRewards() { if (Quest == null || Player?.Deleted != false || !ClaimReward || Removed) + { return; + } var rewards = new List(); foreach (var reward in Quest.Rewards) + { reward.AddRewardItems(Player, rewards); + } if (rewards.Count != 0) { @@ -316,16 +371,20 @@ namespace Server.Engines.MLQuests var canFit = true; foreach (var rewardItem in rewards) + { if (!Player.AddToBackpack(rewardItem)) { canFit = false; break; } + } if (!canFit) { foreach (var rewardItem in rewards) + { rewardItem.Delete(); + } Player.SendLocalizedMessage( 1078524 @@ -338,27 +397,37 @@ namespace Server.Engines.MLQuests var rewardName = rewardItem.Name ?? $"#{rewardItem.LabelNumber}"; if (rewardItem.Stackable) + { Player.SendLocalizedMessage( 1115917, $"{rewardItem.Amount}\t{rewardName}" ); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~ + } else + { Player.SendLocalizedMessage(1074360, rewardName); // You receive a reward: ~1_REWARD~ + } } } foreach (var objective in Objectives) + { objective.OnRewardClaimed(); + } Quest.OnRewardClaimed(this); var context = PlayerContext; if (Quest.RecordCompletion && !Quest.HasRestartDelay) // Quests with restart delays are logged earlier as per OSI + { context.SetDoneQuest(Quest); + } if (Quest.IsChainTriggered) + { context.ChainOffers.Remove(Quest); + } var nextQuestType = Quest.NextQuest; @@ -367,7 +436,9 @@ namespace Server.Engines.MLQuests var nextQuest = MLQuestSystem.FindQuest(nextQuestType); if (nextQuest != null && !context.ChainOffers.Contains(nextQuest)) + { context.ChainOffers.Add(nextQuest); + } } Remove(); @@ -385,12 +456,16 @@ namespace Server.Engines.MLQuests Player.SendSound(0x5B3); // private sound foreach (var obj in Objectives) + { obj.OnQuestCancelled(); + } Quest.OnCancel(this); if (removeChain) + { PlayerContext.ChainOffers.Remove(Quest); + } } public void Remove() @@ -402,7 +477,10 @@ namespace Server.Engines.MLQuests private void StopTimer() { if (m_Timer == null) + { return; + } + m_Timer.Stop(); m_Timer = null; } @@ -410,7 +488,9 @@ namespace Server.Engines.MLQuests public void OnQuesterDeleted() { foreach (var obj in Objectives) + { obj.OnQuesterDeleted(); + } Quest.OnQuesterDeleted(this); } @@ -418,7 +498,9 @@ namespace Server.Engines.MLQuests public void OnPlayerDeath() { foreach (var obj in Objectives) + { obj.OnPlayerDeath(); + } Quest.OnPlayerDeath(this); } @@ -428,9 +510,13 @@ namespace Server.Engines.MLQuests private void SetFlag(MLQuestInstanceFlags flag, bool value) { if (value) + { m_Flags |= flag; + } else + { m_Flags &= ~flag; + } } public void Serialize(IGenericWriter writer) @@ -445,7 +531,9 @@ namespace Server.Engines.MLQuests writer.Write(Objectives.Length); foreach (var objInstance in Objectives) + { objInstance.Serialize(writer); + } } public static MLQuestInstance Deserialize(IGenericReader reader, int version, PlayerMobile pm) @@ -471,11 +559,13 @@ namespace Server.Engines.MLQuests } for (var i = 0; i < objectives; ++i) + { BaseObjectiveInstance.Deserialize( reader, version, instance != null && i < instance.Objectives.Length ? instance.Objectives[i] : null ); + } instance?.Slice(); diff --git a/Projects/UOContent/Engines/MLQuests/MLQuestPersistence.cs b/Projects/UOContent/Engines/MLQuests/MLQuestPersistence.cs index 17455a3ec..57f792935 100644 --- a/Projects/UOContent/Engines/MLQuests/MLQuestPersistence.cs +++ b/Projects/UOContent/Engines/MLQuests/MLQuestPersistence.cs @@ -25,12 +25,16 @@ namespace Server.Engines.MLQuests writer.Write(MLQuestSystem.Contexts.Count); foreach (var context in MLQuestSystem.Contexts.Values) + { context.Serialize(writer); + } writer.Write(MLQuestSystem.Quests.Count); foreach (var quest in MLQuestSystem.Quests.Values) + { MLQuest.Serialize(writer, quest); + } } public override void Deserialize(IGenericReader reader) @@ -45,13 +49,17 @@ namespace Server.Engines.MLQuests var context = new MLQuestContext(reader, version); if (context.Owner != null) + { MLQuestSystem.Contexts[context.Owner] = context; + } } var quests = reader.ReadInt(); for (var i = 0; i < quests; ++i) + { MLQuest.Deserialize(reader, version); + } } } } diff --git a/Projects/UOContent/Engines/MLQuests/Mobiles/BoonCollector.cs b/Projects/UOContent/Engines/MLQuests/Mobiles/BoonCollector.cs index 64f447934..8b0f051e7 100644 --- a/Projects/UOContent/Engines/MLQuests/Mobiles/BoonCollector.cs +++ b/Projects/UOContent/Engines/MLQuests/Mobiles/BoonCollector.cs @@ -34,7 +34,9 @@ namespace Server.Engines.MLQuests.Mobiles public bool CheckComplete(PlayerMobile pm) { if (CompletedCount(pm) == Needed.Length) + { return true; + } pm.SendLocalizedMessage(1073644); // You must complete all the tasks before proceeding... return false; @@ -45,13 +47,17 @@ namespace Server.Engines.MLQuests.Mobiles var context = MLQuestSystem.GetContext(pm); if (context != null) + { foreach (var type in Needed) { var quest = MLQuestSystem.FindQuest(type); if (quest != null) + { context.RemoveDoneQuest(quest); + } } + } } public void OnCancel(PlayerMobile pm) @@ -72,7 +78,9 @@ namespace Server.Engines.MLQuests.Mobiles public override void OnMovement(Mobile m, Point3D oldLocation) { if (m.Player && InRange(m, 6) && !InRange(oldLocation, 6)) + { TryTalkTo(m, false); + } base.OnMovement(m, oldLocation); } @@ -81,9 +89,13 @@ namespace Server.Engines.MLQuests.Mobiles { if (!from.Hidden && !from.HasGump() && !RaceChangeConfirmGump.IsPending(from.NetState) && CanTalkTo(from)) - TalkTo(from as PlayerMobile); + { + TalkTo(@from as PlayerMobile); + } else if (fromClick) - DenyTalk(from); + { + DenyTalk(@from); + } } public virtual bool CanTalkTo(Mobile from) => true; @@ -95,7 +107,9 @@ namespace Server.Engines.MLQuests.Mobiles public void TalkTo(PlayerMobile pm) { if (pm == null || m_Timer?.Running == true) + { return; + } var completed = CompletedCount(pm); @@ -115,15 +129,19 @@ namespace Server.Engines.MLQuests.Mobiles var context = MLQuestSystem.GetContext(pm); if (context != null) + { foreach (var type in Needed) { var quest = MLQuestSystem.FindQuest(type); if (quest == null || context.HasDoneQuest(quest)) + { continue; + } conversation.Add(quest.Title); } + } m_Timer = new InternalTimer(this, pm, conversation, false); } @@ -136,7 +154,9 @@ namespace Server.Engines.MLQuests.Mobiles var context = MLQuestSystem.GetContext(pm); if (context == null) + { return 0; + } var result = 0; @@ -145,7 +165,9 @@ namespace Server.Engines.MLQuests.Mobiles var quest = MLQuestSystem.FindQuest(type); if (quest == null || context.HasDoneQuest(quest)) + { ++result; + } } return result; @@ -203,7 +225,9 @@ namespace Server.Engines.MLQuests.Mobiles if (m_Index >= m_Conversation.Count) { if (m_IsComplete) + { m_Owner.OnComplete(m_Target); + } Stop(); } @@ -212,9 +236,13 @@ namespace Server.Engines.MLQuests.Mobiles if (m_Index == 0) { if (m_Target.ShowFameTitle && m_Target.Fame >= 10000) + { m_Owner.Say(true, $"{(m_Target.Female ? "Lady" : "Lord")} {m_Target.Name}"); + } else + { m_Owner.Say(true, m_Target.Name); + } } TextDefinition.PublicOverheadMessage(m_Owner, MessageType.Regular, 0x3B2, m_Conversation[m_Index++]); diff --git a/Projects/UOContent/Engines/MLQuests/Objectives/BaseObjective.cs b/Projects/UOContent/Engines/MLQuests/Objectives/BaseObjective.cs index 498236a56..89d841c69 100644 --- a/Projects/UOContent/Engines/MLQuests/Objectives/BaseObjective.cs +++ b/Projects/UOContent/Engines/MLQuests/Objectives/BaseObjective.cs @@ -31,7 +31,9 @@ namespace Server.Engines.MLQuests.Objectives Instance = instance; if (obj.IsTimed) + { EndTime = DateTime.UtcNow + obj.Duration; + } } public MLQuestInstance Instance { get; } @@ -47,7 +49,9 @@ namespace Server.Engines.MLQuests.Objectives public virtual void WriteToGump(Gump g, ref int y) { if (IsTimed) + { WriteTimeRemaining(g, ref y, EndTime > DateTime.UtcNow ? EndTime - DateTime.UtcNow : TimeSpan.Zero); + } } public static void WriteTimeRemaining(Gump g, ref int y, TimeSpan timeRemaining) @@ -134,7 +138,9 @@ namespace Server.Engines.MLQuests.Objectives var endTime = reader.ReadDeltaTime(); if (objInstance != null) + { objInstance.EndTime = endTime; + } } var extraDataType = (DataType)reader.ReadByte(); @@ -146,7 +152,9 @@ namespace Server.Engines.MLQuests.Objectives var completed = reader.ReadBool(); if (objInstance is EscortObjectiveInstance instance) + { instance.HasCompleted = completed; + } break; } @@ -155,7 +163,9 @@ namespace Server.Engines.MLQuests.Objectives var slain = reader.ReadInt(); if (objInstance is KillObjectiveInstance instance) + { instance.Slain = slain; + } break; } @@ -164,7 +174,9 @@ namespace Server.Engines.MLQuests.Objectives var completed = reader.ReadBool(); if (objInstance is DeliverObjectiveInstance instance) + { instance.HasCompleted = completed; + } break; } diff --git a/Projects/UOContent/Engines/MLQuests/Objectives/CollectObjective.cs b/Projects/UOContent/Engines/MLQuests/Objectives/CollectObjective.cs index 91b6fff1b..f6891a3c6 100644 --- a/Projects/UOContent/Engines/MLQuests/Objectives/CollectObjective.cs +++ b/Projects/UOContent/Engines/MLQuests/Objectives/CollectObjective.cs @@ -17,7 +17,9 @@ namespace Server.Engines.MLQuests.Objectives var itemid = LabelToItemID(name.Number); if (itemid <= 0 || itemid > 0x4000) + { Console.WriteLine("Warning: cliloc {0} is likely giving the wrong item ID", name.Number); + } } } @@ -36,7 +38,10 @@ namespace Server.Engines.MLQuests.Objectives public static int LabelToItemID(int label) { if (label < 1078872) + { return label - 1020000; + } + return label - 1078872; } @@ -62,9 +67,13 @@ namespace Server.Engines.MLQuests.Objectives else { if (Name.Number > 0) + { g.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x15F90); + } else if (Name.String != null) + { g.AddLabel(98, y, 0x481, Name.String); + } } y += 32; @@ -97,7 +106,9 @@ namespace Server.Engines.MLQuests.Objectives var pack = Instance.Player.Backpack; if (pack == null) + { return 0; + } var items = pack.FindItemsByType(Objective.AcceptedType, false); // Note: subclasses are included return items.Where(item => item.QuestItem && Objective.CheckItem(item)).Sum(item => item.Amount); @@ -113,15 +124,21 @@ namespace Server.Engines.MLQuests.Objectives var pack = pm.Backpack; if (pack == null) + { return; + } var checkType = Objective.AcceptedType; var items = pack.FindItemsByType(checkType, false); foreach (var item in items) + { if (item.QuestItem && !MLQuestSystem.CanMarkQuestItem(pm, item, checkType) ) // does another quest still need this item? (OSI just unmarks everything) + { item.QuestItem = false; + } + } } // Should only be called after IsComplete() is checked to be true @@ -130,7 +147,9 @@ namespace Server.Engines.MLQuests.Objectives var pack = Instance.Player.Backpack; if (pack == null) + { return; + } // TODO: OSI also counts the item in the cursor? @@ -138,10 +157,13 @@ namespace Server.Engines.MLQuests.Objectives var left = Objective.DesiredAmount; foreach (var item in items) + { if (item.QuestItem && Objective.CheckItem(item)) { if (left == 0) + { return; + } if (item.Amount > left) { @@ -154,6 +176,7 @@ namespace Server.Engines.MLQuests.Objectives left -= item.Amount; } } + } } public override void OnAfterClaimReward() diff --git a/Projects/UOContent/Engines/MLQuests/Objectives/DeliverObjective.cs b/Projects/UOContent/Engines/MLQuests/Objectives/DeliverObjective.cs index 00c00c44a..582954fe4 100644 --- a/Projects/UOContent/Engines/MLQuests/Objectives/DeliverObjective.cs +++ b/Projects/UOContent/Engines/MLQuests/Objectives/DeliverObjective.cs @@ -22,7 +22,9 @@ namespace Server.Engines.MLQuests.Objectives var itemid = CollectObjective.LabelToItemID(name.Number); if (itemid <= 0 || itemid > 0x4000) + { Console.WriteLine("Warning: cliloc {0} is likely giving the wrong item ID", name.Number); + } } } @@ -39,14 +41,18 @@ namespace Server.Engines.MLQuests.Objectives public virtual void SpawnDelivery(Container pack) { if (!SpawnsDelivery || pack == null) + { return; + } var delivery = new List(); for (var i = 0; i < Amount; ++i) { if (!(ActivatorUtil.CreateInstance(Delivery) is Item item)) + { continue; + } delivery.Add(item); @@ -58,7 +64,9 @@ namespace Server.Engines.MLQuests.Objectives } foreach (var item in delivery) + { pack.DropItem(item); // Confirmed: on OSI items are added even if your pack is full + } } public override void WriteToGump(Gump g, ref int y) @@ -135,7 +143,9 @@ namespace Server.Engines.MLQuests.Objectives var pack = Instance.Player.Backpack; if (pack == null) + { return 0; + } var items = pack.FindItemsByType(Objective.Delivery, false); // Note: subclasses are included return items.Sum(item => item.Amount); @@ -164,7 +174,9 @@ namespace Server.Engines.MLQuests.Objectives var pack = Instance.Player.Backpack; if (pack == null) + { return; + } var items = pack.FindItemsByType(Objective.Delivery, false); var left = Objective.Amount; @@ -172,7 +184,9 @@ namespace Server.Engines.MLQuests.Objectives foreach (var item in items) { if (left == 0) + { break; + } if (item.Amount > left) { diff --git a/Projects/UOContent/Engines/MLQuests/Objectives/EscortObjective.cs b/Projects/UOContent/Engines/MLQuests/Objectives/EscortObjective.cs index c066d0c1c..f5b793b7e 100644 --- a/Projects/UOContent/Engines/MLQuests/Objectives/EscortObjective.cs +++ b/Projects/UOContent/Engines/MLQuests/Objectives/EscortObjective.cs @@ -15,19 +15,27 @@ namespace Server.Engines.MLQuests.Objectives { if (quester is BaseCreature creature && creature.Controlled || quester is BaseEscortable escortable && escortable.IsBeingDeleted) + { return false; + } var context = MLQuestSystem.GetContext(pm); if (context != null) + { foreach (var instance in context.QuestInstances) + { if (instance.Quest.IsEscort) { if (message) + { MLQuestSystem.Tell(quester, pm, 500896); // I see you already have an escort. + } return false; } + } + } var nextEscort = pm.LastEscortTime + BaseEscortable.EscortDelay; @@ -38,14 +46,18 @@ namespace Server.Engines.MLQuests.Objectives var minutes = (int)Math.Ceiling((nextEscort - DateTime.UtcNow).TotalMinutes); if (minutes == 1) + { MLQuestSystem.Tell(quester, pm, "You must rest 1 minute before we set out on this journey."); + } else + { MLQuestSystem.Tell( quester, pm, 1071195, minutes.ToString() ); // You must rest ~1_minsleft~ minutes before we set out on this journey. + } } return false; @@ -59,9 +71,13 @@ namespace Server.Engines.MLQuests.Objectives g.AddHtmlLocalized(98, y, 312, 16, 1072206, 0x15F90); // Escort to if (Destination.Name.Number > 0) + { g.AddHtmlLocalized(173, y, 312, 20, Destination.Name.Number, 0xFFFFFF); + } else if (Destination.Name.String != null) + { g.AddLabel(173, y, 0x481, Destination.Name.String); + } y += 16; } @@ -69,7 +85,9 @@ namespace Server.Engines.MLQuests.Objectives public override BaseObjectiveInstance CreateInstance(MLQuestInstance instance) { if (instance == null || Destination == null) + { return null; + } return new EscortObjectiveInstance(this, instance); } @@ -92,10 +110,12 @@ namespace Server.Engines.MLQuests.Objectives m_Escort = instance.Quester as BaseCreature; if (MLQuestSystem.Debug && m_Escort == null && instance.Quester != null) + { Console.WriteLine( "Warning: EscortObjective is not supported for type '{0}'", instance.Quester.GetType().Name ); + } } public bool HasCompleted { get; set; } @@ -127,13 +147,17 @@ namespace Server.Engines.MLQuests.Objectives ); // We have arrived! I thank thee, ~1_PLAYER_NAME~! I have no further need of thy services. Here is thy pay. if (pm.Young || m_Escort.Region.IsPartOf("Haven Island")) + { Titles.AwardFame(pm, 10, true); + } else + { VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, m_Escort is BaseEscortable escortable && escortable.IsPrisoner ? 400 : 200 ); + } EndFollow(m_Escort); StopTimer(); @@ -147,7 +171,9 @@ namespace Server.Engines.MLQuests.Objectives else if (pm.Map != m_Escort.Map || !pm.InRange(m_Escort, 30)) // TODO: verify range { if (m_LastSeenEscorter + BaseEscortable.AbandonDelay <= DateTime.UtcNow) + { Abandon(); + } } else { @@ -202,7 +228,9 @@ namespace Server.Engines.MLQuests.Objectives pm.LastEscortTime = DateTime.UtcNow; if (m_Escort != null) + { BeginFollow(m_Escort, pm); + } } public void Abandon() @@ -215,9 +243,13 @@ namespace Server.Engines.MLQuests.Objectives if (m_Escort?.Deleted == false) { if (!pm.Alive) + { m_Escort.Say(500901); // Ack! My escort has come to haunt me! + } else + { m_Escort.Say(500902); // My escort seems to have abandoned me! + } EndFollow(m_Escort); } @@ -227,13 +259,17 @@ namespace Server.Engines.MLQuests.Objectives pm.SendLocalizedMessage(1071194); // You have failed your escort quest... if (!instance.Removed) + { instance.Cancel(); + } } public override void OnQuesterDeleted() { if (IsCompleted() || Instance.Removed) + { return; + } Abandon(); } @@ -242,7 +278,9 @@ namespace Server.Engines.MLQuests.Objectives { // Note: OSI also cancels it when the quest is already complete if ( /*IsCompleted() ||*/ Instance.Removed) + { return; + } Instance.Cancel(); } diff --git a/Projects/UOContent/Engines/MLQuests/Objectives/GainSkillObjective.cs b/Projects/UOContent/Engines/MLQuests/Objectives/GainSkillObjective.cs index 7bae273c0..e6fc4333c 100644 --- a/Projects/UOContent/Engines/MLQuests/Objectives/GainSkillObjective.cs +++ b/Projects/UOContent/Engines/MLQuests/Objectives/GainSkillObjective.cs @@ -25,10 +25,14 @@ namespace Server.Engines.MLQuests.Objectives m_Flags = GainSkillObjectiveFlags.None; if (useReal) + { m_Flags |= GainSkillObjectiveFlags.UseReal; + } if (accelerate) + { m_Flags |= GainSkillObjectiveFlags.Accelerate; + } } public SkillName Skill { get; set; } @@ -54,7 +58,9 @@ namespace Server.Engines.MLQuests.Objectives if ((UseReal ? skill.Fixed : skill.BaseFixedPoint) >= ThresholdFixed) { if (message) + { MLQuestSystem.Tell(quester, pm, 1077772); // I cannot teach you, for you know all I can teach! + } return false; } @@ -83,9 +89,13 @@ namespace Server.Engines.MLQuests.Objectives private void SetFlag(GainSkillObjectiveFlags flag, bool value) { if (value) + { m_Flags |= flag; + } else + { m_Flags &= ~flag; + } } } @@ -116,7 +126,9 @@ namespace Server.Engines.MLQuests.Objectives public override void OnQuestAccepted() { if (!Objective.Accelerate) + { return; + } var pm = Instance.Player; @@ -127,7 +139,9 @@ namespace Server.Engines.MLQuests.Objectives public override void OnQuestCancelled() { if (!Objective.Accelerate) + { return; + } var pm = Instance.Player; diff --git a/Projects/UOContent/Engines/MLQuests/Objectives/KillObjective.cs b/Projects/UOContent/Engines/MLQuests/Objectives/KillObjective.cs index 1d3cfcafa..38b71e558 100644 --- a/Projects/UOContent/Engines/MLQuests/Objectives/KillObjective.cs +++ b/Projects/UOContent/Engines/MLQuests/Objectives/KillObjective.cs @@ -31,9 +31,13 @@ namespace Server.Engines.MLQuests.Objectives g.AddLabel(133, y, 0x481, amount); if (Name.Number > 0) + { g.AddHtmlLocalized(133 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF); + } else if (Name.String != null) + { g.AddLabel(133 + amount.Length * 15, y, 0x481, Name.String); + } y += 16; @@ -42,9 +46,13 @@ namespace Server.Engines.MLQuests.Objectives g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x15F90); // Location if (Area.Name.Number > 0) + { g.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0xFFFFFF); + } else if (Area.Name.String != null) + { g.AddLabel(223, y, 0x481, Area.Name.String); + } y += 16; } @@ -84,23 +92,31 @@ namespace Server.Engines.MLQuests.Objectives var desired = Objective.DesiredAmount; foreach (var acceptedType in Objective.AcceptedTypes) + { if (acceptedType.IsAssignableFrom(type)) { if (Objective.Area?.Contains(mob) == false) + { return false; + } var pm = Instance.Player; if (++Slain >= desired) + { pm.SendLocalizedMessage(1075050); // You have killed all the required quest creatures of this type. + } else + { pm.SendLocalizedMessage( 1075051, (desired - Slain).ToString() ); // You have killed a quest creature. ~1_val~ more left. + } return true; } + } return false; } diff --git a/Projects/UOContent/Engines/MLQuests/QuestArea.cs b/Projects/UOContent/Engines/MLQuests/QuestArea.cs index 5f214da4d..bc2a0379d 100644 --- a/Projects/UOContent/Engines/MLQuests/QuestArea.cs +++ b/Projects/UOContent/Engines/MLQuests/QuestArea.cs @@ -11,7 +11,9 @@ namespace Server.Engines.MLQuests ForceMap = forceMap; if (MLQuestSystem.Debug) + { ValidationQueue.Add(this); + } } public TextDefinition Name { get; set; } @@ -25,7 +27,9 @@ namespace Server.Engines.MLQuests public bool Contains(Region reg) { if (reg == null || ForceMap != null && reg.Map != ForceMap) + { return false; + } return reg.IsPartOf(RegionName); } @@ -36,18 +40,22 @@ namespace Server.Engines.MLQuests var found = false; foreach (var r in Region.Regions) + { if (r.Name == RegionName && (ForceMap == null || r.Map == ForceMap)) { found = true; break; } + } if (!found) + { Console.WriteLine( "Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", RegionName, ForceMap?.ToString() ?? "-null-" ); + } } } } diff --git a/Projects/UOContent/Engines/MLQuests/QuesterNameAttribute.cs b/Projects/UOContent/Engines/MLQuests/QuesterNameAttribute.cs index 4e9aea039..c46d2f953 100644 --- a/Projects/UOContent/Engines/MLQuests/QuesterNameAttribute.cs +++ b/Projects/UOContent/Engines/MLQuests/QuesterNameAttribute.cs @@ -16,10 +16,14 @@ namespace Server.Engines.MLQuests public static string GetQuesterNameFor(Type t) { if (t == null) + { return ""; + } if (m_Cache.TryGetValue(t, out var result)) + { return result; + } var attributes = t.GetCustomAttributes(m_Type, false); diff --git a/Projects/UOContent/Engines/MLQuests/Rewards/ItemReward.cs b/Projects/UOContent/Engines/MLQuests/Rewards/ItemReward.cs index 34e26ad43..8823d9f74 100644 --- a/Projects/UOContent/Engines/MLQuests/Rewards/ItemReward.cs +++ b/Projects/UOContent/Engines/MLQuests/Rewards/ItemReward.cs @@ -59,7 +59,9 @@ namespace Server.Engines.MLQuests.Rewards catch (Exception e) { if (MLQuestSystem.Debug) + { Console.WriteLine("WARNING: ItemReward.CreateItem failed for {0}: {1}", m_Type, e); + } } return spawnedItem; @@ -70,12 +72,16 @@ namespace Server.Engines.MLQuests.Rewards var reward = CreateItem(); if (reward == null) + { return; + } if (reward.Stackable) { if (m_Amount > 1) + { reward.Amount = m_Amount; + } rewards.Add(reward); } @@ -90,7 +96,9 @@ namespace Server.Engines.MLQuests.Rewards reward = CreateItem(); if (reward == null) + { return; + } } } } diff --git a/Projects/UOContent/Engines/Party/DeclineTimer.cs b/Projects/UOContent/Engines/Party/DeclineTimer.cs index d65900849..824950423 100644 --- a/Projects/UOContent/Engines/Party/DeclineTimer.cs +++ b/Projects/UOContent/Engines/Party/DeclineTimer.cs @@ -29,7 +29,9 @@ namespace Server.Engines.PartySystem m_Table.Remove(m_Mobile); if (m_Mobile.Party == m_Leader && PartyCommands.Handler != null) + { PartyCommands.Handler.OnDecline(m_Mobile, m_Leader); + } } } } diff --git a/Projects/UOContent/Engines/Party/Packets.cs b/Projects/UOContent/Engines/Party/Packets.cs index b9f4b580f..829d9d599 100644 --- a/Projects/UOContent/Engines/Party/Packets.cs +++ b/Projects/UOContent/Engines/Party/Packets.cs @@ -26,7 +26,9 @@ namespace Server.Engines.PartySystem Stream.Write((byte)p.Count); for (var i = 0; i < p.Count; ++i) + { Stream.Write(p[i].Mobile.Serial); + } } } @@ -43,7 +45,9 @@ namespace Server.Engines.PartySystem Stream.Write(removed.Serial); for (var i = 0; i < p.Count; ++i) + { Stream.Write(p[i].Mobile.Serial); + } } } @@ -52,7 +56,9 @@ namespace Server.Engines.PartySystem public PartyTextMessage(bool toAll, Mobile from, string text) : base(0xBF) { if (text == null) + { text = ""; + } EnsureCapacity(12 + text.Length * 2); diff --git a/Projects/UOContent/Engines/Party/Party.cs b/Projects/UOContent/Engines/Party/Party.cs index 60fe67c4e..3e9449357 100644 --- a/Projects/UOContent/Engines/Party/Party.cs +++ b/Projects/UOContent/Engines/Party/Party.cs @@ -37,8 +37,12 @@ namespace Server.Engines.PartySystem get { for (var i = 0; i < Members.Count; ++i) + { if (Members[i].Mobile == m) + { return Members[i]; + } + } return null; } @@ -55,7 +59,9 @@ namespace Server.Engines.PartySystem if (c != m && m.Map == c.Map && Utility.InUpdateRange(c, m) && c.CanSee(m)) { if (p == null) + { p = Packet.Acquire(new MobileStamN(m)); + } c.Send(p); } @@ -75,7 +81,9 @@ namespace Server.Engines.PartySystem if (c != m && m.Map == c.Map && Utility.InUpdateRange(c, m) && c.CanSee(m)) { if (p == null) + { p = Packet.Acquire(new MobileManaN(m)); + } c.Send(p); } @@ -90,7 +98,9 @@ namespace Server.Engines.PartySystem Utility.InUpdateRange(beholder, beheld)) { if (!beholder.CanSee(beheld)) + { beholder.Send(new MobileStatusCompact(beheld.CanBeRenamedBy(beholder), beheld)); + } beholder.Send(new MobileAttributesN(beheld)); } @@ -143,11 +153,17 @@ namespace Server.Engines.PartySystem var m = from.LastKiller; if (m == from) - p.SendPublicMessage(from, "I killed myself !!"); + { + p.SendPublicMessage(@from, "I killed myself !!"); + } else if (m == null) - p.SendPublicMessage(from, "I was killed !!"); + { + p.SendPublicMessage(@from, "I was killed !!"); + } else - p.SendPublicMessage(from, $"I was killed by {m.Name} !!"); + { + p.SendPublicMessage(@from, $"I was killed by {m.Name} !!"); + } } } @@ -156,9 +172,13 @@ namespace Server.Engines.PartySystem var p = Get(from); if (p != null) - new RejoinTimer(from).Start(); + { + new RejoinTimer(@from).Start(); + } else - from.Party = null; + { + @from.Party = null; + } } public static void EventSink_Logout(Mobile from) @@ -215,7 +235,9 @@ namespace Server.Engines.PartySystem var theirFaction = Faction.Find(from); if (!force && ourFaction != null && theirFaction != null && ourFaction != theirFaction) + { return; + } // : joined the party. SendToAll( @@ -270,6 +292,7 @@ namespace Server.Engines.PartySystem else { for (var i = 0; i < Members.Count; ++i) + { if (Members[i].Mobile == m) { Members.RemoveAt(i); @@ -284,6 +307,7 @@ namespace Server.Engines.PartySystem break; } + } if (Members.Count == 1) { @@ -323,10 +347,14 @@ namespace Server.Engines.PartySystem var p = Get(from); if (p == null) - from.Party = p = new Party(from); + { + @from.Party = p = new Party(@from); + } if (!p.Candidates.Contains(target)) + { p.Candidates.Add(target); + } // : You are invited to join the party. Type /accept to join or /decline to decline the offer. target.Send( @@ -376,7 +404,9 @@ namespace Server.Engines.PartySystem var mob = m_Listeners[i]; if (mob.Party != this) - m_Listeners[i].SendMessage("[{0}]: {1}", from.Name, text); + { + m_Listeners[i].SendMessage("[{0}]: {1}", @from.Name, text); + } } SendToStaffMessage(from, "[Party]: {0}", text); @@ -391,7 +421,9 @@ namespace Server.Engines.PartySystem var mob = m_Listeners[i]; if (mob.Party != this) - m_Listeners[i].SendMessage("[{0}]->[{1}]: {2}", from.Name, to.Name, text); + { + m_Listeners[i].SendMessage("[{0}]->[{1}]: {2}", @from.Name, to.Name, text); + } } SendToStaffMessage(from, "[Party]->[{0}]: {1}", to.Name, text); @@ -409,18 +441,20 @@ namespace Server.Engines.PartySystem mob.Party != this && !m_Listeners.Contains(mob)) { if (p == null) + { p = Packet.Acquire( new UnicodeMessage( - from.Serial, - from.Body, + @from.Serial, + @from.Body, MessageType.Regular, - from.SpeechHue, + @from.SpeechHue, 3, - from.Language, - from.Name, + @from.Language, + @from.Name, text ) ); + } ns.Send(p); } @@ -439,16 +473,22 @@ namespace Server.Engines.PartySystem p.Acquire(); for (var i = 0; i < Members.Count; ++i) + { Members[i].Mobile.Send(p); + } if (p is MessageLocalized || p is MessageLocalizedAffix || p is UnicodeMessage || p is AsciiMessage) + { for (var i = 0; i < m_Listeners.Count; ++i) { var mob = m_Listeners[i]; if (mob.Party != this) + { mob.Send(p); + } } + } p.Release(); } @@ -464,7 +504,9 @@ namespace Server.Engines.PartySystem var p = Get(m_Mobile); if (p == null) + { return; + } m_Mobile.SendLocalizedMessage(1005437); // You have rejoined the party. m_Mobile.Send(new PartyMemberList(p)); diff --git a/Projects/UOContent/Engines/Party/PartyCommands.cs b/Projects/UOContent/Engines/Party/PartyCommands.cs index 6b9fbad22..db5ebcc05 100644 --- a/Projects/UOContent/Engines/Party/PartyCommands.cs +++ b/Projects/UOContent/Engines/Party/PartyCommands.cs @@ -12,11 +12,17 @@ namespace Server.Engines.PartySystem var p = Party.Get(from); if (p != null && p.Leader != from) - from.SendLocalizedMessage(1005453); // You may only add members to the party if you are the leader. + { + @from.SendLocalizedMessage(1005453); // You may only add members to the party if you are the leader. + } else if (p != null && p.Members.Count + p.Candidates.Count >= Party.Capacity) - from.SendLocalizedMessage(1008095); // You may only have 10 in your party (this includes candidates). + { + @from.SendLocalizedMessage(1008095); // You may only have 10 in your party (this includes candidates). + } else - from.Target = new AddPartyTarget(from); + { + @from.Target = new AddPartyTarget(@from); + } } public override void OnRemove(Mobile from, Mobile target) @@ -43,27 +49,39 @@ namespace Server.Engines.PartySystem public override void OnPrivateMessage(Mobile from, Mobile target, string text) { if (text.Length > 128 || (text = text.Trim()).Length == 0) + { return; + } var p = Party.Get(from); if (p?.Contains(target) == true) - p.SendPrivateMessage(from, target, text); + { + p.SendPrivateMessage(@from, target, text); + } else - from.SendLocalizedMessage(3000211); // You are not in a party. + { + @from.SendLocalizedMessage(3000211); // You are not in a party. + } } public override void OnPublicMessage(Mobile from, string text) { if (text.Length > 128 || (text = text.Trim()).Length == 0) + { return; + } var p = Party.Get(from); if (p != null) - p.SendPublicMessage(from, text); + { + p.SendPublicMessage(@from, text); + } else - from.SendLocalizedMessage(3000211); // You are not in a party. + { + @from.SendLocalizedMessage(3000211); // You are not in a party. + } } public override void OnSetCanLoot(Mobile from, bool canLoot) @@ -83,11 +101,15 @@ namespace Server.Engines.PartySystem mi.CanLoot = canLoot; if (canLoot) - from.SendLocalizedMessage(1005447); // You have chosen to allow your party to loot your corpse. + { + @from.SendLocalizedMessage(1005447); // You have chosen to allow your party to loot your corpse. + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1005448 ); // You have chosen to prevent your party from looting your corpse. + } } } } @@ -100,9 +122,13 @@ namespace Server.Engines.PartySystem var p = Party.Get(leader); if (leader == null || p?.Candidates.Contains(from) != true) - from.SendLocalizedMessage(3000222); // No one has invited you to be in a party. + { + @from.SendLocalizedMessage(3000222); // No one has invited you to be in a party. + } else if (p.Members.Count + p.Candidates.Count <= Party.Capacity) - p.OnAccept(from); + { + p.OnAccept(@from); + } } public override void OnDecline(Mobile from, Mobile sentLeader) @@ -113,9 +139,13 @@ namespace Server.Engines.PartySystem var p = Party.Get(leader); if (leader == null || p?.Candidates.Contains(from) != true) - from.SendLocalizedMessage(3000222); // No one has invited you to be in a party. + { + @from.SendLocalizedMessage(3000222); // No one has invited you to be in a party. + } else - p.OnDecline(from, leader); + { + p.OnDecline(@from, leader); + } } } } diff --git a/Projects/UOContent/Engines/Party/RemoveFromParty.cs b/Projects/UOContent/Engines/Party/RemoveFromParty.cs index ff032b12d..0d8d2978d 100644 --- a/Projects/UOContent/Engines/Party/RemoveFromParty.cs +++ b/Projects/UOContent/Engines/Party/RemoveFromParty.cs @@ -18,12 +18,18 @@ namespace Server.ContextMenus var p = Party.Get(m_From); if (p == null || p.Leader != m_From || !p.Contains(m_Target)) + { return; + } if (m_From == m_Target) + { m_From.SendLocalizedMessage(1005446); // You may only remove yourself from a party if you are not the leader. + } else + { p.Remove(m_Target); + } } } } diff --git a/Projects/UOContent/Engines/Party/RemovePartyTarget.cs b/Projects/UOContent/Engines/Party/RemovePartyTarget.cs index de2c20e17..5d83e6c29 100644 --- a/Projects/UOContent/Engines/Party/RemovePartyTarget.cs +++ b/Projects/UOContent/Engines/Party/RemovePartyTarget.cs @@ -15,14 +15,20 @@ namespace Server.Engines.PartySystem var p = Party.Get(from); if (p == null || p.Leader != from || !p.Contains(m)) + { return; + } if (from == m) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1005446 ); // You may only remove yourself from a party if you are not the leader. + } else + { p.Remove(m); + } } } } diff --git a/Projects/UOContent/Engines/Pathing/FastAStarAlgorithm.cs b/Projects/UOContent/Engines/Pathing/FastAStarAlgorithm.cs index 221381603..876ca7fc1 100644 --- a/Projects/UOContent/Engines/Pathing/FastAStarAlgorithm.cs +++ b/Projects/UOContent/Engines/Pathing/FastAStarAlgorithm.cs @@ -53,22 +53,32 @@ namespace Server.PathAlgorithms.FastAStar private void RemoveFromChain(int node) { if (node < 0 || node >= NodeCount) + { return; + } if (!m_Touched[node] || !m_OnOpen[node]) + { return; + } var prev = m_Nodes[node].prev; var next = m_Nodes[node].next; if (m_OpenList == node) + { m_OpenList = next; + } if (prev != -1) + { m_Nodes[prev].next = next; + } if (next != -1) + { m_Nodes[next].prev = prev; + } m_Nodes[node].prev = -1; m_Nodes[node].next = -1; @@ -77,12 +87,16 @@ namespace Server.PathAlgorithms.FastAStar private void AddToChain(int node) { if (node < 0 || node >= NodeCount) + { return; + } RemoveFromChain(node); if (m_OpenList != -1) + { m_Nodes[m_OpenList].prev = node; + } m_Nodes[node].next = m_OpenList; m_Nodes[node].prev = -1; @@ -96,7 +110,9 @@ namespace Server.PathAlgorithms.FastAStar public override Direction[] Find(Mobile m, Map map, Point3D start, Point3D goal) { if (!Utility.InRange(start, goal, AreaSize)) + { return null; + } m_Touched.SetAll(false); @@ -131,7 +147,9 @@ namespace Server.PathAlgorithms.FastAStar var bestNode = FindBest(m_OpenList); if (++depth > MaxDepth) + { break; + } if (bc != null) { @@ -149,7 +167,9 @@ namespace Server.PathAlgorithms.FastAStar MoveImpl.Goal = Point3D.Zero; if (count == 0) + { break; + } for (var i = 0; i < count; ++i) { @@ -158,7 +178,9 @@ namespace Server.PathAlgorithms.FastAStar var wasTouched = m_Touched[newNode]; if (wasTouched) + { continue; + } var newCost = m_Nodes[bestNode].cost + 1; var newTotal = newCost + Heuristic( @@ -168,19 +190,25 @@ namespace Server.PathAlgorithms.FastAStar ); if (m_Nodes[newNode].total <= newTotal) + { continue; + } m_Nodes[newNode].parent = bestNode; m_Nodes[newNode].cost = newCost; m_Nodes[newNode].total = newTotal; if (m_OnOpen[newNode]) + { continue; + } AddToChain(newNode); if (newNode != destNode) + { continue; + } var pathCount = 0; var parent = m_Nodes[newNode].parent; @@ -197,13 +225,17 @@ namespace Server.PathAlgorithms.FastAStar parent = m_Nodes[newNode].parent; if (newNode == fromNode) + { break; + } } var dirs = new Direction[pathCount]; while (pathCount > 0) + { dirs[backtrack++] = path[--pathCount]; + } return dirs; } @@ -302,7 +334,9 @@ namespace Server.PathAlgorithms.FastAStar y += py; if (x < 0 || x >= AreaSize || y < 0 || y >= AreaSize) + { continue; + } if (CalcMoves.CheckMovement(m, map, p3D, (Direction)i, out var z)) { diff --git a/Projects/UOContent/Engines/Pathing/FastMovement.cs b/Projects/UOContent/Engines/Pathing/FastMovement.cs index d7fb73a1f..3f8a32594 100644 --- a/Projects/UOContent/Engines/Pathing/FastMovement.cs +++ b/Projects/UOContent/Engines/Pathing/FastMovement.cs @@ -22,7 +22,10 @@ namespace Server.Movement public bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ) { - if (!Enabled && _Successor != null) return _Successor.CheckMovement(m, map, loc, d, out newZ); + if (!Enabled && _Successor != null) + { + return _Successor.CheckMovement(m, map, loc, d, out newZ); + } if (map == null || map == Map.Internal) { @@ -54,7 +57,10 @@ namespace Server.Movement var ignoreMovableImpassables = MovementImpl.IgnoreMovableImpassables; var reqFlags = ImpassableSurface; - if (m.CanSwim) reqFlags |= TileFlag.Wet; + if (m.CanSwim) + { + reqFlags |= TileFlag.Wet; + } if (checkDiagonals) { @@ -102,7 +108,9 @@ namespace Server.Movement MovementPool.AcquireMoveCache(ref list, itemsRight); if (!Check(map, m, list, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out _)) + { moveIsOk = false; + } } } else @@ -114,14 +122,19 @@ namespace Server.Movement MovementPool.AcquireMoveCache(ref list, itemsRight); if (!Check(map, m, list, xRight, yRight, startTop, startZ, m.CanSwim, m.CantWalk, out _)) + { moveIsOk = false; + } } } } MovementPool.ClearMoveCache(ref list, true); - if (!moveIsOk) newZ = startZ; + if (!moveIsOk) + { + newZ = startZ; + } return moveIsOk; } @@ -149,13 +162,21 @@ namespace Server.Movement var itemID = item.ItemID & TileData.MaxItemValue; var itemData = TileData.ItemTable[itemID]; - if ((itemData.Flags & ImpassableSurface) == 0) return true; + if ((itemData.Flags & ImpassableSurface) == 0) + { + return true; + } if (((itemData.Flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || itemID == 0x873 || itemID >= 0x6F5 && itemID <= 0x6F6) && ignoreDoors) + { return true; + } - if ((itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956) && ignoreSpellFields) return true; + if ((itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956) && ignoreSpellFields) + { + return true; + } return item.Z + itemData.CalcHeight <= ourZ || ourTop <= item.Z; } @@ -195,8 +216,13 @@ namespace Server.Movement var considerLand = !landTile.Ignored; if (landBlocks && canSwim && (landData.Flags & TileFlag.Wet) != 0) + { landBlocks = false; - else if (cantWalk && (landData.Flags & TileFlag.Wet) == 0) landBlocks = true; + } + else if (cantWalk && (landData.Flags & TileFlag.Wet) == 0) + { + landBlocks = true; + } int landZ = 0, landCenter = 0, landTop = 0; @@ -230,7 +256,10 @@ namespace Server.Movement { if (x >= 307 && x <= 354 && y >= 126 && y <= 192) { - if (tile.Z > newZ) newZ = tile.Z; + if (tile.Z > newZ) + { + newZ = tile.Z; + } moveIsOk = true; } @@ -238,7 +267,10 @@ namespace Server.Movement { if (y >= 333 && y <= 399 || y >= 531 && y <= 597 || y >= 739 && y <= 805) { - if (tile.Z > newZ) newZ = tile.Z; + if (tile.Z > newZ) + { + newZ = tile.Z; + } moveIsOk = true; } @@ -247,9 +279,15 @@ namespace Server.Movement flags = itemData.Flags; - if ((flags & ImpassableSurface) != TileFlag.Surface && (!canSwim || (flags & TileFlag.Wet) == 0)) continue; + if ((flags & ImpassableSurface) != TileFlag.Surface && (!canSwim || (flags & TileFlag.Wet) == 0)) + { + continue; + } - if (cantWalk && (flags & TileFlag.Wet) == 0) continue; + if (cantWalk && (flags & TileFlag.Wet) == 0) + { + continue; + } itemZ = tile.Z; itemTop = itemZ; @@ -261,25 +299,47 @@ namespace Server.Movement { var cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + if (cmp > 0 || cmp == 0 && ourZ > newZ) + { + continue; + } } - if (ourTop > testTop) testTop = ourTop; + if (ourTop > testTop) + { + testTop = ourTop; + } - if (!itemData.Bridge) itemTop += itemData.Height; + if (!itemData.Bridge) + { + itemTop += itemData.Height; + } - if (stepTop < itemTop) continue; + if (stepTop < itemTop) + { + continue; + } var landCheck = itemZ; if (itemData.Height >= StepHeight) + { landCheck += StepHeight; + } else + { landCheck += itemData.Height; + } - if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) continue; + if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) + { + continue; + } - if (!IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) continue; + if (!IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) + { + continue; + } newZ = ourZ; moveIsOk = true; @@ -296,11 +356,20 @@ namespace Server.Movement return true; } - if (item.Movable) continue; + if (item.Movable) + { + continue; + } - if ((flags & ImpassableSurface) != TileFlag.Surface && (!m.CanSwim || (flags & TileFlag.Wet) == 0)) continue; + if ((flags & ImpassableSurface) != TileFlag.Surface && (!m.CanSwim || (flags & TileFlag.Wet) == 0)) + { + continue; + } - if (cantWalk && (flags & TileFlag.Wet) == 0) continue; + if (cantWalk && (flags & TileFlag.Wet) == 0) + { + continue; + } itemZ = item.Z; itemTop = itemZ; @@ -312,37 +381,65 @@ namespace Server.Movement { var cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + if (cmp > 0 || cmp == 0 && ourZ > newZ) + { + continue; + } } - if (ourTop > testTop) testTop = ourTop; + if (ourTop > testTop) + { + testTop = ourTop; + } - if (!itemData.Bridge) itemTop += itemData.Height; + if (!itemData.Bridge) + { + itemTop += itemData.Height; + } - if (stepTop < itemTop) continue; + if (stepTop < itemTop) + { + continue; + } var landCheck = itemZ; if (itemData.Height >= StepHeight) + { landCheck += StepHeight; + } else + { landCheck += itemData.Height; + } - if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) continue; + if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) + { + continue; + } - if (!IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) continue; + if (!IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) + { + continue; + } newZ = ourZ; moveIsOk = true; } - if (!considerLand || landBlocks || stepTop < landZ) return moveIsOk; + if (!considerLand || landBlocks || stepTop < landZ) + { + return moveIsOk; + } ourZ = landCenter; ourTop = ourZ + PersonHeight; testTop = checkTop; - if (ourTop > testTop) testTop = ourTop; + if (ourTop > testTop) + { + testTop = ourTop; + } var shouldCheck = true; @@ -350,10 +447,16 @@ namespace Server.Movement { var cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) shouldCheck = false; + if (cmp > 0 || cmp == 0 && ourZ > newZ) + { + shouldCheck = false; + } } - if (!shouldCheck || !IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) return moveIsOk; + if (!shouldCheck || !IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) + { + return moveIsOk; + } newZ = ourZ; moveIsOk = true; @@ -379,8 +482,13 @@ namespace Server.Movement var landBlocks = (landData.Flags & TileFlag.Impassable) != 0; if (landBlocks && m.CanSwim && (landData.Flags & TileFlag.Wet) != 0) + { landBlocks = false; - else if (m.CantWalk && (landData.Flags & TileFlag.Wet) == 0) landBlocks = true; + } + else if (m.CantWalk && (landData.Flags & TileFlag.Wet) == 0) + { + landBlocks = true; + } int landZ = 0, landCenter = 0, landTop = 0; @@ -406,21 +514,36 @@ namespace Server.Movement var tileData = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; var calcTop = tile.Z + tileData.CalcHeight; - if (isSet && calcTop < zCenter) continue; + if (isSet && calcTop < zCenter) + { + continue; + } if ((tileData.Flags & TileFlag.Surface) == 0 && - (!m.CanSwim || (tileData.Flags & TileFlag.Wet) == 0)) continue; + (!m.CanSwim || (tileData.Flags & TileFlag.Wet) == 0)) + { + continue; + } - if (loc.Z < calcTop) continue; + if (loc.Z < calcTop) + { + continue; + } - if (m.CantWalk && (tileData.Flags & TileFlag.Wet) == 0) continue; + if (m.CantWalk && (tileData.Flags & TileFlag.Wet) == 0) + { + continue; + } zLow = tile.Z; zCenter = calcTop; var top = tile.Z + tileData.Height; - if (!isSet || top > zTop) zTop = top; + if (!isSet || top > zTop) + { + zTop = top; + } isSet = true; } @@ -431,29 +554,48 @@ namespace Server.Movement var calcTop = item.Z + itemData.CalcHeight; - if (isSet && calcTop < zCenter) continue; + if (isSet && calcTop < zCenter) + { + continue; + } if ((itemData.Flags & TileFlag.Surface) == 0 && - (!m.CanSwim || (itemData.Flags & TileFlag.Wet) == 0)) continue; + (!m.CanSwim || (itemData.Flags & TileFlag.Wet) == 0)) + { + continue; + } - if (loc.Z < calcTop) continue; + if (loc.Z < calcTop) + { + continue; + } - if (m.CantWalk && (itemData.Flags & TileFlag.Wet) == 0) continue; + if (m.CantWalk && (itemData.Flags & TileFlag.Wet) == 0) + { + continue; + } zLow = item.Z; zCenter = calcTop; var top = item.Z + itemData.Height; - if (!isSet || top > zTop) zTop = top; + if (!isSet || top > zTop) + { + zTop = top; + } isSet = true; } if (!isSet) + { zLow = zTop = loc.Z; + } else if (loc.Z > zTop) + { zTop = loc.Z; + } } public void Offset(Direction d, ref int x, ref int y) @@ -499,12 +641,16 @@ namespace Server.Movement public static void AcquireMoveCache(ref List cache, IEnumerable items) { if (cache == null) + { lock (_MovePoolLock) { cache = _MoveCachePool.Count > 0 ? _MoveCachePool.Dequeue() : new List(0x10); } + } else + { cache.Clear(); + } cache.AddRange(items); } @@ -513,11 +659,17 @@ namespace Server.Movement { cache?.Clear(); - if (!free) return; + if (!free) + { + return; + } lock (_MovePoolLock) { - if (_MoveCachePool.Count < 0x400) _MoveCachePool.Enqueue(cache); + if (_MoveCachePool.Count < 0x400) + { + _MoveCachePool.Enqueue(cache); + } } cache = null; diff --git a/Projects/UOContent/Engines/Pathing/Movement.cs b/Projects/UOContent/Engines/Pathing/Movement.cs index eaad778af..5e43c9330 100644 --- a/Projects/UOContent/Engines/Pathing/Movement.cs +++ b/Projects/UOContent/Engines/Pathing/Movement.cs @@ -68,7 +68,10 @@ namespace Server.Movement var ignoreMovableImpassables = IgnoreMovableImpassables; var reqFlags = ImpassableSurface; - if (m.CanSwim) reqFlags |= TileFlag.Wet; + if (m.CanSwim) + { + reqFlags |= TileFlag.Wet; + } var mobsForward = m_MobPools[0]; var mobsLeft = m_MobPools[1]; @@ -87,9 +90,20 @@ namespace Server.Movement sectors.Add(sectorStart); - if (!sectors.Contains(sectorForward)) sectors.Add(sectorForward); - if (!sectors.Contains(sectorLeft)) sectors.Add(sectorLeft); - if (!sectors.Contains(sectorRight)) sectors.Add(sectorRight); + if (!sectors.Contains(sectorForward)) + { + sectors.Add(sectorForward); + } + + if (!sectors.Contains(sectorLeft)) + { + sectors.Add(sectorLeft); + } + + if (!sectors.Contains(sectorRight)) + { + sectors.Add(sectorRight); + } for (var i = 0; i < sectors.Count; ++i) { @@ -100,36 +114,65 @@ namespace Server.Movement var item = sector.Items[j]; if (ignoreMovableImpassables && item.Movable && - (item.ItemData.Flags & ImpassableSurface) != 0) continue; + (item.ItemData.Flags & ImpassableSurface) != 0) + { + continue; + } - if ((item.ItemData.Flags & reqFlags) == 0) continue; + if ((item.ItemData.Flags & reqFlags) == 0) + { + continue; + } - if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) continue; + if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) + { + continue; + } if (sector == sectorStart && item.AtWorldPoint(xStart, yStart)) + { itemsStart.Add(item); + } else if (sector == sectorForward && item.AtWorldPoint(xForward, yForward)) + { itemsForward.Add(item); + } else if (sector == sectorLeft && item.AtWorldPoint(xLeft, yLeft)) + { itemsLeft.Add(item); + } else if (sector == sectorRight && item.AtWorldPoint(xRight, yRight)) + { itemsRight.Add(item); + } } if (checkMobs) + { for (var j = 0; j < sector.Mobiles.Count; ++j) { var mob = sector.Mobiles[j]; if (sector == sectorForward && mob.X == xForward && mob.Y == yForward) + { mobsForward.Add(mob); + } else if (sector == sectorLeft && mob.X == xLeft && mob.Y == yLeft) + { mobsLeft.Add(mob); - else if (sector == sectorRight && mob.X == xRight && mob.Y == yRight) mobsRight.Add(mob); + } + else if (sector == sectorRight && mob.X == xRight && mob.Y == yRight) + { + mobsRight.Add(mob); + } } + } } - if (m_Sectors.Count > 0) m_Sectors.Clear(); + if (m_Sectors.Count > 0) + { + m_Sectors.Clear(); + } } else { @@ -143,16 +186,29 @@ namespace Server.Movement var item = sectorStart.Items[i]; if (ignoreMovableImpassables && item.Movable && - (item.ItemData.Flags & ImpassableSurface) != 0) continue; + (item.ItemData.Flags & ImpassableSurface) != 0) + { + continue; + } - if ((item.ItemData.Flags & reqFlags) == 0) continue; + if ((item.ItemData.Flags & reqFlags) == 0) + { + continue; + } - if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) continue; + if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) + { + continue; + } if (item.AtWorldPoint(xStart, yStart)) + { itemsStart.Add(item); + } else if (item.AtWorldPoint(xForward, yForward)) + { itemsForward.Add(item); + } } } else @@ -162,13 +218,21 @@ namespace Server.Movement var item = sectorForward.Items[i]; if (ignoreMovableImpassables && item.Movable && - (item.ItemData.Flags & ImpassableSurface) != 0) continue; + (item.ItemData.Flags & ImpassableSurface) != 0) + { + continue; + } - if ((item.ItemData.Flags & reqFlags) == 0) continue; + if ((item.ItemData.Flags & reqFlags) == 0) + { + continue; + } if (item.AtWorldPoint(xForward, yForward) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue) + { itemsForward.Add(item); + } } for (var i = 0; i < sectorStart.Items.Count; ++i) @@ -176,23 +240,36 @@ namespace Server.Movement var item = sectorStart.Items[i]; if (ignoreMovableImpassables && item.Movable && - (item.ItemData.Flags & ImpassableSurface) != 0) continue; + (item.ItemData.Flags & ImpassableSurface) != 0) + { + continue; + } - if ((item.ItemData.Flags & reqFlags) == 0) continue; + if ((item.ItemData.Flags & reqFlags) == 0) + { + continue; + } if (item.AtWorldPoint(xStart, yStart) && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue) + { itemsStart.Add(item); + } } } if (checkMobs) + { for (var i = 0; i < sectorForward.Mobiles.Count; ++i) { var mob = sectorForward.Mobiles[i]; - if (mob.X == xForward && mob.Y == yForward) mobsForward.Add(mob); + if (mob.X == xForward && mob.Y == yForward) + { + mobsForward.Add(mob); + } } + } } GetStartZ(m, map, loc, itemsStart, out var startZ, out var startTop); @@ -229,7 +306,9 @@ namespace Server.Movement m.CantWalk, out _ )) + { moveIsOk = false; + } } else { @@ -247,17 +326,26 @@ namespace Server.Movement m.CantWalk, out _ )) + { moveIsOk = false; + } } } for (int i = 0, c = checkDiagonals ? 4 : 2; i < c; ++i) + { m_Pools[i].Clear(); + } for (int i = 0, c = checkDiagonals ? 3 : 1; i < c; ++i) + { m_MobPools[i].Clear(); + } - if (!moveIsOk) newZ = startZ; + if (!moveIsOk) + { + newZ = startZ; + } return moveIsOk; } @@ -283,7 +371,10 @@ namespace Server.Movement var checkZ = check.Z; var checkTop = checkZ + itemData.CalcHeight; - if (checkTop > ourZ && ourTop > checkZ) return false; + if (checkTop > ourZ && ourTop > checkZ) + { + return false; + } } } @@ -299,14 +390,22 @@ namespace Server.Movement if (ignoreDoors && ((flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || itemID == 0x873 || itemID >= 0x6F5 && itemID <= 0x6F6)) + { continue; + } - if (ignoreSpellFields && (itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956)) continue; + if (ignoreSpellFields && (itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956)) + { + continue; + } var checkZ = item.Z; var checkTop = checkZ + itemData.CalcHeight; - if (checkTop > ourZ && ourTop > checkZ) return false; + if (checkTop > ourZ && ourTop > checkZ) + { + return false; + } } } @@ -352,7 +451,10 @@ namespace Server.Movement // Surface && !Impassable if ((flags & ImpassableSurface) != TileFlag.Surface && (!canSwim || notWater) || - cantWalk && notWater) continue; + cantWalk && notWater) + { + continue; + } var itemZ = tile.Z; var itemTop = itemZ; @@ -364,23 +466,39 @@ namespace Server.Movement { var cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + if (cmp > 0 || cmp == 0 && ourZ > newZ) + { + continue; + } } - if (ourZ + PersonHeight > testTop) testTop = ourZ + PersonHeight; + if (ourZ + PersonHeight > testTop) + { + testTop = ourZ + PersonHeight; + } - if (!itemData.Bridge) itemTop += itemData.Height; + if (!itemData.Bridge) + { + itemTop += itemData.Height; + } if (stepTop >= itemTop) { var landCheck = itemZ; if (itemData.Height >= StepHeight) + { landCheck += StepHeight; + } else + { landCheck += itemData.Height; + } - if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) continue; + if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) + { + continue; + } if (IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) { @@ -401,7 +519,10 @@ namespace Server.Movement // Surface && !Impassable && !Movable if (item.Movable || (flags & ImpassableSurface) != TileFlag.Surface && (!m.CanSwim || notWater) || - cantWalk && notWater) continue; + cantWalk && notWater) + { + continue; + } var itemZ = item.Z; var itemTop = itemZ; @@ -413,23 +534,39 @@ namespace Server.Movement { var cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + if (cmp > 0 || cmp == 0 && ourZ > newZ) + { + continue; + } } - if (ourZ + PersonHeight > testTop) testTop = ourZ + PersonHeight; + if (ourZ + PersonHeight > testTop) + { + testTop = ourZ + PersonHeight; + } - if (!itemData.Bridge) itemTop += itemData.Height; + if (!itemData.Bridge) + { + itemTop += itemData.Height; + } if (stepTop >= itemTop) { var landCheck = itemZ; if (itemData.Height >= StepHeight) + { landCheck += StepHeight; + } else + { landCheck += itemData.Height; + } - if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) continue; + if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) + { + continue; + } if (IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) { @@ -445,7 +582,10 @@ namespace Server.Movement // int ourTop = ourZ + PersonHeight; var testTop = checkTop; - if (ourZ + PersonHeight > testTop) testTop = ourZ + PersonHeight; + if (ourZ + PersonHeight > testTop) + { + testTop = ourZ + PersonHeight; + } var shouldCheck = true; @@ -453,7 +593,10 @@ namespace Server.Movement { var cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) shouldCheck = false; + if (cmp > 0 || cmp == 0 && ourZ > newZ) + { + shouldCheck = false; + } } if (shouldCheck && IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) @@ -464,12 +607,17 @@ namespace Server.Movement } if (moveIsOk) + { for (var i = 0; moveIsOk && i < mobiles.Count; ++i) { var mob = mobiles[i]; - if (mob != m && mob.Z + 15 > newZ && newZ + 15 > mob.Z && !CanMoveOver(m, mob)) moveIsOk = false; + if (mob != m && mob.Z + 15 > newZ && newZ + 15 > mob.Z && !CanMoveOver(m, mob)) + { + moveIsOk = false; + } } + } return moveIsOk; } @@ -518,14 +666,20 @@ namespace Server.Movement if ((!isSet || calcTop >= zCenter) && ((id.Flags & TileFlag.Surface) != 0 || m.CanSwim && (id.Flags & TileFlag.Wet) != 0) && loc.Z >= calcTop) { - if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) continue; + if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) + { + continue; + } zLow = tile.Z; zCenter = calcTop; var top = tile.Z + id.Height; - if (!isSet || top > zTop) zTop = top; + if (!isSet || top > zTop) + { + zTop = top; + } isSet = true; } @@ -542,22 +696,33 @@ namespace Server.Movement if ((!isSet || calcTop >= zCenter) && ((id.Flags & TileFlag.Surface) != 0 || m.CanSwim && (id.Flags & TileFlag.Wet) != 0) && loc.Z >= calcTop) { - if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) continue; + if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) + { + continue; + } zLow = item.Z; zCenter = calcTop; var top = item.Z + id.Height; - if (!isSet || top > zTop) zTop = top; + if (!isSet || top > zTop) + { + zTop = top; + } isSet = true; } } if (!isSet) + { zLow = zTop = loc.Z; - else if (loc.Z > zTop) zTop = loc.Z; + } + else if (loc.Z > zTop) + { + zTop = loc.Z; + } } public void Offset(Direction d, ref int x, ref int y) diff --git a/Projects/UOContent/Engines/Pathing/MovementPath.cs b/Projects/UOContent/Engines/Pathing/MovementPath.cs index 300601426..edba863ad 100644 --- a/Projects/UOContent/Engines/Pathing/MovementPath.cs +++ b/Projects/UOContent/Engines/Pathing/MovementPath.cs @@ -20,17 +20,23 @@ namespace Server Goal = goal; if (map == null || map == Map.Internal) + { return; + } if (Utility.InRange(start, goal, 1)) + { return; + } try { var alg = OverrideAlgorithm ?? FastAStarAlgorithm.Instance; if (alg?.CheckCondition(m, map, start, goal) == true) + { Directions = alg.Find(m, map, start, goal); + } } catch (Exception e) { @@ -94,7 +100,9 @@ namespace Server public static void Path_OnTarget(Mobile from, object targeted) { if (!(targeted is IPoint3D p)) + { return; + } SpellHelper.GetSurfaceTop(ref p); diff --git a/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs b/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs index cd4c199db..b655dcff3 100644 --- a/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs +++ b/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs @@ -25,7 +25,9 @@ namespace Server.PathAlgorithms var v = y * 3 + x; if (v < 0 || v >= 9) + { return Direction.North; + } return m_CalcDirections[v]; } diff --git a/Projects/UOContent/Engines/Pathing/PathFollower.cs b/Projects/UOContent/Engines/Pathing/PathFollower.cs index 3cd9ef44f..6316c22f7 100644 --- a/Projects/UOContent/Engines/Pathing/PathFollower.cs +++ b/Projects/UOContent/Engines/Pathing/PathFollower.cs @@ -32,7 +32,9 @@ namespace Server public MoveResult Move(Direction d) { if (Mover == null) + { return m_From.Move(d) ? MoveResult.Success : MoveResult.Blocked; + } return Mover(d); } @@ -40,7 +42,9 @@ namespace Server public Point3D GetGoalLocation() { if (Goal is Item item) + { return item.GetWorldLocation(); + } return new Point3D(Goal); } @@ -71,13 +75,17 @@ namespace Server public bool CheckPath() { if (!Enabled) + { return false; + } var goal = GetGoalLocation(); if (m_Path != null && (m_Path.Success && goal == m_LastGoalLoc || m_LastPathTime + RepathDelay > DateTime.Now) && !(m_Path.Success && Check(m_From.Location, m_LastGoalLoc, 0))) + { return false; + } m_LastPathTime = DateTime.UtcNow; m_LastGoalLoc = goal; @@ -101,7 +109,9 @@ namespace Server Direction d; if (Check(m_From.Location, goal, range)) + { return true; + } var repathed = CheckPath(); @@ -110,7 +120,9 @@ namespace Server d = m_From.GetDirectionTo(goal); if (run) + { d |= Direction.Running; + } m_From.SetDirection(d); Move(d); @@ -121,7 +133,9 @@ namespace Server d = m_From.GetDirectionTo(m_Next); if (run) + { d |= Direction.Running; + } m_From.SetDirection(d); @@ -130,7 +144,9 @@ namespace Server if (res == MoveResult.Blocked) { if (repathed) + { return false; + } m_Path = null; CheckPath(); @@ -140,7 +156,9 @@ namespace Server d = m_From.GetDirectionTo(goal); if (run) + { d |= Direction.Running; + } m_From.SetDirection(d); Move(d); @@ -151,14 +169,18 @@ namespace Server d = m_From.GetDirectionTo(m_Next); if (run) + { d |= Direction.Running; + } m_From.SetDirection(d); res = Move(d); if (res == MoveResult.Blocked) + { return false; + } } if (m_From.X == m_Next.X && m_From.Y == m_Next.Y) diff --git a/Projects/UOContent/Engines/Pathing/SlowAStarAlgorithm.cs b/Projects/UOContent/Engines/Pathing/SlowAStarAlgorithm.cs index fff1fe5da..2cedc1cd9 100644 --- a/Projects/UOContent/Engines/Pathing/SlowAStarAlgorithm.cs +++ b/Projects/UOContent/Engines/Pathing/SlowAStarAlgorithm.cs @@ -77,17 +77,21 @@ namespace Server.PathAlgorithms.SlowAStar var popIndex = 0; for (var i = 1; i < openCount; ++i) + { if (open[i].g + open[i].h < curF) { curNode = open[i]; curF = curNode.g + curNode.h; popIndex = i; } + } if (curNode.x == goalNode.x && curNode.y == goalNode.y && Math.Abs(curNode.z - goalNode.z) < 16) { if (closedCount == MaxNodes) + { break; + } closed[closedCount++] = curNode; @@ -96,7 +100,9 @@ namespace Server.PathAlgorithms.SlowAStar var zBacktrack = curNode.pz; if (pathCount == MaxNodes) + { break; + } path[pathCount++] = (Direction)curNode.dir; @@ -105,10 +111,13 @@ namespace Server.PathAlgorithms.SlowAStar var found = false; for (var j = 0; !found && j < closedCount; ++j) + { if (closed[j].x == xBacktrack && closed[j].y == yBacktrack && closed[j].z == zBacktrack) { if (pathCount == MaxNodes) + { break; + } curNode = closed[j]; path[pathCount++] = (Direction)curNode.dir; @@ -117,6 +126,7 @@ namespace Server.PathAlgorithms.SlowAStar zBacktrack = curNode.pz; found = true; } + } if (!found) { @@ -125,16 +135,22 @@ namespace Server.PathAlgorithms.SlowAStar } if (pathCount == MaxNodes) + { break; + } } if (pathCount == MaxNodes) + { break; + } var dirs = new Direction[pathCount]; while (pathCount > 0) + { dirs[iBacktrack++] = path[--pathCount]; + } return dirs; } @@ -142,7 +158,9 @@ namespace Server.PathAlgorithms.SlowAStar --openCount; for (var i = popIndex; i < openCount; ++i) + { open[i] = open[i + 1]; + } var sucCount = 0; @@ -208,7 +226,9 @@ namespace Server.PathAlgorithms.SlowAStar MoveImpl.Goal = Point3D.Zero; if (sucCount == 0 || ++depth > MaxDepth) + { break; + } for (var i = 0; i < sucCount; ++i) { @@ -221,25 +241,39 @@ namespace Server.PathAlgorithms.SlowAStar int openIndex = -1, closedIndex = -1; for (var j = 0; openIndex == -1 && j < openCount; ++j) + { if (open[j].x == x && open[j].y == y && open[j].z == z) + { openIndex = j; + } + } if (openIndex >= 0 && open[openIndex].g < successors[i].g) + { continue; + } for (var j = 0; closedIndex == -1 && j < closedCount; ++j) + { if (closed[j].x == x && closed[j].y == y && closed[j].z == z) + { closedIndex = j; + } + } if (closedIndex >= 0 && closed[closedIndex].g < successors[i].g) + { continue; + } if (openIndex >= 0) { --openCount; for (var j = openIndex; j < openCount; ++j) + { open[j] = open[j + 1]; + } } if (closedIndex >= 0) @@ -247,7 +281,9 @@ namespace Server.PathAlgorithms.SlowAStar --closedCount; for (var j = closedIndex; j < closedCount; ++j) + { closed[j] = closed[j + 1]; + } } successors[i].px = curNode.x; @@ -257,13 +293,17 @@ namespace Server.PathAlgorithms.SlowAStar successors[i].h = Heuristic(x, y, z); if (openCount == MaxNodes) + { break; + } open[openCount++] = successors[i]; } if (openCount == MaxNodes || closedCount == MaxNodes) + { break; + } closed[closedCount++] = curNode; } diff --git a/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs b/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs index 4e6b01d3a..2c36fde67 100644 --- a/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs +++ b/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs @@ -43,7 +43,9 @@ namespace Server.Engines.Plants AddItem(160, 100, 0x15FD); if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant) + { AddItem(156, 130, 0xDCF); // Seed + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -51,7 +53,9 @@ namespace Server.Engines.Plants var from = sender.Mobile; if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant) + { return; + } if (info.ButtonID == 3 && !from.InRange(m_Plant.GetWorldLocation(), 3)) { diff --git a/Projects/UOContent/Engines/Plants/MainPlantGump.cs b/Projects/UOContent/Engines/Plants/MainPlantGump.cs index 43dfa97f1..adf46da5b 100644 --- a/Projects/UOContent/Engines/Plants/MainPlantGump.cs +++ b/Projects/UOContent/Engines/Plants/MainPlantGump.cs @@ -95,8 +95,16 @@ namespace Server.Engines.Plants AddItem(120, 112, 0x914); AddItem(135, 112, 0x914); - if (status >= PlantStatus.Stage2) AddItem(127, 112, 0xC62); - if (status == PlantStatus.Stage3 || status == PlantStatus.Stage4) AddItem(129, 85, 0xC7E); + if (status >= PlantStatus.Stage2) + { + AddItem(127, 112, 0xC62); + } + + if (status == PlantStatus.Stage3 || status == PlantStatus.Stage4) + { + AddItem(129, 85, 0xC7E); + } + if (status >= PlantStatus.Stage4) { AddItem(121, 117, 0xC62); @@ -126,9 +134,13 @@ namespace Server.Engines.Plants // The large images for these trees trigger a client crash, so use a smaller, generic tree. if (m_Plant.PlantType == PlantType.CypressTwisted || m_Plant.PlantType == PlantType.CypressStraight) + { AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, 0x0CCA, hueInfo.Hue); + } else + { AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, typeInfo.ItemID, hueInfo.Hue); + } } if (status != PlantStatus.BowlOfDirt) @@ -217,7 +229,9 @@ namespace Server.Engines.Plants private void AddGrowthIndicator(int x, int y) { if (!m_Plant.IsGrowable) + { return; + } switch (m_Plant.PlantSystem.GrowthIndicator) { @@ -244,7 +258,9 @@ namespace Server.Engines.Plants var from = sender.Mobile; if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant) + { return; + } if ((info.ButtonID >= 6 && info.ButtonID <= 10 || info.ButtonID == 12) && !from.InRange(m_Plant.GetWorldLocation(), 3)) @@ -406,23 +422,31 @@ namespace Server.Engines.Plants public static Item GetPotion(Mobile from, PotionEffect[] effects) { if (from.Backpack == null) + { return null; + } var items = from.Backpack.FindItemsByType(new[] { typeof(BasePotion), typeof(PotionKeg) }); foreach (var item in items) + { if (item is BasePotion potion) { if (Array.IndexOf(effects, potion.PotionEffect) >= 0) + { return potion; + } } else { var keg = (PotionKeg)item; if (keg.Held > 0 && Array.IndexOf(effects, keg.Type) >= 0) + { return keg; + } } + } return null; } diff --git a/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs b/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs index 98180ab28..bca402b98 100644 --- a/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs +++ b/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs @@ -68,7 +68,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Thorn.Deleted) + { return; + } if (!m_Thorn.IsChildOf(from.Backpack)) { @@ -300,7 +302,9 @@ namespace Server.Items public static GreenThornsEffect Create(Mobile from, LandTarget land) { if (!from.Map.CanSpawnMobile(land.Location)) + { return null; + } var tileID = land.TileID; @@ -309,7 +313,9 @@ namespace Server.Items var contains = false; for (var i = 0; !contains && i < taep.Tiles.Length; i += 2) + { contains = tileID >= taep.Tiles[i] && tileID <= taep.Tiles[i + 1]; + } if (contains) { @@ -501,7 +507,9 @@ namespace Server.Items }; if (!SpawnItem(reagents)) + { reagents.Delete(); + } } } @@ -555,7 +563,9 @@ namespace Server.Items BaseCreature spawn = new VorpalBunny(); if (!SpawnCreature(spawn)) + { spawn.Delete(); + } return TimeSpan.Zero; } @@ -611,7 +621,9 @@ namespace Server.Items BaseCreature spawn = new WhippingVine(); if (!SpawnCreature(spawn)) + { spawn.Delete(); + } return TimeSpan.Zero; } @@ -666,13 +678,17 @@ namespace Server.Items BaseCreature spawn = new GiantIceWorm(); if (!SpawnCreature(spawn)) + { spawn.Delete(); + } for (var i = 0; i < 3; i++) { BaseCreature snake = new IceSnake(); if (!SpawnCreature(snake)) + { snake.Delete(); + } } return TimeSpan.Zero; diff --git a/Projects/UOContent/Engines/Plants/MiscItems/OrangePetals.cs b/Projects/UOContent/Engines/Plants/MiscItems/OrangePetals.cs index 12b4e062d..4aa652d95 100644 --- a/Projects/UOContent/Engines/Plants/MiscItems/OrangePetals.cs +++ b/Projects/UOContent/Engines/Plants/MiscItems/OrangePetals.cs @@ -28,7 +28,9 @@ namespace Server.Items public override bool CheckItemUse(Mobile from, Item item) { if (item != this) - return base.CheckItemUse(from, item); + { + return base.CheckItemUse(@from, item); + } if (from != RootParent) { @@ -70,7 +72,9 @@ namespace Server.Items var context = GetContext(m); if (context != null) + { RemoveContext(m, context); + } } private static void RemoveContext(Mobile m, OrangePetalsContext context) @@ -111,12 +115,14 @@ namespace Server.Items protected override void OnTick() { if (!m_Mobile.Deleted) + { m_Mobile.LocalOverheadMessage( MessageType.Regular, 0x3F, true, "* You feel the effects of your poison resistance wearing off *" ); + } RemoveContext(m_Mobile); } diff --git a/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs b/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs index a94acceab..38a6666b4 100644 --- a/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs +++ b/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs @@ -55,7 +55,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_RedLeaves.Deleted) + { return; + } if (!m_RedLeaves.IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Engines/Plants/PlantBowl.cs b/Projects/UOContent/Engines/Plants/PlantBowl.cs index cab30cd32..bfa8cbfe4 100644 --- a/Projects/UOContent/Engines/Plants/PlantBowl.cs +++ b/Projects/UOContent/Engines/Plants/PlantBowl.cs @@ -87,18 +87,28 @@ namespace Server.Engines.Plants int tileID; if (obj is Static staticObj && !staticObj.Movable) + { tileID = (staticObj.ItemID & 0x3FFF) | 0x4000; + } else if (obj is StaticTarget staticTarget) + { tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000; + } else if (obj is LandTarget landTarget) + { tileID = landTarget.TileID; + } else + { return false; + } var contains = false; for (var i = 0; !contains && i < m_DirtPatchTiles.Length; i += 2) + { contains = tileID >= m_DirtPatchTiles[i] && tileID <= m_DirtPatchTiles[i + 1]; + } return contains; } @@ -112,7 +122,9 @@ namespace Server.Engines.Plants protected override void OnTarget(Mobile from, object targeted) { if (m_PlantBowl.Deleted) + { return; + } if (!m_PlantBowl.IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Engines/Plants/PlantHue.cs b/Projects/UOContent/Engines/Plants/PlantHue.cs index 4c28b50e8..6493d0db0 100644 --- a/Projects/UOContent/Engines/Plants/PlantHue.cs +++ b/Projects/UOContent/Engines/Plants/PlantHue.cs @@ -113,31 +113,45 @@ namespace Server.Engines.Plants public static PlantHue Cross(PlantHue first, PlantHue second) { if (!IsCrossable(first) || !IsCrossable(second)) + { return PlantHue.None; + } if (Utility.RandomDouble() < 0.01) + { return Utility.RandomBool() ? PlantHue.Black : PlantHue.White; + } if (first == PlantHue.Plain || second == PlantHue.Plain) + { return PlantHue.Plain; + } var notBrightFirst = GetNotBright(first); var notBrightSecond = GetNotBright(second); if (notBrightFirst == notBrightSecond) + { return first | PlantHue.Bright; + } var firstPrimary = IsPrimary(notBrightFirst); var secondPrimary = IsPrimary(notBrightSecond); if (firstPrimary && secondPrimary) + { return notBrightFirst | notBrightSecond; + } if (firstPrimary) + { return notBrightFirst; + } if (secondPrimary) + { return notBrightSecond; + } return notBrightFirst & notBrightSecond; } diff --git a/Projects/UOContent/Engines/Plants/PlantItem.cs b/Projects/UOContent/Engines/Plants/PlantItem.cs index d0cfb4e3b..9ebb1fa05 100644 --- a/Projects/UOContent/Engines/Plants/PlantItem.cs +++ b/Projects/UOContent/Engines/Plants/PlantItem.cs @@ -68,13 +68,19 @@ namespace Server.Engines.Plants set { if (m_PlantStatus == value || value < PlantStatus.BowlOfDirt || value > PlantStatus.DeadTwigs) + { return; + } double ratio; if (PlantSystem != null) + { ratio = (double)PlantSystem.Hits / PlantSystem.MaxHits; + } else + { ratio = 1.0; + } m_PlantStatus = value; @@ -89,9 +95,13 @@ namespace Server.Engines.Plants var hits = (int)(PlantSystem.MaxHits * ratio); if (hits == 0 && m_PlantStatus > PlantStatus.BowlOfDirt) + { PlantSystem.Hits = hits + 1; + } else + { PlantSystem.Hits = hits; + } } Update(); @@ -137,10 +147,14 @@ namespace Server.Engines.Plants get { if (IsLockedDown && RootParent == null) + { return true; + } if (!(RootParent is Mobile owner)) + { return false; + } return IsChildOf(owner.Backpack) || IsChildOf(owner.FindBankNoCreate()); } @@ -163,13 +177,21 @@ namespace Server.Engines.Plants public override void OnSingleClick(Mobile from) { if (m_PlantStatus >= PlantStatus.DeadTwigs) - LabelTo(from, LabelNumber); + { + LabelTo(@from, LabelNumber); + } else if (m_PlantStatus >= PlantStatus.DecorativePlant) - LabelTo(from, 1061924); // a decorative plant + { + LabelTo(@from, 1061924); // a decorative plant + } else if (m_PlantStatus >= PlantStatus.FullGrownPlant) - LabelTo(from, PlantTypeInfo.GetInfo(m_PlantType).Name); + { + LabelTo(@from, PlantTypeInfo.GetInfo(m_PlantType).Name); + } else - LabelTo(from, 1029913); // plant bowl + { + LabelTo(@from, 1029913); // plant bowl + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -181,11 +203,20 @@ namespace Server.Engines.Plants public int GetLocalizedPlantStatus() { if (m_PlantStatus >= PlantStatus.Plant) + { return 1060812; // plant + } + if (m_PlantStatus >= PlantStatus.Sapling) + { return 1023305; // sapling + } + if (m_PlantStatus >= PlantStatus.Seed) + { return 1060810; // seed + } + return 1026951; // dirt } @@ -228,9 +259,13 @@ namespace Server.Engines.Plants string args; if (ShowContainerType) + { args = $"#{GetLocalizedContainerType()}\t#{PlantSystem.GetLocalizedDirtStatus()}"; + } else + { args = $"#{PlantSystem.GetLocalizedDirtStatus()}"; + } list.Add(1060830, args); // a ~1_val~ of ~2_val~ dirt } @@ -255,19 +290,27 @@ namespace Server.Engines.Plants string args; if (ShowContainerType) + { args = $"#{GetLocalizedContainerType()}\t#{PlantSystem.GetLocalizedDirtStatus()}\t#{PlantSystem.GetLocalizedHealth()}"; + } else + { args = $"#{PlantSystem.GetLocalizedDirtStatus()}\t#{PlantSystem.GetLocalizedHealth()}"; + } if (m_ShowType) { args += $"\t#{hueInfo.Name}\t#{typeInfo.Name}\t#{GetLocalizedPlantStatus()}"; if (m_PlantStatus == PlantStatus.Plant) + { list.Add(typeInfo.GetPlantLabelPlant(hueInfo), args); + } else + { list.Add(typeInfo.GetPlantLabelSeed(hueInfo), args); + } } else { @@ -290,7 +333,9 @@ namespace Server.Engines.Plants public override void OnDoubleClick(Mobile from) { if (m_PlantStatus >= PlantStatus.DecorativePlant) + { return; + } var loc = GetWorldLocation(); @@ -362,7 +407,9 @@ namespace Server.Engines.Plants public void Pour(Mobile from, Item item) { if (m_PlantStatus >= PlantStatus.DeadTwigs) + { return; + } if (m_PlantStatus == PlantStatus.DecorativePlant) { @@ -385,7 +432,9 @@ namespace Server.Engines.Plants } if (!beverage.ValidateUse(from, true)) + { return; + } beverage.Quantity--; PlantSystem.Water++; @@ -445,30 +494,46 @@ namespace Server.Engines.Plants if (effect == PotionEffect.PoisonGreater || effect == PotionEffect.PoisonDeadly) { if (PlantSystem.IsFullPoisonPotion) + { full = true; + } else if (!testOnly) + { PlantSystem.PoisonPotion++; + } } else if (effect == PotionEffect.CureGreater) { if (PlantSystem.IsFullCurePotion) + { full = true; + } else if (!testOnly) + { PlantSystem.CurePotion++; + } } else if (effect == PotionEffect.HealGreater) { if (PlantSystem.IsFullHealPotion) + { full = true; + } else if (!testOnly) + { PlantSystem.HealPotion++; + } } else if (effect == PotionEffect.StrengthGreater) { if (PlantSystem.IsFullStrengthPotion) + { full = true; + } else if (!testOnly) + { PlantSystem.StrengthPotion++; + } } else if (effect == PotionEffect.PoisonLesser || effect == PotionEffect.Poison || effect == PotionEffect.CureLesser || effect == PotionEffect.Cure || @@ -507,7 +572,9 @@ namespace Server.Engines.Plants writer.Write(m_ShowType); if (m_PlantStatus < PlantStatus.DecorativePlant) + { PlantSystem.Save(writer); + } } public override void Deserialize(IGenericReader reader) @@ -527,7 +594,9 @@ namespace Server.Engines.Plants case 0: { if (version < 1) + { Level = SecureLevel.CoOwners; + } m_PlantStatus = (PlantStatus)reader.ReadInt(); m_PlantType = (PlantType)reader.ReadInt(); @@ -535,10 +604,14 @@ namespace Server.Engines.Plants m_ShowType = reader.ReadBool(); if (m_PlantStatus < PlantStatus.DecorativePlant) + { PlantSystem = new PlantSystem(this, reader); + } if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue)) + { m_PlantHue |= PlantHue.Reproduces; + } break; } diff --git a/Projects/UOContent/Engines/Plants/PlantPourTarget.cs b/Projects/UOContent/Engines/Plants/PlantPourTarget.cs index 9c081bb3b..bce2dcbad 100644 --- a/Projects/UOContent/Engines/Plants/PlantPourTarget.cs +++ b/Projects/UOContent/Engines/Plants/PlantPourTarget.cs @@ -11,7 +11,9 @@ namespace Server.Engines.Plants protected override void OnTarget(Mobile from, object targeted) { if (!m_Plant.Deleted && from.InRange(m_Plant.GetWorldLocation(), 3) && targeted is Item item) - m_Plant.Pour(from, item); + { + m_Plant.Pour(@from, item); + } } protected override void OnTargetFinish(Mobile from) @@ -20,7 +22,9 @@ namespace Server.Engines.Plants from.InRange(m_Plant.GetWorldLocation(), 3) && m_Plant.IsUsableBy(from)) { if (from.HasGump()) - from.CloseGump(); + { + @from.CloseGump(); + } from.SendGump(new MainPlantGump(m_Plant)); } diff --git a/Projects/UOContent/Engines/Plants/PlantResources.cs b/Projects/UOContent/Engines/Plants/PlantResources.cs index f8a555072..0b401b604 100644 --- a/Projects/UOContent/Engines/Plants/PlantResources.cs +++ b/Projects/UOContent/Engines/Plants/PlantResources.cs @@ -35,8 +35,12 @@ namespace Server.Engines.Plants public static PlantResourceInfo GetInfo(PlantType plantType, PlantHue plantHue) { foreach (var info in m_ResourceList) + { if (info.PlantType == plantType && info.PlantHue == plantHue) + { return info; + } + } return null; } diff --git a/Projects/UOContent/Engines/Plants/PlantSystem.cs b/Projects/UOContent/Engines/Plants/PlantSystem.cs index 9fd7abd88..c59c9ff8c 100644 --- a/Projects/UOContent/Engines/Plants/PlantSystem.cs +++ b/Projects/UOContent/Engines/Plants/PlantSystem.cs @@ -66,9 +66,13 @@ namespace Server.Engines.Plants FertileDirt = reader.ReadBool(); if (version >= 1) + { NextGrowth = reader.ReadDateTime(); + } else + { NextGrowth = reader.ReadDeltaTime(); + } GrowthIndicator = (PlantGrowthIndicator)reader.ReadInt(); @@ -94,7 +98,9 @@ namespace Server.Engines.Plants m_LeftResources = reader.ReadInt(); if (version < 2 && PlantHueInfo.IsCrossable(m_SeedHue)) + { m_SeedHue |= PlantHue.Reproduces; + } } public PlantItem Plant { get; } @@ -123,12 +129,16 @@ namespace Server.Engines.Plants set { if (m_Hits == value) + { return; + } m_Hits = Math.Clamp(value, 0, MaxHits); if (m_Hits == 0) + { Plant.Die(); + } Plant.InvalidateProperties(); } @@ -143,9 +153,15 @@ namespace Server.Engines.Plants var perc = m_Hits * 100 / MaxHits; if (perc < 33) + { return PlantHealth.Dying; + } + if (perc < 66) + { return PlantHealth.Wilted; + } + return perc < 100 ? PlantHealth.Healthy : PlantHealth.Vibrant; } } @@ -229,7 +245,10 @@ namespace Server.Engines.Plants get => m_AvailableSeeds; set { - if (value >= 0) m_AvailableSeeds = value; + if (value >= 0) + { + m_AvailableSeeds = value; + } } } @@ -238,7 +257,10 @@ namespace Server.Engines.Plants get => m_LeftSeeds; set { - if (value >= 0) m_LeftSeeds = value; + if (value >= 0) + { + m_LeftSeeds = value; + } } } @@ -247,7 +269,10 @@ namespace Server.Engines.Plants get => m_AvailableResources; set { - if (value >= 0) m_AvailableResources = value; + if (value >= 0) + { + m_AvailableResources = value; + } } } @@ -256,7 +281,10 @@ namespace Server.Engines.Plants get => m_LeftResources; set { - if (value >= 0) m_LeftResources = value; + if (value >= 0) + { + m_LeftResources = value; + } } } @@ -290,11 +318,20 @@ namespace Server.Engines.Plants public int GetLocalizedDirtStatus() { if (Water <= 1) + { return 1060826; // hard + } + if (Water <= 2) + { return 1060827; // soft + } + if (Water <= 3) + { return 1060828; // squishy + } + return 1060829; // sopping wet } @@ -314,7 +351,9 @@ namespace Server.Engines.Plants EventSink.WorldLoad += EventSink_WorldLoad; if (!AutoRestart.Enabled) + { EventSink.WorldSave += EventSink_WorldSave; + } EventSink.Login += EventSink_Login; } @@ -326,7 +365,9 @@ namespace Server.Engines.Plants plant => { if (plant.IsGrowable) + { plant.PlantSystem.DoGrowthCheck(); + } } ); @@ -336,7 +377,9 @@ namespace Server.Engines.Plants plant => { if (plant.IsGrowable) + { plant.PlantSystem.DoGrowthCheck(); + } } ); } @@ -351,7 +394,9 @@ namespace Server.Engines.Plants var plant = plants[i]; if (plant.IsGrowable && !(plant.RootParent is Mobile) && now >= plant.PlantSystem.NextGrowth) + { plant.PlantSystem.DoGrowthCheck(); + } } } @@ -368,7 +413,9 @@ namespace Server.Engines.Plants public void DoGrowthCheck() { if (!Plant.IsGrowable) + { return; + } if (DateTime.UtcNow < NextGrowth) { @@ -387,14 +434,19 @@ namespace Server.Engines.Plants if (Plant.PlantStatus == PlantStatus.BowlOfDirt) { if (Water > 2 || Utility.RandomDouble() < 0.9) + { Water--; + } + return; } ApplyBeneficialEffects(); if (!ApplyMaladiesEffects()) // Dead + { return; + } Grow(); @@ -450,9 +502,13 @@ namespace Server.Engines.Plants if (!HasMaladies) { if (HealPotion > 0) + { Hits += HealPotion * 7; + } else + { Hits += 2; + } } HealPotion = 0; @@ -463,21 +519,33 @@ namespace Server.Engines.Plants var damage = 0; if (Infestation > 0) + { damage += Infestation * Utility.RandomMinMax(3, 6); + } if (Fungus > 0) + { damage += Fungus * Utility.RandomMinMax(3, 6); + } if (Poison > 0) + { damage += Poison * Utility.RandomMinMax(3, 6); + } if (Disease > 0) + { damage += Disease * Utility.RandomMinMax(3, 6); + } if (Water > 2) + { damage += (Water - 2) * Utility.RandomMinMax(3, 6); + } else if (Water < 2) + { damage += (2 - Water) * Utility.RandomMinMax(3, 6); + } Hits -= damage; @@ -535,21 +603,31 @@ namespace Server.Engines.Plants var typeInfo = PlantTypeInfo.GetInfo(Plant.PlantType); if (typeInfo.Flowery) + { infestationChance += 0.10; + } if (PlantHueInfo.IsBright(Plant.PlantHue)) + { infestationChance += 0.10; + } if (Utility.RandomDouble() < infestationChance) + { Infestation++; + } var fungusChance = 0.15 - StrengthPotion * 0.075 + (Water - 2) * 0.10; if (Utility.RandomDouble() < fungusChance) + { Fungus++; + } if (Water > 2 || Utility.RandomDouble() < 0.9) + { Water--; + } if (PoisonPotion > 0) { diff --git a/Projects/UOContent/Engines/Plants/PlantType.cs b/Projects/UOContent/Engines/Plants/PlantType.cs index 7aec8f538..58dbdf144 100644 --- a/Projects/UOContent/Engines/Plants/PlantType.cs +++ b/Projects/UOContent/Engines/Plants/PlantType.cs @@ -247,7 +247,10 @@ namespace Server.Engines.Plants var index = (int)plantType; if (index >= 0 && index < m_Table.Length) + { return m_Table[index]; + } + return m_Table[0]; } @@ -339,19 +342,40 @@ namespace Server.Engines.Plants var rand = Utility.RandomDouble(); if (rand < 0.5 / exp4) + { return PlantType.CommonGreenBonsai; + } + if (rand < 1.0 / exp4) + { return PlantType.CommonPinkBonsai; + } + if (rand < (k1 * 0.5 + 1.0) / exp4) + { return PlantType.UncommonGreenBonsai; + } + if (rand < exp1 / exp4) + { return PlantType.UncommonPinkBonsai; + } + if (rand < (k2 * 0.5 + exp1) / exp4) + { return PlantType.RareGreenBonsai; + } + if (rand < exp2 / exp4) + { return PlantType.RarePinkBonsai; + } + if (rand < exp3 / exp4) + { return PlantType.ExceptionalBonsai; + } + return PlantType.ExoticBonsai; } @@ -360,13 +384,18 @@ namespace Server.Engines.Plants public static PlantType Cross(PlantType first, PlantType second) { if (!IsCrossable(first) || !IsCrossable(second)) + { return PlantType.CampionFlowers; + } var firstIndex = (int)first; var secondIndex = (int)second; if (firstIndex + 1 == secondIndex || firstIndex == secondIndex + 1) + { return Utility.RandomBool() ? first : second; + } + return (PlantType)((firstIndex + secondIndex) / 2); } @@ -375,7 +404,9 @@ namespace Server.Engines.Plants public int GetPlantLabelSeed(PlantHueInfo hueInfo) { if (m_PlantLabelSeed != -1) + { return m_PlantLabelSeed; + } return hueInfo.IsBright() @@ -386,13 +417,18 @@ namespace Server.Engines.Plants public int GetPlantLabelPlant(PlantHueInfo hueInfo) { if (m_PlantLabelPlant != -1) + { return m_PlantLabelPlant; + } if (ContainsPlant) + { return hueInfo.IsBright() ? 1060832 : 1060831; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ + } + return hueInfo.IsBright() ? 1061887 @@ -402,17 +438,24 @@ namespace Server.Engines.Plants public int GetPlantLabelFullGrown(PlantHueInfo hueInfo) { if (m_PlantLabelFullGrown != -1) + { return m_PlantLabelFullGrown; + } if (ContainsPlant) + { return hueInfo.IsBright() ? 1061891 : 1061889; // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~ + } + return hueInfo.IsBright() ? 1061892 : 1061890; // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~ plant } public int GetPlantLabelDecorative(PlantHueInfo hueInfo) { if (m_PlantLabelDecorative != -1) + { return m_PlantLabelDecorative; + } return hueInfo.IsBright() ? 1074267 : 1070973; // a decorative [bright] ~1_COLOR~ ~2_TYPE~ } @@ -420,7 +463,9 @@ namespace Server.Engines.Plants public int GetSeedLabel(PlantHueInfo hueInfo) { if (m_SeedLabel != -1) + { return m_SeedLabel; + } return hueInfo.IsBright() ? 1061918 : 1061917; // [bright] ~1_COLOR~ ~2_TYPE~ seed } @@ -428,7 +473,9 @@ namespace Server.Engines.Plants public int GetSeedLabelPlural(PlantHueInfo hueInfo) { if (m_SeedLabelPlural != -1) + { return m_SeedLabelPlural; + } return hueInfo.IsBright() ? 1113493 : 1113492; // ~1_amount~ [bright] ~2_color~ ~3_type~ seeds } diff --git a/Projects/UOContent/Engines/Plants/PollinateTarget.cs b/Projects/UOContent/Engines/Plants/PollinateTarget.cs index 026aeb8b9..038cc7b24 100644 --- a/Projects/UOContent/Engines/Plants/PollinateTarget.cs +++ b/Projects/UOContent/Engines/Plants/PollinateTarget.cs @@ -86,7 +86,10 @@ namespace Server.Engines.Plants { if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant && m_Plant.PlantStatus != PlantStatus.BowlOfDirt && from.InRange(m_Plant.GetWorldLocation(), 3) && - m_Plant.IsUsableBy(from)) from.SendGump(new ReproductionGump(m_Plant)); + m_Plant.IsUsableBy(from)) + { + @from.SendGump(new ReproductionGump(m_Plant)); + } } } } diff --git a/Projects/UOContent/Engines/Plants/ReproductionGump.cs b/Projects/UOContent/Engines/Plants/ReproductionGump.cs index ac3a0710e..b77d2a79d 100644 --- a/Projects/UOContent/Engines/Plants/ReproductionGump.cs +++ b/Projects/UOContent/Engines/Plants/ReproductionGump.cs @@ -69,11 +69,17 @@ namespace Server.Engines.Plants var system = m_Plant.PlantSystem; if (!system.PollenProducing) + { AddLabel(x, y, 0x35, "-"); + } else if (!system.Pollinated) + { AddLabel(x, y, 0x21, "!"); + } else + { AddLabel(x, y, 0x3F, "+"); + } } private void AddResourcesState(int x, int y) @@ -84,14 +90,18 @@ namespace Server.Engines.Plants var totalResources = system.AvailableResources + system.LeftResources; if (resInfo == null || totalResources == 0) + { AddLabel(x + 5, y, 0x21, "X"); + } else + { AddLabel( x, y, PlantHueInfo.GetInfo(m_Plant.PlantHue).GumpHue, $"{system.AvailableResources}/{totalResources}" ); + } } private void AddSeedsState(int x, int y) @@ -100,14 +110,18 @@ namespace Server.Engines.Plants var totalSeeds = system.AvailableSeeds + system.LeftSeeds; if (!m_Plant.Reproduces || totalSeeds == 0) + { AddLabel(x + 5, y, 0x21, "X"); + } else + { AddLabel( x, y, PlantHueInfo.GetInfo(system.SeedHue).GumpHue, $"{system.AvailableSeeds}/{totalSeeds}" ); + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -116,7 +130,9 @@ namespace Server.Engines.Plants if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant || m_Plant.PlantStatus == PlantStatus.BowlOfDirt) + { return; + } if (info.ButtonID >= 6 && info.ButtonID <= 8 && !from.InRange(m_Plant.GetWorldLocation(), 3)) { @@ -140,7 +156,10 @@ namespace Server.Engines.Plants } case 2: // Set to decorative { - if (m_Plant.PlantStatus == PlantStatus.Stage9) from.SendGump(new SetToDecorativeGump(m_Plant)); + if (m_Plant.PlantStatus == PlantStatus.Stage9) + { + @from.SendGump(new SetToDecorativeGump(m_Plant)); + } break; } @@ -205,9 +224,13 @@ namespace Server.Engines.Plants if (resInfo == null) { if (m_Plant.IsCrossable) - m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather! + { + m_Plant.LabelTo(@from, 1053056); // This plant has no resources to gather! + } else - m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources! + { + m_Plant.LabelTo(@from, 1053055); // Mutated plants do not produce resources! + } } else if (system.AvailableResources == 0) { diff --git a/Projects/UOContent/Engines/Plants/Seed.cs b/Projects/UOContent/Engines/Plants/Seed.cs index 1b79e43b1..87e40483c 100644 --- a/Projects/UOContent/Engines/Plants/Seed.cs +++ b/Projects/UOContent/Engines/Plants/Seed.cs @@ -94,9 +94,13 @@ namespace Server.Engines.Plants int title; if (m_ShowType || typeInfo.PlantCategory == PlantCategory.Default) + { title = hueInfo.Name; + } else + { title = (int)typeInfo.PlantCategory; + } if (Amount == 1) { @@ -149,7 +153,9 @@ namespace Server.Engines.Plants public override void OnAfterDuped(Item newItem) { if (!(newItem is Seed newSeed)) + { return; + } newSeed.PlantType = m_PlantType; newSeed.PlantHue = m_PlantHue; @@ -178,13 +184,19 @@ namespace Server.Engines.Plants m_ShowType = reader.ReadBool(); if (Weight != 1.0) + { Weight = 1.0; + } if (version < 1) + { Stackable = Core.SA; + } if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue)) + { m_PlantHue |= PlantHue.Reproduces; + } } private class InternalTarget : Target @@ -200,7 +212,9 @@ namespace Server.Engines.Plants protected override void OnTarget(Mobile from, object targeted) { if (m_Seed.Deleted) + { return; + } if (!m_Seed.IsChildOf(from.Backpack)) { @@ -209,11 +223,17 @@ namespace Server.Engines.Plants } if (targeted is PlantItem plant) - plant.PlantSeed(from, m_Seed); + { + plant.PlantSeed(@from, m_Seed); + } else if (targeted is Item item) - item.LabelTo(from, 1061919); // You must use a seed on a bowl of dirt! + { + item.LabelTo(@from, 1061919); // You must use a seed on a bowl of dirt! + } else - from.SendLocalizedMessage(1061919); // You must use a seed on a bowl of dirt! + { + @from.SendLocalizedMessage(1061919); // You must use a seed on a bowl of dirt! + } } } } diff --git a/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs b/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs index 71335597e..a36f7c1c4 100644 --- a/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs +++ b/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs @@ -40,7 +40,9 @@ namespace Server.Engines.Plants var from = sender.Mobile; if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus != PlantStatus.Stage9) + { return; + } if (info.ButtonID == 3 && !from.InRange(m_Plant.GetWorldLocation(), 3)) { diff --git a/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Conversations.cs b/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Conversations.cs index 5ef475ac7..e0fd86c5a 100644 --- a/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Conversations.cs @@ -54,9 +54,13 @@ namespace Server.Engines.Quests.Ambitious AmbitiousQueenQuest.GiveRewardTo(System.From, ref bagOfSending, ref powderOfTranslocation, ref gold); if (!bagOfSending && !powderOfTranslocation && !gold) + { System.Complete(); + } else + { System.AddConversation(new FullBackpackConversation(true, bagOfSending, powderOfTranslocation, gold)); + } } } @@ -85,7 +89,9 @@ namespace Server.Engines.Quests.Ambitious public override void OnRead() { if (m_Logged) + { System.AddObjective(new GetRewardObjective(m_BagOfSending, m_PowderOfTranslocation, m_Gold)); + } } public override void ChildDeserialize(IGenericReader reader) diff --git a/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs b/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs index b171a2dcd..d2edc0246 100644 --- a/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs +++ b/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs @@ -22,7 +22,9 @@ namespace Server.Engines.Quests.Ambitious Body = 0x30F; if (!RedSolen) + { Hue = 0x453; + } SpeechHue = 0; } @@ -68,8 +70,11 @@ namespace Server.Engines.Quests.Ambitious lastObj.Gold = gold; if (!bagOfSending && !powderOfTranslocation && !gold) + { lastObj.Complete(); + } else + { qs.AddConversation( new FullBackpackConversation( false, @@ -78,6 +83,7 @@ namespace Server.Engines.Quests.Ambitious lastObj.Gold ) ); + } } } } @@ -87,9 +93,13 @@ namespace Server.Engines.Quests.Ambitious QuestSystem newQuest = new AmbitiousQueenQuest(player, RedSolen); if (player.Quest == null && QuestSystem.CanOfferQuest(player, typeof(AmbitiousQueenQuest))) + { newQuest.SendOffer(); + } else + { newQuest.AddConversation(new DontOfferConversation()); + } } } @@ -98,11 +108,13 @@ namespace Server.Engines.Quests.Ambitious Direction = GetDirectionTo(from); if (from is PlayerMobile player) + { if (player.Quest is AmbitiousQueenQuest qs && qs.RedSolen == RedSolen) { QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { if (dropped is ZoogiFungus fungi) { if (fungi.Amount >= 50) @@ -126,7 +138,9 @@ namespace Server.Engines.Quests.Ambitious ); // Our arrangement was for 50 of the zoogi fungus. Please return to me when you have that amount. return false; } + } } + } return base.OnDragDrop(from, dropped); } diff --git a/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Objectives.cs b/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Objectives.cs index 6cb9b5cf6..9a6a435c0 100644 --- a/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Ambitious Solen Queen/Objectives.cs @@ -35,12 +35,17 @@ namespace Server.Engines.Quests.Ambitious public override bool IgnoreYoungProtection(Mobile from) { if (Completed) + { return false; + } var redSolen = ((AmbitiousQueenQuest)System).RedSolen; if (redSolen) - return from is RedSolenQueen; + { + return @from is RedSolenQueen; + } + return from is BlackSolenQueen; } @@ -51,12 +56,16 @@ namespace Server.Engines.Quests.Ambitious if (redSolen) { if (creature is RedSolenQueen) + { CurProgress++; + } } else { if (creature is BlackSolenQueen) + { CurProgress++; + } } } diff --git a/Projects/UOContent/Engines/Quests/Collector/Conversations.cs b/Projects/UOContent/Engines/Quests/Collector/Conversations.cs index d090d44c3..68dece792 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Conversations.cs @@ -254,7 +254,9 @@ namespace Server.Engines.Quests.Collector public override void OnRead() { if (m_Logged) + { System.AddObjective(new MakeRoomObjective()); + } } } } diff --git a/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs b/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs index 7389c3760..1a46f0360 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs @@ -26,6 +26,7 @@ namespace Server.Engines.Quests.Collector var qs = player.Quest; if (qs is CollectorQuest) + { if (qs.IsObjectiveInProgress(typeof(CaptureImagesObjective))) { player.SendAsciiMessage(0x59, "Target the creature whose image you wish to create."); @@ -33,6 +34,7 @@ namespace Server.Engines.Quests.Collector return; } + } } from.SendLocalizedMessage(1010085); // You cannot use this. @@ -65,19 +67,25 @@ namespace Server.Engines.Quests.Collector protected override void OnTarget(Mobile from, object targeted) { if (m_Paints.Deleted || !m_Paints.IsChildOf(from.Backpack)) + { return; + } if (from is PlayerMobile player) { var qs = player.Quest; if (!(qs is CollectorQuest)) + { return; + } var obj = qs.FindObjective(); if (obj?.Completed != false) + { return; + } if (targeted is Mobile) { diff --git a/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs b/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs index 4b3dd13ce..18ce3dd36 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Items/ImageTypeInfo.cs @@ -81,7 +81,10 @@ namespace Server.Engines.Quests.Collector public static ImageType[] RandomList(int count) { - if (count <= 0) return Array.Empty(); + if (count <= 0) + { + return Array.Empty(); + } var length = m_Table.Length; Span list = stackalloc bool[length]; @@ -92,7 +95,9 @@ namespace Server.Engines.Quests.Collector { var rand = Utility.Random(length); if (!(list[rand] && (list[rand] = true))) + { imageTypes[i++] = (ImageType)rand; + } } while (i < count); return imageTypes; diff --git a/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs b/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs index db29aff84..ea41f32c2 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs @@ -97,18 +97,30 @@ namespace Server.Engines.Quests.Collector set { if (value <= 1) + { m_Quantity = 1; + } else if (value >= m_Completed) + { m_Quantity = m_Completed; + } else + { m_Quantity = value; + } if (m_Quantity < m_Partial) + { ItemID = 0x1EA7; + } else if (m_Quantity < m_Completed) + { ItemID = 0x1F13; + } else + { ItemID = 0x12CB; + } InvalidateProperties(); } @@ -132,21 +144,33 @@ namespace Server.Engines.Quests.Collector public override void AddNameProperty(ObjectPropertyList list) { if (m_Quantity < m_Partial) + { list.Add(1055137); // a section of an obsidian statue + } else if (m_Quantity < m_Completed) + { list.Add(1055138); // a partially reconstructed obsidian statue + } else + { list.Add(1055139, m_StatueName); // an obsidian statue of ~1_STATUE_NAME~ + } } public override void OnSingleClick(Mobile from) { if (m_Quantity < m_Partial) - LabelTo(from, 1055137); // a section of an obsidian statue + { + LabelTo(@from, 1055137); // a section of an obsidian statue + } else if (m_Quantity < m_Completed) - LabelTo(from, 1055138); // a partially reconstructed obsidian statue + { + LabelTo(@from, 1055138); // a partially reconstructed obsidian statue + } else - LabelTo(from, 1055139, m_StatueName); // an obsidian statue of ~1_STATUE_NAME~ + { + LabelTo(@from, 1055139, m_StatueName); // an obsidian statue of ~1_STATUE_NAME~ + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -154,7 +178,9 @@ namespace Server.Engines.Quests.Collector base.GetContextMenuEntries(from, list); if (from.Alive && m_Quantity >= m_Partial && m_Quantity < m_Completed && IsChildOf(from.Backpack)) + { list.Add(new DisassembleEntry(this)); + } } public override void OnDoubleClick(Mobile from) @@ -162,7 +188,8 @@ namespace Server.Engines.Quests.Collector if (m_Quantity < m_Completed) { if (!IsChildOf(from.Backpack)) - from.Send( + { + @from.Send( new MessageLocalized( Serial, ItemID, @@ -174,8 +201,11 @@ namespace Server.Engines.Quests.Collector "" ) ); // Nothing Happens. + } else - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } } } @@ -212,7 +242,9 @@ namespace Server.Engines.Quests.Collector m_Obsidian.IsChildOf(from.Backpack) && from.CheckAlive()) { for (var i = 0; i < m_Obsidian.Quantity - 1; i++) - from.AddToBackpack(new Obsidian()); + { + @from.AddToBackpack(new Obsidian()); + } m_Obsidian.Quantity = 1; } @@ -228,10 +260,13 @@ namespace Server.Engines.Quests.Collector protected override void OnTarget(Mobile from, object targeted) { if (m_Obsidian.Deleted || m_Obsidian.Quantity >= m_Completed || !(targeted is Item targ)) + { return; + } if (m_Obsidian.IsChildOf(from.Backpack) && targ.IsChildOf(from.Backpack) && targ is Obsidian targObsidian && targ != m_Obsidian) + { if (targObsidian.Quantity < m_Completed) { if (targObsidian.Quantity + m_Obsidian.Quantity <= m_Completed) @@ -247,9 +282,11 @@ namespace Server.Engines.Quests.Collector } if (targObsidian.Quantity >= m_Completed) - targObsidian.StatueName = RandomName(from); + { + targObsidian.StatueName = RandomName(@from); + } - from.Send( + @from.Send( new AsciiMessage( targObsidian.Serial, targObsidian.ItemID, @@ -263,6 +300,7 @@ namespace Server.Engines.Quests.Collector return; } + } from.Send( new MessageLocalized( diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/AlbertaGiacco.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/AlbertaGiacco.cs index f45ac44cf..4a1c2b489 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/AlbertaGiacco.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/AlbertaGiacco.cs @@ -43,7 +43,9 @@ namespace Server.Engines.Quests.Collector QuestSystem qs = to.Quest as CollectorQuest; if (qs == null) + { return false; + } return qs.IsObjectiveInProgress(typeof(FindAlbertaObjective)) || qs.IsObjectiveInProgress(typeof(SitOnTheStoolObjective)) @@ -61,11 +63,17 @@ namespace Server.Engines.Quests.Collector QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } else if (qs.IsObjectiveInProgress(typeof(SitOnTheStoolObjective))) + { qs.AddConversation(new AlbertaStoolConversation()); + } else if (qs.IsObjectiveInProgress(typeof(ReturnPaintingObjective))) + { qs.AddConversation(new AlbertaAfterPaintingConversation()); + } } } diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs index 2120d0f7c..1b386db5a 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs @@ -118,9 +118,13 @@ namespace Server.Engines.Quests.Collector obj.Complete(); if (GiveReward(player)) + { qs.AddConversation(new EndConversation()); + } else + { qs.AddConversation(new FullEndConversation(true)); + } } else { @@ -149,9 +153,13 @@ namespace Server.Engines.Quests.Collector QuestSystem newQuest = new CollectorQuest(player); if (qs == null && QuestSystem.CanOfferQuest(player, typeof(CollectorQuest))) + { newQuest.SendOffer(); + } else + { newQuest.AddConversation(new DontOfferConversation()); + } } } @@ -187,9 +195,13 @@ namespace Server.Engines.Quests.Collector item = Loot.RandomArmorOrShieldOrJewelry(); if (item is BaseArmor armor) + { BaseRunicTool.ApplyAttributesTo(armor, 2, 20, 30); + } else if (item is BaseJewel jewel) + { BaseRunicTool.ApplyAttributesTo(jewel, 2, 20, 30); + } } else { @@ -205,7 +217,10 @@ namespace Server.Engines.Quests.Collector bag.DropItem(new Obsidian()); - if (to.PlaceInBackpack(bag)) return true; + if (to.PlaceInBackpack(bag)) + { + return true; + } bag.Delete(); return false; diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/GabrielPiete.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/GabrielPiete.cs index 75e7cf5ed..b63e6dadf 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/GabrielPiete.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/GabrielPiete.cs @@ -44,7 +44,9 @@ namespace Server.Engines.Quests.Collector QuestSystem qs = to.Quest as CollectorQuest; if (qs == null) + { return false; + } return qs.IsObjectiveInProgress(typeof(FindGabrielObjective)) || qs.IsObjectiveInProgress(typeof(FindSheetMusicObjective)) @@ -75,9 +77,13 @@ namespace Server.Engines.Quests.Collector obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } else if (qs.IsObjectiveInProgress(typeof(ReturnAutographObjective))) + { qs.AddConversation(new GabrielIgnoreConversation()); + } } } } diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs index 5d5d39d9c..0183a0beb 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs @@ -42,7 +42,9 @@ namespace Server.Engines.Quests.Collector QuestSystem qs = to.Quest as CollectorQuest; if (qs == null) + { return false; + } return qs.IsObjectiveInProgress(typeof(FindSheetMusicObjective)); } @@ -52,7 +54,9 @@ namespace Server.Engines.Quests.Collector var qs = player.Quest; if (!(qs is CollectorQuest)) + { return; + } var obj = qs.FindObjective(); @@ -140,17 +144,22 @@ namespace Server.Engines.Quests.Collector public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1 && info.IsSwitched(1)) + { if (sender.Mobile is PlayerMobile player) { var qs = player.Quest; if (!(qs is CollectorQuest)) + { return; + } var obj = qs.FindObjective(); if (obj?.Completed != false) + { return; + } if (player.Backpack?.ConsumeTotal(typeof(Gold), 10) == true) { @@ -159,13 +168,18 @@ namespace Server.Engines.Quests.Collector else { if (player.FindBankNoCreate()?.ConsumeTotal(typeof(Gold), 10) == true) + { obj.Complete(); + } else + { player.SendLocalizedMessage( 1055108 ); // You don't have enough gold to buy the sheet music. + } } } + } } } } diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs index 2091f7125..b47674977 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs @@ -42,7 +42,9 @@ namespace Server.Engines.Quests.Collector QuestSystem qs = to.Quest as CollectorQuest; if (qs == null) + { return false; + } return qs.IsObjectiveInProgress(typeof(FindTomasObjective)) || qs.IsObjectiveInProgress(typeof(CaptureImagesObjective)) diff --git a/Projects/UOContent/Engines/Quests/Collector/Objectives.cs b/Projects/UOContent/Engines/Quests/Collector/Objectives.cs index e3d149abc..30b744a08 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Objectives.cs @@ -69,8 +69,13 @@ namespace Server.Engines.Quests.Collector if (pm.Map == m_StoolMap && pm.Location == m_StoolLocation) { if (m_Begin == DateTime.MaxValue) + { m_Begin = DateTime.UtcNow; - else if (DateTime.UtcNow - m_Begin > TimeSpan.FromSeconds(30.0)) Complete(); + } + else if (DateTime.UtcNow - m_Begin > TimeSpan.FromSeconds(30.0)) + { + Complete(); + } } else if (m_Begin != DateTime.MaxValue) { @@ -123,7 +128,9 @@ namespace Server.Engines.Quests.Collector public FindSheetMusicObjective(bool init) { if (init) + { InitTheater(); + } } public FindSheetMusicObjective() @@ -149,7 +156,9 @@ namespace Server.Engines.Quests.Collector var region = Region.Find(player.Location, player.Map); if (region == null) + { return false; + } return m_Theater switch { @@ -242,8 +251,12 @@ namespace Server.Engines.Quests.Collector get { for (var i = 0; i < m_Done.Length; i++) + { if (!m_Done[i]) + { return false; + } + } return true; } @@ -252,7 +265,9 @@ namespace Server.Engines.Quests.Collector public override bool IgnoreYoungProtection(Mobile from) { if (Completed) + { return false; + } var fromType = from.GetType(); @@ -261,7 +276,9 @@ namespace Server.Engines.Quests.Collector var info = ImageTypeInfo.Get(m_Images[i]); if (info.Type == fromType) + { return true; + } } return false; @@ -277,7 +294,10 @@ namespace Server.Engines.Quests.Collector { image = m_Images[i]; - if (m_Done[i]) return CaptureResponse.AlreadyDone; + if (m_Done[i]) + { + return CaptureResponse.AlreadyDone; + } m_Done[i] = true; @@ -294,6 +314,7 @@ namespace Server.Engines.Quests.Collector public override void RenderProgress(BaseQuestGump gump) { if (!Completed) + { for (var i = 0; i < m_Images.Length; i++) { var info = ImageTypeInfo.Get(m_Images[i]); @@ -311,8 +332,11 @@ namespace Server.Engines.Quests.Collector false ); } + } else + { base.RenderProgress(gump); + } } public override void OnComplete() diff --git a/Projects/UOContent/Engines/Quests/Core/BaseQuester.cs b/Projects/UOContent/Engines/Quests/Core/BaseQuester.cs index 8bc0c0d8f..aabae6d4b 100644 --- a/Projects/UOContent/Engines/Quests/Core/BaseQuester.cs +++ b/Projects/UOContent/Engines/Quests/Core/BaseQuester.cs @@ -16,7 +16,9 @@ namespace Server.Engines.Quests var from = Owner.From; if (from.CheckAlive() && from is PlayerMobile mobile && m_Quester.CanTalkTo(mobile)) + { m_Quester.OnTalk(mobile, true); + } } } @@ -66,7 +68,9 @@ namespace Server.Engines.Quests base.AddCustomContextEntries(from, list); if (from.Alive && from is PlayerMobile mobile && TalkNumber > 0 && CanTalkTo(mobile)) + { list.Add(new TalkEntry(this)); + } } public override void OnMovement(Mobile m, Point3D oldLocation) @@ -76,7 +80,9 @@ namespace Server.Engines.Quests var range = GetAutoTalkRange(pm); if (pm.Alive && range >= 0 && InRange(m, range) && !InRange(oldLocation, range) && CanTalkTo(pm)) + { OnTalk(pm, false); + } } } diff --git a/Projects/UOContent/Engines/Quests/Core/Items/EnchantedSextant.cs b/Projects/UOContent/Engines/Quests/Core/Items/EnchantedSextant.cs index bad191c35..e5a141cb5 100644 --- a/Projects/UOContent/Engines/Quests/Core/Items/EnchantedSextant.cs +++ b/Projects/UOContent/Engines/Quests/Core/Items/EnchantedSextant.cs @@ -131,50 +131,70 @@ namespace Server.Items var closestMoongate = Point3D.Zero; var moongateDistance = double.MaxValue; if (moongates != null) + { foreach (var entry in moongates.Entries) { - var dist = from.GetDistanceToSqrt(entry.Location); + var dist = @from.GetDistanceToSqrt(entry.Location); if (moongateDistance > dist) { closestMoongate = entry.Location; moongateDistance = dist; } } + } var closestBank = Point2D.Zero; var bankDistance = double.MaxValue; if (banks != null) + { foreach (var p in banks) { - var dist = from.GetDistanceToSqrt(p); + var dist = @from.GetDistanceToSqrt(p); if (bankDistance > dist) { closestBank = p; bankDistance = dist; } } + } int moonMsg; if (moongateDistance == double.MaxValue) + { moonMsg = 1048021; // The sextant fails to find a Moongate nearby. + } else if (moongateDistance > m_LongDistance) - moonMsg = 1046449 + (int)from.GetDirectionTo(closestMoongate); // A moongate is * from here + { + moonMsg = 1046449 + (int)@from.GetDirectionTo(closestMoongate); // A moongate is * from here + } else if (moongateDistance > m_ShortDistance) - moonMsg = 1048010 + (int)from.GetDirectionTo(closestMoongate); // There is a Moongate * of here. + { + moonMsg = 1048010 + (int)@from.GetDirectionTo(closestMoongate); // There is a Moongate * of here. + } else + { moonMsg = 1048018; // You are next to a Moongate at the moment. + } from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg, "", "")); int bankMsg; if (bankDistance == double.MaxValue) + { bankMsg = 1048020; // The sextant fails to find a Bank nearby. + } else if (bankDistance > m_LongDistance) - bankMsg = 1046462 + (int)from.GetDirectionTo(closestBank); // A town is * from here + { + bankMsg = 1046462 + (int)@from.GetDirectionTo(closestBank); // A town is * from here + } else if (bankDistance > m_ShortDistance) - bankMsg = 1048002 + (int)from.GetDirectionTo(closestBank); // There is a city Bank * of here. + { + bankMsg = 1048002 + (int)@from.GetDirectionTo(closestBank); // There is a city Bank * of here. + } else + { bankMsg = 1048019; // You are next to a Bank at the moment. + } from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg, "", "")); } diff --git a/Projects/UOContent/Engines/Quests/Core/Items/QuestItem.cs b/Projects/UOContent/Engines/Quests/Core/Items/QuestItem.cs index 61da83dab..c44187b8d 100644 --- a/Projects/UOContent/Engines/Quests/Core/Items/QuestItem.cs +++ b/Projects/UOContent/Engines/Quests/Core/Items/QuestItem.cs @@ -22,9 +22,16 @@ namespace Server.Engines.Quests if (ret && !Accepted && Parent != from.Backpack) { - if (from.AccessLevel > AccessLevel.Player) return true; + if (from.AccessLevel > AccessLevel.Player) + { + return true; + } + + if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from)) + { + return true; + } - if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from)) return true; from.SendLocalizedMessage( 1049343 ); // You can only drop quest items into the top-most level of your backpack while you still need them for your quest. @@ -40,9 +47,16 @@ namespace Server.Engines.Quests if (ret && !Accepted && Parent != from.Backpack) { - if (from.AccessLevel > AccessLevel.Player) return true; + if (from.AccessLevel > AccessLevel.Player) + { + return true; + } + + if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from)) + { + return true; + } - if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from)) return true; from.SendLocalizedMessage( 1049344 ); // You decide against trading the item. You still need it for your quest. @@ -58,9 +72,16 @@ namespace Server.Engines.Quests if (ret && !Accepted && Parent != from.Backpack) { - if (from.AccessLevel > AccessLevel.Player) return true; + if (from.AccessLevel > AccessLevel.Player) + { + return true; + } + + if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from)) + { + return true; + } - if (!(from is PlayerMobile) || CanDrop((PlayerMobile)from)) return true; from.SendLocalizedMessage( 1049343 ); // You can only drop quest items into the top-most level of your backpack while you still need them for your quest. @@ -73,7 +94,9 @@ namespace Server.Engines.Quests public override DeathMoveResult OnParentDeath(Mobile parent) { if (parent is PlayerMobile mobile && !CanDrop(mobile)) + { return DeathMoveResult.MoveToBackpack; + } return base.OnParentDeath(parent); } diff --git a/Projects/UOContent/Engines/Quests/Core/QuestObjective.cs b/Projects/UOContent/Engines/Quests/Core/QuestObjective.cs index 0c7156e50..aedc5ce78 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestObjective.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestObjective.cs @@ -149,7 +149,9 @@ namespace Server.Engines.Quests public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_System.ShowQuestLog(); + } } } diff --git a/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs b/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs index 6eb8a80ea..2cef83a8b 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestRestartInfo.cs @@ -23,9 +23,13 @@ namespace Server.Engines.Quests public void Reset(TimeSpan restartDelay) { if (restartDelay < TimeSpan.MaxValue) + { RestartTime = DateTime.UtcNow + restartDelay; + } else + { RestartTime = DateTime.MaxValue; + } } } } diff --git a/Projects/UOContent/Engines/Quests/Core/QuestSerializer.cs b/Projects/UOContent/Engines/Quests/Core/QuestSerializer.cs index 2b285bec5..d971e5f73 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestSerializer.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestSerializer.cs @@ -26,12 +26,14 @@ namespace Server.Engines.Quests else { for (var i = 0; i < referenceTable.Length; ++i) + { if (referenceTable[i] == type) { writer.WriteEncodedInt(0x01); writer.WriteEncodedInt(i); return; } + } writer.WriteEncodedInt(0x02); writer.Write(type.FullName); @@ -53,7 +55,9 @@ namespace Server.Engines.Quests var index = reader.ReadEncodedInt(); if (index >= 0 && index < referenceTable.Length) + { return referenceTable[index]; + } return null; } @@ -62,7 +66,9 @@ namespace Server.Engines.Quests var fullName = reader.ReadString(); if (fullName == null) + { return null; + } return AssemblyHandler.FindFirstTypeForName(fullName); } diff --git a/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs b/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs index 22fdb287e..09b6f7792 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs @@ -70,7 +70,9 @@ namespace Server.Engines.Quests public virtual void StartTimer() { if (m_Timer != null) + { return; + } m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), Slice); } @@ -89,7 +91,9 @@ namespace Server.Engines.Quests var obj = Objectives[i]; if (obj.GetTimerEvent()) + { obj.CheckProgress(); + } } } @@ -100,7 +104,9 @@ namespace Server.Engines.Quests var obj = Objectives[i]; if (obj.GetKillEvent(creature, corpse)) + { obj.OnKill(creature, corpse); + } } } @@ -111,7 +117,9 @@ namespace Server.Engines.Quests var obj = Objectives[i]; if (obj.IgnoreYoungProtection(from)) + { return true; + } } return false; @@ -178,12 +186,16 @@ namespace Server.Engines.Quests writer.WriteEncodedInt(Objectives.Count); for (var i = 0; i < Objectives.Count; ++i) + { QuestSerializer.Serialize(referenceTable, Objectives[i], writer); + } writer.WriteEncodedInt(Conversations.Count); for (var i = 0; i < Conversations.Count; ++i) + { QuestSerializer.Serialize(referenceTable, Conversations[i], writer); + } ChildSerialize(writer); } @@ -207,7 +219,9 @@ namespace Server.Engines.Quests var obj = Objectives[i]; if (obj is T t) + { return t; + } } return null; @@ -220,7 +234,9 @@ namespace Server.Engines.Quests var obj = Objectives[i]; if (obj.GetType() == type) + { return obj; + } } return null; @@ -234,10 +250,14 @@ namespace Server.Engines.Quests public virtual void GetContextMenuEntries(List list) { if (Objectives.Count > 0) + { list.Add(new QuestCallbackEntry(6154, ShowQuestLog)); // View Quest Log + } if (Conversations.Count > 0) + { list.Add(new QuestCallbackEntry(6156, ShowQuestConversation)); // Quest Conversation + } list.Add(new QuestCallbackEntry(6155, BeginCancelQuest)); // Cancel Quest } @@ -262,7 +282,9 @@ namespace Server.Engines.Quests var last = Objectives[^1]; if (last.Info != null) + { From.SendGump(new QuestItemInfoGump(last.Info)); + } } } @@ -279,7 +301,9 @@ namespace Server.Engines.Quests var last = Conversations[^1]; if (last.Info != null) + { From.SendGump(new QuestItemInfoGump(last.Info)); + } } } @@ -291,7 +315,9 @@ namespace Server.Engines.Quests public virtual void EndCancelQuest(bool shouldCancel) { if (From.Quest != this) + { return; + } if (shouldCancel) { @@ -345,7 +371,9 @@ namespace Server.Engines.Quests } if (!found) + { From.DoneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay)); + } } } } @@ -355,7 +383,9 @@ namespace Server.Engines.Quests conv.System = this; if (conv.Logged) + { Conversations.Add(conv); + } From.CloseGump(); From.CloseGump(); @@ -363,7 +393,9 @@ namespace Server.Engines.Quests From.SendGump(conv.Logged ? new QuestConversationsGump(Conversations) : new QuestConversationsGump(conv)); if (conv.Info != null) + { From.SendGump(new QuestItemInfoGump(conv.Info)); + } } public virtual void AddObjective(QuestObjective obj) @@ -377,7 +409,9 @@ namespace Server.Engines.Quests public virtual void Accept() { if (From.Quest != null) + { return; + } From.Quest = this; From.SendLocalizedMessage(1049019); // You have accepted the Quest. @@ -397,27 +431,40 @@ namespace Server.Engines.Quests inRestartPeriod = false; if (!(check is PlayerMobile pm)) + { return false; + } if (pm.HasGump()) + { return false; + } if (questType == typeof(DarkTidesQuest) && pm.Profession != 4) // necromancer + { return false; + } if (questType == typeof(UzeraanTurmoilQuest) && pm.Profession != 1 && pm.Profession != 2 && pm.Profession != 5 ) // warrior / magician / paladin + { return false; + } if (questType == typeof(HaochisTrialsQuest) && pm.Profession != 6) // samurai + { return false; + } if (questType == typeof(EminosUndertakingQuest) && pm.Profession != 7) // ninja + { return false; + } var doneQuests = pm.DoneQuests; if (doneQuests != null) + { for (var i = 0; i < doneQuests.Count; ++i) { var restartInfo = doneQuests[i]; @@ -436,6 +483,7 @@ namespace Server.Engines.Quests return true; } } + } return true; } @@ -443,9 +491,13 @@ namespace Server.Engines.Quests public static void FocusTo(Mobile who, Mobile to) { if (Utility.RandomBool()) + { who.Animate(17, 7, 1, true, false, 0); + } else + { who.Animate(32 + Utility.Random(3), 7, 1, true, false, 0); + } who.Direction = who.GetDirectionTo(to); } @@ -453,7 +505,9 @@ namespace Server.Engines.Quests public static int RandomBrightHue() { if (Utility.RandomDouble() < 0.1) + { return Utility.RandomList(0x62, 0x71); + } return Utility.RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59); } @@ -539,7 +593,9 @@ namespace Server.Engines.Quests public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_System.EndCancelQuest(info.IsSwitched(1)); + } } } @@ -602,9 +658,13 @@ namespace Server.Engines.Quests if (info.ButtonID == 1) { if (info.IsSwitched(1)) + { m_System.Accept(); + } else + { m_System.Decline(); + } } } } @@ -650,9 +710,13 @@ namespace Server.Engines.Quests public void AddHtmlObject(int x, int y, int width, int height, object message, int color, bool back, bool scroll) { if (message is int html) + { AddHtmlLocalized(x, y, width, height, html, C16216(color), back, scroll); + } else + { AddHtml(x, y, width, height, Color(message.ToString(), C16232(color)), back, scroll); + } } } } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Conversations.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Conversations.cs index ed25845a2..f43f822c4 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Conversations.cs @@ -136,7 +136,10 @@ namespace Server.Engines.Quests.Necro { get { - if (m_FromMardoth) return 1062058; + if (m_FromMardoth) + { + return 1062058; + } /* You have arrived at the well, but no longer have the scroll * of calling. Use Mardoth's teleporter to return to the diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs b/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs index 0b589780d..a368c0607 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs @@ -74,7 +74,9 @@ namespace Server.Engines.Quests.Necro public override bool IgnoreYoungProtection(Mobile from) { if (from is SummonedPaladin) + { return true; + } return base.IgnoreYoungProtection(from); } @@ -82,15 +84,21 @@ namespace Server.Engines.Quests.Necro public static bool HasLostCallingScroll(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is DarkTidesQuest) + { if (qs.IsObjectiveInProgress(typeof(FindMardothAboutKronusObjective)) || qs.IsObjectiveInProgress(typeof(FindWellOfTearsObjective)) || qs.IsObjectiveInProgress(typeof(UseCallingScrollObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs index 7df17ff4d..c02bdb619 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs @@ -14,15 +14,21 @@ namespace Server.Engines.Quests.Necro public override bool OnMoveOver(Mobile m) { if (m.AccessLevel > AccessLevel.Player) + { return true; + } var mob = m; if (m is BaseCreature creature) + { mob = creature.ControlMaster; + } if (!(mob is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs index c1a6e97a7..d4e347168 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs @@ -28,7 +28,9 @@ namespace Server.Engines.Quests.Necro public override void OnDoubleClick(Mobile from) { if (!IsChildOf(from)) + { return; + } if (from is PlayerMobile pm) { @@ -59,7 +61,9 @@ namespace Server.Engines.Quests.Necro QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } Delete(); new CallingTimer(pm).Start(); @@ -121,7 +125,9 @@ namespace Server.Engines.Quests.Necro } if (!m_Player.Mounted) + { m_Player.Animate(Utility.RandomBool() ? 16 : 17, 7, 1, true, false, 0); + } if (m_Step == 4) { diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs index b781affbb..b24036966 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs @@ -46,7 +46,9 @@ namespace Server.Engines.Quests.Necro ); // You rummage through the scrolls until you find the Scroll of Calling. You quickly put it in your pack. if (obj?.Completed == false) + { obj.Complete(); + } } else { diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs index 0fda629fe..e8d3bfe89 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs @@ -32,10 +32,14 @@ namespace Server.Engines.Quests.Necro public void Awake(Mobile caller) { if (Maabus != null || SpawnLocation == Point3D.Zero) + { return; + } foreach (var c in Components) + { (c as MaabusCoffinComponent)?.TurnToEmpty(); + } Maabus = new Maabus { Location = SpawnLocation, Map = Map }; Maabus.Direction = Maabus.GetDirectionTo(caller); @@ -46,7 +50,9 @@ namespace Server.Engines.Quests.Necro public void BeginSleep() { if (Maabus == null) + { return; + } Effects.PlaySound(Maabus.Location, Maabus.Map, 0x48E); @@ -56,7 +62,9 @@ namespace Server.Engines.Quests.Necro public void Sleep() { if (Maabus == null) + { return; + } Effects.SendLocationParticles( EffectItem.Create(Maabus.Location, Maabus.Map, EffectItem.DefaultDuration), @@ -71,7 +79,9 @@ namespace Server.Engines.Quests.Necro Maabus = null; foreach (MaabusCoffinComponent c in Components) + { c.TurnToFull(); + } } public override void Serialize(IGenericWriter writer) @@ -122,7 +132,10 @@ namespace Server.Engines.Quests.Necro get => Addon is MaabusCoffin coffin ? coffin.SpawnLocation : Point3D.Zero; set { - if (Addon is MaabusCoffin coffin) coffin.SpawnLocation = value; + if (Addon is MaabusCoffin coffin) + { + coffin.SpawnLocation = value; + } } } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs index 0e83beeac..c86e0915f 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs @@ -29,7 +29,9 @@ namespace Server.Engines.Quests.Necro QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } } } } @@ -49,7 +51,9 @@ namespace Server.Engines.Quests.Necro QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } } } } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs index 5d068719c..349e033af 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs @@ -18,7 +18,9 @@ namespace Server.Engines.Quests.Necro public override bool OnMoveOver(Mobile m) { if (m.AccessLevel > AccessLevel.Player) + { return true; + } if (m is PlayerMobile pm && pm.Profession == 4) { diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Horus.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Horus.cs index 4602e7acd..db149b99e 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Horus.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Horus.cs @@ -62,7 +62,9 @@ namespace Server.Engines.Quests.Necro QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } } } @@ -94,7 +96,10 @@ namespace Server.Engines.Quests.Necro BaseJewel jewel = new GoldBracelet(); if (Core.AOS) + { BaseRunicTool.ApplyAttributesTo(jewel, 3, 20, 40); + } + cont.DropItem(jewel); if (!pm.PlaceInBackpack(cont)) @@ -119,7 +124,8 @@ namespace Server.Engines.Quests.Necro base.GetContextMenuEntries(from, list); if (from.Alive) - if (from is PlayerMobile pm) + { + if (@from is PlayerMobile pm) { var qs = pm.Quest; @@ -131,6 +137,7 @@ namespace Server.Engines.Quests.Necro list.Add(new SpeakPasswordEntry(this, pm, enabled)); } } + } } public virtual void OnPasswordSpoken(PlayerMobile from) @@ -176,13 +183,17 @@ namespace Server.Engines.Quests.Necro m_From = from; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_From.Alive) + { m_Horus.OnPasswordSpoken(m_From); + } } } } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs index 9c90a6d93..c4e91ce4f 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs @@ -32,18 +32,19 @@ namespace Server.Engines.Quests.Necro var qs = player.Quest; if (qs is DarkTidesQuest) + { if (dropped is DarkTidesHorn horn) { if (player.Young) { if (horn.Charges < 10) { - SayTo(from, 1049384); // I have recharged the item for you. + SayTo(@from, 1049384); // I have recharged the item for you. horn.Charges = 10; } else { - SayTo(from, 1049385); // That doesn't need recharging yet. + SayTo(@from, 1049385); // That doesn't need recharging yet. } } else @@ -53,6 +54,7 @@ namespace Server.Engines.Quests.Necro return false; } + } } return base.OnDragDrop(from, dropped); @@ -85,7 +87,9 @@ namespace Server.Engines.Quests.Necro public override bool CanTalkTo(PlayerMobile to) { if (!(to.Quest is DarkTidesQuest qs)) + { return to.Quest == null && QuestSystem.CanOfferQuest(to, typeof(DarkTidesQuest)); + } return qs.FindObjective() != null; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs index cabc0e380..826673792 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs @@ -56,7 +56,9 @@ namespace Server.Engines.Quests.Necro public override bool IsHarmfulCriminal(Mobile target) { if (target == m_Necromancer) + { return false; + } return base.IsHarmfulCriminal(target); } @@ -72,14 +74,18 @@ namespace Server.Engines.Quests.Necro } if (Combatant != m_Necromancer) + { Combatant = m_Necromancer; + } if (!m_Necromancer.Alive) { var qs = m_Necromancer.Quest; if (qs is DarkTidesQuest && qs.FindObjective() == null) + { qs.AddObjective(new FindMardothEndObjective(false)); + } Say(1060139, m_Necromancer.Name); // You have made my work easy for me, ~1_NAME~. My task here is done. @@ -123,7 +129,9 @@ namespace Server.Engines.Quests.Necro var qs = m_Necromancer.Quest; if (qs is DarkTidesQuest && qs.FindObjective() == null) + { qs.AddObjective(new FindMardothEndObjective(true)); + } } public override void Serialize(IGenericWriter writer) @@ -146,7 +154,9 @@ namespace Server.Engines.Quests.Necro m_ToDelete = reader.ReadBool(); if (m_ToDelete) + { Delete(); + } } public static void BeginSummon(PlayerMobile player) @@ -172,13 +182,17 @@ namespace Server.Engines.Quests.Necro if (m_Player.Deleted) { if (m_Step > 0) + { m_Paladin.Delete(); + } return; } if (m_Step > 0 && m_Paladin.Deleted) + { return; + } if (m_Step == 0) { diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs index 41167c2ef..ec3366746 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs @@ -48,7 +48,9 @@ namespace Server.Engines.Quests.Necro public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(2024, 1240, -90), 3)) + { Complete(); + } } public override void OnComplete() @@ -64,7 +66,9 @@ namespace Server.Engines.Quests.Necro public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(2024, 1223, -90), 3)) + { Complete(); + } } public override void OnComplete() @@ -80,7 +84,9 @@ namespace Server.Engines.Quests.Necro public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(1076, 519, -90), 5)) + { Complete(); + } } public override void OnComplete() @@ -103,7 +109,9 @@ namespace Server.Engines.Quests.Necro public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(1072, 455, -90), 1)) + { Complete(); + } } public override void OnComplete() @@ -121,7 +129,9 @@ namespace Server.Engines.Quests.Necro if (System.From.Map != Map.Malas || !System.From.InRange(new Point3D(1076, 450, -84), 5) || !SummonFamiliarSpell.Table.TryGetValue(System.From, out var bc) || !(bc is HordeMinionFamiliar hmf) || !hmf.InRange(System.From, 5) || hmf.TargetLocation != null) + { return; + } System.From.SendLocalizedMessage( 1060113 @@ -272,7 +282,9 @@ namespace Server.Engines.Quests.Necro if (DarkTidesQuest.HasLostCallingScroll(System.From)) { if (!m_Inside) + { System.AddConversation(new LostCallingScrollConversation(false)); + } } else { @@ -313,7 +325,10 @@ namespace Server.Engines.Quests.Necro { get { - if (m_Victory) return 1060131; + if (m_Victory) + { + return 1060131; + } /* Although you were slain by the cowardly paladin, * you managed to complete the rite of calling as @@ -350,7 +365,9 @@ namespace Server.Engines.Quests.Necro public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(2048, 1345, -84), 5)) + { Complete(); + } } public override void OnComplete() diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs index 724817cf8..b80b0c8b2 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs @@ -100,13 +100,19 @@ namespace Server.Engines.Quests.Ninja public static bool HasLostNoteForZoel(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is EminosUndertakingQuest) + { if (qs.IsObjectiveInProgress(typeof(GiveZoelNoteObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } @@ -114,13 +120,19 @@ namespace Server.Engines.Quests.Ninja public static bool HasLostEminosKatana(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is EminosUndertakingQuest) + { if (qs.IsObjectiveInProgress(typeof(GiveEminoSwordObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs index 322343cbe..db92617c3 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs @@ -24,9 +24,12 @@ namespace Server.Engines.Quests.Ninja private void GenerateTreasure() { for (var i = Items.Count - 1; i >= 0; i--) + { Items[i].Delete(); + } for (var i = 0; i < 75; i++) + { DropItem( Utility.Random(10) switch { @@ -35,6 +38,7 @@ namespace Server.Engines.Quests.Ninja _ => Loot.RandomGem() // 2 } ); + } } public override void OnDoubleClick(Mobile from) @@ -93,17 +97,23 @@ namespace Server.Engines.Quests.Ninja public override bool CheckLift(Mobile from, Item item, ref LRReason reject) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (from is PlayerMobile player && player.Quest is EminosUndertakingQuest) { var obj = player.Quest.FindObjective(); if (obj?.StolenTreasure == true) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1063247 ); // The guard is watching you carefully! It would be unwise to remove another item from here. + } else + { return true; + } } return false; @@ -115,7 +125,9 @@ namespace Server.Engines.Quests.Ninja { var obj = player.Quest.FindObjective(); if (obj != null) + { obj.StolenTreasure = true; + } } } diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/GuardianBarrier.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/GuardianBarrier.cs index 4115f9632..573a1bea0 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/GuardianBarrier.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/GuardianBarrier.cs @@ -18,11 +18,15 @@ namespace Server.Engines.Quests.Ninja public override bool OnMoveOver(Mobile m) { if (m.AccessLevel > AccessLevel.Player) + { return true; + } // If the mobile is to the north of the barrier, allow him to pass if (Y >= m.Y) + { return true; + } if (m is BaseCreature creature) { @@ -38,7 +42,9 @@ namespace Server.Engines.Quests.Ninja if (obj != null) { if (m.Hidden) + { return true; // Hidden ninjas can pass + } if (!obj.TaughtHowToUseSkills) { diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/WhiteNinjaQuestTeleporter.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/WhiteNinjaQuestTeleporter.cs index a822b0678..9f225cbb3 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/WhiteNinjaQuestTeleporter.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/WhiteNinjaQuestTeleporter.cs @@ -28,7 +28,9 @@ namespace Server.Engines.Quests.Ninja if (obj != null) { if (!obj.Completed) + { obj.Complete(); + } loc = new Point3D(411, 1085, 0); map = Map.Malas; diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs index ec3c23afd..d566b5910 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs @@ -115,7 +115,9 @@ namespace Server.Engines.Quests.Ninja var cont = GetNewContainer(); for (var i = 0; i < 10; i++) + { cont.DropItem(new LesserHealPotion()); + } cont.DropItem(new LeatherNinjaHood()); cont.DropItem(new LeatherNinjaJacket()); @@ -147,7 +149,9 @@ namespace Server.Engines.Quests.Ninja Item katana = null; if (player.Backpack != null) + { katana = player.Backpack.FindItemByType(); + } if (katana != null) { @@ -156,14 +160,20 @@ namespace Server.Engines.Quests.Ninja var walk = qs.FindObjective(); if (walk != null) + { stolenTreasure = walk.StolenTreasure; + } var kama = new Kama(); if (stolenTreasure) + { BaseRunicTool.ApplyAttributesTo(kama, 1, 10, 20); + } else + { BaseRunicTool.ApplyAttributesTo(kama, 1, 10, 30); + } if (player.PlaceInBackpack(kama)) { @@ -171,9 +181,13 @@ namespace Server.Engines.Quests.Ninja obj.Complete(); if (stolenTreasure) + { qs.AddConversation(new EarnLessGiftsConversation()); + } else + { qs.AddConversation(new EarnGiftsConversation()); + } } else { diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Henchman.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Henchman.cs index e62ad31e5..1d10745b6 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Henchman.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Henchman.cs @@ -21,9 +21,13 @@ namespace Server.Engines.Quests.Ninja AddItem(new NinjaTabi()); if (Utility.RandomBool()) + { AddItem(new Kama()); + } else + { AddItem(new Tessen()); + } SetSkill(SkillName.Swords, 50.0); SetSkill(SkillName.Tactics, 50.0); diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs index 013fc7346..06b511eb3 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs @@ -53,9 +53,13 @@ namespace Server.Engines.Quests.Ninja AddItem(new HakamaShita(GetRandomHue())); if (Utility.RandomBool()) + { AddItem(new Shoes(GetShoeHue())); + } else + { AddItem(new Sandals(GetShoeHue())); + } } public override int GetAutoTalkRange(PlayerMobile pm) => 3; diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs index cc5bf06f0..f1f696c1c 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs @@ -59,7 +59,9 @@ namespace Server.Engines.Quests.Ninja QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } } } @@ -70,6 +72,7 @@ namespace Server.Engines.Quests.Ninja var qs = player.Quest; if (qs is EminosUndertakingQuest) + { if (dropped is NoteForZoel) { QuestObjective obj = qs.FindObjective(); @@ -81,6 +84,7 @@ namespace Server.Engines.Quests.Ninja return true; } } + } } return base.OnDragDrop(from, dropped); diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Objectives.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Objectives.cs index 980c1061c..942095497 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Objectives.cs @@ -30,7 +30,9 @@ namespace Server.Engines.Quests.Ninja public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(406, 1141, 0), 2)) + { Complete(); + } } public override void OnComplete() @@ -48,7 +50,9 @@ namespace Server.Engines.Quests.Ninja public override void CheckProgress() { if (System.From.Map == Map.Malas && System.From.InRange(new Point3D(412, 1123, 0), 3)) + { Complete(); + } } public override void OnComplete() @@ -100,7 +104,9 @@ namespace Server.Engines.Quests.Ninja Mobile from = System.From; if (from.Map == Map.Malas && from.X > 399 && from.X < 408 && from.Y > 1091 && from.Y < 1099) + { Complete(); + } } public override void OnComplete() @@ -164,7 +170,9 @@ namespace Server.Engines.Quests.Ninja Mobile from = System.From; if (from.Map != Map.Malas || from.Y > 992) + { Complete(); + } } public override void OnComplete() @@ -198,7 +206,9 @@ namespace Server.Engines.Quests.Ninja public override void OnKill(BaseCreature creature, Container corpse) { if (creature is Henchman) + { CurProgress++; + } } public override void OnComplete() diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs index e3abd7792..861b3620e 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs @@ -51,7 +51,10 @@ namespace Server.Engines.Quests.Samurai { get { - if (m_CursedSoul) return 1063040; + if (m_CursedSoul) + { + return 1063040; + } // You have just gained some Karma for killing a Young Ronin. return 1063041; @@ -89,7 +92,10 @@ namespace Server.Engines.Quests.Samurai { get { - if (m_CursedSoul) return 1063045; + if (m_CursedSoul) + { + return 1063045; + } /* It is good that you rid the land of those dishonorable Samurai. * Perhaps they will learn a greater lesson in death.

@@ -147,7 +153,10 @@ namespace Server.Engines.Quests.Samurai { get { - if (m_Dragon) return 1063060; + if (m_Dragon) + { + return 1063060; + } /* Fear remains in your eyes but you have learned that not all is * what it appears to be.

@@ -231,7 +240,10 @@ namespace Server.Engines.Quests.Samurai { get { - if (m_KilledCat) return 1063071; + if (m_KilledCat) + { + return 1063071; + } /* You showed respect by helping another out while allowing the gypsy * what little dignity she has left.

@@ -303,7 +315,10 @@ namespace Server.Engines.Quests.Samurai { get { - if (m_StolenTreasure) return 1063077; + if (m_StolenTreasure) + { + return 1063077; + } /* Thank you for returning this sword to me and leaving the remaining * treasure alone.

diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs index bb43950ff..1a3791938 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs @@ -103,13 +103,19 @@ namespace Server.Engines.Quests.Samurai public static bool HasLostHaochisKatana(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is HaochisTrialsQuest) + { if (qs.IsObjectiveInProgress(typeof(FifthTrialReturnObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisTreasureChest.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisTreasureChest.cs index 38d95fbc5..91488f70c 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisTreasureChest.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisTreasureChest.cs @@ -24,9 +24,12 @@ namespace Server.Engines.Quests.Samurai private void GenerateTreasure() { for (var i = Items.Count - 1; i >= 0; i--) + { Items[i].Delete(); + } for (var i = 0; i < 75; i++) + { DropItem( Utility.Random(10) switch { @@ -35,6 +38,7 @@ namespace Server.Engines.Quests.Samurai _ => Loot.RandomGem() // 2 } ); + } } public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) => @@ -45,17 +49,23 @@ namespace Server.Engines.Quests.Samurai public override bool CheckLift(Mobile from, Item item, ref LRReason reject) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (from is PlayerMobile player && player.Quest is HaochisTrialsQuest) { var obj = player.Quest.FindObjective(); if (obj?.StolenTreasure == true) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1063247 ); // The guard is watching you carefully! It would be unwise to remove another item from here. + } else + { return true; + } } return false; @@ -67,7 +77,9 @@ namespace Server.Engines.Quests.Samurai { var obj = player.Quest.FindObjective(); if (obj != null) + { obj.StolenTreasure = true; + } } Timer.DelayCall(TimeSpan.FromMinutes(2.0), GenerateTreasure); diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs index 68fb86454..07e015e56 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs @@ -31,7 +31,9 @@ namespace Server.Engines.Quests.Samurai if (!wasBurning && Burning) { if (!(from is PlayerMobile player)) + { return; + } var qs = player.Quest; @@ -40,7 +42,9 @@ namespace Server.Engines.Quests.Samurai QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { obj.Complete(); + } SendLocalizedMessageTo(from, 1063251); // You light a candle in honor. } diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs index 4f5de01dd..d1b3851b9 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs @@ -79,7 +79,9 @@ namespace Server.Engines.Quests.Samurai if (obj?.Completed == false) { if (((SecondTrialReturnObjective)obj).Dragon) + { player.AddToBackpack(new LeatherSuneate()); + } obj.Complete(); return; @@ -116,16 +118,22 @@ namespace Server.Engines.Quests.Samurai { var katana = player.Backpack?.FindItemByType(); if (katana == null) + { return; + } katana.Delete(); obj.Complete(); obj = qs.FindObjective(); if (((FifthTrialIntroObjective)obj)?.StolenTreasure == true) + { qs.AddConversation(new SixthTrialIntroConversation(true)); + } else + { qs.AddConversation(new SixthTrialIntroConversation(false)); + } } obj = qs.FindObjective(); diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs index 0a879c95e..2f6ce3322 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs @@ -54,16 +54,18 @@ namespace Server.Engines.Quests.Samurai QuestObjective obj = qs.FindObjective(); if (obj?.Completed == false) + { if (dropped is Gold gold) { obj.Complete(); qs.AddObjective(new FourthTrialReturnObjective(false)); - SayTo(from, 1063241); // I thank thee. This gold will be a great help to me and mine! + SayTo(@from, 1063241); // I thank thee. This gold will be a great help to me and mine! gold.Consume(); // Intentional difference from OSI: don't take all the gold of poor newbies! return gold.Deleted; } + } } } diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Objectives.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Objectives.cs index da8215ad5..8f5dfe9a5 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Objectives.cs @@ -38,7 +38,9 @@ namespace Server.Engines.Quests.Samurai if (creature is CursedSoul) { if (m_CursedSoulsKilled == 0) + { System.AddConversation(new GainKarmaConversation(true)); + } m_CursedSoulsKilled++; @@ -48,7 +50,9 @@ namespace Server.Engines.Quests.Samurai else if (creature is YoungRonin) { if (m_YoungRoninKilled == 0) + { System.AddConversation(new GainKarmaConversation(false)); + } m_YoungRoninKilled++; @@ -177,7 +181,9 @@ namespace Server.Engines.Quests.Samurai public override void OnKill(BaseCreature creature, Container corpse) { if (creature is InjuredWolf) + { Complete(); + } } public override void OnComplete() @@ -312,7 +318,9 @@ namespace Server.Engines.Quests.Samurai public override void OnKill(BaseCreature creature, Container corpse) { if (creature is YoungNinja) + { CurProgress++; + } } public override void OnComplete() diff --git a/Projects/UOContent/Engines/Quests/Solen Matriarch/Conversations.cs b/Projects/UOContent/Engines/Quests/Solen Matriarch/Conversations.cs index aba0bcdb7..e00eaa566 100644 --- a/Projects/UOContent/Engines/Quests/Solen Matriarch/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Solen Matriarch/Conversations.cs @@ -14,7 +14,10 @@ namespace Server.Engines.Quests.Matriarch { get { - if (m_Friend) return 1054081; + if (m_Friend) + { + return 1054081; + } /* The Solen Matriarch smiles as she eats the seed you offered.

* @@ -93,7 +96,10 @@ namespace Server.Engines.Quests.Matriarch { get { - if (m_Friend) return 1054097; + if (m_Friend) + { + return 1054097; + } /* The Solen Matriarch listens as you report the completion of your * tasks to her.

@@ -155,7 +161,9 @@ namespace Server.Engines.Quests.Matriarch public override void OnRead() { if (m_Logged) + { System.AddObjective(new GetRewardObjective()); + } } } diff --git a/Projects/UOContent/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs b/Projects/UOContent/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs index b7ebe4b2e..e5c44668a 100644 --- a/Projects/UOContent/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs +++ b/Projects/UOContent/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs @@ -14,7 +14,9 @@ namespace Server.Engines.Quests.Matriarch Body = 0x328; if (!RedSolen) + { Hue = 0x44E; + } SpeechHue = 0; } @@ -32,7 +34,9 @@ namespace Server.Engines.Quests.Matriarch public override bool CanTalkTo(PlayerMobile to) { if (SolenMatriarchQuest.IsFriend(to, RedSolen)) + { return true; + } return to.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen; } @@ -78,9 +82,13 @@ namespace Server.Engines.Quests.Matriarch if (obj?.Completed == false) { if (SolenMatriarchQuest.GiveRewardTo(player)) + { obj.Complete(); + } else + { qs.AddConversation(new FullBackpackConversation(false)); + } } } } @@ -91,9 +99,13 @@ namespace Server.Engines.Quests.Matriarch QuestSystem newQuest = new SolenMatriarchQuest(player, RedSolen); if (player.Quest == null && QuestSystem.CanOfferQuest(player, typeof(SolenMatriarchQuest))) + { newQuest.SendOffer(); + } else + { newQuest.AddConversation(new DontOfferConversation(true)); + } } } @@ -112,11 +124,15 @@ namespace Server.Engines.Quests.Matriarch QuestSystem newQuest = new SolenMatriarchQuest(player, RedSolen); if (player.Quest == null && QuestSystem.CanOfferQuest(player, typeof(SolenMatriarchQuest))) + { newQuest.SendOffer(); + } else + { newQuest.AddConversation( new DontOfferConversation(SolenMatriarchQuest.IsFriend(player, RedSolen)) ); + } } dropped.Delete(); @@ -139,10 +155,18 @@ namespace Server.Engines.Quests.Matriarch base.GetContextMenuEntries(from, list); if (from.Alive) - if (from is PlayerMobile pm) + { + if (@from is PlayerMobile pm) + { if (pm.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen) + { if (qs.IsObjectiveInProgress(typeof(ProcessFungiObjective))) + { list.Add(new ProcessZoogiFungusEntry(this, pm)); + } + } + } + } } public void OnGivenFungi(PlayerMobile player, ZoogiFungus fungi) @@ -158,14 +182,20 @@ namespace Server.Engines.Quests.Matriarch var amount = fungi.Amount / 2; if (amount > 100) + { amount = 100; + } if (amount > 0) { if (amount * 2 >= fungi.Amount) + { fungi.Delete(); + } else + { fungi.Amount -= amount * 2; + } var powder = new PowderOfTranslocation(amount); player.AddToBackpack(powder); @@ -206,7 +236,9 @@ namespace Server.Engines.Quests.Matriarch public override void OnClick() { if (m_From.Alive) + { m_From.Target = new ProcessFungiTarget(m_Matriarch, m_From); + } } } @@ -231,9 +263,13 @@ namespace Server.Engines.Quests.Matriarch if (targeted is ZoogiFungus fungus) { if (fungus.IsChildOf(m_From.Backpack)) + { m_Matriarch.OnGivenFungi(m_From, fungus); + } else + { m_From.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } } } diff --git a/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs b/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs index 09bcc3eeb..cbbb10b17 100644 --- a/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs @@ -35,12 +35,17 @@ namespace Server.Engines.Quests.Matriarch public override bool IgnoreYoungProtection(Mobile from) { if (Completed) + { return false; + } var redSolen = ((SolenMatriarchQuest)System).RedSolen; if (redSolen) - return from is BlackSolenInfiltratorWarrior || from is BlackSolenInfiltratorQueen; + { + return @from is BlackSolenInfiltratorWarrior || @from is BlackSolenInfiltratorQueen; + } + return from is RedSolenInfiltratorWarrior || from is RedSolenInfiltratorQueen; } @@ -51,12 +56,16 @@ namespace Server.Engines.Quests.Matriarch if (redSolen) { if (creature is BlackSolenInfiltratorWarrior || creature is BlackSolenInfiltratorQueen) + { CurProgress++; + } } else { if (creature is RedSolenInfiltratorWarrior || creature is RedSolenInfiltratorQueen) + { CurProgress++; + } } } @@ -117,9 +126,13 @@ namespace Server.Engines.Quests.Matriarch System.AddConversation(new ProcessFungiConversation(friend)); if (redSolen) + { player.SolenFriendship = SolenFriendship.Red; + } else + { player.SolenFriendship = SolenFriendship.Black; + } } } @@ -130,9 +143,13 @@ namespace Server.Engines.Quests.Matriarch public override void OnComplete() { if (SolenMatriarchQuest.GiveRewardTo(System.From)) + { System.Complete(); + } else + { System.AddConversation(new FullBackpackConversation(true)); + } } } diff --git a/Projects/UOContent/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs b/Projects/UOContent/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs index c0c9ac9c0..5615ca6c2 100644 --- a/Projects/UOContent/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs +++ b/Projects/UOContent/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs @@ -40,7 +40,10 @@ namespace Server.Engines.Quests.Matriarch { get { - if (IsFriend(From, RedSolen)) return 1054083; + if (IsFriend(From, RedSolen)) + { + return 1054083; + } /* The Solen Matriarch smiles happily as she eats the seed you offered.

* @@ -100,7 +103,10 @@ namespace Server.Engines.Quests.Matriarch public static bool IsFriend(PlayerMobile player, bool redSolen) { if (redSolen) + { return player.SolenFriendship == SolenFriendship.Red; + } + return player.SolenFriendship == SolenFriendship.Black; } diff --git a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs index 9c00a198c..7bd062749 100644 --- a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs +++ b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs @@ -42,7 +42,9 @@ namespace Server.Engines.Quests.Naturalist { var study = qs.FindObjective(); if (study == null) + { return; + } if (!study.Completed) { @@ -102,9 +104,13 @@ namespace Server.Engines.Quests.Naturalist PlaySound(0x41B); if (study.StudiedSpecialNest) + { qs.AddConversation(new SpecialEndConversation()); + } else + { qs.AddConversation(new EndConversation()); + } } else { diff --git a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/NestArea.cs b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/NestArea.cs index 4ee10df47..a03b6884e 100644 --- a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/NestArea.cs +++ b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/NestArea.cs @@ -47,8 +47,13 @@ namespace Server.Engines.Quests.Naturalist get { for (var i = 0; i < m_Areas.Length; i++) + { if (m_Areas[i] == this) + { return i; + } + } + return 0; } } @@ -61,7 +66,10 @@ namespace Server.Engines.Quests.Naturalist public static NestArea GetByID(int id) { if (id >= 0 && id < m_Areas.Length) + { return m_Areas[id]; + } + return null; } diff --git a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs index 86f4dddc3..c78a03154 100644 --- a/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Study of the Solen Hive/Objectives.cs @@ -55,9 +55,11 @@ namespace Server.Engines.Quests.Naturalist else if (m_StudyState == StudyState.FirstStep && time > TimeSpan.FromSeconds(15.0)) { if (!nest.Special) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1054058 ); // You begin recording your completed notes on a bit of parchment. + } m_StudyState = StudyState.SecondStep; } @@ -66,9 +68,11 @@ namespace Server.Engines.Quests.Naturalist else { if (m_StudyState != StudyState.Inactive) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1054046 ); // You abandon your study of the Solen Egg Nest without gathering the needed information. + } m_CurrentNest = null; } @@ -95,18 +99,26 @@ namespace Server.Engines.Quests.Naturalist m_StudyState = StudyState.FirstStep; if (nest.Special) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1054056 ); // You notice something very odd about this Solen Egg Nest. You begin taking notes. + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1054045 ); // You begin studying the Solen Egg Nest to gather information. + } if (from.Female) - from.PlaySound(0x30B); + { + @from.PlaySound(0x30B); + } else - from.PlaySound(0x419); + { + @from.PlaySound(0x419); + } } } } @@ -152,7 +164,9 @@ namespace Server.Engines.Quests.Naturalist writer.WriteEncodedInt(m_StudiedNests.Count); foreach (var nest in m_StudiedNests) + { writer.WriteEncodedInt(nest.ID); + } writer.Write(StudiedSpecialNest); } diff --git a/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Mobiles/AnsellaGryen.cs b/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Mobiles/AnsellaGryen.cs index d637eedbd..9784e9892 100644 --- a/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Mobiles/AnsellaGryen.cs +++ b/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Mobiles/AnsellaGryen.cs @@ -41,7 +41,10 @@ namespace Server.Engines.Quests.Zento public override int GetAutoTalkRange(PlayerMobile m) { if (m.Quest == null) + { return 3; + } + return -1; } @@ -108,10 +111,12 @@ namespace Server.Engines.Quests.Zento if (qs != null) { if (contextMenu) + { SayTo( player, 1063322 ); // Before you can help me with the Terrible Hatchlings, you'll need to finish the quest you've already taken! + } } else if (QuestSystem.CanOfferQuest(player, typeof(TerribleHatchlingsQuest), out var inRestartPeriod)) { diff --git a/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Objectives.cs b/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Objectives.cs index fa6627f7b..3d6183cbd 100644 --- a/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Terrible Hatchlings/Objectives.cs @@ -27,7 +27,9 @@ namespace Server.Engines.Quests.Zento public override void OnKill(BaseCreature creature, Container corpse) { if (creature is DeathwatchBeetleHatchling) + { Complete(); + } } public override void OnComplete() @@ -108,7 +110,9 @@ namespace Server.Engines.Quests.Zento public override void OnKill(BaseCreature creature, Container corpse) { if (creature is DeathwatchBeetleHatchling) + { CurProgress++; + } } public override void OnComplete() diff --git a/Projects/UOContent/Engines/Quests/The Summoning/Items/BellOfTheDead.cs b/Projects/UOContent/Engines/Quests/The Summoning/Items/BellOfTheDead.cs index 326bf467f..6a2afb45f 100644 --- a/Projects/UOContent/Engines/Quests/The Summoning/Items/BellOfTheDead.cs +++ b/Projects/UOContent/Engines/Quests/The Summoning/Items/BellOfTheDead.cs @@ -32,9 +32,13 @@ namespace Server.Engines.Quests.Doom public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 2)) - BeginSummon(from); + { + BeginSummon(@from); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public virtual void BeginSummon(Mobile from) diff --git a/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Chyloth.cs b/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Chyloth.cs index 4e976a4a8..24a63f417 100644 --- a/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Chyloth.cs +++ b/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Chyloth.cs @@ -52,7 +52,9 @@ namespace Server.Engines.Quests.Doom public virtual void BeginGiveWarning() { if (Deleted || AngryAt == null) + { return; + } Timer.DelayCall(TimeSpan.FromSeconds(4.0), EndGiveWarning); } @@ -60,7 +62,9 @@ namespace Server.Engines.Quests.Doom public virtual void EndGiveWarning() { if (Deleted || AngryAt == null) + { return; + } PublicOverheadMessage( MessageType.Regular, @@ -76,7 +80,9 @@ namespace Server.Engines.Quests.Doom public virtual void BeginSummonDragon() { if (Deleted || AngryAt == null) + { return; + } Timer.DelayCall(TimeSpan.FromSeconds(30.0), EndSummonDragon); } @@ -89,7 +95,9 @@ namespace Server.Engines.Quests.Doom public virtual void EndRemove() { if (Deleted) + { return; + } var loc = Location; var map = Map; @@ -112,15 +120,21 @@ namespace Server.Engines.Quests.Doom public virtual void EndSummonDragon() { if (Deleted || AngryAt == null) + { return; + } var map = AngryAt.Map; if (map == null) + { return; + } if (!AngryAt.Region.IsPartOf("Doom")) + { return; + } PublicOverheadMessage(MessageType.Regular, 0x3B2, 1050015); // Feel the wrath of my legions!!! PublicOverheadMessage(MessageType.Regular, 0x3B2, false, "MUHAHAHAHA HAHAH HAHA"); // A wee bit crazy, aren't we? @@ -154,12 +168,16 @@ namespace Server.Engines.Quests.Doom } if (!foundLoc) + { dragon.MoveToWorld(AngryAt.Location, map); + } dragon.Combatant = AngryAt; if (Bell != null) + { Bell.Dragon = dragon; + } } public static void TeleportToFerry(Mobile from) @@ -208,7 +226,9 @@ namespace Server.Engines.Quests.Doom if (member != from && member.Map == Map.Malas && member.Region.IsPartOf("Doom")) { if (AngryAt == member) + { AngryAt = null; + } member.CloseGump(); member.SendGump(new ChylothPartyGump(from, member)); @@ -216,7 +236,9 @@ namespace Server.Engines.Quests.Doom } if (AngryAt == from) + { AngryAt = null; + } TeleportToFerry(from); diff --git a/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Victoria.cs b/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Victoria.cs index 42fa4a2aa..4fb4fedbf 100644 --- a/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Victoria.cs +++ b/Projects/UOContent/Engines/Quests/The Summoning/Mobiles/Victoria.cs @@ -30,12 +30,16 @@ namespace Server.Engines.Quests.Doom { if (m_Altar?.Deleted != false || m_Altar.Map != Map || !Utility.InRange(m_Altar.Location, Location, AltarRange)) + { foreach (var item in GetItemsInRange(AltarRange)) + { if (item is SummoningAltar altar) { m_Altar = altar; break; } + } + } return m_Altar; } @@ -74,6 +78,7 @@ namespace Server.Engines.Quests.Doom var qs = player.Quest; if (qs is TheSummoningQuest) + { if (dropped is DaemonBone bones) { QuestObjective obj = qs.FindObjective(); @@ -95,23 +100,26 @@ namespace Server.Engines.Quests.Doom bones.Consume(need); if (!bones.Deleted) + { SayTo( - from, + @from, 1050038 ); // You have already given me all the Daemon bones necessary to weave the spell. Keep these for a later time. + } } } else { // TODO: Accurate? SayTo( - from, + @from, 1050038 ); // You have already given me all the Daemon bones necessary to weave the spell. Keep these for a later time. } return false; } + } } return base.OnDragDrop(from, dropped); diff --git a/Projects/UOContent/Engines/Quests/The Summoning/Objectives.cs b/Projects/UOContent/Engines/Quests/The Summoning/Objectives.cs index 880875b16..9830f5dda 100644 --- a/Projects/UOContent/Engines/Quests/The Summoning/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/The Summoning/Objectives.cs @@ -45,6 +45,7 @@ namespace Server.Engines.Quests.Doom public override void RenderMessage(BaseQuestGump gump) { if (CurProgress > 0 && CurProgress < MaxProgress) + { gump.AddHtmlObject( 70, 130, @@ -55,8 +56,11 @@ namespace Server.Engines.Quests.Doom false, false ); // Victoria has accepted the Daemon bones, but the requirement is not yet met. + } else + { base.RenderMessage(gump); + } } public override void RenderProgress(BaseQuestGump gump) @@ -103,7 +107,9 @@ namespace Server.Engines.Quests.Doom public override void CheckProgress() { if (m_Daemon?.Alive != true) + { Complete(); + } } public override void OnComplete() @@ -156,7 +162,9 @@ namespace Server.Engines.Quests.Doom from.SendLocalizedMessage(1050035); // The devourer lies dead. Search his corpse to claim your prize! if (m_Daemon != null) + { CorpseWithSkull = m_Daemon.Corpse as Corpse; + } } } } diff --git a/Projects/UOContent/Engines/Quests/The Summoning/TheSummoningQuest.cs b/Projects/UOContent/Engines/Quests/The Summoning/TheSummoningQuest.cs index fe2167ece..803d415b7 100644 --- a/Projects/UOContent/Engines/Quests/The Summoning/TheSummoningQuest.cs +++ b/Projects/UOContent/Engines/Quests/The Summoning/TheSummoningQuest.cs @@ -43,12 +43,14 @@ namespace Server.Engines.Quests.Doom var altar = Victoria.Altar; if (altar != null && altar.Daemon?.Alive != true) + { if (From.Map == Victoria.Map && From.InRange(Victoria, 8)) { WaitForSummon = false; AddConversation(new VanquishDaemonConversation()); } + } } base.Slice(); @@ -57,14 +59,22 @@ namespace Server.Engines.Quests.Doom public static int GetDaemonBonesFor(BaseCreature creature) { if (creature?.Controlled != false || creature.Summoned) + { return 0; + } var fame = creature.Fame; if (fame < 1500) + { return Utility.Dice(2, 5, -1); + } + if (fame < 20000) + { return Utility.Dice(2, 4, 8); + } + return 50; } diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Conversations.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Conversations.cs index 07d93e2f1..2a0424a46 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Conversations.cs @@ -32,10 +32,15 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 1) // warrior + { return 1049088; + } if (System.From.Profession == 2) // magician + { return 1049386; + } + /* Uzeraan nods at you with approval and begins to speak...

* * Now that you are ready, let me give you your first task.

@@ -84,7 +89,9 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 2) // magician + { return 1049387; + } /* You give your report to Uzeraan and after a while, * he begins to speak...

@@ -136,7 +143,9 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 5) // paladin + { return 1060749; + } /* Schmendrick barely pays you any attention as you approach him. His * mind seems to be occupied with something else. You explain to him that @@ -209,7 +218,9 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 2) // magician + { return 1049388; + } /* Uzeraan takes the dirt from you and smiles...

* @@ -261,6 +272,7 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 2) // magician + { return "You hand Uzeraan the Vial of Blood, which he hastily accepts...
" + "
" + "Excellent work! Only one reagent remains and the spell is complete! The final " @@ -277,6 +289,7 @@ namespace Server.Engines.Quests.Haven + "battle. The scrolls should help you make short work of the undead.
" + "
" + "Return here when you have found a Daemon Bone."; + } /* You hand Uzeraan the Vial of Blood, which he hastily accepts...

* @@ -304,7 +317,10 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 5) // paladin + { return m_InfoPaladin; + } + return m_Info; } } @@ -356,7 +372,10 @@ namespace Server.Engines.Quests.Haven { get { - if (m_FromUzeraan) return 1049377; + if (m_FromUzeraan) + { + return 1049377; + } /* You've lost the scroll? Argh! I will have to try and re-construct * the scroll from memory. Bring me a blank scroll, which you can @@ -402,7 +421,10 @@ namespace Server.Engines.Quests.Haven { get { - if (m_FromUzeraan) return 1049374; + if (m_FromUzeraan) + { + return 1049374; + } /* You've lost the dirt I gave you?

* diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs index 312e97c67..cd2798209 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs @@ -93,7 +93,9 @@ namespace Server.Engines.Quests.Haven public override void OnMovement(Mobile m, Point3D oldLocation) { if (!(Canoneer?.Deleted == false && Canoneer.Active)) + { return; + } var canFire = CannonDirection switch { @@ -104,13 +106,17 @@ namespace Server.Engines.Quests.Haven }; if (canFire && Canoneer.WillFire(this, m)) + { Fire(Canoneer, m); + } } public override void Serialize(IGenericWriter writer) { if (Canoneer?.Deleted == true) + { Canoneer = null; + } base.Serialize(writer); @@ -147,7 +153,10 @@ namespace Server.Engines.Quests.Haven get => Addon is Cannon cannon ? cannon.Canoneer : null; set { - if (Addon is Cannon cannon) cannon.Canoneer = value; + if (Addon is Cannon cannon) + { + cannon.Canoneer = value; + } } } diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/DaemonBloodChest.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/DaemonBloodChest.cs index c81db5fe2..556a4679e 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/DaemonBloodChest.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/DaemonBloodChest.cs @@ -35,7 +35,9 @@ namespace Server.Engines.Quests.Haven ); // You take a vial of blood from the chest and put it in your pack. if (obj?.Completed == false) + { obj.Complete(); + } } else { diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs index b5a358e11..44be3e506 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs @@ -18,7 +18,9 @@ namespace Server.Engines.Quests.Haven Direction = Direction.West; foreach (var item in EquipItems) + { DropItem(item); + } m_Lantern = new Lantern { Movable = false, Protected = true }; m_Lantern.Ignite(); @@ -86,7 +88,8 @@ namespace Server.Engines.Quests.Haven var hue = Notoriety.GetHue(NotorietyHandlers.CorpseNotoriety(from, this)); if (ItemID == 0x2006) // Corpse form - from.Send( + { + @from.Send( new MessageLocalized( Serial, ItemID, @@ -98,8 +101,10 @@ namespace Server.Engines.Quests.Haven Name ) ); // the remains of ~1_NAME~ the apprentice + } else - from.Send( + { + @from.Send( new MessageLocalized( Serial, ItemID, @@ -111,12 +116,15 @@ namespace Server.Engines.Quests.Haven "" ) ); // the remains of a wizard's apprentice + } } public override void Open(Mobile from, bool checkSelfLoot) { if (!from.InRange(GetWorldLocation(), 2)) + { return; + } if (from is PlayerMobile player) { @@ -160,13 +168,17 @@ namespace Server.Engines.Quests.Haven public override void OnLocationChange(Point3D oldLoc) { if (m_Lantern?.Deleted == false) + { m_Lantern.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Lantern?.Deleted == false) + { m_Lantern.Map = Map; + } } public override void OnAfterDelete() @@ -174,13 +186,17 @@ namespace Server.Engines.Quests.Haven base.OnAfterDelete(); if (m_Lantern?.Deleted == false) + { m_Lantern.Delete(); + } } public override void Serialize(IGenericWriter writer) { if (m_Lantern?.Deleted == true) + { m_Lantern = null; + } base.Serialize(writer); diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs index 75e077c04..ee03d1d0c 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs @@ -106,10 +106,11 @@ namespace Server.Engines.Quests.Haven public override bool OnDragDrop(Mobile from, Item dropped) { if (from is PlayerMobile player) + { if (player.Quest is UzeraanTurmoilQuest qs && dropped is Apple && - UzeraanTurmoilQuest.HasLostFertileDirt(from)) + UzeraanTurmoilQuest.HasLostFertileDirt(@from)) { - FocusTo(from); + FocusTo(@from); Item fertileDirt = new QuestFertileDirt(); @@ -126,6 +127,7 @@ namespace Server.Engines.Quests.Haven qs.AddConversation(new DryadAppleConversation()); return dropped.Deleted; } + } return base.OnDragDrop(from, dropped); } diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs index 04cc87aee..f7de69d65 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs @@ -51,13 +51,17 @@ namespace Server.Engines.Quests.Haven public override bool IsEnemy(Mobile m) { if (m.Player || m is BaseVendor) + { return false; + } if (m is BaseCreature bc) { var master = bc.GetMaster(); if (master != null) + { return IsEnemy(master); + } } return m.Karma < 0; diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs index 10e5896f0..5735d5a8f 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs @@ -62,13 +62,17 @@ namespace Server.Engines.Quests.Haven public override bool IsEnemy(Mobile m) { if (m.Player || m is BaseVendor) + { return false; + } if (m is BaseCreature bc) { var master = bc.GetMaster(); if (master != null) + { return IsEnemy(master); + } } return m.Karma < 0; @@ -122,7 +126,8 @@ namespace Server.Engines.Quests.Haven var hue = Notoriety.GetHue(NotorietyHandlers.CorpseNotoriety(from, this)); if (ItemID == 0x2006) // Corpse form - from.Send( + { + @from.Send( new MessageLocalized( Serial, ItemID, @@ -134,8 +139,10 @@ namespace Server.Engines.Quests.Haven Name ) ); // the remains of ~1_NAME~ the militia fighter + } else - from.Send( + { + @from.Send( new MessageLocalized( Serial, ItemID, @@ -147,16 +154,19 @@ namespace Server.Engines.Quests.Haven "" ) ); // the remains of a militia fighter + } } public override void Open(Mobile from, bool checkSelfLoot) { if (from.InRange(GetWorldLocation(), 2)) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1049661, "", 0x22 ); // Thinking about his sacrifice, you can't bring yourself to loot the body of this militia fighter. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs index f5816da6b..fa63dbddd 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs @@ -85,7 +85,9 @@ namespace Server.Engines.Quests.Haven || backpack.GetAmount(typeof(Nightshade)) < 30 || backpack.GetAmount(typeof(SulfurousAsh)) < 30 || backpack.GetAmount(typeof(SpidersSilk)) < 30) + { qs.AddConversation(new FewReagentsConversation()); + } } QuestObjective obj = qs.FindObjective(); @@ -114,7 +116,10 @@ namespace Server.Engines.Quests.Haven { cont.DropItem(new MarkScroll(5)); cont.DropItem(new RecallScroll(5)); - for (var i = 0; i < 5; i++) cont.DropItem(new RecallRune()); + for (var i = 0; i < 5; i++) + { + cont.DropItem(new RecallRune()); + } } else { @@ -264,7 +269,9 @@ namespace Server.Engines.Quests.Haven cont.DropItem(new SpidersSilk(20)); for (var i = 0; i < 3; i++) + { cont.DropItem(Loot.RandomScroll(0, 23, SpellbookType.Regular)); + } } else { @@ -272,7 +279,9 @@ namespace Server.Engines.Quests.Haven cont.DropItem(new Bandage(25)); for (var i = 0; i < 5; i++) + { cont.DropItem(new LesserHealPotion()); + } } if (!player.PlaceInBackpack(cont)) diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs index 29f621670..fa6020e81 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs @@ -11,9 +11,13 @@ namespace Server.Engines.Quests.Haven public override void OnComplete() { if (System.From.Profession == 5) // paladin + { System.AddConversation(new UzeraanTitheConversation()); + } else + { System.AddConversation(new UzeraanFirstTaskConversation()); + } } } @@ -31,13 +35,17 @@ namespace Server.Engines.Quests.Haven var curTithingPoints = pm.TithingPoints; if (curTithingPoints >= 500) + { Complete(); + } else if (curTithingPoints > m_OldTithingPoints && m_OldTithingPoints >= 0) + { pm.SendLocalizedMessage( 1060240, "", 0x41 ); // You must have at least 500 tithing points before you can continue in your quest. + } m_OldTithingPoints = curTithingPoints; } @@ -104,12 +112,14 @@ namespace Server.Engines.Quests.Haven get { if (System.From.Profession == 5) // paladin + { return Step switch { KillHordeMinionsStep.First => 1, KillHordeMinionsStep.LearnKarma => 2, _ => 5 }; + } return 5; } @@ -120,7 +130,10 @@ namespace Server.Engines.Quests.Haven get { if (Step == KillHordeMinionsStep.LearnKarma && HasBeenRead) + { return true; + } + return base.Completed; } } @@ -148,7 +161,9 @@ namespace Server.Engines.Quests.Haven // This restriction continues until the quest is ended if (from is HordeMinion && from.Map == Map.Trammel && from.X >= 3314 && from.X <= 3814 && from.Y >= 2345 && from.Y <= 3095) // Haven island + { return true; + } return false; } @@ -159,7 +174,9 @@ namespace Server.Engines.Quests.Haven corpse.Y >= 2345 && corpse.Y <= 3095) // Haven island { if (CurProgress == 0) + { System.From.Send(new DisplayHelpTopic(29, false)); // HEALING + } CurProgress++; } @@ -168,6 +185,7 @@ namespace Server.Engines.Quests.Haven public override void OnComplete() { if (System.From.Profession == 5) + { switch (Step) { case KillHordeMinionsStep.First: @@ -190,8 +208,11 @@ namespace Server.Engines.Quests.Haven break; } } + } else + { System.AddObjective(new FindUzeraanAboutReportObjective()); + } } public override void ChildDeserialize(IGenericReader reader) @@ -228,7 +249,9 @@ namespace Server.Engines.Quests.Haven // This restriction begins when this objective is completed, and continues until the quest is ended if (Completed && from is RestlessSoul && from.Map == Map.Trammel && from.X >= 5199 && from.X <= 5271 && from.Y >= 1812 && from.Y <= 1865) // Schmendrick's cave + { return true; + } return false; } @@ -350,7 +373,10 @@ namespace Server.Engines.Quests.Haven { get { - if (System.From.Profession == 5) return 1060755; + if (System.From.Profession == 5) + { + return 1060755; + } /* Use Uzeraan's teleporter to get to the Haunted graveyard.

* @@ -370,7 +396,9 @@ namespace Server.Engines.Quests.Haven // This restriction continues until the end of the quest if ((from is Zombie || from is Skeleton) && from.Map == Map.Trammel && from.X >= 3391 && from.X <= 3424 && from.Y >= 2639 && from.Y <= 2664) // Haven graveyard + { return true; + } return false; } @@ -378,7 +406,9 @@ namespace Server.Engines.Quests.Haven public override bool GetKillEvent(BaseCreature creature, Container corpse) { if (base.GetKillEvent(creature, corpse)) + { return true; + } return UzeraanTurmoilQuest.HasLostDaemonBone(System.From); } @@ -387,8 +417,12 @@ namespace Server.Engines.Quests.Haven { if ((creature is Zombie || creature is Skeleton) && corpse.Map == Map.Trammel && corpse.X >= 3391 && corpse.X <= 3424 && corpse.Y >= 2639 && corpse.Y <= 2664) // Haven graveyard + { if (Utility.RandomDouble() < 0.25) + { CorpseWithBone = corpse; + } + } } public override void ChildDeserialize(IGenericReader reader) @@ -401,7 +435,9 @@ namespace Server.Engines.Quests.Haven public override void ChildSerialize(IGenericWriter writer) { if (CorpseWithBone?.Deleted == true) + { CorpseWithBone = null; + } writer.WriteEncodedInt(0); // version diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs index 26d6eda25..1cd23c210 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs @@ -111,13 +111,19 @@ namespace Server.Engines.Quests.Haven public static bool HasLostScrollOfPower(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is UzeraanTurmoilQuest) + { if (qs.IsObjectiveInProgress(typeof(ReturnScrollOfPowerObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } @@ -125,13 +131,19 @@ namespace Server.Engines.Quests.Haven public static bool HasLostFertileDirt(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is UzeraanTurmoilQuest) + { if (qs.IsObjectiveInProgress(typeof(ReturnFertileDirtObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } @@ -139,13 +151,19 @@ namespace Server.Engines.Quests.Haven public static bool HasLostDaemonBlood(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is UzeraanTurmoilQuest) + { if (qs.IsObjectiveInProgress(typeof(ReturnDaemonBloodObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } @@ -153,13 +171,19 @@ namespace Server.Engines.Quests.Haven public static bool HasLostDaemonBone(Mobile from) { if (!(from is PlayerMobile pm)) + { return false; + } var qs = pm.Quest; if (qs is UzeraanTurmoilQuest) + { if (qs.IsObjectiveInProgress(typeof(ReturnDaemonBoneObjective))) - return from.Backpack?.FindItemByType() == null; + { + return @from.Backpack?.FindItemByType() == null; + } + } return false; } diff --git a/Projects/UOContent/Engines/Quests/Witch Apprentice/Conversations.cs b/Projects/UOContent/Engines/Quests/Witch Apprentice/Conversations.cs index bb9f2dff4..6b74cbae1 100644 --- a/Projects/UOContent/Engines/Quests/Witch Apprentice/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Witch Apprentice/Conversations.cs @@ -120,7 +120,9 @@ namespace Server.Engines.Quests.Hag { var obj = System.FindObjective(); if (obj != null) + { System.AddObjective(new FindIngredientObjective(obj.Ingredients, true)); + } } } @@ -145,7 +147,10 @@ namespace Server.Engines.Quests.Hag { if (m_Tricorne) { - if (m_Drunken) return 1055059; + if (m_Drunken) + { + return 1055059; + } /* Captain Blackheart looks up from polishing his cutlass, glaring at * you with red-rimmed eyes.

@@ -170,7 +175,10 @@ namespace Server.Engines.Quests.Hag return 1055057; } - if (m_Drunken) return 1055056; + if (m_Drunken) + { + return 1055056; + } /* Captain Blackheart looks up from his drink, almost tipping over * his chair as he looks you up and down.

@@ -222,7 +230,10 @@ namespace Server.Engines.Quests.Hag { get { - if (m_FirstMet) return 1055054; + if (m_FirstMet) + { + return 1055054; + } /* The drunken pirate, Captain Blackheart, looks up from his bottle * of whiskey with a pleased expression.

diff --git a/Projects/UOContent/Engines/Quests/Witch Apprentice/Ingredient.cs b/Projects/UOContent/Engines/Quests/Witch Apprentice/Ingredient.cs index e431cab6e..5ef2e7d5a 100644 --- a/Projects/UOContent/Engines/Quests/Witch Apprentice/Ingredient.cs +++ b/Projects/UOContent/Engines/Quests/Witch Apprentice/Ingredient.cs @@ -76,7 +76,10 @@ namespace Server.Engines.Quests.Hag var index = (int)ingredient; if (index >= 0 && index < m_Table.Length) + { return m_Table[index]; + } + return m_Table[0]; } @@ -91,11 +94,17 @@ namespace Server.Engines.Quests.Hag var found = false; for (var j = 0; !found && j < oldIngredients.Length; j++) + { if (oldIngredients[j] == currIngredient) + { found = true; + } + } if (!found) + { ingredients[n++] = currIngredient; + } } return ingredients.RandomElement(); diff --git a/Projects/UOContent/Engines/Quests/Witch Apprentice/Items/HagApprenticeCorpse.cs b/Projects/UOContent/Engines/Quests/Witch Apprentice/Items/HagApprenticeCorpse.cs index ade91e45d..0578ea900 100644 --- a/Projects/UOContent/Engines/Quests/Witch Apprentice/Items/HagApprenticeCorpse.cs +++ b/Projects/UOContent/Engines/Quests/Witch Apprentice/Items/HagApprenticeCorpse.cs @@ -14,7 +14,9 @@ namespace Server.Engines.Quests.Hag Direction = Direction.South; foreach (var item in EquipItems) + { DropItem(item); + } } public HagApprenticeCorpse(Serial serial) : base(serial) @@ -52,7 +54,9 @@ namespace Server.Engines.Quests.Hag public override void Open(Mobile from, bool checkSelfLoot) { if (!from.InRange(GetWorldLocation(), 2)) + { return; + } if (from is PlayerMobile player) { diff --git a/Projects/UOContent/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs b/Projects/UOContent/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs index fc721a261..1f9e051d8 100644 --- a/Projects/UOContent/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs +++ b/Projects/UOContent/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs @@ -136,9 +136,13 @@ namespace Server.Engines.Quests.Hag item = Loot.RandomArmorOrShieldOrJewelry(); if (item is BaseArmor armor) + { BaseRunicTool.ApplyAttributesTo(armor, 2, 20, 30); + } else if (item is BaseJewel jewel) + { BaseRunicTool.ApplyAttributesTo(jewel, 2, 20, 30); + } } else { @@ -153,7 +157,9 @@ namespace Server.Engines.Quests.Hag } if (player.BAC > 0) + { cont.DropItem(new HangoverCure()); + } if (player.PlaceInBackpack(cont)) { @@ -165,7 +171,9 @@ namespace Server.Engines.Quests.Hag 250, ref gainedPath )) // TODO: Check amount on OSI. + { player.SendLocalizedMessage(1054160); // You have gained in sacrifice. + } PlaySound(0x253); PlaySound(0x20); diff --git a/Projects/UOContent/Engines/Quests/Witch Apprentice/Objectives.cs b/Projects/UOContent/Engines/Quests/Witch Apprentice/Objectives.cs index 00e17d60d..c167d4fcd 100644 --- a/Projects/UOContent/Engines/Quests/Witch Apprentice/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Witch Apprentice/Objectives.cs @@ -20,7 +20,9 @@ namespace Server.Engines.Quests.Hag public FindApprenticeObjective(bool init) { if (init) + { m_CorpseLocation = RandomCorpseLocation(); + } } public FindApprenticeObjective() @@ -40,7 +42,9 @@ namespace Server.Engines.Quests.Hag if (Corpse?.Deleted == false || map != Map.Trammel && map != Map.Felucca || !player.InRange(m_CorpseLocation, 8)) + { return; + } Corpse = new HagApprenticeCorpse(); Corpse.MoveToWorld(m_CorpseLocation, map); @@ -92,13 +96,17 @@ namespace Server.Engines.Quests.Hag } if (version == 0) + { m_CorpseLocation = RandomCorpseLocation(); + } } public override void ChildSerialize(IGenericWriter writer) { if (Corpse?.Deleted == true) + { Corpse = null; + } writer.WriteEncodedInt(1); // version @@ -124,7 +132,9 @@ namespace Server.Engines.Quests.Hag public KillImpsObjective(bool init) { if (init) + { m_MaxProgress = Utility.RandomMinMax(1, 4); + } } public KillImpsObjective() @@ -138,7 +148,9 @@ namespace Server.Engines.Quests.Hag public override bool IgnoreYoungProtection(Mobile from) { if (!Completed && from is Imp) + { return true; + } return false; } @@ -146,7 +158,9 @@ namespace Server.Engines.Quests.Hag public override void OnKill(BaseCreature creature, Container corpse) { if (creature is Imp) + { CurProgress++; + } } public override void OnComplete() @@ -259,7 +273,9 @@ namespace Server.Engines.Quests.Hag Ingredients = new Ingredient[oldIngredients.Length + 1]; for (var i = 0; i < oldIngredients.Length; i++) + { Ingredients[i] = oldIngredients[i]; + } Ingredients[^1] = IngredientInfo.RandomIngredient(oldIngredients); } @@ -268,7 +284,9 @@ namespace Server.Engines.Quests.Hag Ingredients = new Ingredient[oldIngredients.Length]; for (var i = 0; i < oldIngredients.Length; i++) + { Ingredients[i] = oldIngredients[i]; + } } BlackheartMet = blackheartMet; @@ -283,6 +301,7 @@ namespace Server.Engines.Quests.Hag get { if (!BlackheartMet) + { return Step switch { 1 => @@ -297,6 +316,7 @@ namespace Server.Engines.Quests.Hag 1055044, _ => 1055045 }; + } /* You are still attempting to obtain a jug of Captain Blackheart's * Whiskey, but the drunkard Captain refuses to share his unique brew. @@ -343,14 +363,20 @@ namespace Server.Engines.Quests.Hag public override bool IgnoreYoungProtection(Mobile from) { if (Completed) + { return false; + } var info = IngredientInfo.Get(Ingredient); var fromType = from.GetType(); for (var i = 0; i < info.Creatures.Length; i++) + { if (fromType == info.Creatures[i]) + { return true; + } + } return false; } @@ -379,7 +405,10 @@ namespace Server.Engines.Quests.Hag public override void OnComplete() { - if (Ingredient != Ingredient.Whiskey) NextStep(); + if (Ingredient != Ingredient.Whiskey) + { + NextStep(); + } } public void NextStep() @@ -389,9 +418,13 @@ namespace Server.Engines.Quests.Hag ); // You have completed your current task on the Hag's Magic Brew Recipe list. if (Step < 3) + { System.AddObjective(new FindIngredientObjective(Ingredients)); + } else + { System.AddObjective(new ReturnIngredientsObjective()); + } } public override void ChildDeserialize(IGenericReader reader) @@ -400,7 +433,9 @@ namespace Server.Engines.Quests.Hag Ingredients = new Ingredient[reader.ReadEncodedInt()]; for (var i = 0; i < Ingredients.Length; i++) + { Ingredients[i] = (Ingredient)reader.ReadEncodedInt(); + } BlackheartMet = reader.ReadBool(); } @@ -411,7 +446,9 @@ namespace Server.Engines.Quests.Hag writer.WriteEncodedInt(Ingredients.Length); for (var i = 0; i < Ingredients.Length; i++) + { writer.WriteEncodedInt((int)Ingredients[i]); + } writer.Write(BlackheartMet); } diff --git a/Projects/UOContent/Engines/Spawners/BaseSpawner.cs b/Projects/UOContent/Engines/Spawners/BaseSpawner.cs index c2022084c..668792153 100644 --- a/Projects/UOContent/Engines/Spawners/BaseSpawner.cs +++ b/Projects/UOContent/Engines/Spawners/BaseSpawner.cs @@ -63,7 +63,9 @@ namespace Server.Engines.Spawners { InitSpawn(amount, minDelay, maxDelay, team, homeRange); for (var i = 0; i < spawnedNames.Length; i++) + { AddEntry(spawnedNames[i], 100, amount, false); + } } public BaseSpawner(DynamicJson json, JsonSerializerOptions options) : base(0x1f13) @@ -81,7 +83,9 @@ namespace Server.Engines.Spawners json.GetProperty("entries", options, out List entries); foreach (var entry in entries) + { AddEntry(entry.SpawnedName, entry.SpawnedProbability, entry.SpawnedMaxCount, false); + } } public BaseSpawner(Serial serial) : base(serial) @@ -106,7 +110,9 @@ namespace Server.Engines.Spawners m_Count = value; if (m_Timer != null && (!IsFull && !m_Timer.Running || IsFull && m_Timer.Running)) + { DoTimer(); + } InvalidateProperties(); } @@ -122,9 +128,13 @@ namespace Server.Engines.Spawners set { if (value) + { Start(); + } else + { Stop(); + } InvalidateProperties(); } @@ -229,7 +239,9 @@ namespace Server.Engines.Spawners } if (m_Running && !IsFull && m_Timer?.Running == false) + { DoTimer(); + } } public virtual void Respawn() @@ -237,7 +249,9 @@ namespace Server.Engines.Spawners RemoveSpawns(); for (var i = 0; i < m_Count; i++) + { Spawn(); + } DoTimer(); // Turn off the timer! } @@ -247,13 +261,17 @@ namespace Server.Engines.Spawners public override void OnAfterDuped(Item newItem) { if (newItem is BaseSpawner newSpawner) + { for (var i = 0; i < Entries.Count; i++) + { newSpawner.AddEntry( Entries[i].SpawnedName, Entries[i].SpawnedProbability, Entries[i].SpawnedMaxCount, false ); + } + } } public SpawnerEntry AddEntry(string creaturename, int probability = 100, int amount = 1, bool dotimer = true) @@ -261,7 +279,9 @@ namespace Server.Engines.Spawners var entry = new SpawnerEntry(creaturename, probability, amount); Entries.Add(entry); if (dotimer) + { DoTimer(TimeSpan.FromSeconds(1)); + } return entry; } @@ -286,7 +306,9 @@ namespace Server.Engines.Spawners public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.Developer) - from.SendGump(new SpawnerGump(this)); + { + @from.SendGump(new SpawnerGump(this)); + } } public virtual void GetSpawnerProperties(ObjectPropertyList list) @@ -312,7 +334,9 @@ namespace Server.Engines.Spawners GetSpawnerProperties(list); for (var i = 0; i < 6 && i < Entries.Count; ++i) + { list.Add(1060658 + i, "\t{0}\t{1}", Entries[i].SpawnedName, CountSpawns(Entries[i])); + } } else { @@ -325,19 +349,25 @@ namespace Server.Engines.Spawners base.OnSingleClick(from); if (m_Running) - LabelTo(from, "[Running]"); + { + LabelTo(@from, "[Running]"); + } else - LabelTo(from, "[Off]"); + { + LabelTo(@from, "[Off]"); + } } public void Start() { if (!m_Running) + { if (Entries.Count > 0) { m_Running = true; DoTimer(); } + } } public void Stop() @@ -354,21 +384,27 @@ namespace Server.Engines.Spawners Entries ??= new List(); for (var i = 0; i < Entries.Count; ++i) + { Entries[i].Defrag(this); + } } public virtual bool OnDefragSpawn(ISpawnable spawned, bool remove) { if (!remove) // Override could have set it to true already + { remove = spawned.Deleted || spawned.Spawner == null || spawned switch { Item item => item.RootParent is Mobile || item.IsLockedDown || item.IsSecure, Mobile m => m is BaseCreature c && (c.Controlled || c.IsStabled), _ => true }; + } if (remove) + { Spawned.Remove(spawned); + } return remove; } @@ -380,7 +416,9 @@ namespace Server.Engines.Spawners Defrag(); if (Spawned.Count > 0) + { return; + } Respawn(); } @@ -397,12 +435,16 @@ namespace Server.Engines.Spawners Defrag(); if (Entries.Count <= 0 || IsFull) + { return; + } var probsum = Entries.Where(t => !t.IsFull).Sum(t => t.SpawnedProbability); if (probsum <= 0) + { return; + } var rand = Utility.RandomMinMax(1, probsum); @@ -410,7 +452,9 @@ namespace Server.Engines.Spawners { var entry = Entries[i]; if (entry.IsFull) + { continue; + } if (rand <= entry.SpawnedProbability) { @@ -467,15 +511,25 @@ namespace Server.Engines.Spawners var propName = props[i, 0]; for (var j = 0; thisProp == null && j < allProps.Length; ++j) + { if (Insensitive.Equals(propName, allProps[j].Name)) + { thisProp = allProps[j]; + } + } if (thisProp == null) + { return null; + } + var attr = Properties.GetCPA(thisProp); if (attr == null || attr.WriteLevel > AccessLevel.Developer || !thisProp.CanWrite || attr.ReadOnly) + { return null; + } + realProps[i] = thisProp; } } @@ -486,7 +540,10 @@ namespace Server.Engines.Spawners public bool Spawn(int index, out EntryFlags flags) { if (index >= 0 && index < Entries.Count) + { return Spawn(Entries[index], out flags); + } + flags = EntryFlags.InvalidEntry; return false; } @@ -497,7 +554,9 @@ namespace Server.Engines.Spawners flags = EntryFlags.None; if (map == null || map == Map.Internal || Parent != null) + { return false; + } // Defrag taken care of in Spawn(), beforehand // Count check taken care of in Spawn(), beforehand @@ -561,6 +620,7 @@ namespace Server.Engines.Spawners } for (var i = 0; i < realProps.Length; i++) + { if (realProps[i] != null) { object toSet = null; @@ -584,6 +644,7 @@ namespace Server.Engines.Spawners return false; } } + } if (o is Mobile m) { @@ -605,7 +666,9 @@ namespace Server.Engines.Spawners c.CurrentWayPoint = WayPoint; if (m_Team > 0) + { c.Team = m_Team; + } c.Home = Location; c.HomeMap = Map; @@ -656,7 +719,9 @@ namespace Server.Engines.Spawners public void DoTimer() { if (!m_Running) + { return; + } var minSeconds = (int)m_MinDelay.TotalSeconds; var maxSeconds = (int)m_MaxDelay.TotalSeconds; @@ -668,7 +733,9 @@ namespace Server.Engines.Spawners public virtual void DoTimer(TimeSpan delay) { if (!m_Running) + { return; + } End = DateTime.UtcNow + delay; @@ -676,7 +743,9 @@ namespace Server.Engines.Spawners m_Timer = new InternalTimer(this, delay); if (!IsFull) + { m_Timer.Start(); + } } public int CountSpawns(SpawnerEntry entry) @@ -700,7 +769,9 @@ namespace Server.Engines.Spawners Entries.Remove(entry); if (m_Running && !IsFull && m_Timer?.Running == false) + { DoTimer(); + } InvalidateProperties(); } @@ -708,7 +779,9 @@ namespace Server.Engines.Spawners public void RemoveSpawn(int index) // Entry { if (index >= 0 && index < Entries.Count) + { RemoveSpawn(Entries[index]); + } } public void RemoveSpawn(SpawnerEntry entry) @@ -749,7 +822,9 @@ namespace Server.Engines.Spawners } if (m_Running && !IsFull && m_Timer?.Running == false) + { DoTimer(); + } InvalidateProperties(); } @@ -758,7 +833,10 @@ namespace Server.Engines.Spawners { Defrag(); - foreach (var e in Spawned.Keys) e?.MoveToWorld(Location, Map); + foreach (var e in Spawned.Keys) + { + e?.MoveToWorld(Location, Map); + } } public override void OnDelete() @@ -780,7 +858,9 @@ namespace Server.Engines.Spawners writer.Write(Entries.Count); for (var i = 0; i < Entries.Count; ++i) + { Entries[i].Serialize(writer); + } writer.Write(m_WalkingRange); @@ -796,7 +876,9 @@ namespace Server.Engines.Spawners writer.Write(m_Running); if (m_Running) + { writer.WriteDeltaTime(End); + } } public override void Deserialize(IGenericReader reader) @@ -808,7 +890,9 @@ namespace Server.Engines.Spawners Spawned = new Dictionary(); if (version < 7) + { Entries = new List(); + } switch (version) { @@ -824,7 +908,9 @@ namespace Server.Engines.Spawners Entries = new List(size); for (var i = 0; i < size; ++i) + { Entries.Add(new SpawnerEntry(this, reader)); + } goto case 4; // Skip the other crap } @@ -835,10 +921,16 @@ namespace Server.Engines.Spawners var addentries = Entries.Count == 0; for (var i = 0; i < size; ++i) + { if (addentries) + { Entries.Add(new SpawnerEntry(string.Empty, 100, reader.ReadInt())); + } else + { Entries[i].SpawnedMaxCount = reader.ReadInt(); + } + } goto case 5; } @@ -849,10 +941,16 @@ namespace Server.Engines.Spawners var addentries = Entries.Count == 0; for (var i = 0; i < size; ++i) + { if (addentries) + { Entries.Add(new SpawnerEntry(string.Empty, reader.ReadInt(), 1)); + } else + { Entries[i].SpawnedProbability = reader.ReadInt(); + } + } goto case 4; } @@ -889,7 +987,9 @@ namespace Server.Engines.Spawners var ts = TimeSpan.Zero; if (m_Running) + { ts = reader.ReadDeltaTime() - DateTime.UtcNow; + } if (version < 7) { @@ -902,9 +1002,13 @@ namespace Server.Engines.Spawners var typeName = reader.ReadString(); if (addentries) + { Entries.Add(new SpawnerEntry(typeName, 100, 1)); + } else + { Entries[i].SpawnedName = typeName; + } if (AssemblyHandler.FindFirstTypeForName(typeName) == null) { @@ -917,21 +1021,27 @@ namespace Server.Engines.Spawners var count = reader.ReadInt(); for (var i = 0; i < count; ++i) + { if (reader.ReadEntity() is ISpawnable e) { if (e is BaseCreature creature) + { creature.RemoveIfUntamed = true; + } e.Spawner = this; for (var j = 0; j < Entries.Count; j++) + { if (AssemblyHandler.FindFirstTypeForName(Entries[j].SpawnedName) == e.GetType()) { Entries[j].Spawned.Add(e); Spawned.Add(e, Entries[j]); break; } + } } + } } DoTimer(ts); @@ -941,7 +1051,9 @@ namespace Server.Engines.Spawners } if (version < 4) + { m_WalkingRange = m_HomeRange; + } } private class InternalTimer : Timer @@ -951,9 +1063,13 @@ namespace Server.Engines.Spawners public InternalTimer(BaseSpawner spawner, TimeSpan delay) : base(delay) { if (spawner.IsFull) + { Priority = TimerPriority.FiveSeconds; + } else + { Priority = TimerPriority.OneSecond; + } m_Spawner = spawner; } @@ -961,8 +1077,12 @@ namespace Server.Engines.Spawners protected override void OnTick() { if (m_Spawner != null) + { if (!m_Spawner.Deleted) + { m_Spawner.OnTick(); + } + } } } @@ -993,6 +1113,7 @@ namespace Server.Engines.Spawners op.WriteLine(); foreach (var e in m_List) + { op.WriteLine( "{0}\t{1}\t{2}\t{3}\t{4}", e.m_Point.X, @@ -1001,6 +1122,7 @@ namespace Server.Engines.Spawners e.m_Map, e.m_Name ); + } op.WriteLine(); op.WriteLine(); diff --git a/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs b/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs index 2adf2ebe8..8701cedc6 100644 --- a/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs +++ b/Projects/UOContent/Engines/Spawners/ProximitySpawner.cs @@ -89,7 +89,9 @@ namespace Server.Engines.Spawners public override void DoTimer(TimeSpan delay) { if (!Running) + { return; + } End = DateTime.UtcNow + delay; } @@ -104,7 +106,9 @@ namespace Server.Engines.Spawners public virtual bool ValidTrigger(Mobile m) { if (m is BaseCreature bc && (bc.IsDeadBondedPet || !(bc.Controlled || bc.Summoned))) + { return false; + } return m.AccessLevel == AccessLevel.Player && (m.Player || m.Alive && !m.Hidden && m.CanBeDamaged()); } @@ -112,7 +116,9 @@ namespace Server.Engines.Spawners public override void OnMovement(Mobile m, Point3D oldLocation) { if (!Running) + { return; + } if (IsEmpty && End <= DateTime.UtcNow && m.InRange(GetWorldLocation(), TriggerRange) && m.Location != oldLocation && ValidTrigger(m)) @@ -123,9 +129,15 @@ namespace Server.Engines.Spawners Spawn(); if (InstantFlag) + { foreach (var spawned in Spawned.Keys) + { if (spawned is Mobile mobile) + { mobile.Combatant = m; + } + } + } } } diff --git a/Projects/UOContent/Engines/Spawners/RegionSpawner.cs b/Projects/UOContent/Engines/Spawners/RegionSpawner.cs index 83bf2f714..2754feb9f 100644 --- a/Projects/UOContent/Engines/Spawners/RegionSpawner.cs +++ b/Projects/UOContent/Engines/Spawners/RegionSpawner.cs @@ -73,14 +73,18 @@ namespace Server.Engines.Spawners base.GetSpawnerProperties(list); if (Running && m_SpawnRegion != null) + { list.Add(1076228, "region:\t{0}", m_SpawnRegion.Name); // ~1_DUMMY~ ~2_DUMMY~ + } } public override Point3D GetSpawnPosition(ISpawnable spawned, Map map) { if (m_SpawnRegion == null || map == null || map == Map.Internal || map != m_SpawnRegion.Map || m_SpawnRegion.TotalWeight <= 0) + { return Location; + } bool waterMob, waterOnlyMob; @@ -125,17 +129,27 @@ namespace Server.Engines.Spawners if (waterMob) { if (IsValidWater(map, x, y, Z)) + { return new Point3D(x, y, Z); + } + if (IsValidWater(map, x, y, mapZ)) + { return new Point3D(x, y, mapZ); + } } if (!waterOnlyMob) { if (map.CanSpawnMobile(x, y, Z)) + { return new Point3D(x, y, Z); + } + if (map.CanSpawnMobile(x, y, mapZ)) + { return new Point3D(x, y, mapZ); + } } } diff --git a/Projects/UOContent/Engines/Spawners/Spawner.cs b/Projects/UOContent/Engines/Spawners/Spawner.cs index 13671f567..0c1330850 100644 --- a/Projects/UOContent/Engines/Spawners/Spawner.cs +++ b/Projects/UOContent/Engines/Spawners/Spawner.cs @@ -50,12 +50,16 @@ namespace Server.Engines.Spawners public static bool IsValidWater(Map map, int x, int y, int z) { if (!Region.Find(new Point3D(x, y, z), map).AllowSpawn() || !map.CanFit(x, y, z, 16, false, true, false)) + { return false; + } var landTile = map.Tiles.GetLandTile(x, y); if (landTile.Z == z && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0) + { return true; + } var staticTiles = map.Tiles.GetStaticTiles(x, y, true); @@ -65,7 +69,9 @@ namespace Server.Engines.Spawners if (staticTile.Z == z && (TileData.ItemTable[staticTile.ID & TileData.MaxItemValue].Flags & TileFlag.Wet) != 0) + { return true; + } } return false; @@ -89,7 +95,9 @@ namespace Server.Engines.Spawners public override Point3D GetSpawnPosition(ISpawnable spawned, Map map) { if (map == null || map == Map.Internal) + { return Location; + } bool waterMob, waterOnlyMob; @@ -115,17 +123,27 @@ namespace Server.Engines.Spawners if (waterMob) { if (IsValidWater(map, x, y, Z)) + { return new Point3D(x, y, Z); + } + if (IsValidWater(map, x, y, mapZ)) + { return new Point3D(x, y, mapZ); + } } if (!waterOnlyMob) { if (map.CanSpawnMobile(x, y, Z)) + { return new Point3D(x, y, Z); + } + if (map.CanSpawnMobile(x, y, mapZ)) + { return new Point3D(x, y, mapZ); + } } } diff --git a/Projects/UOContent/Engines/Spawners/SpawnerGump.cs b/Projects/UOContent/Engines/Spawners/SpawnerGump.cs index b16dabe23..4cddc8a0b 100644 --- a/Projects/UOContent/Engines/Spawners/SpawnerGump.cs +++ b/Projects/UOContent/Engines/Spawners/SpawnerGump.cs @@ -36,9 +36,12 @@ namespace Server.Engines.Spawners SpawnerEntry entry = null; if (entryindex < spawner.Entries.Count) + { entry = m_Spawner.Entries[entryindex]; + } if (entry == null || m_Entry != entry) + { AddButton( 5, 22 * i + 21 + offset, @@ -46,7 +49,9 @@ namespace Server.Engines.Spawners entry != null ? 0xFBC : 0xFA7, GetButtonID(2, i * 2) ); // Expand + } else + { AddButton( 5, 22 * i + 21 + offset, @@ -54,6 +59,7 @@ namespace Server.Engines.Spawners 0xFBC, GetButtonID(2, i * 2) ); // Unexpand + } AddButton(38, 22 * i + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + i * 2)); // Delete @@ -142,14 +148,22 @@ namespace Server.Engines.Spawners AddLabel(286, 325 + offset, 0x384, "Apply"); if (m_Page > 0) + { AddButton(276, 308 + offset, 0x15E3, 0x15E7, GetButtonID(1, 0)); + } else + { AddImage(276, 308 + offset, 0x25EA); + } if ((m_Page + 1) * 13 <= m_Spawner.Entries.Count) + { AddButton(293, 308 + offset, 0x15E1, 0x15E5, GetButtonID(1, 1)); + } else + { AddImage(293, 308 + offset, 0x25E6); + } } public int GetButtonID(int type, int index) => 1 + index * 10 + type; @@ -172,7 +186,9 @@ namespace Server.Engines.Spawners var propte = info.GetTextEntry(index + 4); if (cte == null) + { continue; + } var str = cte.Text.Trim().ToLower(); @@ -194,10 +210,14 @@ namespace Server.Engines.Spawners entry.SpawnedName = str; if (mte != null) + { entry.SpawnedMaxCount = Utility.ToInt32(mte.Text.Trim()); + } if (poste != null) + { entry.SpawnedProbability = Utility.ToInt32(poste.Text.Trim()); + } } else { @@ -205,19 +225,27 @@ namespace Server.Engines.Spawners var probcount = 100; if (mte != null) + { maxcount = Utility.ToInt32(mte.Text.Trim()); + } if (poste != null) + { probcount = Utility.ToInt32(poste.Text.Trim()); + } entry = spawner.AddEntry(str, probcount, maxcount); } if (parmte != null) + { entry.Parameters = parmte.Text.Trim(); + } if (propte != null) + { entry.Properties = propte.Text.Trim(); + } } else if (entryindex < ocount && spawner.Entries[entryindex] != null) { @@ -226,21 +254,29 @@ namespace Server.Engines.Spawners } for (var i = 0; i < rementries.Count; i++) + { spawner.RemoveEntry(rementries[i]); + } if (ocount == 0 && spawner.Entries.Count > 0) + { spawner.Start(); + } } public override void OnResponse(NetState state, RelayInfo info) { if (m_Spawner.Deleted) + { return; + } var val = info.ButtonID - 1; if (val < 0) + { return; + } var type = val % 10; var index = val / 10; @@ -306,9 +342,13 @@ namespace Server.Engines.Spawners { var entry = m_Spawner.Entries[entryindex]; if (buttontype == 0) // Spawn creature + { m_Entry = m_Entry != entry ? entry : null; + } else // Remove creatures + { m_Spawner.RemoveSpawn(entryindex); + } } CreateArray(info, state.Mobile, m_Spawner); @@ -317,9 +357,13 @@ namespace Server.Engines.Spawners } if (m_Entry != null && m_Spawner.Entries?.Contains(m_Entry) == true) + { state.Mobile.SendGump(new SpawnerGump(m_Spawner, m_Entry, m_Page)); + } else + { state.Mobile.SendGump(new SpawnerGump(m_Spawner, null, m_Page)); + } } } } diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs b/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs index c8ef4d6ae..c1c090ad6 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs @@ -117,7 +117,9 @@ namespace Server.Items base.GetProperties(list); if (m_Label != null && m_Label > 0) + { TextDefinition.AddTo(list, m_Label); + } list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ } @@ -139,7 +141,9 @@ namespace Server.Items { if (Deleted || UsesRemaining <= 0 || !from.InRange(GetWorldLocation(), 3) || !IsAccessibleTo(from)) + { return; + } if (!(targeted is Item i)) { @@ -187,7 +191,9 @@ namespace Server.Items i.Hue = Hue; if (--UsesRemaining <= 0) + { Delete(); + } from.PlaySound(0x23E); // As per OSI TC1 } @@ -196,24 +202,36 @@ namespace Server.Items public static bool IsValidItem(Item i) { if (i is BasePigmentsOfTokuno) + { return false; + } var t = i.GetType(); var resource = CraftResource.None; if (i is BaseWeapon weapon) + { resource = weapon.Resource; + } else if (i is BaseArmor armor) + { resource = armor.Resource; + } else if (i is BaseClothing clothing) + { resource = clothing.Resource; + } if (!CraftResources.IsStandard(resource)) + { return true; + } if (i is ITokunoDyable) + { return true; + } return IsInTypeList(t, TreasuresOfTokuno.LesserArtifactsTotal) || IsInTypeList(t, TreasuresOfTokuno.GreaterArtifacts) @@ -232,8 +250,12 @@ namespace Server.Items private static bool IsInTypeList(Type t, Type[] list) { for (var i = 0; i < list.Length; i++) + { if (list[i] == t) + { return true; + } + } return false; } @@ -265,11 +287,17 @@ namespace Server.Items InheritsItem = true; if (this is LesserPigmentsOfTokuno) + { ((LesserPigmentsOfTokuno)this).Type = (LesserPigmentType)reader.ReadEncodedInt(); + } else if (this is PigmentsOfTokuno) + { ((PigmentsOfTokuno)this).Type = (PigmentType)reader.ReadEncodedInt(); + } else if (this is MetalPigmentsOfTokuno) + { reader.ReadEncodedInt(); + } m_UsesRemaining = reader.ReadEncodedInt(); diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs b/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs index 00101d4fe..57f412128 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs @@ -83,7 +83,9 @@ namespace Server.Items } if (version == 0) + { LootType = LootType.Regular; + } } } @@ -531,7 +533,9 @@ namespace Server.Items var v = (int)type; if (v < 0 || v >= m_Table.Length) + { v = 0; + } return m_Table[v]; } diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/LesserArtifacts.cs b/Projects/UOContent/Engines/Treasures of Tokuno/LesserArtifacts.cs index b9c02c682..e7412891c 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/LesserArtifacts.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/LesserArtifacts.cs @@ -42,7 +42,9 @@ namespace Server.Items } if (version == 0) + { SkillBonuses.SetValues(0, SkillName.AnimalLore, 5.0); + } } } @@ -835,9 +837,13 @@ namespace Server.Items else if (Core.AOS) { if (item is BaseHat hat) + { BaseRunicTool.ApplyAttributesTo(hat, attributeCount, min, max); + } else if (item is BaseJewel jewel) + { BaseRunicTool.ApplyAttributesTo(jewel, attributeCount, min, max); + } } DropItem(item); @@ -900,7 +906,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Slayer == SlayerName.Fey) + { Slayer = SlayerGroup.Groups[Utility.Random(SlayerGroup.Groups.Length - 1)].Super.Name; + } } } @@ -1016,7 +1024,9 @@ namespace Server.Items var v = (int)type; if (v < 0 || v >= m_Table.Length) + { v = 0; + } return m_Table[v]; } @@ -1063,9 +1073,13 @@ namespace Server.Items { var a = Utility.Random(0, 30); if (a != 0) + { Hue = a + 0x960; + } else + { Hue = 0; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs index 20f173812..e5bb5f815 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs @@ -99,7 +99,9 @@ namespace Server.Misc m_GreaterArtifacts[i] = new Type[ToTRedeemGump.NormalRewards[i].Length]; for (var j = 0; j < m_GreaterArtifacts[i].Length; j++) + { m_GreaterArtifacts[i][j] = ToTRedeemGump.NormalRewards[i][j].Type; + } } } @@ -112,11 +114,15 @@ namespace Server.Misc var r = m.Region; if (r.IsPartOf() || BaseBoat.FindBoatAt(m, m.Map) != null) + { return false; + } // TODO: a CanReach of something check as opposed to above? if (r.IsPartOf("Yomotsu Mines") || r.IsPartOf("Fan Dancer's Dojo")) + { return true; + } return m.Map == Map.Tokuno; } @@ -125,10 +131,14 @@ namespace Server.Misc { if (DropEra == TreasuresOfTokunoEra.None || !(killer is PlayerMobile pm) || !(victim is BaseCreature bc) || !CheckLocation(bc) || !CheckLocation(pm) || !killer.InRange(victim, 18)) + { return; + } if (bc.Controlled || bc.Owners.Count > 0 || bc.Fame <= 0) + { return; + } // 25000 for 1/100 chance, 10 hyrus // 1500, 1/1000 chance, 20 lizard men for that chance. @@ -268,26 +278,34 @@ namespace Server.Mobiles pm.CloseGump(); // Sanity if (!pm.HasGump()) + { pm.SendGump(new ToTRedeemGump(this, false)); + } } else { if (pm.ToTItemsTurnedIn == 0) + { SayTo( pm, 1071013 ); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item. + } else + { SayTo( pm, 1070981, $"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}" ); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward. + } var buttons = ToTTurnInGump.FindRedeemableItems(pm); if (buttons.Count > 0 && !pm.HasGump()) + { pm.SendGump(new ToTTurnInGump(this, buttons)); + } } } @@ -336,7 +354,9 @@ namespace Server.Gumps { var pack = m.Backpack; if (pack == null) + { return new List(); + } var buttons = new List(); @@ -346,13 +366,19 @@ namespace Server.Gumps { var item = items[i]; if (item is ChestOfHeirlooms heirlooms && !heirlooms.Locked) + { continue; + } if (item is ChestOfHeirlooms ofHeirlooms && ofHeirlooms.TrapLevel != 10) + { continue; + } if (item is PigmentsOfTokuno tokuno && tokuno.Type != PigmentType.None) + { continue; + } buttons.Add(new ItemTileButtonInfo(item)); } @@ -367,7 +393,9 @@ namespace Server.Gumps var item = ((ItemTileButtonInfo)buttonInfo).Item; if (!(pm != null && item.IsChildOf(pm.Backpack) && pm.InRange(m_Collector.Location, 7))) + { return; + } item.Delete(); @@ -381,7 +409,9 @@ namespace Server.Gumps pm.CloseGump(); // Sanity if (!pm.HasGump()) + { pm.SendGump(new ToTRedeemGump(m_Collector, false)); + } } else { @@ -396,29 +426,39 @@ namespace Server.Gumps pm.CloseGump(); // Sanity if (buttons.Count > 0) + { pm.SendGump(new ToTTurnInGump(m_Collector, buttons)); + } } } public override void HandleCancel(NetState sender) { if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7)) + { return; + } if (pm.ToTItemsTurnedIn == 0) + { m_Collector.SayTo( pm, 1071013 ); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item. + } else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward ) // This case should ALWAYS be true with this gump, jsut a sanity check + { m_Collector.SayTo( pm, 1070981, $"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}" ); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward. + } else + { m_Collector.SayTo(pm, 1070982); // When you wish to choose your reward, you have but to approach me again. + } } } @@ -528,7 +568,9 @@ namespace Server.Gumps { if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7) || !(pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)) + { return; + } Item item = null; @@ -561,7 +603,9 @@ namespace Server.Gumps } if (item == null) + { return; // Sanity + } if (pm.AddToBackpack(item)) { @@ -585,22 +629,30 @@ namespace Server.Gumps public override void HandleCancel(NetState sender) { if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7)) + { return; + } if (pm.ToTItemsTurnedIn == 0) + { m_Collector.SayTo( pm, 1071013 ); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item. + } else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward ) // This and above case should ALWAYS be FALSE with this gump, jsut a sanity check + { m_Collector.SayTo( pm, 1070981, $"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}" ); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward. + } else + { m_Collector.SayTo(pm, 1070982); // When you wish to choose your reward, you have but to approach me again. + } } public class TypeTileButtonInfo : ImageTileButtonInfo diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs index 08c01b964..0f7fbafc5 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs @@ -7,9 +7,13 @@ namespace Server.Misc Movable = false; if (Instance?.Deleted != false) + { Instance = this; + } else + { base.Delete(); + } } public TreasuresOfTokunoPersistance(Serial serial) : base(serial) => Instance = this; @@ -21,7 +25,9 @@ namespace Server.Misc public static void Initialize() { if (Instance == null) + { new TreasuresOfTokunoPersistance(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs index 2a118abee..0fcbcb8c2 100644 --- a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs +++ b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs @@ -135,12 +135,16 @@ namespace Server.Mobiles { if (m_SculptedBy.ShowFameTitle && (m_SculptedBy.Player || m_SculptedBy.Body.IsHuman) && m_SculptedBy.Fame >= 10000) + { list.Add( 1076202, $"{(m_SculptedBy.Female ? "Lady" : "Lord")} {m_SculptedBy.Name}" ); // Sculpted by ~1_Name~ + } else + { list.Add(1076202, m_SculptedBy.Name); // Sculpted by ~1_Name~ + } } } @@ -153,7 +157,9 @@ namespace Server.Mobiles var house = BaseHouse.FindHouseAt(this); if (house?.IsCoOwner(from) == true || from.AccessLevel > AccessLevel.Counselor) + { list.Add(new DemolishEntry(this)); + } } } @@ -162,7 +168,9 @@ namespace Server.Mobiles base.OnAfterDelete(); if (Plinth?.Deleted == false) + { Plinth.Delete(); + } } protected override void OnMapChange(Map oldMap) @@ -170,7 +178,9 @@ namespace Server.Mobiles InvalidatePose(); if (Plinth != null) + { Plinth.Map = Map; + } } protected override void OnLocationChange(Point3D oldLocation) @@ -178,7 +188,9 @@ namespace Server.Mobiles InvalidatePose(); if (Plinth != null) + { Plinth.Location = new Point3D(X, Y, Z - 5); + } } public override bool CanBeRenamedBy(Mobile from) => false; @@ -232,7 +244,9 @@ namespace Server.Mobiles Frozen = true; if (m_SculptedBy == null || Map == Map.Internal) // Remove preview statues + { Timer.DelayCall(Delete); + } } public void Sculpt(Mobile by) @@ -292,14 +306,18 @@ namespace Server.Mobiles public void CloneClothes(Mobile from) { for (var i = Items.Count - 1; i >= 0; i--) + { Items[i].Delete(); + } for (var i = from.Items.Count - 1; i >= 0; i--) { var item = from.Items[i]; if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) + { AddItem(CloneItem(item)); + } } } @@ -324,10 +342,14 @@ namespace Server.Mobiles HairHue = Hue; if (FacialHairItemID > 0) + { FacialHairHue = Hue; + } for (var i = Items.Count - 1; i >= 0; i--) + { Items[i].Hue = Hue; + } Plinth?.InvalidateHue(); } @@ -394,7 +416,9 @@ namespace Server.Mobiles public override void OnClick() { if (m_Statue.Deleted) + { return; + } m_Statue.Demolish(Owner.From); } @@ -431,7 +455,10 @@ namespace Server.Mobiles { var t = m_Type; - if (Statue != null) t = Statue.StatueType; + if (Statue != null) + { + t = Statue.StatueType; + } return t switch { @@ -452,7 +479,9 @@ namespace Server.Mobiles get { if (Statue != null) + { return Statue.StatueType; + } return m_Type; } @@ -475,10 +504,14 @@ namespace Server.Mobiles base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076222); // 6th Year Veteran Reward + } if (Statue != null) + { list.Add(1076231, Statue.Name); // Statue of ~1_Name~ + } } public override void OnDoubleClick(Mobile from) @@ -543,7 +576,10 @@ namespace Server.Mobiles var version = reader.ReadEncodedInt(); - if (version >= 1) m_Type = (StatueType)reader.ReadInt(); + if (version >= 1) + { + m_Type = (StatueType)reader.ReadInt(); + } Statue = reader.ReadMobile() as CharacterStatue; m_IsRewardItem = reader.ReadBool(); @@ -567,7 +603,9 @@ namespace Server.Mobiles var map = from.Map; if (p == null || map == null || m_Maker?.Deleted != false) + { return; + } if (m_Maker.IsChildOf(from.Backpack)) { @@ -597,7 +635,9 @@ namespace Server.Mobiles house.Addons.Add(plinth); if (m_Maker is IRewardItem rewardItem) + { statue.IsRewardItem = rewardItem.IsRewardItem; + } statue.Plinth = plinth; plinth.MoveToWorld(loc, map); @@ -638,9 +678,14 @@ namespace Server.Mobiles public static AddonFitResult CouldFit(Point3D p, Map map, Mobile from, ref BaseHouse house) { if (!map.CanFit(p.X, p.Y, p.Z, 20, true)) + { return AddonFitResult.Blocked; + } + if (!BaseAddon.CheckHouse(from, p, map, 20, ref house)) + { return AddonFitResult.NotInHouse; + } return CheckDoors(p, 20, house); } @@ -658,7 +703,9 @@ namespace Server.Mobiles if (Utility.InRange(doorLoc, p, 1) && (p.Z == doorLoc.Z || p.Z + height > doorLoc.Z && doorLoc.Z + doorHeight > p.Z)) + { return AddonFitResult.DoorTooClose; + } } return AddonFitResult.Valid; diff --git a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatueMaker.cs b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatueMaker.cs index db85c035b..d1f2ab359 100644 --- a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatueMaker.cs +++ b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatueMaker.cs @@ -49,7 +49,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, new object[] { m_Type })) + { return; + } if (IsChildOf(from.Backpack)) { @@ -74,7 +76,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076222); // 6th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs index 14fe325ce..a29e3ab45 100644 --- a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs +++ b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs @@ -27,17 +27,23 @@ namespace Server.Items var point = new Point3D(p.X, p.Y, p.Z); if (map?.CanFit(point, 20) != true) + { return false; + } var house = BaseHouse.FindHouseAt(point, map, 20); if (house == null) + { return false; + } var result = CharacterStatueTarget.CheckDoors(point, 20, house); if (result == AddonFitResult.Valid) + { return true; + } return false; } @@ -47,25 +53,33 @@ namespace Server.Items base.OnAfterDelete(); if (m_Statue?.Deleted == false) + { m_Statue.Delete(); + } } public override void OnMapChange() { if (m_Statue != null) + { m_Statue.Map = Map; + } } public override void OnLocationChange(Point3D oldLocation) { if (m_Statue != null) + { m_Statue.Location = new Point3D(X, Y, Z + 5); + } } public override void OnDoubleClick(Mobile from) { if (m_Statue != null) - from.SendGump(new CharacterPlinthGump(m_Statue)); + { + @from.SendGump(new CharacterPlinthGump(m_Statue)); + } } public override void Serialize(IGenericWriter writer) @@ -86,13 +100,17 @@ namespace Server.Items m_Statue = reader.ReadMobile() as CharacterStatue; if (m_Statue?.SculptedBy == null || Map == Map.Internal) + { Timer.DelayCall(Delete); + } } public void InvalidateHue() { if (m_Statue != null) + { Hue = 0xB8F + (int)m_Statue.StatueType * 4 + (int)m_Statue.Material; + } } private class CharacterPlinthGump : Gump diff --git a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs index a61922071..427dd4ca3 100644 --- a/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs +++ b/Projects/UOContent/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs @@ -16,7 +16,9 @@ namespace Server.Gumps m_Owner = owner; if (m_Statue == null) + { return; + } Closable = true; Disposable = true; @@ -83,7 +85,9 @@ namespace Server.Gumps case StatueMaterial.Dark: if (type == StatueType.Marble) + { return 1076183; + } return 1076182; case StatueMaterial.Medium: return 1076184; @@ -111,7 +115,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (m_Statue?.Deleted != false) + { return; + } var sendGump = false; @@ -167,7 +173,9 @@ namespace Server.Gumps var backup = deed.Statue; if (backup != null) + { m_Statue.Restore(backup); + } } sendGump = true; @@ -178,7 +186,9 @@ namespace Server.Gumps } if (sendGump) + { state.Mobile.SendGump(new CharacterStatueGump(m_Maker, m_Statue, m_Owner)); + } } private enum Buttons diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardChoiceGump.cs b/Projects/UOContent/Engines/VeteranRewards/RewardChoiceGump.cs index 12c3467ff..c3f00bb8d 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardChoiceGump.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardChoiceGump.cs @@ -37,15 +37,25 @@ namespace Server.Engines.VeteranRewards string intervalAsString; if (rewardInterval == TimeSpan.FromDays(30.0)) + { intervalAsString = "month"; + } else if (rewardInterval == TimeSpan.FromDays(60.0)) + { intervalAsString = "two months"; + } else if (rewardInterval == TimeSpan.FromDays(90.0)) + { intervalAsString = "three months"; + } else if (rewardInterval == TimeSpan.FromDays(365.0)) + { intervalAsString = "year"; + } else + { intervalAsString = $"{rewardInterval.TotalDays} day{(rewardInterval.TotalDays == 1 ? "" : "s")}"; + } AddPage(1); @@ -84,15 +94,21 @@ namespace Server.Engines.VeteranRewards page += PagesPerCategory(categories[i]); if (categories[i].NameString != null) + { AddHtml(135, 180 + i * 40, 300, 20, categories[i].NameString); + } else + { AddHtmlLocalized(135, 180 + i * 40, 300, 20, categories[i].Name); + } } page = 2; for (var i = 0; i < categories.Length; ++i) + { RenderCategory(categories[i], i, ref page); + } } private int PagesPerCategory(RewardCategory category) @@ -101,8 +117,12 @@ namespace Server.Engines.VeteranRewards var i = 0; for (var j = 0; j < entries.Count; j++) + { if (RewardSystem.HasAccess(m_From, entries[j])) + { i++; + } + } return (int)Math.Ceiling(i / 24.0); } @@ -122,7 +142,9 @@ namespace Server.Engines.VeteranRewards var entry = entries[j]; if (!RewardSystem.HasAccess(m_From, entry)) + { continue; + } if (i == 24) { @@ -140,9 +162,14 @@ namespace Server.Engines.VeteranRewards AddButton(55 + i / 12 * 250, 80 + i % 12 * 25, 5540, 5541, GetButtonID(index, j)); if (entry.NameString != null) + { AddHtml(80 + i / 12 * 250, 80 + i % 12 * 25, 250, 20, entry.NameString); + } else + { AddHtmlLocalized(80 + i / 12 * 250, 80 + i % 12 * 25, 250, 20, entry.Name); + } + ++i; } @@ -158,7 +185,9 @@ namespace Server.Engines.VeteranRewards RewardSystem.ComputeRewardInfo(m_From, out var cur, out var max); if (cur < max) + { m_From.SendGump(new RewardNoticeGump(m_From)); + } } else { @@ -178,7 +207,9 @@ namespace Server.Engines.VeteranRewards var entry = category.Entries[index]; if (!RewardSystem.HasAccess(m_From, entry)) + { return; + } m_From.SendGump(new RewardConfirmGump(m_From, entry)); } diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardConfirmGump.cs b/Projects/UOContent/Engines/VeteranRewards/RewardConfirmGump.cs index 07947febd..5be5067ef 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardConfirmGump.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardConfirmGump.cs @@ -23,9 +23,13 @@ namespace Server.Engines.VeteranRewards AddHtmlLocalized(30, 55, 300, 35, 1006000); // You have selected: if (entry.NameString != null) + { AddHtml(335, 55, 150, 35, entry.NameString); + } else + { AddHtmlLocalized(335, 55, 150, 35, entry.Name); + } AddHtmlLocalized(30, 95, 300, 35, 1006001); // This will be assigned to this character: AddLabel(335, 95, 0, from.Name); @@ -52,26 +56,36 @@ namespace Server.Engines.VeteranRewards if (info.ButtonID == 1) { if (!RewardSystem.HasAccess(m_From, m_Entry)) + { return; + } var item = m_Entry.Construct(); if (item != null) { if (item is RedSoulstone soulstone) + { soulstone.Account = m_From.Account.Username; + } if (RewardSystem.ConsumeRewardPoint(m_From)) + { m_From.AddToBackpack(item); + } else + { item.Delete(); + } } } RewardSystem.ComputeRewardInfo(m_From, out var cur, out var max); if (cur < max) + { m_From.SendGump(new RewardNoticeGump(m_From)); + } } } } diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardDemolitionGump.cs b/Projects/UOContent/Engines/VeteranRewards/RewardDemolitionGump.cs index 4fac605d9..39de782c7 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardDemolitionGump.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardDemolitionGump.cs @@ -32,7 +32,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (!(m_Addon is Item item) || item.Deleted) + { return; + } if (info.ButtonID == (int)Buttons.Confirm) { diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardEntry.cs b/Projects/UOContent/Engines/VeteranRewards/RewardEntry.cs index e2fb63206..90124ac3a 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardEntry.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardEntry.cs @@ -72,7 +72,9 @@ namespace Server.Engines.VeteranRewards var item = ActivatorUtil.CreateInstance(ItemType, Args) as Item; if (item is IRewardItem rewardItem) + { rewardItem.IsRewardItem = true; + } return item; } diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardList.cs b/Projects/UOContent/Engines/VeteranRewards/RewardList.cs index e50264ddf..027c52d72 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardList.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardList.cs @@ -10,7 +10,9 @@ namespace Server.Engines.VeteranRewards Entries = entries; for (var i = 0; i < entries.Length; ++i) + { entries[i].List = this; + } } public TimeSpan Age { get; } diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardNoticeGump.cs b/Projects/UOContent/Engines/VeteranRewards/RewardNoticeGump.cs index b70850d40..78479500d 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardNoticeGump.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardNoticeGump.cs @@ -32,7 +32,9 @@ namespace Server.Engines.VeteranRewards public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_From.SendGump(new RewardChoiceGump(m_From)); + } } } } diff --git a/Projects/UOContent/Engines/VeteranRewards/RewardOptionGump.cs b/Projects/UOContent/Engines/VeteranRewards/RewardOptionGump.cs index baac91a36..97716d86f 100644 --- a/Projects/UOContent/Engines/VeteranRewards/RewardOptionGump.cs +++ b/Projects/UOContent/Engines/VeteranRewards/RewardOptionGump.cs @@ -32,9 +32,13 @@ namespace Server.Gumps AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL if (title > 0) + { AddHtmlLocalized(14, 12, 273, 20, title, 0x7FFF); + } else + { AddHtmlLocalized(14, 12, 273, 20, 1080392, 0x7FFF); // Select your choice from the menu below. + } AddPage(1); @@ -48,17 +52,25 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Option != null && Contains(info.ButtonID)) + { m_Option.OnOptionSelected(sender.Mobile, info.ButtonID); + } } private bool Contains(int chosen) { if (m_Options == null) + { return false; + } foreach (var option in m_Options) + { if (option.ID == chosen) + { return true; + } + } return false; } diff --git a/Projects/UOContent/Engines/Virtues/Compassion.cs b/Projects/UOContent/Engines/Virtues/Compassion.cs index 394ea0c02..954447534 100644 --- a/Projects/UOContent/Engines/Virtues/Compassion.cs +++ b/Projects/UOContent/Engines/Virtues/Compassion.cs @@ -21,7 +21,9 @@ namespace Server public static void CheckAtrophy(Mobile from) { if (!(from is PlayerMobile pm)) + { return; + } try { diff --git a/Projects/UOContent/Engines/Virtues/Honor.cs b/Projects/UOContent/Engines/Virtues/Honor.cs index 93fcee61e..d3b844e89 100644 --- a/Projects/UOContent/Engines/Virtues/Honor.cs +++ b/Projects/UOContent/Engines/Virtues/Honor.cs @@ -71,11 +71,17 @@ namespace Server int usedPoints; if (pm.Virtues.Honor < 4399) + { usedPoints = 400; + } else if (pm.Virtues.Honor < 10599) + { usedPoints = 600; + } else + { usedPoints = 1000; + } VirtueHelper.Atrophy(pm, VirtueName.Honor, usedPoints); @@ -100,12 +106,16 @@ namespace Server var map = source.Map; if (honorTarget == null) + { return; + } if (honorTarget.ReceivedHonorContext != null) { if (honorTarget.ReceivedHonorContext.Source == source) + { return; + } if (honorTarget.ReceivedHonorContext.CheckDistance()) { @@ -150,7 +160,9 @@ namespace Server source.Direction = source.GetDirectionTo(target); if (!source.Mounted) + { source.Animate(32, 5, 1, true, true, 0); + } } private class InternalTarget : Target @@ -160,12 +172,18 @@ namespace Server protected override void OnTarget(Mobile from, object targeted) { if (!(from is PlayerMobile pm)) + { return; + } if (targeted == pm) + { EmbraceHonor(pm); + } else if (targeted is Mobile mobile) + { Honor(pm, mobile); + } } protected override void OnTargetOutOfRange(Mobile from, object targeted) @@ -213,7 +231,10 @@ namespace Server TimeSpan.FromMinutes(40), () => { - if (source.m_hontime < DateTime.UtcNow && source.SentHonorContext != null) Cancel(); + if (source.m_hontime < DateTime.UtcNow && source.SentHonorContext != null) + { + Cancel(); + } } ); } @@ -229,10 +250,14 @@ namespace Server public void OnSourceDamaged(Mobile from, int amount) { if (from != Target) + { return; + } if (m_FirstHit == FirstHit.NotDelivered) + { m_FirstHit = FirstHit.Granted; + } } public void OnTargetPoisoned() @@ -243,7 +268,9 @@ namespace Server public void OnTargetDamaged(Mobile from, int amount) { if (m_FirstHit == FirstHit.NotDelivered) + { m_FirstHit = FirstHit.Delivered; + } if (m_Poisoned) { @@ -260,9 +287,13 @@ namespace Server if (Target.CanSee(Source) && Target.InLOS(Source) && (Source.InRange(Target, 1) || Source.Location == m_InitialLocation && Source.Map == m_InitialMap)) + { m_HonorDamage += amount; + } else + { m_HonorDamage += amount * 0.8; + } } else if (from is BaseCreature creature && creature.GetMaster() == Source) { @@ -273,11 +304,15 @@ namespace Server public void OnTargetHit(Mobile from) { if (from != Source || PerfectionDamageBonus == 100) + { return; + } var bushido = (int)from.Skills.Bushido.Value; if (bushido < 50) + { return; + } PerfectionDamageBonus += bushido / 10; @@ -295,7 +330,9 @@ namespace Server public void OnTargetMissed(Mobile from) { if (from != Source || PerfectionDamageBonus == 0) + { return; + } PerfectionDamageBonus -= 25; @@ -313,7 +350,9 @@ namespace Server public void OnSourceBeneficialAction(Mobile to) { if (to != Target) + { return; + } if (PerfectionDamageBonus >= 0) { @@ -342,15 +381,21 @@ namespace Server } if (Source.Virtues.Honor > targetFame) + { return; + } var dGain = targetFame / 100.0 * (m_HonorDamage / m_TotalDamage); // Initial honor gain is 100th of the monsters honor if (m_HonorDamage == m_TotalDamage && m_FirstHit == FirstHit.Granted) + { dGain *= 1.5; // honor gain is increased alot more if the combat was fully honorable + } else + { dGain *= 0.9; + } // Minimum gain of 1 honor when the honor is under the monsters fame var gain = Math.Clamp((int)dGain, 1, 200); @@ -365,9 +410,13 @@ namespace Server if (VirtueHelper.Award(Source, VirtueName.Honor, gain, ref gainedPath)) { if (gainedPath) + { Source.SendLocalizedMessage(1063226); // You have gained a path in Honor! + } else + { Source.SendLocalizedMessage(1063225); // You have gained in Honor. + } } } diff --git a/Projects/UOContent/Engines/Virtues/Justice.cs b/Projects/UOContent/Engines/Virtues/Justice.cs index 317a8096f..dbe51f361 100644 --- a/Projects/UOContent/Engines/Virtues/Justice.cs +++ b/Projects/UOContent/Engines/Virtues/Justice.cs @@ -21,7 +21,9 @@ namespace Server var map = first.Map; if (second.Map != map) + { return false; + } return GetMapRegion(map, first.Location) == GetMapRegion(map, second.Location); } @@ -29,13 +31,19 @@ namespace Server public static int GetMapRegion(Map map, Point3D loc) { if (map == null || map.MapID >= 2) + { return 0; + } if (loc.X < 5120) + { return 0; + } if (loc.Y < 2304) + { return 1; + } return 2; } @@ -43,10 +51,14 @@ namespace Server public static void OnVirtueUsed(Mobile from) { if (!from.CheckAlive()) + { return; + } if (!(from is PlayerMobile protector)) + { return; + } if (!VirtueHelper.IsSeeker(protector, VirtueName.Justice)) { @@ -77,28 +89,50 @@ namespace Server var pm = obj as PlayerMobile; if (protector == null) + { return; + } if (!VirtueHelper.IsSeeker(protector, VirtueName.Justice)) + { protector.SendLocalizedMessage(1049610); // You must reach the first path in this virtue to invoke it. + } else if (!protector.CanBeginAction()) + { protector.SendLocalizedMessage(1049370); // You must wait a while before offering your protection again. + } else if (protector.JusticeProtectors.Count > 0) + { protector.SendLocalizedMessage(1049542); // You cannot protect someone while being protected. + } else if (protector.Map != Map.Felucca) + { protector.SendLocalizedMessage(1049372); // You cannot use this ability here. + } else if (pm == null) + { protector.SendLocalizedMessage(1049678); // Only players can be protected. + } else if (pm.Map != Map.Felucca) + { protector.SendLocalizedMessage(1049372); // You cannot use this ability here. + } else if (pm == protector || pm.Criminal || pm.Kills >= 5) + { protector.SendLocalizedMessage(1049436); // That player cannot be protected. + } else if (pm.JusticeProtectors.Count > 0) + { protector.SendLocalizedMessage(1049369); // You cannot protect that player right now. + } else if (pm.HasGump()) + { protector.SendLocalizedMessage(1049369); // You cannot protect that player right now. + } else + { pm.SendGump(new AcceptProtectorGump(protector, pm)); + } } public static void OnVirtueAccepted(PlayerMobile protector, PlayerMobile protectee) @@ -150,20 +184,26 @@ namespace Server protector.SendLocalizedMessage(1049454, args); // ~2_NAME~ has declined your protection. if (protector.BeginAction()) + { Timer.DelayCall(TimeSpan.FromMinutes(15.0), protector.EndAction); + } } public static void CheckAtrophy(Mobile from) { if (!(from is PlayerMobile pm)) + { return; + } try { if (pm.LastJusticeLoss + LossDelay < DateTime.UtcNow) { if (VirtueHelper.Atrophy(from, VirtueName.Justice, LossAmount)) - from.SendLocalizedMessage(1049373); // You have lost some Justice. + { + @from.SendLocalizedMessage(1049373); // You have lost some Justice. + } pm.LastJusticeLoss = DateTime.UtcNow; } @@ -235,9 +275,13 @@ namespace Server var okay = info.IsSwitched(1); if (okay) + { JusticeVirtue.OnVirtueAccepted(m_Protector, m_Protectee); + } else + { JusticeVirtue.OnVirtueRejected(m_Protector, m_Protectee); + } } } } diff --git a/Projects/UOContent/Engines/Virtues/Sacrifice.cs b/Projects/UOContent/Engines/Virtues/Sacrifice.cs index cc40fb19b..c78d6c812 100644 --- a/Projects/UOContent/Engines/Virtues/Sacrifice.cs +++ b/Projects/UOContent/Engines/Virtues/Sacrifice.cs @@ -22,9 +22,13 @@ namespace Server if (!from.Hidden) { if (from.Alive) - from.Target = new InternalTarget(); + { + @from.Target = new InternalTarget(); + } else - Resurrect(from); + { + Resurrect(@from); + } } else { @@ -35,14 +39,18 @@ namespace Server public static void CheckAtrophy(Mobile from) { if (!(from is PlayerMobile pm)) + { return; + } try { if (pm.LastSacrificeLoss + LossDelay < DateTime.UtcNow) { if (VirtueHelper.Atrophy(from, VirtueName.Sacrifice, LossAmount)) - from.SendLocalizedMessage(1052041); // You have lost some Sacrifice. + { + @from.SendLocalizedMessage(1052041); // You have lost some Sacrifice. + } var level = VirtueHelper.GetLevel(from, VirtueName.Sacrifice); @@ -59,10 +67,14 @@ namespace Server public static void Resurrect(Mobile from) { if (from.Alive) + { return; + } if (!(from is PlayerMobile pm)) + { return; + } if (from.Criminal) { @@ -90,13 +102,19 @@ namespace Server public static void Sacrifice(Mobile from, object targeted) { if (!from.CheckAlive()) + { return; + } if (!(from is PlayerMobile pm)) + { return; + } if (!(targeted is Mobile targ)) + { return; + } if (!ValidateCreature(targ)) { @@ -127,11 +145,17 @@ namespace Server int toGain; if (from.Fame < 5000) + { toGain = 500; + } else if (from.Fame < 10000) + { toGain = 1000; + } else + { toGain = 2000; + } from.Fame = 0; @@ -153,7 +177,9 @@ namespace Server from.SendLocalizedMessage(1052008); // You have gained a path in Sacrifice! if (pm.AvailableResurrects < 3) + { ++pm.AvailableResurrects; + } } else { @@ -168,7 +194,9 @@ namespace Server public static bool ValidateCreature(Mobile m) { if (m is BaseCreature creature && (creature.Controlled || creature.Summoned)) + { return false; + } return m is Lich || m is Succubus || m is Daemon || m is EvilMage || m is EnslavedGargoyle || m is GargoyleEnforcer; diff --git a/Projects/UOContent/Engines/Virtues/Valor.cs b/Projects/UOContent/Engines/Virtues/Valor.cs index 098d13b51..aa3e98c55 100644 --- a/Projects/UOContent/Engines/Virtues/Valor.cs +++ b/Projects/UOContent/Engines/Virtues/Valor.cs @@ -27,14 +27,18 @@ namespace Server public static void CheckAtrophy(Mobile from) { if (!(from is PlayerMobile pm)) + { return; + } try { if (pm.LastValorLoss + LossDelay < DateTime.UtcNow) { if (VirtueHelper.Atrophy(from, VirtueName.Valor, LossAmount)) - from.SendLocalizedMessage(1054040); // You have lost some Valor. + { + @from.SendLocalizedMessage(1054040); // You have lost some Valor. + } pm.LastValorLoss = DateTime.UtcNow; } @@ -65,7 +69,9 @@ namespace Server if (idol.Spawn.Active) { if (idol.Spawn.Champion != null) // TODO: Message? + { return; + } int needed, consumed; switch (idol.Spawn.GetSubLevel()) diff --git a/Projects/UOContent/Engines/Virtues/VirtueGump.cs b/Projects/UOContent/Engines/Virtues/VirtueGump.cs index bb8ab0b29..be4ed8bd5 100644 --- a/Projects/UOContent/Engines/Virtues/VirtueGump.cs +++ b/Projects/UOContent/Engines/Virtues/VirtueGump.cs @@ -70,7 +70,9 @@ namespace Server private static void EventSink_VirtueItemRequest(Mobile beholder, Mobile beheld, int gumpID) { if (beholder != beheld) + { return; + } beholder.CloseGump(); @@ -81,9 +83,13 @@ namespace Server } if (m_Callbacks.TryGetValue(gumpID, out var callback)) + { callback(beholder); + } else + { beholder.SendLocalizedMessage(1052066); // That virtue is not active yet. + } } private static void EventSink_VirtueMacroRequest(Mobile beholder, int virtue) @@ -115,28 +121,44 @@ namespace Server private int GetHueFor(int index) { if (m_Beheld.Virtues.GetValue(index) == 0) + { return 2402; + } var value = m_Beheld.Virtues.GetValue(index); if (value < 4000) + { return 2402; + } if (value >= 30000) + { value = 20000; // Sanity + } int vl; if (value < 10000) + { vl = 0; + } else if (value >= 20000 && index == 5) + { vl = 2; + } else if (value >= 21000 && index != 1) + { vl = 2; + } else if (value >= 22000 && index == 1) + { vl = 2; + } else + { vl = 1; + } return m_Table[index * 3 + vl]; } @@ -144,7 +166,9 @@ namespace Server public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1 && m_Beholder == m_Beheld) + { m_Beholder.SendGump(new VirtueStatusGump(m_Beholder)); + } } private class InternalEntry : GumpImage diff --git a/Projects/UOContent/Engines/Virtues/VirtueHelper.cs b/Projects/UOContent/Engines/Virtues/VirtueHelper.cs index 40450e172..b4b076172 100644 --- a/Projects/UOContent/Engines/Virtues/VirtueHelper.cs +++ b/Projects/UOContent/Engines/Virtues/VirtueHelper.cs @@ -36,11 +36,17 @@ namespace Server int vl; if (v < 4000) + { vl = 0; + } else if (v >= GetMaxAmount(virtue)) + { vl = 3; + } else + { vl = (v + 9999) / 10000; + } return (VirtueLevel)vl; } @@ -60,10 +66,14 @@ namespace Server var maxAmount = GetMaxAmount(virtue); if (current >= maxAmount) + { return false; + } if (current + amount >= maxAmount) + { amount = maxAmount - current; + } var oldLevel = GetLevel(from, virtue); @@ -81,9 +91,13 @@ namespace Server var current = from.Virtues.GetValue((int)virtue); if (current - amount >= 0) - from.Virtues.SetValue((int)virtue, current - amount); + { + @from.Virtues.SetValue((int)virtue, current - amount); + } else - from.Virtues.SetValue((int)virtue, 0); + { + @from.Virtues.SetValue((int)virtue, 0); + } return current > 0; } @@ -118,9 +132,13 @@ namespace Server { // TODO: Localize? if (gainedPath) + { pm.SendMessage("You have gained a path in {0}!", virtueName); + } else + { pm.SendMessage("You have gained in {0}.", virtueName); + } if (virtue == VirtueName.Compassion) { @@ -128,9 +146,11 @@ namespace Server ++pm.CompassionGains; if (pm.CompassionGains >= 5) + { pm.SendLocalizedMessage( 1053004 ); // You must wait about a day before you can gain in compassion again. + } } } else diff --git a/Projects/UOContent/Engines/Virtues/VirtueInfoGump.cs b/Projects/UOContent/Engines/Virtues/VirtueInfoGump.cs index 46467f80a..6e683e545 100644 --- a/Projects/UOContent/Engines/Virtues/VirtueInfoGump.cs +++ b/Projects/UOContent/Engines/Virtues/VirtueInfoGump.cs @@ -36,35 +36,63 @@ namespace Server int dots; if (value < 4000) + { dots = value / 400; + } else if (value < 10000) + { dots = (value - 4000) / 600; + } else if (value < maxValue) + { dots = (value - 10000) / ((maxValue - 10000) / 10); + } else + { dots = 10; + } for (var i = 0; i < 10; ++i) + { AddImage(95 + i * 17, 50, i < dots ? 2362 : 2360); + } if (value < 1) + { valueDesc = 1052044; // You have not started on the path of this Virtue. + } else if (value < 400) + { valueDesc = 1052045; // You have barely begun your journey through the path of this Virtue. + } else if (value < 2000) + { valueDesc = 1052046; // You have progressed in this Virtue, but still have much to do. + } else if (value < 3600) + { valueDesc = 1052047; // Your journey through the path of this Virtue is going well. + } else if (value < 4000) + { valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. + } else if (dots < 1) + { valueDesc = 1052049; // You have achieved a path in this Virtue. + } else if (dots < 9) + { valueDesc = 1052047; // Your journey through the path of this Virtue is going well. + } else if (dots < 10) + { valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. + } else + { valueDesc = 1052050; // You have achieved the highest path in this Virtue. + } AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue); AddHtmlLocalized(75, 95, 220, 140, description); @@ -92,7 +120,10 @@ namespace Server m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, m_Virtue, m_Desc, m_Page)); if (m_Page != null) + { state.Send(new LaunchBrowser(m_Page)); // No message about web browser starting on OSI + } + break; } case 2: diff --git a/Projects/UOContent/Gumps/AddDoorGump.cs b/Projects/UOContent/Gumps/AddDoorGump.cs index 195850e65..52bbf5978 100644 --- a/Projects/UOContent/Gumps/AddDoorGump.cs +++ b/Projects/UOContent/Gumps/AddDoorGump.cs @@ -71,7 +71,9 @@ namespace Server.Gumps if (m_Type == -1) { if (button >= 0 && button < m_Types.Length) - from.SendGump(new AddDoorGump(button)); + { + @from.SendGump(new AddDoorGump(button)); + } } else { diff --git a/Projects/UOContent/Gumps/BanDurationGump.cs b/Projects/UOContent/Gumps/BanDurationGump.cs index d24476dcd..6cd9fa24b 100644 --- a/Projects/UOContent/Gumps/BanDurationGump.cs +++ b/Projects/UOContent/Gumps/BanDurationGump.cs @@ -69,7 +69,9 @@ namespace Server.Gumps var from = sender.Mobile; if (from.AccessLevel < AccessLevel.Administrator) + { return; + } var d = info.GetTextEntry(0); var h = info.GetTextEntry(1); @@ -104,6 +106,7 @@ namespace Server.Gumps case 2: // From D:H:M:S { if (d != null && h != null && m != null && s != null) + { try { duration = new TimeSpan( @@ -120,6 +123,7 @@ namespace Server.Gumps { // ignored } + } duration = TimeSpan.Zero; shouldSet = false; @@ -129,6 +133,7 @@ namespace Server.Gumps case 3: // From D { if (d != null) + { try { duration = TimeSpan.FromDays(Utility.ToDouble(d.Text)); @@ -140,6 +145,7 @@ namespace Server.Gumps { // ignored } + } duration = TimeSpan.Zero; shouldSet = false; @@ -149,6 +155,7 @@ namespace Server.Gumps case 4: // From H { if (h != null) + { try { duration = TimeSpan.FromHours(Utility.ToDouble(h.Text)); @@ -160,6 +167,7 @@ namespace Server.Gumps { // ignored } + } duration = TimeSpan.Zero; shouldSet = false; @@ -169,6 +177,7 @@ namespace Server.Gumps case 5: // From M { if (m != null) + { try { duration = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); @@ -180,6 +189,7 @@ namespace Server.Gumps { // ignored } + } duration = TimeSpan.Zero; shouldSet = false; @@ -189,6 +199,7 @@ namespace Server.Gumps case 6: // From S { if (s != null) + { try { duration = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); @@ -200,6 +211,7 @@ namespace Server.Gumps { // ignored } + } duration = TimeSpan.Zero; shouldSet = false; @@ -220,18 +232,24 @@ namespace Server.Gumps a.SetBanTags(from, DateTime.UtcNow, duration); if (comment != null) + { a.Comments.Add( new AccountComment( - from.RawName, + @from.RawName, $"Duration: {(duration == TimeSpan.MaxValue ? "Infinite" : duration.ToString())}, Comment: {comment}" ) ); + } } if (duration == TimeSpan.MaxValue) - from.SendMessage("Ban Duration: Infinite"); + { + @from.SendMessage("Ban Duration: Infinite"); + } else - from.SendMessage("Ban Duration: {0}", duration); + { + @from.SendMessage("Ban Duration: {0}", duration); + } } else { diff --git a/Projects/UOContent/Gumps/BaseConfirmGump.cs b/Projects/UOContent/Gumps/BaseConfirmGump.cs index e76b66e0c..944e09a79 100644 --- a/Projects/UOContent/Gumps/BaseConfirmGump.cs +++ b/Projects/UOContent/Gumps/BaseConfirmGump.cs @@ -55,9 +55,13 @@ namespace Server.Gumps if (info.ButtonID == (int)Buttons.Confirm) { if (info.IsSwitched((int)Buttons.Break)) + { Confirm(state.Mobile); + } else + { Refuse(state.Mobile); + } } } diff --git a/Projects/UOContent/Gumps/BaseGridGump.cs b/Projects/UOContent/Gumps/BaseGridGump.cs index 69b5a3b3d..7b7ae2b35 100644 --- a/Projects/UOContent/Gumps/BaseGridGump.cs +++ b/Projects/UOContent/Gumps/BaseGridGump.cs @@ -63,10 +63,14 @@ namespace Server.Gumps public void FinishPage() { if (m_Background != null) + { m_Background.Height = CurrentY + EntryHeight + OffsetSize + BorderSize; + } if (m_Offset != null) + { m_Offset.Height = CurrentY + EntryHeight + OffsetSize - BorderSize; + } } public void AddNewPage() @@ -98,12 +102,16 @@ namespace Server.Gumps width = CurrentX + BorderSize; if (m_Background != null && width > m_Background.Width) + { m_Background.Width = width; + } width = CurrentX - BorderSize; if (m_Offset != null && width > m_Offset.Width) + { m_Offset.Width = width; + } } public void AddEntryLabel(int width, string text) @@ -142,7 +150,9 @@ namespace Server.Gumps public void AddBlankLine() { if (m_Offset != null) + { AddImageTiled(m_Offset.X, CurrentY, m_Offset.Width, EntryHeight, BackGumpID + 4); + } AddNewLine(); } diff --git a/Projects/UOContent/Gumps/BaseImageTileButtonsGump.cs b/Projects/UOContent/Gumps/BaseImageTileButtonsGump.cs index 50b9e3c10..ad2dbcb5c 100644 --- a/Projects/UOContent/Gumps/BaseImageTileButtonsGump.cs +++ b/Projects/UOContent/Gumps/BaseImageTileButtonsGump.cs @@ -126,9 +126,13 @@ namespace Server.Gumps var adjustedID = info.ButtonID - 100; if (adjustedID >= 0 && adjustedID < Buttons.Length) + { HandleButtonResponse(sender, adjustedID, Buttons[adjustedID]); + } else + { HandleCancel(sender); + } } public virtual void HandleButtonResponse(NetState sender, int adjustedButton, ImageTileButtonInfo buttonInfo) diff --git a/Projects/UOContent/Gumps/ClientGump.cs b/Projects/UOContent/Gumps/ClientGump.cs index 326fc8458..bbf7c8795 100644 --- a/Projects/UOContent/Gumps/ClientGump.cs +++ b/Projects/UOContent/Gumps/ClientGump.cs @@ -15,7 +15,9 @@ namespace Server.Gumps public ClientGump(Mobile from, NetState state, string initialText = "") : base(30, 20) { if (state == null) + { return; + } m_State = state; @@ -136,7 +138,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (m_State == null) + { return; + } var focus = m_State.Mobile; var from = state.Mobile; diff --git a/Projects/UOContent/Gumps/CommentsGump.cs b/Projects/UOContent/Gumps/CommentsGump.cs index 58e376b41..042ba35f8 100644 --- a/Projects/UOContent/Gumps/CommentsGump.cs +++ b/Projects/UOContent/Gumps/CommentsGump.cs @@ -20,7 +20,10 @@ namespace Server.Gumps var title = $"Comments for '{acct.Username}'"; var x = 205 - title.Length / 2 * 7; if (x < 120) + { x = 120; + } + AddLabel(x, 12, 2100, title); AddPage(1); @@ -29,6 +32,7 @@ namespace Server.Gumps var list = acct.Comments; if (list.Count > 0) + { for (var i = 0; i < list.Count; ++i) { var comment = list[i]; @@ -46,8 +50,11 @@ namespace Server.Gumps $"[Added By: {comment.AddedBy} on {comment.LastModified.ToString("H:mm M/d/yy")}]
{comment.Content}"; AddHtml(12, 44 + i % 5 * 80, 386, 70, html, true, true); } + } else + { AddLabel(12, 44, 2100, "There are no comments for this account."); + } } public static void Initialize() @@ -72,9 +79,13 @@ namespace Server.Gumps } if (m.Account == null) - from.SendMessage("That player doesn't have an account loaded... weird."); + { + @from.SendMessage("That player doesn't have an account loaded... weird."); + } else - from.SendGump(new CommentsGump((Account)m.Account)); + { + @from.SendGump(new CommentsGump((Account)m.Account)); + } } public override void OnResponse(NetState state, RelayInfo info) diff --git a/Projects/UOContent/Gumps/ConfirmBreakCrystalGump.cs b/Projects/UOContent/Gumps/ConfirmBreakCrystalGump.cs index 8664ed4ea..484077c09 100644 --- a/Projects/UOContent/Gumps/ConfirmBreakCrystalGump.cs +++ b/Projects/UOContent/Gumps/ConfirmBreakCrystalGump.cs @@ -14,12 +14,16 @@ namespace Server.Gumps public override void Confirm(Mobile from) { if (m_Item?.Deleted != false) + { return; + } var summon = m_Item.Summon; if (summon == null) + { return; + } if (!summon.SetControlMaster(from)) { diff --git a/Projects/UOContent/Gumps/ConfirmHeritageGump.cs b/Projects/UOContent/Gumps/ConfirmHeritageGump.cs index e1eec6f98..0b1cd88d7 100644 --- a/Projects/UOContent/Gumps/ConfirmHeritageGump.cs +++ b/Projects/UOContent/Gumps/ConfirmHeritageGump.cs @@ -31,7 +31,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Token?.Deleted != false) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Gumps/ConfirmHouseResize.cs b/Projects/UOContent/Gumps/ConfirmHouseResize.cs index 6151616d0..168f9ef6d 100644 --- a/Projects/UOContent/Gumps/ConfirmHouseResize.cs +++ b/Projects/UOContent/Gumps/ConfirmHouseResize.cs @@ -109,16 +109,22 @@ namespace Server.Gumps if (m_House.IsAosRules) { if (m_House.Price > 0) + { toGive = new BankCheck(m_House.Price); + } else + { toGive = m_House.GetDeed(); + } } else { toGive = m_House.GetDeed(); if (toGive == null && m_House.Price > 0) + { toGive = new BankCheck(m_House.Price); + } } if (toGive != null) @@ -128,10 +134,12 @@ namespace Server.Gumps if (box.TryDropItem(m_Mobile, toGive, false)) { if (toGive is BankCheck check) + { m_Mobile.SendLocalizedMessage( 1060397, check.Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } m_House.RemoveKeys(m_Mobile); new TempNoHousingRegion(m_House, m_Mobile); diff --git a/Projects/UOContent/Gumps/ConfirmReleaseGump.cs b/Projects/UOContent/Gumps/ConfirmReleaseGump.cs index 0dd5f204a..862f49f7d 100644 --- a/Projects/UOContent/Gumps/ConfirmReleaseGump.cs +++ b/Projects/UOContent/Gumps/ConfirmReleaseGump.cs @@ -34,7 +34,10 @@ namespace Server.Gumps if (info.ButtonID != 2 || m_Pet.Deleted || !(m_Pet.Controlled && m_From == m_Pet.ControlMaster && m_From.CheckAlive() && m_Pet.Map == m_From.Map && m_Pet.InRange(m_From, 14))) + { return; + } + m_Pet.ControlTarget = null; m_Pet.ControlOrder = OrderType.Release; } diff --git a/Projects/UOContent/Gumps/DawnsMusicBoxGump.cs b/Projects/UOContent/Gumps/DawnsMusicBoxGump.cs index ed8bb1d8b..d65b46df0 100644 --- a/Projects/UOContent/Gumps/DawnsMusicBoxGump.cs +++ b/Projects/UOContent/Gumps/DawnsMusicBoxGump.cs @@ -45,7 +45,9 @@ namespace Server.Gumps } if (info == null) + { continue; + } AddButton(19, y, 0x845, 0x846, 100 + i); AddHtmlLocalized(44, y - 2, 213, 20, info.Name, 0x7FFF); @@ -68,20 +70,30 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Box?.Deleted != false) + { return; + } var m = sender.Mobile; if (!m_Box.IsChildOf(m.Backpack) && !m_Box.IsLockedDown) + { m.SendLocalizedMessage( 1061856 ); // You must have the item in your backpack or locked down in order to use it. + } else if (m_Box.IsLockedDown && !m_Box.HasAccces(m)) + { m.SendLocalizedMessage(502691); // You must be the owner to use this. + } else if (info.ButtonID == 1) + { m_Box.EndMusic(m); + } else if (info.ButtonID >= 100 && info.ButtonID - 100 < m_Box.Tracks.Count) + { m_Box.PlayMusic(m, m_Box.Tracks[info.ButtonID - 100]); + } } } } diff --git a/Projects/UOContent/Gumps/Go/GoGump.cs b/Projects/UOContent/Gumps/Go/GoGump.cs index ab510514a..d95f9ae7b 100644 --- a/Projects/UOContent/Gumps/Go/GoGump.cs +++ b/Projects/UOContent/Gumps/Go/GoGump.cs @@ -73,9 +73,13 @@ namespace Server.Gumps from.CloseGump(); if (node == tree.Root) - tree.LastBranch.Remove(from); + { + tree.LastBranch.Remove(@from); + } else - tree.LastBranch[from] = node; + { + tree.LastBranch[@from] = node; + } m_Page = page; m_Tree = tree; @@ -100,16 +104,22 @@ namespace Server.Gumps ); if (OldStyle) + { AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); + } else + { AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + } if (node.Parent != null) { AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); if (PrevLabel) + { AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); + } } x += PrevWidth + OffsetSize; @@ -118,6 +128,7 @@ namespace Server.Gumps (OldStyle ? SetWidth + OffsetSize : 0); if (!OldStyle) + { AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, @@ -125,35 +136,46 @@ namespace Server.Gumps EntryHeight, EntryGumpID ); + } AddHtml(x + TextOffsetX, y, emptyWidth - TextOffsetX, EntryHeight, $"
{node.Name}
"); x += emptyWidth + OffsetSize; if (OldStyle) + { AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); + } else + { AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + } if (page > 0) { AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2); if (PrevLabel) + { AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); + } } x += PrevWidth + OffsetSize; if (!OldStyle) + { AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID); + } if ((page + 1) * EntryCount < node.Categories.Length + node.Locations.Length) { AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1); if (NextLabel) + { AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next"); + } } var totalEntryCount = node.Categories.Length + node.Locations.Length; @@ -173,7 +195,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, index + 4); } @@ -184,23 +208,39 @@ namespace Server.Gumps LocationTree tree; if (from.Map == Map.Ilshenar) + { tree = Ilshenar ??= new LocationTree("ilshenar", Map.Ilshenar); + } else if (from.Map == Map.Felucca) + { tree = Felucca ??= new LocationTree("felucca", Map.Felucca); + } else if (from.Map == Map.Trammel) + { tree = Trammel ??= new LocationTree("trammel", Map.Trammel); + } else if (from.Map == Map.Malas) + { tree = Malas ??= new LocationTree("malas", Map.Malas); + } else if (from.Map == Map.Tokuno) + { tree = Tokuno ??= new LocationTree("tokuno", Map.Tokuno); + } else + { tree = TerMur ??= new LocationTree("termur", Map.TerMur); + } if (!tree.LastBranch.TryGetValue(from, out var branch)) + { branch = tree.Root; + } if (branch != null) - from.SendGump(new GoGump(0, from, tree, branch)); + { + @from.SendGump(new GoGump(0, @from, tree, branch)); + } } public override void OnResponse(NetState state, RelayInfo info) @@ -212,21 +252,27 @@ namespace Server.Gumps case 1: { if (m_Node.Parent != null) - from.SendGump(new GoGump(0, from, m_Tree, m_Node.Parent)); + { + @from.SendGump(new GoGump(0, @from, m_Tree, m_Node.Parent)); + } break; } case 2: { if (m_Page > 0) - from.SendGump(new GoGump(m_Page - 1, from, m_Tree, m_Node)); + { + @from.SendGump(new GoGump(m_Page - 1, @from, m_Tree, m_Node)); + } break; } case 3: { if ((m_Page + 1) * EntryCount < m_Node.Categories.Length + m_Node.Locations.Length) - from.SendGump(new GoGump(m_Page + 1, from, m_Tree, m_Node)); + { + @from.SendGump(new GoGump(m_Page + 1, @from, m_Tree, m_Node)); + } break; } @@ -235,7 +281,9 @@ namespace Server.Gumps var index = info.ButtonID - 4; if (index < 0) + { break; + } if (index < m_Node.Categories.Length) { @@ -245,7 +293,9 @@ namespace Server.Gumps { index -= m_Node.Categories.Length; if (index < m_Node.Locations.Length) - from.MoveToWorld(m_Node.Locations[index].Location, m_Tree.Map); + { + @from.MoveToWorld(m_Node.Locations[index].Location, m_Tree.Map); + } } break; diff --git a/Projects/UOContent/Gumps/Go/LocationTree.cs b/Projects/UOContent/Gumps/Go/LocationTree.cs index 891a68231..9154a382e 100644 --- a/Projects/UOContent/Gumps/Go/LocationTree.cs +++ b/Projects/UOContent/Gumps/Go/LocationTree.cs @@ -52,7 +52,9 @@ namespace Server.Gumps } for (var j = 0; j < parent.Locations.Length; j++) + { parent.Locations[j].Parent = parent; + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/DeclareFealtyGump.cs b/Projects/UOContent/Gumps/Guilds/DeclareFealtyGump.cs index 017291c63..a51e80334 100644 --- a/Projects/UOContent/Gumps/Guilds/DeclareFealtyGump.cs +++ b/Projects/UOContent/Gumps/Guilds/DeclareFealtyGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { @@ -38,7 +40,9 @@ namespace Server.Gumps var m = m_List[index]; if (m?.Deleted == false) + { state.Mobile.GuildFealty = m; + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/GrantGuildTitleGump.cs b/Projects/UOContent/Gumps/Guilds/GrantGuildTitleGump.cs index edfac7e88..88e901a57 100644 --- a/Projects/UOContent/Gumps/Guilds/GrantGuildTitleGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GrantGuildTitleGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildAbbrvPrompt.cs b/Projects/UOContent/Gumps/Guilds/GuildAbbrvPrompt.cs index cf4f6903b..15dbd3ed9 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildAbbrvPrompt.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildAbbrvPrompt.cs @@ -17,7 +17,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); @@ -26,12 +28,16 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } text = text.Trim(); if (text.Length > 3) + { text = text.Substring(0, 3); + } if (text.Length > 0) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildAcceptWarGump.cs b/Projects/UOContent/Gumps/Guilds/GuildAcceptWarGump.cs index 4cf9bf34c..824e797e3 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildAcceptWarGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildAcceptWarGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { @@ -48,9 +50,13 @@ namespace Server.Gumps GuildGump.EnsureClosed(m_Mobile); if (m_Guild.WarInvitations.Count > 0) + { m_Mobile.SendGump(new GuildAcceptWarGump(m_Mobile, m_Guild)); + } else + { m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/GuildAdminCandidatesGump.cs b/Projects/UOContent/Gumps/Guilds/GuildAdminCandidatesGump.cs index 8756c6b39..447c42944 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildAdminCandidatesGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildAdminCandidatesGump.cs @@ -24,7 +24,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } switch (info.ButtonID) { @@ -58,17 +60,23 @@ namespace Server.Gumps if (guildFaction != targetFaction) { if (guildFaction == null) + { m_Mobile.SendLocalizedMessage( 1013027 ); // That player cannot join a non-faction guild. + } else if (targetFaction == null) + { m_Mobile.SendLocalizedMessage( 1013026 ); // That player must be in a faction before joining this guild. + } else + { m_Mobile.SendLocalizedMessage( 1013028 ); // That person has a different faction affiliation. + } break; } @@ -88,9 +96,13 @@ namespace Server.Gumps GuildGump.EnsureClosed(m_Mobile); if (m_Guild.Candidates.Count > 0) + { m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); + } else + { m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } } @@ -116,9 +128,13 @@ namespace Server.Gumps GuildGump.EnsureClosed(m_Mobile); if (m_Guild.Candidates.Count > 0) + { m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); + } else + { m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/GuildCandidatesGump.cs b/Projects/UOContent/Gumps/Guilds/GuildCandidatesGump.cs index aae1c93f7..10b642c59 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildCandidatesGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildCandidatesGump.cs @@ -20,7 +20,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs b/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs index 5c7a3a90a..44acc68c6 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildChangeTypeGump.cs @@ -45,7 +45,9 @@ namespace Server.Gumps { if (Guild.NewGuildSystem && !BaseGuildGump.IsLeader(m_Mobile, m_Guild) || !Guild.NewGuildSystem && GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } var newType = info.ButtonID switch { @@ -78,7 +80,9 @@ namespace Server.Gumps if (Guild.NewGuildSystem) { if (m_Mobile is PlayerMobile mobile) + { mobile.SendGump(new GuildInfoGump(mobile, m_Guild)); + } return; } diff --git a/Projects/UOContent/Gumps/Guilds/GuildCharterGump.cs b/Projects/UOContent/Gumps/Guilds/GuildCharterGump.cs index 348df7165..f297a9a61 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildCharterGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildCharterGump.cs @@ -26,9 +26,13 @@ namespace Server.Gumps string charter; if ((charter = guild.Charter) == null || (charter = charter.Trim()).Length <= 0) + { AddHtmlLocalized(20, 20, 400, 35, 1013032); // No charter has been defined. + } else + { AddHtml(20, 20, 510, 75, charter, true, true); + } AddButton(20, 200, 4005, 4007, 2); AddHtmlLocalized(55, 200, 300, 20, 1011122); // Visit the guild website : @@ -36,7 +40,9 @@ namespace Server.Gumps string website; if ((website = guild.Website) == null || (website = website.Trim()).Length <= 0) + { website = DefaultWebsite; + } AddHtml(55, 220, 300, 20, website); } @@ -44,7 +50,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } switch (info.ButtonID) { @@ -55,7 +63,9 @@ namespace Server.Gumps string website; if ((website = m_Guild.Website) == null || (website = website.Trim()).Length <= 0) + { website = DefaultWebsite; + } m_Mobile.LaunchBrowser(website); break; diff --git a/Projects/UOContent/Gumps/Guilds/GuildCharterPrompt.cs b/Projects/UOContent/Gumps/Guilds/GuildCharterPrompt.cs index 11cf443a0..aa1af0613 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildCharterPrompt.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildCharterPrompt.cs @@ -17,7 +17,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); @@ -26,15 +28,21 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } text = text.Trim(); if (text.Length > 50) + { text = text.Substring(0, 50); + } if (text.Length > 0) + { m_Guild.Charter = text; + } m_Mobile.SendLocalizedMessage(1013072); // Enter the new website for the guild (50 characters max): m_Mobile.Prompt = new GuildWebsitePrompt(m_Mobile, m_Guild); diff --git a/Projects/UOContent/Gumps/Guilds/GuildDeclarePeaceGump.cs b/Projects/UOContent/Gumps/Guilds/GuildDeclarePeaceGump.cs index b840305e1..d76305ece 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildDeclarePeaceGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildDeclarePeaceGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { @@ -51,9 +53,13 @@ namespace Server.Gumps GuildGump.EnsureClosed(m_Mobile); if (m_Guild.Enemies.Count > 0) + { m_Mobile.SendGump(new GuildDeclarePeaceGump(m_Mobile, m_Guild)); + } else + { m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/GuildDeclareWarGump.cs b/Projects/UOContent/Gumps/Guilds/GuildDeclareWarGump.cs index 6ef52c163..919d653c9 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildDeclareWarGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildDeclareWarGump.cs @@ -26,7 +26,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildDeclareWarPrompt.cs b/Projects/UOContent/Gumps/Guilds/GuildDeclareWarPrompt.cs index 756322d01..9269758b5 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildDeclareWarPrompt.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildDeclareWarPrompt.cs @@ -17,7 +17,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildWarAdminGump(m_Mobile, m_Guild)); @@ -26,7 +28,9 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } text = text.Trim(); diff --git a/Projects/UOContent/Gumps/Guilds/GuildDismissGump.cs b/Projects/UOContent/Gumps/Guilds/GuildDismissGump.cs index 48cedfd9e..fa3a0021a 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildDismissGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildDismissGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildGump.cs b/Projects/UOContent/Gumps/Guilds/GuildGump.cs index b9ab49dda..59e8b3c4b 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildGump.cs @@ -38,16 +38,22 @@ namespace Server.Gumps var fealty = beholder.GuildFealty; if (fealty == null || !guild.IsMember(fealty)) + { fealty = leader; + } fealty ??= beholder; var fealtyName = fealty.Name?.Trim().IsNullOrDefault("(empty)"); if (beholder == fealty) + { AddHtmlLocalized(55, 70, 470, 20, 1018002); // yourself + } else + { AddHtml(55, 70, 470, 20, fealtyName); + } AddButton(215, 50, 4005, 4007, 2); AddHtmlLocalized(250, 50, 170, 20, 1013023); // Display guild abbreviation @@ -112,7 +118,9 @@ namespace Server.Gumps public static bool BadLeader(Mobile m, Guild g) { if (m.Deleted || g.Disbanded || m.AccessLevel < AccessLevel.GameMaster && g.Leader != m) + { return true; + } var stone = g.Guildstone; @@ -122,7 +130,9 @@ namespace Server.Gumps public static bool BadMember(Mobile m, Guild g) { if (m.Deleted || g.Disbanded || m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m)) + { return true; + } var stone = g.Guildstone; @@ -132,7 +142,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (BadMember(m_Mobile, m_Guild)) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildListGump.cs b/Projects/UOContent/Gumps/Guilds/GuildListGump.cs index 21e81e531..4c44099ad 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildListGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildListGump.cs @@ -44,14 +44,18 @@ namespace Server.Gumps } if (radio) + { AddRadio(20, 35 + i % 11 * 30, 208, 209, false, i); + } var g = m_List[i]; string name; if ((name = g.Name) != null && (name = name.Trim()).Length <= 0) + { name = "(empty)"; + } AddLabel(radio ? 55 : 20, 35 + i % 11 * 30, 0, name); } diff --git a/Projects/UOContent/Gumps/Guilds/GuildMobileListGump.cs b/Projects/UOContent/Gumps/Guilds/GuildMobileListGump.cs index e7b48d27b..b4666db8f 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildMobileListGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildMobileListGump.cs @@ -45,14 +45,18 @@ namespace Server.Gumps } if (radio) + { AddRadio(20, 35 + i % 11 * 30, 208, 209, false, i); + } var m = m_List[i]; string name; if ((name = m.Name) != null && (name = name.Trim()).Length <= 0) + { name = "(empty)"; + } AddLabel(radio ? 55 : 20, 35 + i % 11 * 30, 0, name); } diff --git a/Projects/UOContent/Gumps/Guilds/GuildNamePrompt.cs b/Projects/UOContent/Gumps/Guilds/GuildNamePrompt.cs index b748b8057..6255f6c09 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildNamePrompt.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildNamePrompt.cs @@ -17,7 +17,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); @@ -26,12 +28,16 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } text = text.Trim(); if (text.Length > 40) + { text = text.Substring(0, 40); + } if (text.Length > 0) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildRejectWarGump.cs b/Projects/UOContent/Gumps/Guilds/GuildRejectWarGump.cs index 5d240a339..9fb2b9565 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildRejectWarGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildRejectWarGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { @@ -45,9 +47,13 @@ namespace Server.Gumps GuildGump.EnsureClosed(m_Mobile); if (m_Guild.WarInvitations.Count > 0) + { m_Mobile.SendGump(new GuildRejectWarGump(m_Mobile, m_Guild)); + } else + { m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/GuildRescindDeclarationGump.cs b/Projects/UOContent/Gumps/Guilds/GuildRescindDeclarationGump.cs index ec4b13c7c..b922c5e79 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildRescindDeclarationGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildRescindDeclarationGump.cs @@ -23,7 +23,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { @@ -45,9 +47,13 @@ namespace Server.Gumps GuildGump.EnsureClosed(m_Mobile); if (m_Guild.WarDeclarations.Count > 0) + { m_Mobile.SendGump(new GuildRescindDeclarationGump(m_Mobile, m_Guild)); + } else + { m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/GuildRosterGump.cs b/Projects/UOContent/Gumps/Guilds/GuildRosterGump.cs index 40a5bbb9e..173baff84 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildRosterGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildRosterGump.cs @@ -20,7 +20,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildTitlePrompt.cs b/Projects/UOContent/Gumps/Guilds/GuildTitlePrompt.cs index af7225a7b..80198e22a 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildTitlePrompt.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildTitlePrompt.cs @@ -19,9 +19,14 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (GuildGump.BadLeader(m_Leader, m_Guild)) + { return; + } + if (m_Target.Deleted || !m_Guild.IsMember(m_Target)) + { return; + } GuildGump.EnsureClosed(m_Leader); m_Leader.SendGump(new GuildmasterGump(m_Leader, m_Guild)); @@ -30,17 +35,26 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (GuildGump.BadLeader(m_Leader, m_Guild)) + { return; + } + if (m_Target.Deleted || !m_Guild.IsMember(m_Target)) + { return; + } text = text.Trim(); if (text.Length > 20) + { text = text.Substring(0, 20); + } if (text.Length > 0) + { m_Target.GuildTitle = text; + } GuildGump.EnsureClosed(m_Leader); m_Leader.SendGump(new GuildmasterGump(m_Leader, m_Guild)); diff --git a/Projects/UOContent/Gumps/Guilds/GuildWarAdminGump.cs b/Projects/UOContent/Gumps/Guilds/GuildWarAdminGump.cs index 26a0f3e03..6112477ca 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildWarAdminGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildWarAdminGump.cs @@ -66,7 +66,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildWarGump.cs b/Projects/UOContent/Gumps/Guilds/GuildWarGump.cs index a05094d7b..3b3acb359 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildWarGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildWarGump.cs @@ -34,14 +34,18 @@ namespace Server.Gumps var enemies = guild.Enemies; if (enemies.Count == 0) + { AddHtmlLocalized(20, 65, 400, 20, 1013033); // No current wars + } else + { for (var i = 0; i < enemies.Count; ++i) { var g = enemies[i]; AddHtml(20, 65 + i * 20, 300, 20, g.Name); } + } AddPage(2); @@ -56,14 +60,18 @@ namespace Server.Gumps var declared = guild.WarDeclarations; if (declared.Count == 0) + { AddHtmlLocalized(20, 65, 400, 20, 1018012); // No current invitations received for war. + } else + { for (var i = 0; i < declared.Count; ++i) { var g = declared[i]; AddHtml(20, 65 + i * 20, 300, 20, g.Name); } + } AddPage(3); @@ -75,20 +83,26 @@ namespace Server.Gumps var invites = guild.WarInvitations; if (invites.Count == 0) + { AddHtmlLocalized(20, 65, 400, 20, 1013055); // No current war declarations + } else + { for (var i = 0; i < invites.Count; ++i) { var g = invites[i]; AddHtml(20, 65 + i * 20, 300, 20, g.Name); } + } } public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } if (info.ButtonID == 1) { diff --git a/Projects/UOContent/Gumps/Guilds/GuildWebsitePrompt.cs b/Projects/UOContent/Gumps/Guilds/GuildWebsitePrompt.cs index 54b76dd76..b76a4168e 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildWebsitePrompt.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildWebsitePrompt.cs @@ -17,7 +17,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); @@ -26,15 +28,21 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } text = text.Trim(); if (text.Length > 50) + { text = text.Substring(0, 50); + } if (text.Length > 0) + { m_Guild.Website = text; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); diff --git a/Projects/UOContent/Gumps/Guilds/GuildmasterGump.cs b/Projects/UOContent/Gumps/Guilds/GuildmasterGump.cs index e8ca35e9a..ae88b6895 100644 --- a/Projects/UOContent/Gumps/Guilds/GuildmasterGump.cs +++ b/Projects/UOContent/Gumps/Guilds/GuildmasterGump.cs @@ -85,7 +85,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (GuildGump.BadLeader(m_Mobile, m_Guild)) + { return; + } switch (info.ButtonID) { @@ -113,7 +115,9 @@ namespace Server.Gumps case 4: // Change guild type { if (!Guild.OrderChaos) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildChangeTypeGump(m_Mobile, m_Guild)); diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs index 790f183df..96a1ed51d 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/AdvancedSearch.cs @@ -57,18 +57,24 @@ namespace Server.Guilds base.OnResponse(sender, info); if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + { return; + } var display = m_Display; if (info.ButtonID == 5) + { for (var i = 0; i < 3; i++) + { if (info.IsSwitched(i)) { display = (GuildDisplayType)i; m_Callback(display); break; } + } + } } } } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs index e0b57f77d..03a1e369e 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs @@ -41,10 +41,14 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm)) + { return; + } if (!IsMember(pm, guild)) + { return; + } switch (info.ButtonID) { @@ -80,7 +84,9 @@ namespace Server.Guilds // With testing on OSI, Guild stuff seems to follow a 'simpler' method of profanity protection if (s.Length < 1 || s.Length > maxLength) + { return false; + } var exceptions = ProfanityProtection.Exceptions; @@ -95,19 +101,29 @@ namespace Server.Guilds var except = false; for (var j = 0; !except && j < exceptions.Length; j++) + { if (c == exceptions[j]) + { except = true; + } + } if (!except) + { return false; + } } } var disallowed = ProfanityProtection.Disallowed; for (var i = 0; i < disallowed.Length; i++) + { if (s.IndexOf(disallowed[i]) != -1) + { return false; + } + } return true; } @@ -115,9 +131,13 @@ namespace Server.Guilds public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll) { if (text?.Number > 0) + { AddHtmlLocalized(x, y, width, height, text.Number, back, scroll); + } else if (text?.String != null) + { AddHtml(x, y, width, height, text.String, back, scroll); + } } public static string Color(string text, int color) => $"{text}"; diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs index 542d898d4..7271b31ab 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs @@ -42,8 +42,12 @@ namespace Server.Guilds { m_List = new List(); for (var i = 0; i < list.Count; i++) + { if (!IsFiltered(list[i], m_Filter)) + { m_List.Add(list[i]); + } + } } else { @@ -76,25 +80,41 @@ namespace Server.Guilds } if (m_StartNumber <= 0) + { AddButton(65, 80, 0x15E3, 0x15E7, 0, GumpButtonType.Page); + } else + { AddButton(65, 80, 0x15E3, 0x15E7, 6); // Back + } if (m_StartNumber + itemsPerPage > m_List.Count) + { AddButton(95, 80, 0x15E1, 0x15E5, 0, GumpButtonType.Page); + } else + { AddButton(95, 80, 0x15E1, 0x15E5, 7); // Forward + } var itemNumber = 0; if (m_Ascending) + { for (var i = m_StartNumber; i < m_StartNumber + itemsPerPage && i < m_List.Count; i++) + { DrawEntry(m_List[i], i, itemNumber++); + } + } else // descending, go from bottom of list to the top + { for (var i = m_List.Count - 1 - m_StartNumber; i >= 0 && i >= m_List.Count - itemsPerPage - m_StartNumber; i--) + { DrawEntry(m_List[i], i, itemNumber++); + } + } DrawEndingEntry(itemNumber); } @@ -128,9 +148,13 @@ namespace Server.Guilds } if (HasRelationship(o)) + { AddButton(40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index); // Info Button + } else + { AddButton(40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index); // Info Button + } } protected abstract TextDefinition[] GetValuesFor(T o, int aryLength); @@ -141,7 +165,9 @@ namespace Server.Guilds base.OnResponse(sender, info); if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + { return; + } var id = info.ButtonID; @@ -174,7 +200,9 @@ namespace Server.Guilds var comparer = m_Fields[id - 100].Comparer; if (m_Comparer.GetType() == comparer.GetType()) + { m_Ascending = !m_Ascending; + } pm.SendGump(GetResentGump(player, guild, comparer, m_Ascending, m_Filter, 0)); } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs index f6e4ae824..55368bca9 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs @@ -35,9 +35,13 @@ namespace Server.Guilds AddButton(345, 217, 0xF2, 0xF1, 0); if (pm.AcceptGuildInvites) + { AddButton(20, 260, 0xD2, 0xD3, 2); + } else + { AddButton(20, 260, 0xD3, 0xD2, 2); + } AddHtmlLocalized(45, 260, 200, 30, 1062943, 0x0); // Ignore Guild Invites } @@ -45,7 +49,9 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm) || pm.Guild != null) + { return; // Sanity + } switch (info.ButtonID) { @@ -115,9 +121,13 @@ namespace Server.Guilds pm.AcceptGuildInvites = !pm.AcceptGuildInvites; if (pm.AcceptGuildInvites) + { pm.SendLocalizedMessage(1070699); // You are now accepting guild invitations. + } else + { pm.SendLocalizedMessage(1070698); // You are now ignoring guild invitations. + } break; } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs index 7533ed709..2c9554796 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs @@ -98,7 +98,9 @@ namespace Server.Guilds get { if (m_Display == GuildDisplayType.All) + { return base.WillFilter; + } return true; } @@ -123,9 +125,13 @@ namespace Server.Guilds if (guild.IsAlly(g)) { if (guild.Alliance.Leader == g) + { defs[2] = 1063237; // Alliance Leader + } else + { defs[2] = 1062964; // Ally + } } else if (guild.IsWar(g)) { @@ -138,10 +144,14 @@ namespace Server.Guilds public override bool HasRelationship(Guild g) { if (g == guild) + { return false; + } if (guild.FindPendingWar(g) != null) + { return true; + } var alliance = guild.Alliance; @@ -152,7 +162,9 @@ namespace Server.Guilds if (leader != null) { if (guild == leader && alliance.IsPendingMember(g) || g == leader && alliance.IsPendingMember(guild)) + { return true; + } } else if (alliance.IsPendingMember(g)) { @@ -169,9 +181,13 @@ namespace Server.Guilds // AddHtmlText( 66, 153 + itemNumber * 28, 280, 26, m_LowerText, false, false ); if (m_LowerText?.Number > 0) + { AddHtmlLocalized(66, 153 + itemNumber * 28, 280, 26, m_LowerText.Number, 0xF); + } else if (m_LowerText?.String != null) + { AddHtml(66, 153 + itemNumber * 28, 280, 26, Color(m_LowerText.String, 0x99)); + } if (AllowAdvancedSearch) { @@ -184,7 +200,9 @@ namespace Server.Guilds protected override bool IsFiltered(Guild g, string filter) { if (g == null) + { return true; + } switch (m_Display) { @@ -194,7 +212,9 @@ namespace Server.Guilds if (!(guild.FindActiveWar(g) != null || guild.IsAlly(g)) ) // As per OSI, only the guild leader wars show up under the sorting by relation + { return true; + } return false; } @@ -216,7 +236,9 @@ namespace Server.Guilds public override Gump GetObjectInfoGump(PlayerMobile pm, Guild g, Guild o) { if (guild == o) + { return new GuildInfoGump(pm, g); + } return new OtherGuildInfo(pm, g, o); } @@ -226,10 +248,14 @@ namespace Server.Guilds base.OnResponse(sender, info); if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + { return; + } if (AllowAdvancedSearch && info.ButtonID == 8) + { pm.SendGump(new GuildAdvancedSearchGump(pm, guild, m_Display, AdvancedSearch_Callback)); + } } public void AdvancedSearch_Callback(GuildDisplayType display) @@ -245,11 +271,19 @@ namespace Server.Guilds public int Compare(Guild x, Guild y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } return Insensitive.Compare(x.Name, y.Name); } @@ -264,24 +298,40 @@ namespace Server.Guilds public int Compare(Guild x, Guild y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } var aStatus = GuildCompareStatus.Peace; var bStatus = GuildCompareStatus.Peace; if (m_Guild.IsAlly(x)) + { aStatus = GuildCompareStatus.Ally; + } else if (m_Guild.IsWar(x)) + { aStatus = GuildCompareStatus.War; + } if (m_Guild.IsAlly(y)) + { bStatus = GuildCompareStatus.Ally; + } else if (m_Guild.IsWar(y)) + { bStatus = GuildCompareStatus.War; + } return ((int)aStatus).CompareTo((int)bStatus); } @@ -301,11 +351,19 @@ namespace Server.Guilds public int Compare(Guild x, Guild y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } return Insensitive.Compare(x.Abbreviation, y.Abbreviation); } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs index 4efc64551..81fcb2509 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInfoGump.cs @@ -38,7 +38,9 @@ namespace Server.Guilds } if (Guild.OrderChaos && isLeader) + { AddButton(40, 154, 0x4B9, 0x4BA, 100); // Guild Faction + } AddImageTiled(65, 148, 160, 26, 0xA40); AddImageTiled(67, 150, 156, 22, 0xBBC); @@ -48,9 +50,13 @@ namespace Server.Guilds Faction f; if ((gt = guild.Type) != GuildType.Regular) + { AddHtml(233, 152, 320, 26, gt.ToString()); + } else if ((f = Faction.Find(guild.Leader)) != null) + { AddHtml(233, 152, 320, 26, f.ToString()); + } AddImageTiled(65, 196, 480, 4, 0x238D); @@ -58,13 +64,17 @@ namespace Server.Guilds AddHtml(65, 216, 480, 80, s, true, true); if (isLeader) + { AddButton(40, 251, 0x4B9, 0x4BA, 4); // Charter Edit button + } s = guild.Website.IsNullOrDefault("Guild website not yet set."); AddHtml(65, 306, 480, 30, s, true); if (isLeader) + { AddButton(40, 313, 0x4B9, 0x4BA, 5); // Website Edit button + } AddCheck(65, 370, 0xD2, 0xD3, player.DisplayGuildTitle, 0); AddHtmlLocalized(95, 370, 150, 26, 1063085, 0x0); // Show Guild Title @@ -81,7 +91,9 @@ namespace Server.Guilds var pm = (PlayerMobile)sender.Mobile; if (!IsMember(pm, guild)) + { return; + } pm.DisplayGuildTitle = info.IsSwitched(0); @@ -119,7 +131,9 @@ namespace Server.Guilds { // Alliance Roster if (guild.Alliance?.IsMember(guild) == true) + { pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, guild.Alliance)); + } break; } @@ -155,7 +169,9 @@ namespace Server.Guilds public void SetCharter_Callback(Mobile from, string text) { if (!IsLeader(from, guild)) + { return; + } var charter = Utility.FixHtml(text.Trim()); @@ -173,7 +189,9 @@ namespace Server.Guilds public void SetWebsite_Callback(Mobile from, string text) { if (!IsLeader(from, guild)) + { return; + } var site = Utility.FixHtml(text.Trim()); diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs index bb7aecc4b..26417765d 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs @@ -39,7 +39,9 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { if (guild.Disbanded || player.Guild != null) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs index abb38fb95..e27552421 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs @@ -69,7 +69,9 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild) || !IsMember(m_Member, guild)) + { return; + } var playerRank = pm.GuildRank; var targetRank = m_Member.GuildRank; @@ -130,9 +132,13 @@ namespace Server.Guilds if (targetRank == RankDefinition.Lowest) { if (RankDefinition.Lowest.Name.Number == 1062963) + { pm.SendLocalizedMessage(1063333); // You can't demote a ronin. + } else + { pm.SendMessage("You can't demote a {0}.", RankDefinition.Lowest.Name); + } } else { @@ -239,16 +245,22 @@ namespace Server.Guilds public void SetTitle_Callback(Mobile from, string text) { if (!(from is PlayerMobile pm) || m_Member == null) + { return; + } if (!(m_Member.Guild is Guild g) || !IsMember(pm, g) || !(pm.GuildRank.GetFlag(RankFlags.CanSetGuildTitle) && (pm.GuildRank.Rank > m_Member.GuildRank.Rank || pm == m_Member))) { if (m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0) + { pm.SendLocalizedMessage(1070746); // You don't have the permission to set that member's guild title. + } else + { pm.SendLocalizedMessage(1063148); // You don't have permission to change this member's guild title. + } return; } @@ -266,9 +278,13 @@ namespace Server.Guilds else { if (Insensitive.Equals(title, "none")) + { m_Member.GuildTitle = null; + } else + { m_Member.GuildTitle = title; + } pm.SendLocalizedMessage(1063156, m_Member.Name); // The guild information for ~1_val~ has been updated. } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs index eb70abd39..6cc5db868 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs @@ -60,9 +60,13 @@ namespace Server.Guilds var name = $"{pm.Name}{(player.GuildFealty == pm && player.GuildFealty != guild.Leader ? " *" : "")}"; if (pm == player) + { name = Color(name, 0x006600); + } else if (pm.NetState != null) + { name = Color(name, 0x000066); + } defs[0] = name; defs[1] = pm.GuildRank.Name; @@ -77,7 +81,9 @@ namespace Server.Guilds protected override bool IsFiltered(PlayerMobile pm, string filter) { if (pm == null) + { return true; + } return !Insensitive.Contains(pm.Name, filter); } @@ -96,7 +102,9 @@ namespace Server.Guilds base.OnResponse(sender, info); if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + { return; + } if (info.ButtonID == 8) { @@ -155,11 +163,17 @@ namespace Server.Guilds else if (guildFaction != targetFaction) { if (guildFaction == null) + { pm.SendLocalizedMessage(1013027); // That player cannot join a non-faction guild. + } else if (targetFaction == null) + { pm.SendLocalizedMessage(1013026); // That player must be in a faction before joining this guild. + } else + { pm.SendLocalizedMessage(1013028); // That person has a different faction affiliation. + } } else if (targetState?.IsLeaving == true) { @@ -180,11 +194,19 @@ namespace Server.Guilds public int Compare(PlayerMobile x, PlayerMobile y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } return Insensitive.Compare(x.Name, y.Name); } @@ -197,21 +219,38 @@ namespace Server.Guilds public int Compare(PlayerMobile x, PlayerMobile y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } var aState = x.NetState; var bState = y.NetState; if (aState == null && bState == null) + { return x.LastOnline.CompareTo(y.LastOnline); + } + if (aState == null) + { return -1; + } + if (bState == null) + { return 1; + } + return 0; } } @@ -223,11 +262,19 @@ namespace Server.Guilds public int Compare(PlayerMobile x, PlayerMobile y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } return Insensitive.Compare(x.GuildTitle, y.GuildTitle); } @@ -240,11 +287,19 @@ namespace Server.Guilds public int Compare(PlayerMobile x, PlayerMobile y) { if (x == null && y == null) + { return 0; + } + if (x == null) + { return -1; + } + if (y == null) + { return 1; + } return x.GuildRank.Rank.CompareTo(y.GuildRank.Rank); } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs index 00964d29b..41be14838 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs @@ -51,7 +51,9 @@ namespace Server.Guilds AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true); // Alliance if (otherAlliance?.IsMember(m_Other) == true) + { AddHtml(150, 83, 360, 26, otherAlliance.Name); + } AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true); // Abbreviation AddHtml(150, 113, 120, 26, m_Other.Abbreviation); @@ -69,13 +71,17 @@ namespace Server.Guilds var timeRemaining = TimeSpan.Zero; if (activeWar.WarLength != TimeSpan.Zero && activeWar.WarBeginning + activeWar.WarLength > DateTime.UtcNow) + { timeRemaining = activeWar.WarBeginning + activeWar.WarLength - DateTime.UtcNow; + } time = $"{timeRemaining.Hours:D2}:{DateTime.MinValue + timeRemaining:mm}"; otherWar = m_Other.FindActiveWar(guild); if (otherWar != null) + { otherKills = $"{otherWar.Kills}/{otherWar.MaxKills}"; + } } else if (PendingWar) { @@ -85,7 +91,9 @@ namespace Server.Guilds otherWar = m_Other.FindPendingWar(guild); if (otherWar != null) + { otherKills = Color($"{otherWar.Kills}/{otherWar.MaxKills}", 0x990000); + } } AddHtmlLocalized(280, 110, 120, 26, 1062966, 0x0, true); // Your Kills @@ -185,7 +193,9 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm && IsMember(pm, guild))) + { return; + } var playerRank = pm.GuildRank; @@ -463,15 +473,19 @@ namespace Server.Guilds else if (otherAlliance != null) { if (otherAlliance.IsPendingMember(m_Other)) + { pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal. + } else + { pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance. + } } else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) { @@ -509,15 +523,19 @@ namespace Server.Guilds else if (otherAlliance != null) { if (otherAlliance.IsPendingMember(m_Other)) + { pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal. + } else + { pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance. + } } else if (alliance.IsPendingMember(guild)) { @@ -565,7 +583,9 @@ namespace Server.Guilds case 10: // Show Alliance Roster { if (alliance != null && alliance == otherAlliance) + { pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, alliance)); + } break; } @@ -696,13 +716,17 @@ namespace Server.Guilds public void CreateAlliance_Callback(Mobile from, string text) { if (!(from is PlayerMobile pm)) + { return; + } var alliance = guild.Alliance; var otherAlliance = m_Other.Alliance; if (!IsMember(from, guild) || alliance != null) + { return; + } var playerRank = pm.GuildRank; @@ -720,12 +744,16 @@ namespace Server.Guilds else if (otherAlliance != null) { if (otherAlliance.IsPendingMember(m_Other)) + { pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal. + } else + { pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. + } } else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) { diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/War Declaration gump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/War Declaration gump.cs index e479ffe69..20ebcc85c 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/War Declaration gump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/War Declaration gump.cs @@ -41,7 +41,9 @@ namespace Server.Guilds var pm = sender.Mobile as PlayerMobile; if (!IsMember(pm, guild)) + { return; + } var playerRank = pm.GuildRank; @@ -123,14 +125,18 @@ namespace Server.Guilds } if (war != null) + { pm.SendLocalizedMessage(1070752); // The proposal has been updated. + } else + { m_Other.GuildMessage( 1070781, guild.Alliance != null ? guild.Alliance.Name : guild.Name ); // ~1_val~ has proposed a war. + } pm.SendLocalizedMessage( 1070751, diff --git a/Projects/UOContent/Gumps/Guilds/RecruitTarget.cs b/Projects/UOContent/Gumps/Guilds/RecruitTarget.cs index 1c3834939..beda0ab27 100644 --- a/Projects/UOContent/Gumps/Guilds/RecruitTarget.cs +++ b/Projects/UOContent/Gumps/Guilds/RecruitTarget.cs @@ -18,7 +18,9 @@ namespace Server.Gumps protected override void OnTarget(Mobile from, object targeted) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } if (targeted is Mobile m) { @@ -57,13 +59,19 @@ namespace Server.Gumps else if (guildFaction != targetFaction) { if (guildFaction == null) + { m_Mobile.SendLocalizedMessage(1013027); // That player cannot join a non-faction guild. + } else if (targetFaction == null) + { m_Mobile.SendLocalizedMessage( 1013026 ); // That player must be in a faction before joining this guild. + } else + { m_Mobile.SendLocalizedMessage(1013028); // That person has a different faction affiliation. + } } else if (targetState?.IsLeaving == true) { @@ -84,7 +92,9 @@ namespace Server.Gumps protected override void OnTargetFinish(Mobile from) { if (GuildGump.BadMember(m_Mobile, m_Guild)) + { return; + } GuildGump.EnsureClosed(m_Mobile); m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); diff --git a/Projects/UOContent/Gumps/HeritageTokenGump.cs b/Projects/UOContent/Gumps/HeritageTokenGump.cs index 28a873f93..2f95d1c9f 100644 --- a/Projects/UOContent/Gumps/HeritageTokenGump.cs +++ b/Projects/UOContent/Gumps/HeritageTokenGump.cs @@ -274,7 +274,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Token?.Deleted != false || info.ButtonID == 0) + { return; + } var types = new List(); var cliloc = 0; diff --git a/Projects/UOContent/Gumps/HonorSelf.cs b/Projects/UOContent/Gumps/HonorSelf.cs index 7204fb6c6..e76fa9172 100644 --- a/Projects/UOContent/Gumps/HonorSelf.cs +++ b/Projects/UOContent/Gumps/HonorSelf.cs @@ -18,7 +18,10 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { - if (info.ButtonID == 1) HonorVirtue.ActivateEmbrace(m_from); + if (info.ButtonID == 1) + { + HonorVirtue.ActivateEmbrace(m_from); + } } } } diff --git a/Projects/UOContent/Gumps/HouseDemolishGump.cs b/Projects/UOContent/Gumps/HouseDemolishGump.cs index 2657e1b8d..ec667c541 100644 --- a/Projects/UOContent/Gumps/HouseDemolishGump.cs +++ b/Projects/UOContent/Gumps/HouseDemolishGump.cs @@ -57,7 +57,10 @@ namespace Server.Gumps { if (m_House.IsOwner(m_Mobile)) { - if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0) return; + if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0) + { + return; + } if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) { @@ -107,16 +110,22 @@ namespace Server.Gumps if (m_House.IsAosRules) { if (m_House.Price > 0) + { toGive = new BankCheck(m_House.Price); + } else + { toGive = m_House.GetDeed(); + } } else { toGive = m_House.GetDeed(); if (toGive == null && m_House.Price > 0) + { toGive = new BankCheck(m_House.Price); + } } var check = toGive as BankCheck; @@ -145,10 +154,12 @@ namespace Server.Gumps if (box.TryDropItem(m_Mobile, toGive, false)) { if (check != null) + { m_Mobile.SendLocalizedMessage( 1060397, check.Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } m_House.RemoveKeys(m_Mobile); m_House.Delete(); diff --git a/Projects/UOContent/Gumps/HouseGump.cs b/Projects/UOContent/Gumps/HouseGump.cs index 975486884..049e99d6b 100644 --- a/Projects/UOContent/Gumps/HouseGump.cs +++ b/Projects/UOContent/Gumps/HouseGump.cs @@ -13,7 +13,9 @@ namespace Server.Gumps public HouseListGump(int number, List list, BaseHouse house, bool accountOf) : base(20, 30) { if (house.Deleted) + { return; + } m_House = house; @@ -28,17 +30,25 @@ namespace Server.Gumps AddHtmlLocalized(20, 20, 350, 20, number); if (list == null) + { return; + } for (var i = 0; i < list.Count; ++i) { if (i % 16 == 0) { - if (i != 0) AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 16 + 1); + if (i != 0) + { + AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 16 + 1); + } AddPage(i / 16 + 1); - if (i != 0) AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 16); + if (i != 0) + { + AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 16); + } } var m = list[i]; @@ -46,7 +56,9 @@ namespace Server.Gumps string name; if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0) + { continue; + } AddLabel( 55, @@ -62,7 +74,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (m_House.Deleted) + { return; + } var from = state.Mobile; @@ -81,7 +95,9 @@ namespace Server.Gumps public HouseRemoveGump(int number, List list, BaseHouse house, bool accountOf) : base(20, 30) { if (house.Deleted) + { return; + } m_House = house; m_List = list; @@ -102,7 +118,9 @@ namespace Server.Gumps AddHtmlLocalized(20, 20, 350, 20, number); if (list == null) + { return; + } m_Copy = new List(list); @@ -110,11 +128,17 @@ namespace Server.Gumps { if (i % 15 == 0) { - if (i != 0) AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 15 + 1); + if (i != 0) + { + AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 15 + 1); + } AddPage(i / 15 + 1); - if (i != 0) AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 15); + if (i != 0) + { + AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 15); + } } var m = list[i]; @@ -122,7 +146,9 @@ namespace Server.Gumps string name; if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0) + { continue; + } AddCheck(34, 52 + i % 15 * 20, 0xD2, 0xD3, false, i); AddLabel( @@ -139,7 +165,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (m_House.Deleted) + { return; + } var from = state.Mobile; @@ -154,7 +182,9 @@ namespace Server.Gumps var index = switches[i]; if (index >= 0 && index < m_Copy.Count) + { m_List.Remove(m_Copy[index]); + } } if (m_List.Count > 0) @@ -179,7 +209,9 @@ namespace Server.Gumps public HouseGump(Mobile from, BaseHouse house) : base(20, 30) { if (house.Deleted) + { return; + } m_House = house; @@ -194,7 +226,9 @@ namespace Server.Gumps var isFriend = isCoOwner || m_House.IsFriend(from); if (isCombatRestricted) + { isFriend = isCoOwner = isOwner = false; + } AddPage(0); @@ -219,7 +253,9 @@ namespace Server.Gumps } if (!isFriend) + { return; + } AddHtmlLocalized(55, 103, 75, 20, 1011233); // INFO AddButton(20, 103, 4005, 4007, 0, GumpButtonType.Page, 1); @@ -369,7 +405,9 @@ namespace Server.Gumps private List Wrap(string value) { if (value == null || (value = value.Trim()).Length <= 0) + { return null; + } var values = value.Split(' '); var list = new List(); @@ -390,7 +428,9 @@ namespace Server.Gumps list.Add(v); if (list.Count == 6) + { return list; + } current = ""; } @@ -399,7 +439,9 @@ namespace Server.Gumps list.Add(current); if (list.Count == 6) + { return list; + } current = val; } @@ -410,7 +452,9 @@ namespace Server.Gumps list.Add(v.Substring(0, 10)); if (list.Count == 6) + { return list; + } v = v.Substring(10); } @@ -420,7 +464,9 @@ namespace Server.Gumps } if (current.Length > 0) + { list.Add(current); + } return list; } @@ -430,12 +476,16 @@ namespace Server.Gumps var m = m_House.Owner; if (m == null) + { return "(unowned)"; + } string name; if ((name = m.Name) == null || (name = name.Trim()).Length <= 0) + { name = "(no name)"; + } return name; } @@ -443,7 +493,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_House.Deleted) + { return; + } var from = sender.Mobile; @@ -454,15 +506,21 @@ namespace Server.Gumps var isFriend = isCoOwner || m_House.IsFriend(from); if (isCombatRestricted) + { isFriend = isCoOwner = isOwner = false; + } if (!isFriend || !from.Alive) + { return; + } Item sign = m_House.Sign; if (sign == null || from.Map != sign.Map || !from.InRange(sign.GetWorldLocation(), 18)) + { return; + } switch (info.ButtonID) { @@ -724,7 +782,9 @@ namespace Server.Gumps var index = info.Switches[0] - 1; if (index >= 0 && index < 53) + { m_House.ChangeSignType(2980 + index * 2); + } } } else @@ -752,7 +812,9 @@ namespace Server.Prompts if (m_House.IsFriend(from)) { if (m_House.Sign != null) + { m_House.Sign.Name = text; + } from.SendMessage("Sign changed."); } diff --git a/Projects/UOContent/Gumps/HouseGumpAOS.cs b/Projects/UOContent/Gumps/HouseGumpAOS.cs index 9e6030409..46f85fe06 100644 --- a/Projects/UOContent/Gumps/HouseGumpAOS.cs +++ b/Projects/UOContent/Gumps/HouseGumpAOS.cs @@ -89,7 +89,9 @@ namespace Server.Gumps var isFriend = isCoOwner || house.IsFriend(from); if (isCombatRestricted) + { isFriend = isCoOwner = isOwner = false; + } AddPage(0); @@ -132,7 +134,9 @@ namespace Server.Gumps } if (!isFriend) + { return; + } if (house.Public) { @@ -456,7 +460,10 @@ namespace Server.Gumps if (_HouseSigns.Count == 0) { // Add standard signs - for (var i = 0; i < 54; ++i) _HouseSigns.Add(2980 + i * 2); + for (var i = 0; i < 54; ++i) + { + _HouseSigns.Add(2980 + i * 2); + } // Add library and beekeeper signs ( ML ) _HouseSigns.Add(2966); @@ -579,7 +586,9 @@ namespace Server.Gumps public void AddButtonLabeled(int x, int y, int buttonID, int number, bool enabled = true) { if (enabled) + { AddButton(x, y, 4005, 4007, buttonID); + } AddHtmlLocalized(x + 35, y, 240, 20, number, enabled ? LabelColor : DisabledColor); } @@ -587,7 +596,9 @@ namespace Server.Gumps public void AddList(List list, int button, bool accountOf, bool leadingStar, Mobile from) { if (list == null) + { return; + } m_List = new List(list); @@ -603,12 +614,16 @@ namespace Server.Gumps if (page != lastPage) { if (lastPage != 0) + { AddButton(40, 360, 4005, 4007, 0, GumpButtonType.Page, page); + } AddPage(page); if (lastPage != 0) + { AddButton(10, 360, 4014, 4016, 0, GumpButtonType.Page, lastPage); + } lastPage = page; } @@ -623,7 +638,9 @@ namespace Server.Gumps name = vendor.ShopName; if (vendor.IsOwner(from)) + { labelHue = HighlightedLabelHue; + } } else if (m != null) { @@ -635,16 +652,24 @@ namespace Server.Gumps } if ((name = name.Trim()).Length <= 0) + { continue; + } if (button != -1) + { AddButton(10 + xoffset, 150 + yoffset, 4005, 4007, GetButtonID(button, i)); + } if (accountOf && m.Player && m.Account != null) + { name = $"Account of {name}"; + } if (leadingStar) + { name = $"* {name}"; + } AddLabel(button > 0 ? 45 + xoffset : 10 + xoffset, 150 + yoffset, labelHue, name); ++index; @@ -656,19 +681,25 @@ namespace Server.Gumps public static void PublicPrivateNotice_Callback(Mobile from, BaseHouse house) { if (!house.Deleted) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, @from, house)); + } } public static void CustomizeNotice_Callback(Mobile from, BaseHouse house) { if (!house.Deleted) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, house)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, @from, house)); + } } public static void ClearCoOwners_Callback(Mobile from, bool okay, BaseHouse house) { if (house.Deleted) + { return; + } if (okay && house.IsOwner(from)) { @@ -683,7 +714,9 @@ namespace Server.Gumps public static void ClearFriends_Callback(Mobile from, bool okay, BaseHouse house) { if (house.Deleted) + { return; + } if (okay && house.IsCoOwner(from)) { @@ -698,7 +731,9 @@ namespace Server.Gumps public static void ClearBans_Callback(Mobile from, bool okay, BaseHouse house) { if (house.Deleted) + { return; + } if (okay && house.IsFriend(from)) { @@ -713,7 +748,9 @@ namespace Server.Gumps public static void ClearAccess_Callback(Mobile from, bool okay, BaseHouse house) { if (house.Deleted) + { return; + } if (okay && house.IsFriend(from)) { @@ -741,14 +778,18 @@ namespace Server.Gumps public static void ConvertHouse_Callback(Mobile from, bool okay, BaseHouse house) { if (house.Deleted) + { return; + } if (okay && house.IsOwner(from) && !house.HasRentedVendors) { var e = house.ConvertEntry; if (e == null) + { return; + } var cost = e.Cost - house.Price; @@ -772,12 +813,16 @@ namespace Server.Gumps else if (cost < 0) { if (Banker.Deposit(from, -cost)) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1060397, (-cost).ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } else + { return; + } } var newHouse = e.ConstructHouse(from); @@ -799,16 +844,25 @@ namespace Server.Gumps newHouse.VendorInventories.AddRange(house.VendorInventories); house.VendorInventories.Clear(); - foreach (var inventory in newHouse.VendorInventories) inventory.House = newHouse; + foreach (var inventory in newHouse.VendorInventories) + { + inventory.House = newHouse; + } newHouse.InternalizedVendors.AddRange(house.InternalizedVendors); house.InternalizedVendors.Clear(); foreach (var mobile in newHouse.InternalizedVendors) + { if (mobile is PlayerVendor vendor) + { vendor.House = newHouse; + } else if (mobile is PlayerBarkeeper barkeeper) + { barkeeper.House = newHouse; + } + } if (house.MovingCrate != null) { @@ -830,9 +884,15 @@ namespace Server.Gumps ); house.Delete(); - foreach (var item in items) item.Location = newHouse.BanLocation; + foreach (var item in items) + { + item.Location = newHouse.BanLocation; + } - foreach (var mobile in mobiles) mobile.Location = newHouse.BanLocation; + foreach (var mobile in mobiles) + { + mobile.Location = newHouse.BanLocation; + } /* You have successfully replaced your original house with a new house. * The value of the replaced house has been deposited into your bank box. @@ -854,7 +914,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_House.Deleted) + { return; + } var from = sender.Mobile; @@ -865,15 +927,21 @@ namespace Server.Gumps var isFriend = isCoOwner || m_House.IsFriend(from); if (isCombatRestricted) + { isCoOwner = isFriend = false; + } if (!from.CheckAlive()) + { return; + } Item sign = m_House.Sign; if (sign == null || from.Map != sign.Map || !from.InRange(sign.GetWorldLocation(), 18)) + { return; + } var foundation = m_House as HouseFoundation; var isCustomizable = foundation != null; @@ -881,7 +949,9 @@ namespace Server.Gumps var val = info.ButtonID - 1; if (val < 0) + { return; + } var type = val % 15; var index = val / 15; @@ -893,23 +963,33 @@ namespace Server.Gumps var vendor = (PlayerVendor)m_List[index]; if (!vendor.CanInteractWith(from, false)) + { return; + } if (from.Map != sign.Map || !from.InRange(sign, 5)) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1062429 ); // You must be within five paces of the house sign to use this option. + } else if (vendor.IsOwner(from)) - vendor.SendOwnerGump(from); + { + vendor.SendOwnerGump(@from); + } else - vendor.OpenBackpack(from); + { + vendor.OpenBackpack(@from); + } } return; } if (!isFriend) + { return; + } switch (type) { @@ -930,7 +1010,9 @@ namespace Server.Gumps case 1: // Lift Ban { if (m_House.Public) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, @from, m_House)); + } break; } @@ -949,7 +1031,9 @@ namespace Server.Gumps case 3: // Revoke Access { if (!m_House.Public) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, @from, m_House)); + } break; } @@ -991,7 +1075,9 @@ namespace Server.Gumps case 0: // View Co-Owner List { if (isCoOwner) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListCoOwner, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListCoOwner, @from, m_House)); + } break; } @@ -1010,14 +1096,17 @@ namespace Server.Gumps case 2: // Remove a Co-Owner { if (isOwner) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, @from, m_House)); + } break; } case 3: // Clear Co-Owner List { if (isOwner) - from.SendGump( + { + @from.SendGump( new WarningGump( 1060635, 30720, @@ -1025,9 +1114,10 @@ namespace Server.Gumps 32512, 420, 280, - okay => ClearCoOwners_Callback(from, okay, m_House) + okay => ClearCoOwners_Callback(@from, okay, m_House) ) ); + } break; } @@ -1052,14 +1142,17 @@ namespace Server.Gumps case 6: // Remove a Friend { if (isCoOwner) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, @from, m_House)); + } break; } case 7: // Clear Friend List { if (isCoOwner) - from.SendGump( + { + @from.SendGump( new WarningGump( 1060635, 30720, @@ -1067,9 +1160,10 @@ namespace Server.Gumps 32512, 420, 280, - okay => ClearFriends_Callback(from, okay, m_House) + okay => ClearFriends_Callback(@from, okay, m_House) ) ); + } break; } @@ -1180,7 +1274,9 @@ namespace Server.Gumps var m = list[i]; if (!m_House.HasAccess(m) && m_House.IsInside(m)) + { m.Location = m_House.BanLocation; + } } } @@ -1196,7 +1292,8 @@ namespace Server.Gumps m_House.RemoveLocks(); if (BaseHouse.NewVendorSystem) - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -1204,11 +1301,13 @@ namespace Server.Gumps 32512, 320, 180, - () => PublicPrivateNotice_Callback(from, m_House) + () => PublicPrivateNotice_Callback(@from, m_House) ) ); + } else - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -1216,9 +1315,10 @@ namespace Server.Gumps 0xF8C000, 320, 180, - () => PublicPrivateNotice_Callback(from, m_House) + () => PublicPrivateNotice_Callback(@from, m_House) ) ); + } var r = m_House.Region; var list = r.GetMobiles(); @@ -1228,7 +1328,9 @@ namespace Server.Gumps var m = list[i]; if (m_House.IsBanned(m) && m_House.IsInside(m)) + { m.Location = m_House.BanLocation; + } } } @@ -1266,7 +1368,8 @@ namespace Server.Gumps var e = m_House.ConvertEntry; if (e != null) - from.SendGump( + { + @from.SendGump( new WarningGump( 1060635, 30720, @@ -1274,9 +1377,10 @@ namespace Server.Gumps 32512, 420, 280, - okay => ConvertHouse_Callback(from, okay, m_House) + okay => ConvertHouse_Callback(@from, okay, m_House) ) ); + } } } @@ -1287,7 +1391,8 @@ namespace Server.Gumps if (isOwner && isCustomizable) { if (m_House.HasRentedVendors) - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -1295,11 +1400,13 @@ namespace Server.Gumps 32512, 320, 180, - () => CustomizeNotice_Callback(from, m_House) + () => CustomizeNotice_Callback(@from, m_House) ) ); + } else if (m_House.HasAddonContainers) - from.SendGump( + { + @from.SendGump( new NoticeGump( 1060637, 30720, @@ -1307,11 +1414,14 @@ namespace Server.Gumps 32512, 320, 180, - () => CustomizeNotice_Callback(from, m_House) + () => CustomizeNotice_Callback(@from, m_House) ) ); + } else - foundation.BeginCustomize(from); + { + foundation.BeginCustomize(@from); + } } break; @@ -1338,28 +1448,36 @@ namespace Server.Gumps case 3: // Change House Sign { if (isOwner && m_House.Public) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeSign, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeSign, @from, m_House)); + } break; } case 4: // Change House Sign Hanger { if (isOwner && isCustomizable) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeHanger, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeHanger, @from, m_House)); + } break; } case 5: // Change Signpost { if (isOwner && isCustomizable && foundation.Signpost != null) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangePost, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangePost, @from, m_House)); + } break; } case 6: // Change Foundation Style { if (isOwner && isCustomizable) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeFoundation, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeFoundation, @from, m_House)); + } break; } @@ -1447,7 +1565,9 @@ namespace Server.Gumps var hanger = foundation.SignHanger; if (hanger != null) + { hanger.ItemID = m_HangerNumbers[index]; + } from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); } @@ -1461,6 +1581,7 @@ namespace Server.Gumps FoundationType newType; if (Core.ML && index >= 5) + { switch (index) { case 5: @@ -1477,7 +1598,9 @@ namespace Server.Gumps break; default: return; } + } else + { switch (index) { case 0: @@ -1497,6 +1620,7 @@ namespace Server.Gumps break; default: return; } + } foundation.Type = newType; @@ -1536,9 +1660,13 @@ namespace Server.Gumps m_House.RemoveCoOwner(from, m_List[index]); if (m_House.CoOwners.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, @from, m_House)); + } else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, @from, m_House)); + } } break; @@ -1550,9 +1678,13 @@ namespace Server.Gumps m_House.RemoveFriend(from, m_List[index]); if (m_House.Friends.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, @from, m_House)); + } else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, @from, m_House)); + } } break; @@ -1564,9 +1696,13 @@ namespace Server.Gumps m_House.RemoveBan(from, m_List[index]); if (m_House.Bans.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, @from, m_House)); + } else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, @from, m_House)); + } } break; @@ -1578,9 +1714,13 @@ namespace Server.Gumps m_House.RemoveAccess(from, m_List[index]); if (m_House.Access.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, @from, m_House)); + } else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, @from, m_House)); + } } break; @@ -1603,7 +1743,9 @@ namespace Server.Gumps private List Wrap(string value) { if (value == null || (value = value.Trim()).Length <= 0) + { return null; + } var values = value.Split(' '); var list = new List(); @@ -1624,7 +1766,9 @@ namespace Server.Gumps list.Add(v); if (list.Count == 6) + { return list; + } current = ""; } @@ -1633,7 +1777,9 @@ namespace Server.Gumps list.Add(current); if (list.Count == 6) + { return list; + } current = val; } @@ -1644,7 +1790,9 @@ namespace Server.Gumps list.Add(v.Substring(0, 10)); if (list.Count == 6) + { return list; + } v = v.Substring(10); } @@ -1654,7 +1802,9 @@ namespace Server.Gumps } if (current.Length > 0) + { list.Add(current); + } return list; } diff --git a/Projects/UOContent/Gumps/HouseTransferGump.cs b/Projects/UOContent/Gumps/HouseTransferGump.cs index 3bce440af..5e744a338 100644 --- a/Projects/UOContent/Gumps/HouseTransferGump.cs +++ b/Projects/UOContent/Gumps/HouseTransferGump.cs @@ -57,7 +57,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1 && !m_House.Deleted) + { m_House.EndConfirmTransfer(m_From, m_To); + } } } } diff --git a/Projects/UOContent/Gumps/NoticeGump.cs b/Projects/UOContent/Gumps/NoticeGump.cs index c06d398de..582e25c96 100644 --- a/Projects/UOContent/Gumps/NoticeGump.cs +++ b/Projects/UOContent/Gumps/NoticeGump.cs @@ -29,8 +29,11 @@ namespace Server.Gumps AddAlphaRegion(10, 40, width - 20, height - 80); if (content is int i) + { AddHtmlLocalized(10, 40, width - 20, height - 80, i, contentColor, false, true); + } else if (content is string) + { AddHtml( 10, 40, @@ -40,6 +43,7 @@ namespace Server.Gumps false, true ); + } AddImageTiled(10, height - 30, width - 20, 20, 2624); AddAlphaRegion(10, height - 30, width - 20, 20); @@ -50,7 +54,9 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_Callback?.Invoke(); + } } } } diff --git a/Projects/UOContent/Gumps/PetResurrectGump.cs b/Projects/UOContent/Gumps/PetResurrectGump.cs index 07b07c78f..244ee121c 100644 --- a/Projects/UOContent/Gumps/PetResurrectGump.cs +++ b/Projects/UOContent/Gumps/PetResurrectGump.cs @@ -36,7 +36,9 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (m_Pet.Deleted || !m_Pet.IsBonded || !m_Pet.IsDeadPet) + { return; + } var from = state.Mobile; @@ -63,15 +65,23 @@ namespace Server.Gumps double decreaseAmount; if (from == m_Pet.ControlMaster) + { decreaseAmount = 0.1; + } else + { decreaseAmount = 0.2; + } for (var i = 0; i < m_Pet.Skills.Length; ++i) // Decrease all skills on pet. + { m_Pet.Skills[i].Base -= decreaseAmount; + } if (!m_Pet.IsDeadPet && m_HitsScalar > 0) + { m_Pet.Hits = (int)(m_Pet.HitsMax * m_HitsScalar); + } } } } diff --git a/Projects/UOContent/Gumps/PlayerVendorGumps.cs b/Projects/UOContent/Gumps/PlayerVendorGumps.cs index b3b721462..02dcafd9b 100644 --- a/Projects/UOContent/Gumps/PlayerVendorGumps.cs +++ b/Projects/UOContent/Gumps/PlayerVendorGumps.cs @@ -21,9 +21,13 @@ namespace Server.Gumps AddHtmlLocalized(125, 20, 250, 24, 1019070); // You have agreed to purchase: if (!string.IsNullOrEmpty(vi.Description)) + { AddLabel(125, 45, 0, vi.Description); + } else + { AddHtmlLocalized(125, 45, 250, 24, 1019072); // an item without a description + } AddHtmlLocalized(125, 70, 250, 24, 1019071); // for the amount of: AddLabel(125, 95, 0, vi.Price.ToString()); @@ -40,7 +44,9 @@ namespace Server.Gumps var from = state.Mobile; if (!m_Vendor.CanInteractWith(from, false)) + { return; + } if (m_Vendor.IsOwner(from)) { @@ -61,7 +67,9 @@ namespace Server.Gumps var totalGold = 0; if (from.Backpack != null) - totalGold += from.Backpack.GetAmount(typeof(Gold)); + { + totalGold += @from.Backpack.GetAmount(typeof(Gold)); + } totalGold += Banker.GetBalance(from); @@ -78,10 +86,14 @@ namespace Server.Gumps var leftPrice = m_VI.Price; if (from.Backpack != null) - leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice); + { + leftPrice -= @from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice); + } if (leftPrice > 0) - Banker.Withdraw(from, leftPrice); + { + Banker.Withdraw(@from, leftPrice); + } m_Vendor.HoldGold += m_VI.Price; @@ -138,7 +150,9 @@ namespace Server.Gumps var from = state.Mobile; if (!m_Vendor.CanInteractWith(from, true)) + { return; + } switch (info.ButtonID) { @@ -245,10 +259,14 @@ namespace Server.Gumps var from = sender.Mobile; if (info.ButtonID == 1 || info.ButtonID == 2) // See goods or Customize - m_Vendor.CheckTeleport(from); + { + m_Vendor.CheckTeleport(@from); + } if (!m_Vendor.CanInteractWith(from, true)) + { return; + } switch (info.ButtonID) { @@ -517,7 +535,9 @@ namespace Server.Gumps AddHtmlLocalized(x, y, 100, entry.LongText ? 36 : 18, entry.LocNumber); if (entry.ArtNumber != 0) + { AddItem(x + 20, y + 25, entry.ArtNumber); + } AddRadio(x, y + (entry.LongText ? 40 : 20), 210, 211, false, (c << 8) + i); } @@ -536,15 +556,21 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { if (m_Vendor.Deleted) + { return; + } var from = state.Mobile; if (m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith(from, true)) + { return; + } if (m_Vendor is PlayerBarkeeper barkeeper && !barkeeper.IsOwner(from)) + { return; + } if (info.ButtonID == 0) { @@ -577,8 +603,12 @@ namespace Server.Gumps var type = checkitem.GetType(); for (var j = 0; item == null && j < Categories[cat].Entries.Length; ++j) + { if (type == Categories[cat].Entries[j].Type) + { item = checkitem; + } + } } item?.Delete(); @@ -619,7 +649,9 @@ namespace Server.Gumps item.Layer = Categories[cat].Layer; if (!m_Vendor.EquipItem(item)) + { item.Delete(); + } } } @@ -656,12 +688,18 @@ namespace Server.Gumps var type = checkitem.GetType(); for (var j = 0; item == null && j < category.Entries.Length; ++j) + { if (type == category.Entries[j].Type) + { item = checkitem; + } + } } if (item != null) - new PVHuePicker(item, m_Vendor, from).SendTo(state); + { + new PVHuePicker(item, m_Vendor, @from).SendTo(state); + } } } } @@ -693,8 +731,12 @@ namespace Server.Gumps var type = checkitem.GetType(); for (var j = 0; item == null && j < category.Entries.Length; ++j) + { if (type == category.Entries[j].Type) + { item = checkitem; + } + } } item?.Delete(); @@ -739,7 +781,9 @@ namespace Server.Gumps public Item Create() { if (Type == null) + { return null; + } Item i = null; @@ -747,7 +791,9 @@ namespace Server.Gumps { var ctor = Type.GetConstructor(Array.Empty()); if (ctor != null) + { i = ctor.Invoke(null) as Item; + } } catch { @@ -793,13 +839,19 @@ namespace Server.Gumps public override void OnResponse(int hue) { if (m_Item.Deleted) + { return; + } if (m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith(m_Mob, true)) + { return; + } if (m_Vendor is PlayerBarkeeper barkeeper && !barkeeper.IsOwner(m_Mob)) + { return; + } m_Item.Hue = hue; m_Mob.SendGump(new PlayerVendorCustomizeGump(m_Vendor, m_Mob)); @@ -822,18 +874,28 @@ namespace Server.Gumps public override void OnResponse(int hue) { if (m_Vendor.Deleted) + { return; + } if (m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith(m_Mob, true)) + { return; + } if (m_Vendor is PlayerBarkeeper barkeeper && !barkeeper.IsOwner(m_Mob)) + { return; + } if (m_FacialHair) + { m_Vendor.FacialHairHue = hue; + } else + { m_Vendor.HairHue = hue; + } m_Mob.SendGump(new PlayerVendorCustomizeGump(m_Vendor, m_Mob)); } @@ -939,7 +1001,9 @@ namespace Server.Gumps var from = sender.Mobile; if (!m_Vendor.CanInteractWith(from, true)) + { return; + } switch (info.ButtonID) { @@ -981,9 +1045,13 @@ namespace Server.Gumps case 3: // Color hair { if (m_Vendor.HairItemID > 0) - new PVHuePicker(m_Vendor, false, from).SendTo(from.NetState); + { + new PVHuePicker(m_Vendor, false, @from).SendTo(@from.NetState); + } else - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + { + @from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + } break; } @@ -998,9 +1066,13 @@ namespace Server.Gumps case 5: // Color beard { if (m_Vendor.FacialHairItemID > 0) - new PVHuePicker(m_Vendor, true, from).SendTo(from.NetState); + { + new PVHuePicker(m_Vendor, true, @from).SendTo(@from.NetState); + } else - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + { + @from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + } break; } @@ -1013,7 +1085,9 @@ namespace Server.Gumps var index = info.ButtonID & 0xFF; if (index >= m_HairStyles.Length) + { return; + } var hairStyle = m_HairStyles[index]; @@ -1031,12 +1105,16 @@ namespace Server.Gumps else if ((info.ButtonID & 0x200) != 0) // Beard style selected { if (m_Vendor.Female) + { return; + } var index = info.ButtonID & 0xFF; if (index >= m_BeardStyles.Length) + { return; + } var beardStyle = m_BeardStyles[index]; @@ -1086,12 +1164,18 @@ namespace Server.Gumps public override void OnResponse(int hue) { if (!m_Vendor.CanInteractWith(m_From, true)) + { return; + } if (m_FacialHair) + { m_Vendor.FacialHairHue = hue; + } else + { m_Vendor.HairHue = hue; + } m_From.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); } diff --git a/Projects/UOContent/Gumps/PolymorphGump.cs b/Projects/UOContent/Gumps/PolymorphGump.cs index 04388a4bf..0649d3a80 100644 --- a/Projects/UOContent/Gumps/PolymorphGump.cs +++ b/Projects/UOContent/Gumps/PolymorphGump.cs @@ -130,11 +130,13 @@ namespace Server.Gumps var ent = cnum >> 8; if (cat >= 0 && cat < Categories.Length) + { if (ent >= 0 && ent < Categories[cat].Entries.Length) { Spell spell = new PolymorphSpell(m_Caster, m_Scroll, Categories[cat].Entries[ent].BodyID); spell.Cast(); } + } } } @@ -234,7 +236,9 @@ namespace Server.Gumps var idx = info.ButtonID - 1; if (idx < 0 || idx >= m_Entries.Length) + { return; + } Spell spell = new PolymorphSpell(m_Caster, m_Scroll, m_Entries[idx].BodyID); spell.Cast(); diff --git a/Projects/UOContent/Gumps/Props/SetBodyGump.cs b/Projects/UOContent/Gumps/Props/SetBodyGump.cs index 3f0c85c0c..bad8f90fa 100644 --- a/Projects/UOContent/Gumps/Props/SetBodyGump.cs +++ b/Projects/UOContent/Gumps/Props/SetBodyGump.cs @@ -91,10 +91,14 @@ namespace Server.Gumps } if (ourPage > 0) + { AddButton(480, 12, 0x15E3, 0x15E7, 5); + } if ((ourPage + 1) * 12 < ourList.Count) + { AddButton(497, 12, 0x15E1, 0x15E5, 6); + } } } @@ -121,7 +125,9 @@ namespace Server.Gumps else if (index >= 0 && index < 4) { if (m_Monster == null) + { LoadLists(); + } ModelBodyType type; List list; @@ -236,7 +242,9 @@ namespace Server.Gumps var bodyID = oldEntry.Body.BodyID; if (((Body)bodyID).IsEmpty) + { continue; + } List list; @@ -260,7 +268,9 @@ namespace Server.Gumps var itemID = ShrinkTable.Lookup(bodyID, -1); if (itemID != -1) + { list.Add(new InternalEntry(bodyID, itemID, oldEntry.Name)); + } } m_Monster.Sort(); @@ -299,11 +309,13 @@ namespace Server.Gumps DisplayName = name.ToLower(); for (var i = 0; i < m_GroupNames.Length; ++i) + { if (DisplayName.StartsWith(m_GroupNames[i])) { DisplayName = DisplayName.Substring(m_GroupNames[i].Length); break; } + } DisplayName = DisplayName.Replace('_', ' '); } @@ -319,7 +331,9 @@ namespace Server.Gumps public int CompareTo(InternalEntry comp) { if (Name == null && comp.Name == null) + { return 0; + } var v = Name?.CompareTo(comp.Name) ?? 1; diff --git a/Projects/UOContent/Gumps/Props/SetCustomEnumGump.cs b/Projects/UOContent/Gumps/Props/SetCustomEnumGump.cs index 997a20b06..d2e304155 100644 --- a/Projects/UOContent/Gumps/Props/SetCustomEnumGump.cs +++ b/Projects/UOContent/Gumps/Props/SetCustomEnumGump.cs @@ -21,6 +21,7 @@ namespace Server.Gumps var index = relayInfo.ButtonID - 1; if (index >= 0 && index < m_Names.Length) + { try { var info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) }); @@ -28,6 +29,7 @@ namespace Server.Gumps string result; if (info != null) + { result = Properties.SetDirect( m_Mobile, m_Object, @@ -37,7 +39,9 @@ namespace Server.Gumps info.Invoke(null, new object[] { m_Names[index] }), true ); + } else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum))) + { result = Properties.SetDirect( m_Mobile, m_Object, @@ -47,18 +51,24 @@ namespace Server.Gumps Enum.Parse(m_Property.PropertyType, m_Names[index], false), true ); + } else + { result = ""; + } m_Mobile.SendMessage(result); if (result == "Property has been set.") + { PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); + } } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } diff --git a/Projects/UOContent/Gumps/Props/SetGump.cs b/Projects/UOContent/Gumps/Props/SetGump.cs index 58bba761c..1e82952a9 100644 --- a/Projects/UOContent/Gumps/Props/SetGump.cs +++ b/Projects/UOContent/Gumps/Props/SetGump.cs @@ -109,7 +109,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -119,7 +121,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); @@ -133,7 +137,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); } @@ -148,7 +154,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); } @@ -163,7 +171,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4); } @@ -239,6 +249,7 @@ namespace Server.Gumps } if (shouldSet) + { try { CommandLogging.LogChangeProperty( @@ -254,9 +265,12 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } if (shouldSend) + { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + } } private class InternalPicker : HuePicker diff --git a/Projects/UOContent/Gumps/Props/SetListOptionGump.cs b/Projects/UOContent/Gumps/Props/SetListOptionGump.cs index b92588d59..389cd58d9 100644 --- a/Projects/UOContent/Gumps/Props/SetListOptionGump.cs +++ b/Projects/UOContent/Gumps/Props/SetListOptionGump.cs @@ -90,7 +90,9 @@ namespace Server.Gumps var count = names.Length - start; if (count > EntryCount) + { count = EntryCount; + } var totalHeight = OffsetSize + (count + 2) * (EntryHeight + OffsetSize); var backHeight = BorderSize + totalHeight + BorderSize; @@ -125,12 +127,15 @@ namespace Server.Gumps ); if (PrevLabel) + { AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); + } } x += PrevWidth + OffsetSize; if (!OldStyle) + { AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, @@ -138,11 +143,14 @@ namespace Server.Gumps EntryHeight, HeaderGumpID ); + } x += emptyWidth + OffsetSize; if (!OldStyle) + { AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID); + } if (page < pages) { @@ -157,13 +165,17 @@ namespace Server.Gumps ); if (NextLabel) + { AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next"); + } } AddRect(0, prop.Name, 0); for (var i = 0; i < count; ++i) + { AddRect(i + 1, names[index], ++index); + } } } @@ -178,10 +190,14 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } if (button != 0) + { AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button); + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -189,6 +205,7 @@ namespace Server.Gumps var index = info.ButtonID - 1; if (index >= 0 && index < m_Values.Length) + { try { var toSet = m_Values[index]; @@ -206,12 +223,15 @@ namespace Server.Gumps m_Mobile.SendMessage(result); if (result == "Property has been set.") + { PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); + } } catch { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } diff --git a/Projects/UOContent/Gumps/Props/SetObjectGump.cs b/Projects/UOContent/Gumps/Props/SetObjectGump.cs index 214cbfd99..8bd85b7b1 100644 --- a/Projects/UOContent/Gumps/Props/SetObjectGump.cs +++ b/Projects/UOContent/Gumps/Props/SetObjectGump.cs @@ -93,7 +93,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -103,7 +105,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); @@ -115,7 +119,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); @@ -127,7 +133,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); @@ -139,7 +147,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4); } @@ -208,21 +218,31 @@ namespace Server.Gumps var obj = m_Property.GetValue(m_Object, null); if (obj == null) + { m_Mobile.SendMessage("The property is null and so you cannot view its properties."); + } else if (!BaseCommand.IsAccessible(m_Mobile, obj)) + { m_Mobile.SendMessage("You may not view their properties."); + } else + { viewProps = obj; + } break; } } if (shouldSend) + { m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); + } if (viewProps != null) + { m_Mobile.SendGump(new PropertiesGump(m_Mobile, viewProps)); + } } private class InternalPrompt : Prompt @@ -263,13 +283,18 @@ namespace Server.Gumps var toSet = World.FindEntity(serial); if (toSet == null) + { m_Mobile.SendMessage("No object with that serial was found."); + } else if (!m_Type.IsInstanceOfType(toSet)) + { m_Mobile.SendMessage( "The object with that serial could not be assigned to a property of type : {0}", m_Type.Name ); + } else + { try { CommandLogging.LogChangeProperty( @@ -285,6 +310,7 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } } catch { diff --git a/Projects/UOContent/Gumps/Props/SetObjectTarget.cs b/Projects/UOContent/Gumps/Props/SetObjectTarget.cs index c7666eef3..07b7282a6 100644 --- a/Projects/UOContent/Gumps/Props/SetObjectTarget.cs +++ b/Projects/UOContent/Gumps/Props/SetObjectTarget.cs @@ -36,10 +36,14 @@ namespace Server.Gumps try { if (m_Type == typeof(Type)) + { targeted = targeted.GetType(); + } else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) && targeted is AddonComponent addonComponent) + { targeted = addonComponent.Addon; + } if (m_Type.IsInstanceOfType(targeted)) { @@ -61,9 +65,13 @@ namespace Server.Gumps protected override void OnTargetFinish(Mobile from) { if (m_Type == typeof(Type)) - from.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + { + @from.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + } else - from.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); + { + @from.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List)); + } } } } diff --git a/Projects/UOContent/Gumps/Props/SetPoint2DGump.cs b/Projects/UOContent/Gumps/Props/SetPoint2DGump.cs index 95cd0ecb6..61ec8efce 100644 --- a/Projects/UOContent/Gumps/Props/SetPoint2DGump.cs +++ b/Projects/UOContent/Gumps/Props/SetPoint2DGump.cs @@ -90,7 +90,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -100,7 +102,10 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); x = BorderSize + OffsetSize; @@ -111,7 +116,10 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); x = BorderSize + OffsetSize; @@ -128,7 +136,10 @@ namespace Server.Gumps x += CoordWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); } @@ -182,6 +193,7 @@ namespace Server.Gumps } if (shouldSet) + { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString()); @@ -192,9 +204,12 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } if (shouldSend) + { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + } } private class InternalTarget : Target @@ -222,6 +237,7 @@ namespace Server.Gumps protected override void OnTarget(Mobile from, object targeted) { if (targeted is IPoint3D p) + { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString()); @@ -232,6 +248,7 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } } protected override void OnTargetFinish(Mobile from) diff --git a/Projects/UOContent/Gumps/Props/SetPoint3DGump.cs b/Projects/UOContent/Gumps/Props/SetPoint3DGump.cs index 75eee4232..8ab7733d3 100644 --- a/Projects/UOContent/Gumps/Props/SetPoint3DGump.cs +++ b/Projects/UOContent/Gumps/Props/SetPoint3DGump.cs @@ -90,7 +90,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -100,7 +102,10 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); x = BorderSize + OffsetSize; @@ -111,7 +116,10 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); x = BorderSize + OffsetSize; @@ -133,7 +141,10 @@ namespace Server.Gumps x += CoordWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); } @@ -189,6 +200,7 @@ namespace Server.Gumps } if (shouldSet) + { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString()); @@ -199,9 +211,12 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } if (shouldSend) + { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + } } private class InternalTarget : Target @@ -229,6 +244,7 @@ namespace Server.Gumps protected override void OnTarget(Mobile from, object targeted) { if (targeted is IPoint3D p) + { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point3D(p).ToString()); @@ -239,6 +255,7 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } } protected override void OnTargetFinish(Mobile from) diff --git a/Projects/UOContent/Gumps/Props/SetTimeSpanGump.cs b/Projects/UOContent/Gumps/Props/SetTimeSpanGump.cs index 628372dde..148a29f58 100644 --- a/Projects/UOContent/Gumps/Props/SetTimeSpanGump.cs +++ b/Projects/UOContent/Gumps/Props/SetTimeSpanGump.cs @@ -99,15 +99,21 @@ namespace Server.Gumps AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str); if (text != -1) + { AddTextEntry(x + 16 + TextOffsetX, y, EntryWidth - TextOffsetX - 16, EntryHeight, TextHue, text, ""); + } x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } if (button != 0) + { AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button); + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -133,9 +139,13 @@ namespace Server.Gumps { var successfulParse = false; if (h != null && m != null && s != null) + { successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet); + } else + { toSet = TimeSpan.Zero; + } shouldSet = shouldSend = successfulParse; @@ -144,6 +154,7 @@ namespace Server.Gumps case 3: // From H { if (h != null) + { try { toSet = TimeSpan.FromHours(Utility.ToDouble(h.Text)); @@ -156,6 +167,7 @@ namespace Server.Gumps { // ignored } + } toSet = TimeSpan.Zero; shouldSet = false; @@ -166,6 +178,7 @@ namespace Server.Gumps case 4: // From M { if (m != null) + { try { toSet = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); @@ -178,6 +191,7 @@ namespace Server.Gumps { // ignored } + } toSet = TimeSpan.Zero; shouldSet = false; @@ -188,6 +202,7 @@ namespace Server.Gumps case 5: // From S { if (s != null) + { try { toSet = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); @@ -200,6 +215,7 @@ namespace Server.Gumps { // ignored } + } toSet = TimeSpan.Zero; shouldSet = false; @@ -218,6 +234,7 @@ namespace Server.Gumps } if (shouldSet) + { try { CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString()); @@ -228,9 +245,12 @@ namespace Server.Gumps { m_Mobile.SendMessage("An exception was caught. The property may not have changed."); } + } if (shouldSend) + { m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + } } } } diff --git a/Projects/UOContent/Gumps/ReclaimVendorGump.cs b/Projects/UOContent/Gumps/ReclaimVendorGump.cs index bc332e76c..938a155a1 100644 --- a/Projects/UOContent/Gumps/ReclaimVendorGump.cs +++ b/Projects/UOContent/Gumps/ReclaimVendorGump.cs @@ -39,17 +39,23 @@ namespace Server.Gumps if (info.ButtonID == 0 || !m_House.IsActive || !m_House.IsInside(from) || !m_House.IsOwner(from) || !from.CheckAlive()) + { return; + } var index = info.ButtonID - 1; if (index < 0 || index >= m_Vendors.Count) + { return; + } var mob = m_Vendors[index]; if (!m_House.InternalizedVendors.Contains(mob)) + { return; + } if (mob.Deleted) { diff --git a/Projects/UOContent/Gumps/ReportMurderer.cs b/Projects/UOContent/Gumps/ReportMurderer.cs index 23f321162..aedac2575 100644 --- a/Projects/UOContent/Gumps/ReportMurderer.cs +++ b/Projects/UOContent/Gumps/ReportMurderer.cs @@ -34,22 +34,30 @@ namespace Server.Gumps foreach (var ai in m.Aggressors) { if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported) + { if (!Core.SE || !((PlayerMobile)m).RecentlyReported.Contains(ai.Attacker)) { killers.Add(ai.Attacker); ai.Reported = true; ai.CanReportMurder = false; } + } if (ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker)) + { toGive.Add(ai.Attacker); + } } foreach (var ai in m.Aggressed) + { if (ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender)) + { toGive.Add(ai.Defender); + } + } foreach (var g in toGive) { @@ -63,19 +71,27 @@ namespace Server.Gumps var karmaAward = 0; if (innocent) + { karmaAward = ourKarma > -2500 ? -850 : -110 - m.Karma / 100; + } else if (criminal) + { karmaAward = 50; + } Titles.AwardFame(g, fameAward, false); Titles.AwardKarma(g, karmaAward, true); } if (m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild) + { return; + } if (killers.Count > 0) + { new GumpTimer(m, killers).Start(); + } } private void BuildGump() @@ -110,7 +126,9 @@ namespace Server.Gumps public static void ReportedListExpiry_Callback(PlayerMobile from, Mobile killer) { if (from.RecentlyReported.Contains(killer)) - from.RecentlyReported.Remove(killer); + { + @from.RecentlyReported.Remove(killer); + } } public override void OnResponse(NetState state, RelayInfo info) @@ -139,9 +157,13 @@ namespace Server.Gumps pk.SendLocalizedMessage(1049067); // You have been reported for murder! if (pk.Kills == 5) + { pk.SendLocalizedMessage(502134); // You are now known as a murderer! + } else if (Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild) + { pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild. + } } } @@ -155,7 +177,9 @@ namespace Server.Gumps m_Idx++; if (m_Idx < m_Killers.Count) - from.SendGump(new ReportMurdererGump(from, m_Killers, m_Idx)); + { + @from.SendGump(new ReportMurdererGump(@from, m_Killers, m_Idx)); + } } private class GumpTimer : Timer diff --git a/Projects/UOContent/Gumps/ResurrectGump.cs b/Projects/UOContent/Gumps/ResurrectGump.cs index 0e42be518..bfd5ef061 100644 --- a/Projects/UOContent/Gumps/ResurrectGump.cs +++ b/Projects/UOContent/Gumps/ResurrectGump.cs @@ -140,7 +140,9 @@ namespace Server.Gumps from.CloseGump(); if (info.ButtonID != 1 && info.ButtonID != 2) + { return; + } if (from.Map?.CanFit(from.Location, 16, false, false) != true) { @@ -212,7 +214,9 @@ namespace Server.Gumps var item = items[i]; if (item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable) + { pack.DropItem(item); + } } } } @@ -229,24 +233,42 @@ namespace Server.Gumps var loss = (100.0 - (4.0 + from.ShortTermMurders / 5.0)) / 100.0; // 5 to 15% loss if (loss < 0.85) + { loss = 0.85; + } else if (loss > 0.95) + { loss = 0.95; + } if (from.RawStr * loss > 10) - from.RawStr = (int)(from.RawStr * loss); + { + @from.RawStr = (int)(@from.RawStr * loss); + } + if (from.RawInt * loss > 10) - from.RawInt = (int)(from.RawInt * loss); + { + @from.RawInt = (int)(@from.RawInt * loss); + } + if (from.RawDex * loss > 10) - from.RawDex = (int)(from.RawDex * loss); + { + @from.RawDex = (int)(@from.RawDex * loss); + } for (var s = 0; s < from.Skills.Length; s++) - if (from.Skills[s].Base * loss > 35) - from.Skills[s].Base *= loss; + { + if (@from.Skills[s].Base * loss > 35) + { + @from.Skills[s].Base *= loss; + } + } } if (from.Alive && m_HitsScalar > 0) - from.Hits = (int)(from.HitsMax * m_HitsScalar); + { + @from.Hits = (int)(@from.HitsMax * m_HitsScalar); + } } } } diff --git a/Projects/UOContent/Gumps/RewardGump.cs b/Projects/UOContent/Gumps/RewardGump.cs index e47b1ba7a..7c26a804b 100644 --- a/Projects/UOContent/Gumps/RewardGump.cs +++ b/Projects/UOContent/Gumps/RewardGump.cs @@ -40,9 +40,13 @@ namespace Server.Gumps AddImageTiled(70, 55, 230, 2, 0x23C5); if (Title.String != null) + { AddHtml(70, 35, 270, 20, Title.String); + } else if (Title.Number != 0) + { AddHtmlLocalized(70, 35, 270, 20, Title.Number, 1); + } AddHtmlLocalized(50, 65, 150, 20, 1072843, 1); // Your Reward Points: AddLabel(230, 65, 0x64, Points.ToString()); @@ -78,7 +82,9 @@ namespace Server.Gumps var half = offset + height / 2; if (available) + { AddButton(35, half - 6, 0x837, 0x838, 100 + i); + } AddItem( 83 - bounds.Width / 2 - bounds.X, @@ -88,16 +94,22 @@ namespace Server.Gumps ); if (entry.Tooltip != 0) + { AddTooltip(entry.Tooltip); + } AddLabel(133, half - 10, available ? 0x64 : 0x21, entry.Price.ToString()); if (entry.Description != null) { if (entry.Description.String != null) + { AddHtml(190, offset, 114, height, entry.Description.String); + } else if (entry.Description.Number != 0) + { AddHtmlLocalized(190, offset, 114, height, entry.Description.Number, 1); + } } offset += height + 10; @@ -117,7 +129,9 @@ namespace Server.Gumps var choice = info.ButtonID; if (choice == 0) + { return; // Close + } choice -= 100; @@ -126,7 +140,9 @@ namespace Server.Gumps var entry = Rewards[choice]; if (entry.Price <= Points) + { sender.Mobile.SendGump(new RewardConfirmGump(this, choice, entry)); + } } } } @@ -168,7 +184,9 @@ namespace Server.Gumps AddItem(140, 120, entry.ItemID, entry.Hue); if (entry.Tooltip != 0) + { AddTooltip(entry.Tooltip); + } AddHtmlLocalized(25, 22, 200, 20, 1074974, 0x7D00); // Confirm Selection AddImage(25, 40, 0xBBF); @@ -183,9 +201,13 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 7 && info.IsSwitched(1)) + { m_Parent.OnPicked(sender.Mobile, m_Index); + } else + { sender.Mobile.SendGump(new RewardGump(m_Parent.Title, m_Parent.Rewards, m_Parent.Points, m_Parent.OnPicked)); + } } } } diff --git a/Projects/UOContent/Gumps/RunebookGump.cs b/Projects/UOContent/Gumps/RunebookGump.cs index 38c0ad257..687043238 100644 --- a/Projects/UOContent/Gumps/RunebookGump.cs +++ b/Projects/UOContent/Gumps/RunebookGump.cs @@ -24,10 +24,14 @@ namespace Server.Gumps AddButton(125, 14, 2205, 2205, 0, GumpButtonType.Page, 1 + page); if (page < 7) + { AddButton(393, 14, 2206, 2206, 0, GumpButtonType.Page, 3 + page); + } for (var half = 0; half < 2; ++half) + { AddDetails(page * 2 + half, half); + } } } @@ -36,15 +40,29 @@ namespace Server.Gumps public int GetMapHue(Map map) { if (map == Map.Trammel) + { return 10; + } + if (map == Map.Felucca) + { return 81; + } + if (map == Map.Ilshenar) + { return 1102; + } + if (map == Map.Malas) + { return 1102; + } + if (map == Map.Tokuno) + { return 1154; + } return 0; } @@ -52,7 +70,9 @@ namespace Server.Gumps public string GetName(string name) { if (name == null || (name = name.Trim()).Length <= 0) + { return "(indescript)"; + } return name; } @@ -73,18 +93,24 @@ namespace Server.Gumps xOffset += 20; for (var j = 0; j < 6; ++j, xOffset += 15) + { AddImage(xOffset, 50, 58); + } AddImage(xOffset - 5, 50, 59); } // First four page buttons for (int i = 0, xOffset = 130, gumpID = 2225; i < 4; ++i, xOffset += 35, ++gumpID) + { AddButton(xOffset, 187, gumpID, gumpID, 0, GumpButtonType.Page, 2 + i); + } // Next four page buttons for (int i = 0, xOffset = 300, gumpID = 2229; i < 4; ++i, xOffset += 35, ++gumpID) + { AddButton(xOffset, 187, gumpID, gumpID, 0, GumpButtonType.Page, 6 + i); + } // Charges AddHtmlLocalized(140, 40, 80, 18, 1011296); // Charges: @@ -288,7 +314,9 @@ namespace Server.Gumps from.CloseGump(); if (!Core.ML) - from.SendGump(new RunebookGump(from, Book)); + { + @from.SendGump(new RunebookGump(@from, Book)); + } } else { @@ -446,7 +474,9 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (m_Book.Deleted || !from.InRange(m_Book.GetWorldLocation(), Core.ML ? 3 : 1)) + { return; + } if (m_Book.CheckAccess(from)) { diff --git a/Projects/UOContent/Gumps/SkillsGump.cs b/Projects/UOContent/Gumps/SkillsGump.cs index 4751e853e..075f97754 100644 --- a/Projects/UOContent/Gumps/SkillsGump.cs +++ b/Projects/UOContent/Gumps/SkillsGump.cs @@ -86,7 +86,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -96,7 +98,9 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); } @@ -104,6 +108,7 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { try { if (m_From.AccessLevel >= AccessLevel.GameMaster) @@ -128,8 +133,11 @@ namespace Server.Gumps m_From.SendMessage("Bad format. ###.# expected."); m_From.SendGump(new EditSkillGump(m_From, m_Target, m_Skill, m_Selected)); } + } else + { m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); + } } } @@ -214,7 +222,9 @@ namespace Server.Gumps var count = m_Groups.Length; if (selected != null) + { count += selected.Skills.Length; + } var totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1); @@ -235,13 +245,18 @@ namespace Server.Gumps var emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 - (OldStyle ? SetWidth + OffsetSize : 0); if (OldStyle) + { AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); + } else + { AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + } x += PrevWidth + OffsetSize; if (!OldStyle) + { AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, @@ -249,11 +264,14 @@ namespace Server.Gumps EntryHeight, HeaderGumpID ); + } x += emptyWidth + OffsetSize; if (!OldStyle) + { AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID); + } for (var i = 0; i < m_Groups.Length; ++i) { @@ -265,9 +283,13 @@ namespace Server.Gumps AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); if (group == selected) + { AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E2, 0x15E6, GetButtonID(0, i)); + } else + { AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(0, i)); + } x += PrevWidth + OffsetSize; @@ -280,7 +302,9 @@ namespace Server.Gumps x += OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } if (group == selected) { @@ -318,7 +342,9 @@ namespace Server.Gumps x += OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } if (sk != null) { @@ -401,9 +427,13 @@ namespace Server.Gumps var newSelection = m_Groups[index]; if (m_Selected != newSelection) + { m_From.SendGump(new SkillsGump(m_From, m_Target, newSelection)); + } else + { m_From.SendGump(new SkillsGump(m_From, m_Target)); + } } break; @@ -443,6 +473,7 @@ namespace Server.Gumps if (sk != null) { if (m_From.AccessLevel >= AccessLevel.GameMaster) + { switch (sk.Lock) { case SkillLock.Up: @@ -458,8 +489,11 @@ namespace Server.Gumps sk.Update(); break; } + } else + { m_From.SendMessage("You may not change that."); + } m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); } diff --git a/Projects/UOContent/Gumps/TithingGump.cs b/Projects/UOContent/Gumps/TithingGump.cs index 449011fc1..c6d238cb6 100644 --- a/Projects/UOContent/Gumps/TithingGump.cs +++ b/Projects/UOContent/Gumps/TithingGump.cs @@ -90,7 +90,9 @@ namespace Server.Gumps m_Offer = Math.Clamp(m_Offer, 0, totalGold); if (m_From.TithingPoints + m_Offer > 100000) // TODO: What's the maximum? + { m_Offer = 100000 - m_From.TithingPoints; + } if (m_Offer <= 0) { diff --git a/Projects/UOContent/Gumps/VendorInventoryGump.cs b/Projects/UOContent/Gumps/VendorInventoryGump.cs index ff838174c..f6944a4c0 100644 --- a/Projects/UOContent/Gumps/VendorInventoryGump.cs +++ b/Projects/UOContent/Gumps/VendorInventoryGump.cs @@ -32,7 +32,9 @@ namespace Server.Gumps var y = 40 + 20 * i; if (inventory.Owner == from) + { AddButton(10, y, 0xFA5, 0xFA7, i + 1); + } AddLabel(45, y, 0x481, $"{inventory.ShopName} ({inventory.VendorName})"); @@ -47,13 +49,17 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0) + { return; + } var from = sender.Mobile; var sign = m_House.Sign; if (m_House.Deleted || sign?.Deleted != false || !from.CheckAlive()) + { return; + } if (from.Map != sign.Map || !from.InRange(sign, 5)) { @@ -63,12 +69,16 @@ namespace Server.Gumps var index = info.ButtonID - 1; if (index < 0 || index >= m_Inventories.Count) + { return; + } var inventory = m_Inventories[index]; if (inventory.Owner != from || !m_House.VendorInventories.Contains(inventory)) + { return; + } var totalItems = 0; var givenToBackpack = 0; diff --git a/Projects/UOContent/Gumps/VendorRentalGumps.cs b/Projects/UOContent/Gumps/VendorRentalGumps.cs index 3538c901c..ef86d0886 100644 --- a/Projects/UOContent/Gumps/VendorRentalGumps.cs +++ b/Projects/UOContent/Gumps/VendorRentalGumps.cs @@ -15,7 +15,9 @@ namespace Server.Gumps ) : base(100, 100) { if (type == GumpType.Offer) + { Closable = false; + } AddPage(0); @@ -44,12 +46,18 @@ namespace Server.Gumps } if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + { AddButton(30, 96, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 2); + } + AddHtmlLocalized(50, 95, 150, 20, 1062354, 0x1); // Contract Length AddHtmlLocalized(230, 95, 270, 20, duration.Name, 0x1); if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + { AddButton(30, 116, 0x15E1, 0x15E5, 1); + } + AddHtmlLocalized(50, 115, 150, 20, 1062356, 0x1); // Price Per Rental AddLabel(230, 115, 0x64, price > 0 ? price.ToString() : "FREE"); @@ -69,12 +77,18 @@ namespace Server.Gumps AddHtmlLocalized(60, 170, 250, 20, 1062355, 0x1); // Renew On Expiration? if (type == GumpType.LockedContract || type == GumpType.UnlockedContract || type == GumpType.VendorLandlord) + { AddButton(30, 192, 0x15E1, 0x15E5, 3); + } + AddHtmlLocalized(85, 190, 250, 20, 1062359, 0x1); // Landlord: AddHtmlLocalized(230, 190, 270, 20, landlordRenew ? 1049717 : 1049718, 0x1); // YES / NO if (type == GumpType.VendorRenter) + { AddButton(30, 212, 0x15E1, 0x15E5, 4); + } + AddHtmlLocalized(85, 210, 250, 20, 1062360, 0x1); // Renter: AddHtmlLocalized(230, 210, 270, 20, renterRenew ? 1049717 : 1049718, 0x1); // YES / NO @@ -102,7 +116,10 @@ namespace Server.Gumps else if (type == GumpType.VendorLandlord || type == GumpType.VendorRenter) { if (type == GumpType.VendorLandlord) + { AddButton(30, 250, 0x15E1, 0x15E1, 6); + } + AddHtmlLocalized(85, 250, 250, 20, 1062499, 0x1); // Renewal Price AddLabel(230, 250, 0x64, renewalPrice.ToString()); @@ -129,14 +146,18 @@ namespace Server.Gumps var from = sender.Mobile; if (!IsValidResponse(from)) + { return; + } if ((info.ButtonID & 0x10) != 0) // Contract duration { var index = info.ButtonID & 0xF; if (index < VendorRentalDuration.Instances.Length) - SetContractDuration(from, VendorRentalDuration.Instances[index]); + { + SetContractDuration(@from, VendorRentalDuration.Instances[index]); + } } else { @@ -276,12 +297,16 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (!m_Contract.IsUsableBy(from, true, true, true, true)) + { return; + } text = text.Trim(); if (!int.TryParse(text, out var price)) + { price = -1; + } if (price < 0) { @@ -303,7 +328,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (m_Contract.IsUsableBy(from, true, true, true, true)) - from.SendGump(new VendorRentalContractGump(m_Contract, from)); + { + @from.SendGump(new VendorRentalContractGump(m_Contract, @from)); + } } } @@ -317,7 +344,9 @@ namespace Server.Gumps protected override void OnTarget(Mobile from, object targeted) { if (!m_Contract.IsUsableBy(from, true, false, true, true)) + { return; + } if (!(targeted is Mobile mob) || !mob.Player || !mob.Alive || mob == from) { @@ -384,7 +413,9 @@ namespace Server.Gumps var house = BaseHouse.FindHouseAt(m_Contract); if (house == null) + { return; + } var price = m_Contract.Price; int goldToGive; @@ -402,13 +433,17 @@ namespace Server.Gumps goldToGive = price - depositedGold; if (depositedGold > 0) + { m_Landlord.SendLocalizedMessage( 1060397, price.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } if (goldToGive > 0) + { m_Landlord.SendLocalizedMessage(500390); // Your bank box is full. + } } else { @@ -525,12 +560,16 @@ namespace Server.Gumps public override void OnResponse(Mobile from, string text) { if (!m_Vendor.CanInteractWith(from, false) || !m_Vendor.IsLandlord(from)) + { return; + } text = text.Trim(); if (!int.TryParse(text, out var price)) + { price = -1; + } if (price < 0) { @@ -554,7 +593,9 @@ namespace Server.Gumps public override void OnCancel(Mobile from) { if (m_Vendor.CanInteractWith(from, false) && m_Vendor.IsLandlord(from)) - from.SendGump(new LandlordVendorRentalGump(m_Vendor)); + { + @from.SendGump(new LandlordVendorRentalGump(m_Vendor)); + } } } } @@ -607,7 +648,9 @@ namespace Server.Gumps if (!m_Vendor.CanInteractWith(from, true) || !m_Vendor.CanInteractWith(m_Landlord, false) || !m_Vendor.IsLandlord(m_Landlord)) + { return; + } if (info.ButtonID == 1) { @@ -621,10 +664,12 @@ namespace Server.Gumps var depositedGold = Banker.DepositUpTo(from, m_RefundAmount); if (depositedGold > 0) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } m_Vendor.HoldGold += m_RefundAmount - depositedGold; diff --git a/Projects/UOContent/Gumps/ViewHousesGump.cs b/Projects/UOContent/Gumps/ViewHousesGump.cs index 2384336ae..cdd019298 100644 --- a/Projects/UOContent/Gumps/ViewHousesGump.cs +++ b/Projects/UOContent/Gumps/ViewHousesGump.cs @@ -36,7 +36,9 @@ namespace Server.Gumps AddHtml(35, 15, 120, 20, Color("House Type", White)); if (list.Count == 0) + { AddHtml(35, 40, 160, 40, Color("There were no houses found for that player.", White)); + } AddImage(190, 17, 0x25EA); AddImage(207, 17, 0x25E6); @@ -48,12 +50,16 @@ namespace Server.Gumps if (i % 15 == 0) { if (page > 0) + { AddButton(207, 17, 0x15E1, 0x15E5, 0, GumpButtonType.Page, page + 1); + } AddPage(++page); if (page > 1) + { AddButton(190, 17, 0x15E3, 0x15E7, 0, GumpButtonType.Page, page - 1); + } } var name = FindHouseName(list[i]); @@ -61,9 +67,13 @@ namespace Server.Gumps AddHtml(15, 40 + i % 15 * 20, 20, 20, Color($"{i + 1}.", White)); if (name.Number > 0) + { AddHtmlLocalized(35, 40 + i % 15 * 20, 160, 20, name, White16); + } else + { AddHtml(35, 40 + i % 15 * 20, 160, 20, Color(name, White)); + } AddButton(198, 39 + i % 15 * 20, 4005, 4007, i + 1); } @@ -91,9 +101,13 @@ namespace Server.Gumps ); if (valid) + { location = $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}° {xMins}'{(xEast ? "E" : "W")}"; + } else + { location = "unknown"; + } AddHtml(10, 15, 220, 20, Color(Center("House Properties"), White)); @@ -158,7 +172,9 @@ namespace Server.Gumps public static void ViewHouses_OnTarget(Mobile from, object targeted) { if (targeted is Mobile mobile) - from.SendGump(new ViewHousesGump(from, GetHouses(mobile), null)); + { + @from.SendGump(new ViewHousesGump(@from, GetHouses(mobile), null)); + } } public static List GetHouses(Mobile owner) @@ -166,15 +182,21 @@ namespace Server.Gumps var list = new List(); if (!(owner.Account is Account acct)) + { list.AddRange(BaseHouse.GetHouses(owner)); + } else + { for (var i = 0; i < acct.Length; ++i) { var mob = acct[i]; if (mob != null) + { list.AddRange(BaseHouse.GetHouses(mob)); + } } + } list.Sort(HouseComparer.Instance); @@ -188,7 +210,9 @@ namespace Server.Gumps var v = info.ButtonID - 1; if (v >= 0 && v < m_List.Count) + { m_From.SendGump(new ViewHousesGump(m_From, m_List, m_List[v])); + } } else if (!m_Selection.Deleted) { @@ -204,7 +228,9 @@ namespace Server.Gumps var map = m_Selection.Map; if (map != null && map != Map.Internal) + { m_From.MoveToWorld(m_Selection.BanLocation, map); + } m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); @@ -217,7 +243,9 @@ namespace Server.Gumps var sign = m_Selection.Sign; if (sign?.Deleted == false) + { sign.OnDoubleClick(m_From); + } break; } @@ -245,20 +273,32 @@ namespace Server.Gumps var entries = HousePlacementEntry.ClassicHouses; for (var i = 0; i < entries.Length; ++i) + { if (entries[i].MultiID == multiID) + { return entries[i].Description; + } + } entries = HousePlacementEntry.TwoStoryFoundations; for (var i = 0; i < entries.Length; ++i) + { if (entries[i].MultiID == multiID) + { return entries[i].Description; + } + } entries = HousePlacementEntry.ThreeStoryFoundations; for (var i = 0; i < entries.Length; ++i) + { if (entries[i].MultiID == multiID) + { return entries[i].Description; + } + } return house.GetType().Name; } diff --git a/Projects/UOContent/Gumps/WarningGump.cs b/Projects/UOContent/Gumps/WarningGump.cs index 8ecd0b909..8b3acfd41 100644 --- a/Projects/UOContent/Gumps/WarningGump.cs +++ b/Projects/UOContent/Gumps/WarningGump.cs @@ -29,8 +29,11 @@ namespace Server.Gumps AddAlphaRegion(10, 40, width - 20, height - 80); if (content is int i) + { AddHtmlLocalized(10, 40, width - 20, height - 80, i, contentColor, false, true); + } else if (content is string) + { AddHtml( 10, 40, @@ -40,6 +43,7 @@ namespace Server.Gumps false, true ); + } AddImageTiled(10, height - 30, width - 20, 20, 2624); AddAlphaRegion(10, height - 30, width - 20, 20); @@ -57,12 +61,18 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { if (m_Callback == null) + { return; + } if (info.ButtonID == 1) + { m_Callback(true); + } else + { m_Callback.Invoke(false); + } } } } diff --git a/Projects/UOContent/Gumps/WhoGump.cs b/Projects/UOContent/Gumps/WhoGump.cs index 71e237f3b..f1cb8ab46 100644 --- a/Projects/UOContent/Gumps/WhoGump.cs +++ b/Projects/UOContent/Gumps/WhoGump.cs @@ -106,7 +106,9 @@ namespace Server.Gumps m is PlayerMobile mobile && mobile.VisibilityList.Contains(owner))) { if (filter != null && !(m.Name?.ToLower().IndexOf(filter) >= 0)) + { continue; + } list.Add(m); } @@ -142,6 +144,7 @@ namespace Server.Gumps var emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 - (OldStyle ? SetWidth + OffsetSize : 0); if (!OldStyle) + { AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, @@ -149,6 +152,7 @@ namespace Server.Gumps EntryHeight, EntryGumpID ); + } AddLabel( x + TextOffsetX, @@ -160,29 +164,39 @@ namespace Server.Gumps x += emptyWidth + OffsetSize; if (OldStyle) + { AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); + } else + { AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); + } if (page > 0) { AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); if (PrevLabel) + { AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); + } } x += PrevWidth + OffsetSize; if (!OldStyle) + { AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID); + } if ((page + 1) * EntryCount < m_Mobiles.Count) { AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1); if (NextLabel) + { AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next"); + } } for (int i = 0, index = page * EntryCount; i < EntryCount && index < m_Mobiles.Count; ++i, ++index) @@ -205,10 +219,14 @@ namespace Server.Gumps x += EntryWidth + OffsetSize; if (SetGumpID != 0) + { AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); + } if (m.NetState != null && !m.Deleted) + { AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3); + } } } @@ -243,14 +261,18 @@ namespace Server.Gumps case 1: // Previous { if (m_Page > 0) - from.SendGump(new WhoGump(from, m_Mobiles, m_Page - 1)); + { + @from.SendGump(new WhoGump(@from, m_Mobiles, m_Page - 1)); + } break; } case 2: // Next { if ((m_Page + 1) * EntryCount < m_Mobiles.Count) - from.SendGump(new WhoGump(from, m_Mobiles, m_Page + 1)); + { + @from.SendGump(new WhoGump(@from, m_Mobiles, m_Page + 1)); + } break; } @@ -296,12 +318,20 @@ namespace Server.Gumps public int Compare(Mobile x, Mobile y) { if (x == null || y == null) + { throw new ArgumentException(); + } if (x.AccessLevel > y.AccessLevel) + { return -1; + } + if (x.AccessLevel < y.AccessLevel) + { return 1; + } + return Insensitive.Compare(x.Name, y.Name); } } diff --git a/Projects/UOContent/Gumps/YoungGumps.cs b/Projects/UOContent/Gumps/YoungGumps.cs index abb420f3d..d730ff87a 100644 --- a/Projects/UOContent/Gumps/YoungGumps.cs +++ b/Projects/UOContent/Gumps/YoungGumps.cs @@ -88,7 +88,9 @@ namespace Server.Gumps if (info.ButtonID == 1) { if (from.Account is Account acc) + { acc.RemoveYoungStatus(502085); // You have chosen to renounce your `Young' player status. + } } else { diff --git a/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs b/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs index 94d5e228a..6f721d58a 100644 --- a/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs +++ b/Projects/UOContent/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs @@ -28,7 +28,9 @@ namespace Server.Items get { if (ItemID == 0x2336) + { return true; + } return false; } @@ -47,10 +49,15 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true) + { return false; + } if (FacingSouth) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // north wall + } + return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // west wall } @@ -121,7 +128,9 @@ namespace Server.Items from.CloseGump(); if (!from.SendGump(new FacingGump(this, from))) - from.SendLocalizedMessage(1150062); // You fail to re-deed the holiday fireflies. + { + @from.SendLocalizedMessage(1150062); // You fail to re-deed the holiday fireflies. + } } else { @@ -216,7 +225,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_FirefliesDeed?.Deleted != false) + { return; + } if (m_FirefliesDeed.IsChildOf(from.Backpack)) { @@ -228,7 +239,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null || map == Map.Internal) + { return; + } var p3d = new Point3D(p); var id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; diff --git a/Projects/UOContent/Holiday Stuff/Easter/2011/Items/DragonEasterEgg.cs b/Projects/UOContent/Holiday Stuff/Easter/2011/Items/DragonEasterEgg.cs index 5c96dc7ec..1e2575f53 100644 --- a/Projects/UOContent/Holiday Stuff/Easter/2011/Items/DragonEasterEgg.cs +++ b/Projects/UOContent/Holiday Stuff/Easter/2011/Items/DragonEasterEgg.cs @@ -18,7 +18,9 @@ public bool Dye(Mobile from, DyeTub sender) { if (Deleted || !sender.AllowDyables) + { return false; + } Hue = sender.DyedHue; diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index d473c19dc..c7166f233 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -16,7 +16,9 @@ namespace Server.Engines.Events var now = DateTime.UtcNow; if (DateTime.UtcNow >= HolidaySettings.StartHalloween && DateTime.UtcNow <= HolidaySettings.FinishHalloween) + { EventSink.Speech += EventSink_Speech; + } } private static void EventSink_Speech(SpeechEventArgs e) @@ -32,22 +34,28 @@ namespace Server.Engines.Events public static void Bleeding(Mobile m_From) { if (CheckMobile(m_From)) + { if (m_From.Location != Point3D.Zero) { var amount = Utility.RandomMinMax(3, 7); for (var i = 0; i < amount; i++) + { new Blood(Utility.RandomMinMax(0x122C, 0x122F)).MoveToWorld( RandomPointOneAway(m_From.X, m_From.Y, m_From.Z, m_From.Map), m_From.Map ); + } } + } } public static void RemoveHueMod(Mobile target) { if (target?.Deleted == false) + { target.SolidHueOverride = -1; + } } public static void SolidHueMobile(Mobile target) @@ -69,20 +77,32 @@ namespace Server.Engines.Events Mobile twin = new NaughtyTwin(m_From); if (twin.Deleted) + { return; + } foreach (var item in m_From.Items) + { if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) + { m_Items.Add(item); + } + } if (m_Items.Count > 0) { for (var i = 0; i < m_Items.Count; i++) /* dupe exploits start out like this ... */ + { twin.AddItem(Mobile.LiftItemDupe(m_Items[i], 1)); + } foreach (var item in twin.Items) /* ... and end like this */ + { if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) + { item.Movable = false; + } + } } twin.Hue = m_From.Hue; @@ -99,7 +119,10 @@ namespace Server.Engines.Events public static void DeleteTwin(Mobile m_Twin) { - if (CheckMobile(m_Twin)) m_Twin.Delete(); + if (CheckMobile(m_Twin)) + { + m_Twin.Delete(); + } } public static Point3D RandomPointOneAway(int x, int y, int z, Map map) @@ -124,7 +147,9 @@ namespace Server.Engines.Events protected override void OnTarget(Mobile from, object targ) { if (targ == null || !CheckMobile(from)) + { return; + } if (!(targ is Mobile)) { @@ -153,7 +178,9 @@ namespace Server.Engines.Events begged.NextTrickOrTreat = now + TimeSpan.FromMinutes(Utility.RandomMinMax(5, 10)); if (from.Backpack?.Deleted != false) + { return; + } if (Utility.RandomDouble() > .10) { @@ -186,11 +213,17 @@ namespace Server.Engines.Events var action = Utility.Random(4); if (action == 0) - Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from); + { + Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, @from); + } else if (action == 1) - Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from); + { + Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, @from); + } else - Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from); + { + Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, @from); + } } } } @@ -261,7 +294,9 @@ namespace Server.Engines.Events public override void OnThink() { if (m_From?.Deleted != false) + { Delete(); + } } public static Item FindCandyTypes(Mobile target) @@ -270,7 +305,9 @@ namespace Server.Engines.Events { typeof(WrappedCandy), typeof(Lollipops), typeof(NougatSwirl), typeof(Taffy), typeof(JellyBeans) }; if (TrickOrTreat.CheckMobile(target)) + { return target.Backpack.FindItemByType(types); + } return null; } @@ -286,7 +323,9 @@ namespace Server.Engines.Events target.SendLocalizedMessage(1113967); /* Your naughty twin steals some of your candy. */ if (item?.Deleted == false) + { item.Delete(); + } } else { diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs index 45b04e151..77a772fba 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs @@ -26,7 +26,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) + { return; + } var douse = false; @@ -90,7 +92,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Name == null && ItemID == 0x4698) + { AssignRandomName(); + } } } } diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs b/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs index 80acd42c1..feb6c42c2 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs @@ -26,7 +26,9 @@ namespace Server.Engines.Events var now = DateTime.UtcNow; if (now >= HolidaySettings.StartHalloween && now <= HolidaySettings.FinishHalloween) + { m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(30), 0, PumpkinPatchSpawnerCallback); + } } protected static void PumpkinPatchSpawnerCallback() @@ -45,7 +47,9 @@ namespace Server.Engines.Events var pumpkins = map.GetItemsInBounds(rect).OfType().Count(); if (spawncount > pumpkins) + { new HalloweenPumpkin().MoveToWorld(RandomPointIn(rect, map), map); + } } } diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs b/Projects/UOContent/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs index a6b095b9f..91db7652c 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs @@ -51,7 +51,10 @@ namespace Server.Items.Holiday var version = reader.ReadInt(); - if (version == 1) m_Staffer = Utility.Intern(reader.ReadString()); + if (version == 1) + { + m_Staffer = Utility.Intern(reader.ReadString()); + } } } } diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs b/Projects/UOContent/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs index 4c7d41211..e1d0842b5 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs @@ -62,6 +62,7 @@ namespace Server.Mobiles public override void GenerateLoot() { if (Utility.RandomDouble() < .05) + { switch (Utility.Random(5)) { case 0: @@ -80,6 +81,7 @@ namespace Server.Mobiles PackItem(new PaintedPorcelainMask()); break; } + } PackItem(new WrappedCandy()); AddLoot(LootPack.UltraRich, 2); @@ -108,8 +110,12 @@ namespace Server.Mobiles public override void OnDamage(int amount, Mobile from, bool willKill) { if (Utility.RandomBool()) - if (from?.Map != null && Map != Map.Internal && Map == from.Map && from.InRange(this, 12)) - SpillAcid(willKill ? this : from, willKill ? 3 : 1); + { + if (@from?.Map != null && Map != Map.Internal && Map == @from.Map && @from.InRange(this, 12)) + { + SpillAcid(willKill ? this : @from, willKill ? 3 : 1); + } + } base.OnDamage(amount, from, willKill); } diff --git a/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs b/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs index 4b89ad430..9e0e2bc10 100644 --- a/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs +++ b/Projects/UOContent/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs @@ -29,7 +29,10 @@ namespace Server.Items get { if (m_Owner != null) + { return $"{m_Owner}'s St. Valentine Bear"; + } + return "St. Valentine Bear"; } } @@ -88,9 +91,13 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (m_Owner != null) + { list.Add(1150295, m_Owner); // ~1_NAME~'s St. Valentine Bear + } else + { list.Add(1150294); // St. Valentine Bear + } AddLine(list, 1150301, m_Line1); // [ ~1_LINE0~ ] AddLine(list, 1150302, m_Line2); // [ ~1_LINE1~ ] @@ -100,7 +107,9 @@ namespace Server.Items private static void AddLine(ObjectPropertyList list, int cliloc, string line) { if (line != null) + { list.Add(cliloc, line); + } } public override void OnSingleClick(Mobile from) @@ -115,13 +124,17 @@ namespace Server.Items private void ShowLine(Mobile from, int cliloc, string line) { if (line != null) - LabelTo(from, cliloc, line); + { + LabelTo(@from, cliloc, line); + } } public override void OnDoubleClick(Mobile from) { if (!CupidsArrow.CheckSeason(from) || !CanSign) + { return; + } if (!IsChildOf(from.Backpack)) { @@ -198,7 +211,9 @@ namespace Server.Items var from = sender.Mobile; if (m_Bear.Deleted || !m_Bear.IsChildOf(from.Backpack) || !m_Bear.CanSign || info.ButtonID != 1) + { return; + } var line1 = GetLine(info, 0); var line2 = GetLine(info, 1); @@ -221,7 +236,9 @@ namespace Server.Items } if (!m_Bear.IsSigned) + { m_Bear.EditLimit = DateTime.UtcNow + TimeSpan.FromMinutes(10); + } m_Bear.Line1 = Utility.FixHtml(line1); m_Bear.Line2 = Utility.FixHtml(line2); diff --git a/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs b/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs index eaa3cef13..ba59b8b48 100644 --- a/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs +++ b/Projects/UOContent/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs @@ -50,13 +50,17 @@ namespace Server.Items base.AddNameProperty(list); if (IsSigned) + { list.Add(1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ + } } public static bool CheckSeason(Mobile from) { if (DateTime.UtcNow.Month == 2) + { return true; + } from.SendLocalizedMessage(1152318); // You may not use this item out of season. return false; @@ -67,13 +71,17 @@ namespace Server.Items base.OnSingleClick(from); if (IsSigned) - LabelTo(from, 1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ + { + LabelTo(@from, 1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ + } } public override void OnDoubleClick(Mobile from) { if (IsSigned || !CheckSeason(from)) + { return; + } if (!IsChildOf(from.Backpack)) { @@ -88,7 +96,9 @@ namespace Server.Items private void OnTarget(Mobile from, object targeted) { if (IsSigned || !IsChildOf(from.Backpack)) + { return; + } if (targeted is Mobile m) { diff --git a/Projects/UOContent/Items/Addons/AddonComponent.cs b/Projects/UOContent/Items/Addons/AddonComponent.cs index fdc42ea46..769452c64 100644 --- a/Projects/UOContent/Items/Addons/AddonComponent.cs +++ b/Projects/UOContent/Items/Addons/AddonComponent.cs @@ -191,7 +191,9 @@ namespace Server.Items base.Hue = value; if (Addon?.ShareHue == true) + { Addon.Hue = value; + } } } @@ -201,9 +203,13 @@ namespace Server.Items public void OnChop(Mobile from) { if (Addon != null && from.InRange(GetWorldLocation(), 3)) - Addon.OnChop(from); + { + Addon.OnChop(@from); + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } public override void OnDoubleClick(Mobile from) @@ -214,13 +220,17 @@ namespace Server.Items public override void OnLocationChange(Point3D old) { if (Addon != null) + { Addon.Location = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z); + } } public override void OnMapChange() { if (Addon != null) + { Addon.Map = Map; + } } public override void OnAfterDelete() @@ -263,13 +273,17 @@ namespace Server.Items } if (version < 1 && Weight == 0) + { Weight = -1; + } } public static void ApplyLightTo(Item item) { if ((item.ItemData.Flags & TileFlag.LightSource) == 0) + { return; // not a light source + } var itemID = item.ItemID; @@ -280,7 +294,9 @@ namespace Server.Items var contains = false; for (var j = 0; !contains && j < toMatch.Length; ++j) + { contains = itemID == toMatch[j]; + } if (contains) { diff --git a/Projects/UOContent/Items/Addons/AddonContainerComponent.cs b/Projects/UOContent/Items/Addons/AddonContainerComponent.cs index fae148d6b..2f4d3fb59 100644 --- a/Projects/UOContent/Items/Addons/AddonContainerComponent.cs +++ b/Projects/UOContent/Items/Addons/AddonContainerComponent.cs @@ -36,22 +36,30 @@ namespace Server.Items base.Hue = value; if (Addon?.ShareHue == true) + { Addon.Hue = value; + } } } public virtual void OnChop(Mobile from) { if (Addon != null && from.InRange(GetWorldLocation(), 3)) - Addon.OnChop(from); + { + Addon.OnChop(@from); + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } public override bool OnDragDrop(Mobile from, Item dropped) { if (Addon != null) - return Addon.OnDragDrop(from, dropped); + { + return Addon.OnDragDrop(@from, dropped); + } return false; } @@ -64,7 +72,9 @@ namespace Server.Items public override void OnLocationChange(Point3D old) { if (Addon != null) + { Addon.Location = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z); + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -75,7 +85,9 @@ namespace Server.Items public override void OnMapChange() { if (Addon != null) + { Addon.Map = Map; + } } public override void OnAfterDelete() @@ -125,7 +137,9 @@ namespace Server.Items get { if (m_LabelNumber > 0) + { return m_LabelNumber; + } return base.LabelNumber; } diff --git a/Projects/UOContent/Items/Addons/ArcaneCircleAddon.cs b/Projects/UOContent/Items/Addons/ArcaneCircleAddon.cs index 3d903e66a..50e7f2d50 100644 --- a/Projects/UOContent/Items/Addons/ArcaneCircleAddon.cs +++ b/Projects/UOContent/Items/Addons/ArcaneCircleAddon.cs @@ -36,17 +36,21 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0) + { ValidationQueue.Add(this); + } } public void Validate() { foreach (var c in Components) + { if (c.ItemID == 0x3083) { c.Offset = new Point3D(-1, -1, 0); c.MoveToWorld(new Point3D(X + c.Offset.X, Y + c.Offset.Y, Z + c.Offset.Z), Map); } + } } } diff --git a/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs b/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs index 0644fc4c3..9c56c4f20 100644 --- a/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs +++ b/Projects/UOContent/Items/Addons/ArcheryButteAddon.cs @@ -47,9 +47,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if ((Arrows > 0 || Bolts > 0) && from.InRange(GetWorldLocation(), 1)) - Gather(from); + { + Gather(@from); + } else - Fire(from); + { + Fire(@from); + } } public void Gather(Mobile from) @@ -57,10 +61,14 @@ namespace Server.Items from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500592); // You gather the arrows and bolts. if (Arrows > 0) - from.AddToBackpack(new Arrow(Arrows)); + { + @from.AddToBackpack(new Arrow(Arrows)); + } if (Bolts > 0) - from.AddToBackpack(new Bolt(Bolts)); + { + @from.AddToBackpack(new Bolt(Bolts)); + } Arrows = 0; Bolts = 0; @@ -71,10 +79,14 @@ namespace Server.Items private ScoreEntry GetEntryFor(Mobile from) { if (m_Entries == null) + { m_Entries = new Dictionary(); + } if (!m_Entries.TryGetValue(from, out var e)) - m_Entries[from] = e = new ScoreEntry(); + { + m_Entries[@from] = e = new ScoreEntry(); + } return e; } @@ -88,7 +100,9 @@ namespace Server.Items } if (DateTime.UtcNow < LastUse + UseDelay) + { return; + } var worldLoc = GetWorldLocation(); @@ -138,19 +152,25 @@ namespace Server.Items if (pack?.ConsumeTotal(ammoType) != true) { if (isArrow) - from.LocalOverheadMessage( + { + @from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500594 ); // You do not have any arrows with which to practice. + } else if (isBolt) - from.LocalOverheadMessage( + { + @from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500595 ); // You do not have any crossbow bolts with which to practice. + } else - SendLocalizedMessageTo(from, 500593); // You must practice with ranged weapons on this. + { + SendLocalizedMessageTo(@from, 500593); // You must practice with ranged weapons on this. + } return; } @@ -172,9 +192,13 @@ namespace Server.Items se.Record(0); if (se.Count == 1) + { PublicOverheadMessage(MessageType.Regular, 0x3B2, 1062719, se.Total.ToString()); + } else + { PublicOverheadMessage(MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}"); + } return; } @@ -226,17 +250,25 @@ namespace Server.Items PublicOverheadMessage(MessageType.Regular, 0x3B2, 1010035 + area, from.Name); if (isArrow) + { ++Arrows; + } else if (isBolt) + { ++Bolts; + } } se.Record(split ? splitScore : score); if (se.Count == 1) + { PublicOverheadMessage(MessageType.Regular, 0x3B2, 1062719, se.Total.ToString()); + } else + { PublicOverheadMessage(MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}"); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Addons/BallotBox.cs b/Projects/UOContent/Items/Addons/BallotBox.cs index 0ce3ad8cd..97ad761ff 100644 --- a/Projects/UOContent/Items/Addons/BallotBox.cs +++ b/Projects/UOContent/Items/Addons/BallotBox.cs @@ -41,7 +41,9 @@ namespace Server.Items public void AddLineToTopic(string line) { if (Topic.Length >= MaxTopicLines) + { return; + } var newTopic = new string[Topic.Length + 1]; Topic.CopyTo(newTopic, 0); @@ -61,7 +63,9 @@ namespace Server.Items public bool IsOwner(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } var house = BaseHouse.FindHouseAt(this); return house?.IsOwner(from) == true; @@ -97,7 +101,9 @@ namespace Server.Items writer.WriteEncodedInt(Topic.Length); for (var i = 0; i < Topic.Length; i++) + { writer.Write(Topic[i]); + } writer.Write(Yes, true); writer.Write(No, true); @@ -112,7 +118,9 @@ namespace Server.Items Topic = new string[reader.ReadEncodedInt()]; for (var i = 0; i < Topic.Length; i++) + { Topic[i] = reader.ReadString(); + } Yes = reader.ReadStrongMobileList(); No = reader.ReadStrongMobileList(); @@ -129,9 +137,13 @@ namespace Server.Items AddBackground(0, 0, 400, 350, 0xA28); if (isOwner) + { AddHtmlLocalized(0, 15, 400, 35, 1011000); //
Ballot Box Owner's Menu
+ } else + { AddHtmlLocalized(0, 15, 400, 35, 1011001); //
Ballot Box -- Vote Here!
+ } AddHtmlLocalized(0, 50, 400, 35, 1011002); //
Topic
@@ -143,7 +155,9 @@ namespace Server.Items var line = box.Topic[i]; if (!string.IsNullOrEmpty(line)) + { AddLabelCropped(30, 90 + i * 20, 340, 20, 0x3E3, line); + } } var yesCount = box.Yes.Count; @@ -153,12 +167,18 @@ namespace Server.Items AddHtmlLocalized(0, 215, 400, 35, 1011003); //
votes
if (!isOwner) + { AddButton(20, 240, 0xFA5, 0xFA7, 3); + } + AddHtmlLocalized(55, 242, 25, 35, 1011004); // aye: AddLabel(78, 242, 0x0, $"[{yesCount}]"); if (!isOwner) + { AddButton(20, 275, 0xFA5, 0xFA7, 4); + } + AddHtmlLocalized(55, 277, 25, 35, 1011005); // nay: AddLabel(78, 277, 0x0, $"[{noCount}]"); @@ -184,7 +204,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Box.Deleted || info.ButtonID == 0) + { return; + } var from = sender.Mobile; @@ -276,7 +298,9 @@ namespace Server.Items public override void OnResponse(Mobile from, string text) { if (m_Box.Deleted || !m_Box.IsOwner(from)) + { return; + } if (from.Map != m_Box.Map || !from.InRange(m_Box.GetWorldLocation(), 2)) { @@ -301,7 +325,9 @@ namespace Server.Items public override void OnCancel(Mobile from) { if (m_Box.Deleted || !m_Box.IsOwner(from)) + { return; + } if (from.Map != m_Box.Map || !from.InRange(m_Box.GetWorldLocation(), 2)) { diff --git a/Projects/UOContent/Items/Addons/BaseAddon.cs b/Projects/UOContent/Items/Addons/BaseAddon.cs index 7d172edee..c4329f856 100644 --- a/Projects/UOContent/Items/Addons/BaseAddon.cs +++ b/Projects/UOContent/Items/Addons/BaseAddon.cs @@ -56,8 +56,12 @@ namespace Server.Items base.Hue = value; if (!Deleted && ShareHue && Components != null) + { foreach (var c in Components) + { c.Hue = value; + } + } } } } @@ -98,13 +102,17 @@ namespace Server.Items var hue = 0; if (RetainDeedHue) + { for (var i = 0; hue == 0 && i < Components.Count; ++i) { var c = Components[i]; if (c.Hue != 0) + { hue = c.Hue; + } } + } Delete(); @@ -115,7 +123,9 @@ namespace Server.Items if (deed != null) { if (RetainDeedHue) + { deed.Hue = hue; + } from.AddToBackpack(deed); } @@ -125,7 +135,9 @@ namespace Server.Items public void AddComponent(AddonComponent c, int x, int y, int z) { if (Deleted) + { return; + } Components.Add(c); @@ -137,23 +149,32 @@ namespace Server.Items public virtual AddonFitResult CouldFit(IPoint3D p, Map map, Mobile from, ref BaseHouse house) { if (Deleted) + { return AddonFitResult.Blocked; + } foreach (var c in Components) { var p3D = new Point3D(p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z); if (!map.CanFit(p3D.X, p3D.Y, p3D.Z, c.ItemData.Height, false, true, c.Z == 0)) + { return AddonFitResult.Blocked; + } + if (!CheckHouse(from, p3D, map, c.ItemData.Height, ref house)) + { return AddonFitResult.NotInHouse; + } if (c.NeedsWall) { var wall = c.WallPosition; if (!IsWall(p3D.X + wall.X, p3D.Y + wall.Y, p3D.Z + wall.Z, map)) + { return AddonFitResult.NoWall; + } } } @@ -174,7 +195,9 @@ namespace Server.Items if (Utility.InRange(doorLoc, addonLoc, 1) && (addonLoc.Z == doorLoc.Z || addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z)) + { return AddonFitResult.DoorTooClose; + } } } @@ -187,7 +210,9 @@ namespace Server.Items public static bool IsWall(int x, int y, int z, Map map) { if (map == null) + { return false; + } var tiles = map.Tiles.GetStaticTiles(x, y, true); @@ -197,7 +222,9 @@ namespace Server.Items var id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; if ((id.Flags & TileFlag.Wall) != 0 && z + 16 > t.Z && t.Z + t.Height > z) + { return true; + } } return false; @@ -214,19 +241,27 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLoc) { if (Deleted) + { return; + } foreach (var c in Components) + { c.Location = new Point3D(X + c.Offset.X, Y + c.Offset.Y, Z + c.Offset.Z); + } } public override void OnMapChange() { if (Deleted) + { return; + } foreach (var c in Components) + { c.Map = Map; + } } public override void OnAfterDelete() @@ -234,7 +269,9 @@ namespace Server.Items base.OnAfterDelete(); foreach (var c in Components) + { c.Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -263,7 +300,9 @@ namespace Server.Items } if (version < 1 && Weight == 0) + { Weight = -1; + } } } } diff --git a/Projects/UOContent/Items/Addons/BaseAddonContainer.cs b/Projects/UOContent/Items/Addons/BaseAddonContainer.cs index 919352897..60a30f56f 100644 --- a/Projects/UOContent/Items/Addons/BaseAddonContainer.cs +++ b/Projects/UOContent/Items/Addons/BaseAddonContainer.cs @@ -36,7 +36,9 @@ namespace Server.Items Hue = value; foreach (var c in Components) + { c.Hue = value; + } } } } @@ -89,13 +91,17 @@ namespace Server.Items var hue = 0; if (RetainDeedHue) + { for (var i = 0; hue == 0 && i < Components.Count; ++i) { var c = Components[i]; if (c.Hue != 0) + { hue = c.Hue; + } } + } DropItemsToGround(); @@ -110,7 +116,9 @@ namespace Server.Items deed.Resource = Resource; if (RetainDeedHue) + { deed.Hue = hue; + } from.AddToBackpack(deed); } @@ -127,10 +135,14 @@ namespace Server.Items base.OnLocationChange(oldLoc); if (Deleted) + { return; + } foreach (var c in Components) + { c.Location = new Point3D(X + c.Offset.X, Y + c.Offset.Y, Z + c.Offset.Z); + } } public override void OnMapChange() @@ -138,10 +150,14 @@ namespace Server.Items base.OnMapChange(); if (Deleted) + { return; + } foreach (var c in Components) + { c.Map = Map; + } } public override void OnDelete() @@ -158,7 +174,9 @@ namespace Server.Items base.GetProperties(list); if (!CraftResources.IsStandard(m_Resource)) + { list.Add(CraftResources.GetLocalizationNumber(m_Resource)); + } } public override void OnAfterDelete() @@ -166,7 +184,9 @@ namespace Server.Items base.OnAfterDelete(); foreach (var c in Components) + { c.Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -194,13 +214,17 @@ namespace Server.Items public virtual void DropItemsToGround() { for (var i = Items.Count - 1; i >= 0; i--) + { Items[i].MoveToWorld(Location); + } } public void AddComponent(AddonContainerComponent c, int x, int y, int z) { if (Deleted) + { return; + } Components.Add(c); @@ -212,39 +236,55 @@ namespace Server.Items public AddonFitResult CouldFit(IPoint3D p, Map map, Mobile from, ref BaseHouse house) { if (Deleted) + { return AddonFitResult.Blocked; + } foreach (var c in Components) { var p3D = new Point3D(p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z); if (!map.CanFit(p3D.X, p3D.Y, p3D.Z, c.ItemData.Height, false, true, c.Z == 0)) + { return AddonFitResult.Blocked; + } + if (!BaseAddon.CheckHouse(from, p3D, map, c.ItemData.Height, ref house)) + { return AddonFitResult.NotInHouse; + } if (c.NeedsWall) { var wall = c.WallPosition; if (!BaseAddon.IsWall(p3D.X + wall.X, p3D.Y + wall.Y, p3D.Z + wall.Z, map)) + { return AddonFitResult.NoWall; + } } } var p3 = new Point3D(p.X, p.Y, p.Z); if (!map.CanFit(p3.X, p3.Y, p3.Z, ItemData.Height, false, true, Z == 0)) + { return AddonFitResult.Blocked; + } + if (!BaseAddon.CheckHouse(from, p3, map, ItemData.Height, ref house)) + { return AddonFitResult.NotInHouse; + } if (NeedsWall) { var wall = WallPosition; if (!BaseAddon.IsWall(p3.X + wall.X, p3.Y + wall.Y, p3.Z + wall.Z, map)) + { return AddonFitResult.NoWall; + } } if (house != null) @@ -256,7 +296,9 @@ namespace Server.Items var door = doors[i]; if (door?.Open == true) + { return AddonFitResult.DoorsNotClosed; + } var doorLoc = door.GetWorldLocation(); var doorHeight = door.ItemData.CalcHeight; @@ -270,7 +312,9 @@ namespace Server.Items if (Utility.InRange(doorLoc, addonLoc, 1) && (addonLoc.Z == doorLoc.Z || addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z)) + { return AddonFitResult.DoorTooClose; + } } var addonLo = new Point3D(p.X, p.Y, p.Z); @@ -279,7 +323,9 @@ namespace Server.Items if (Utility.InRange(doorLoc, addonLo, 1) && (addonLo.Z == doorLoc.Z || addonLo.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLo.Z)) + { return AddonFitResult.DoorTooClose; + } } } diff --git a/Projects/UOContent/Items/Addons/BaseAddonContainerDeed.cs b/Projects/UOContent/Items/Addons/BaseAddonContainerDeed.cs index ddbe3adca..75f7b1f16 100644 --- a/Projects/UOContent/Items/Addons/BaseAddonContainerDeed.cs +++ b/Projects/UOContent/Items/Addons/BaseAddonContainerDeed.cs @@ -16,7 +16,9 @@ namespace Server.Items Weight = 1.0; if (!Core.AOS) + { LootType = LootType.Newbied; + } } public BaseAddonContainerDeed(Serial serial) : base(serial) @@ -53,7 +55,9 @@ namespace Server.Items var context = craftSystem.GetContext(from); if (context?.DoNotColor == true) + { Hue = 0; + } return quality; } @@ -84,9 +88,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } else - from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used. + { + @from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used. + } } public override void GetProperties(ObjectPropertyList list) @@ -94,7 +102,9 @@ namespace Server.Items base.GetProperties(list); if (!CraftResources.IsStandard(m_Resource)) + { list.Add(CraftResources.GetLocalizationNumber(m_Resource)); + } } private class InternalTarget : Target @@ -114,7 +124,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null || m_Deed.Deleted) + { return; + } if (m_Deed.IsChildOf(from.Backpack)) { @@ -128,17 +140,29 @@ namespace Server.Items var res = addon.CouldFit(p, map, from, ref house); if (res == AddonFitResult.Valid) + { addon.MoveToWorld(new Point3D(p), map); + } else if (res == AddonFitResult.Blocked) - from.SendLocalizedMessage(500269); // You cannot build that there. + { + @from.SendLocalizedMessage(500269); // You cannot build that there. + } else if (res == AddonFitResult.NotInHouse) - from.SendLocalizedMessage(500274); // You can only place this in a house that you own! + { + @from.SendLocalizedMessage(500274); // You can only place this in a house that you own! + } else if (res == AddonFitResult.DoorsNotClosed) - from.SendMessage("You must close all house doors before placing this."); + { + @from.SendMessage("You must close all house doors before placing this."); + } else if (res == AddonFitResult.DoorTooClose) - from.SendLocalizedMessage(500271); // You cannot build near the door. + { + @from.SendLocalizedMessage(500271); // You cannot build near the door. + } else if (res == AddonFitResult.NoWall) - from.SendLocalizedMessage(500268); // This object needs to be mounted on something. + { + @from.SendLocalizedMessage(500268); // This object needs to be mounted on something. + } if (res == AddonFitResult.Valid) { diff --git a/Projects/UOContent/Items/Addons/BaseAddonDeed.cs b/Projects/UOContent/Items/Addons/BaseAddonDeed.cs index e58f89ac7..563a0b252 100644 --- a/Projects/UOContent/Items/Addons/BaseAddonDeed.cs +++ b/Projects/UOContent/Items/Addons/BaseAddonDeed.cs @@ -14,7 +14,9 @@ namespace Server.Items Weight = 1.0; if (!Core.AOS) + { LootType = LootType.Newbied; + } } public BaseAddonDeed(Serial serial) : base(serial) @@ -53,15 +55,21 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 0.0) + { Weight = 1.0; + } } public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } private class InternalTarget : Target @@ -81,7 +89,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null || m_Deed.Deleted) + { return; + } if (m_Deed.IsChildOf(from.Backpack)) { @@ -94,15 +104,25 @@ namespace Server.Items var res = addon.CouldFit(p, map, from, ref house); if (res == AddonFitResult.Valid) + { addon.MoveToWorld(new Point3D(p), map); + } else if (res == AddonFitResult.Blocked) - from.SendLocalizedMessage(500269); // You cannot build that there. + { + @from.SendLocalizedMessage(500269); // You cannot build that there. + } else if (res == AddonFitResult.NotInHouse) - from.SendLocalizedMessage(500274); // You can only place this in a house that you own! + { + @from.SendLocalizedMessage(500274); // You can only place this in a house that you own! + } else if (res == AddonFitResult.DoorTooClose) - from.SendLocalizedMessage(500271); // You cannot build near the door. + { + @from.SendLocalizedMessage(500271); // You cannot build near the door. + } else if (res == AddonFitResult.NoWall) - from.SendLocalizedMessage(500268); // This object needs to be mounted on something. + { + @from.SendLocalizedMessage(500268); // This object needs to be mounted on something. + } if (res == AddonFitResult.Valid) { diff --git a/Projects/UOContent/Items/Addons/DartBoard.cs b/Projects/UOContent/Items/Addons/DartBoard.cs index fa4b854f0..991c21ef9 100644 --- a/Projects/UOContent/Items/Addons/DartBoard.cs +++ b/Projects/UOContent/Items/Addons/DartBoard.cs @@ -22,27 +22,43 @@ namespace Server.Items { Direction dir; if (from.Location != Location) - dir = from.GetDirectionTo(this); + { + dir = @from.GetDirectionTo(this); + } else if (East) + { dir = Direction.West; + } else + { dir = Direction.North; + } from.Direction = dir; bool canThrow; if (!from.InRange(this, 4) || !from.InLOS(this)) + { canThrow = false; + } else if (East) + { canThrow = dir == Direction.Left || dir == Direction.West || dir == Direction.Up; + } else + { canThrow = dir == Direction.Up || dir == Direction.North || dir == Direction.Right; + } if (canThrow) - Throw(from); + { + Throw(@from); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public void Throw(Mobile from) @@ -61,17 +77,29 @@ namespace Server.Items int message; if (rand < 0.05) + { message = 500752; // BULLSEYE! 50 Points! + } else if (rand < 0.20) + { message = 500753; // Just missed the center! 20 points. + } else if (rand < 0.45) + { message = 500754; // 10 point shot. + } else if (rand < 0.70) + { message = 500755; // 5 pointer. + } else if (rand < 0.85) + { message = 500756; // 1 point. Bad throw. + } else + { message = 500757; // Missed. + } PublicOverheadMessage(MessageType.Regular, 0x3B2, message); } diff --git a/Projects/UOContent/Items/Addons/ElvenSpinningwheelEastAddon.cs b/Projects/UOContent/Items/Addons/ElvenSpinningwheelEastAddon.cs index 7d170d716..474cd199f 100644 --- a/Projects/UOContent/Items/Addons/ElvenSpinningwheelEastAddon.cs +++ b/Projects/UOContent/Items/Addons/ElvenSpinningwheelEastAddon.cs @@ -26,6 +26,7 @@ namespace Server.Items m_Timer.Start(); foreach (var c in Components) + { switch (c.ItemID) { case 0x2DD9: @@ -34,6 +35,7 @@ namespace Server.Items ++c.ItemID; break; } + } } public override void Serialize(IGenericWriter writer) @@ -69,6 +71,7 @@ namespace Server.Items m_Timer = null; foreach (var c in Components) + { switch (c.ItemID) { case 0x1016: @@ -78,6 +81,7 @@ namespace Server.Items --c.ItemID; break; } + } callback?.Invoke(this, from, hue); } diff --git a/Projects/UOContent/Items/Addons/ElvenSpinningwheelSouthAddon.cs b/Projects/UOContent/Items/Addons/ElvenSpinningwheelSouthAddon.cs index 1c73cd496..21aa88ea5 100644 --- a/Projects/UOContent/Items/Addons/ElvenSpinningwheelSouthAddon.cs +++ b/Projects/UOContent/Items/Addons/ElvenSpinningwheelSouthAddon.cs @@ -26,6 +26,7 @@ namespace Server.Items m_Timer.Start(); foreach (var c in Components) + { switch (c.ItemID) { case 0x1015: @@ -35,6 +36,7 @@ namespace Server.Items ++c.ItemID; break; } + } } public override void Serialize(IGenericWriter writer) @@ -71,6 +73,7 @@ namespace Server.Items m_Timer = null; foreach (var c in Components) + { switch (c.ItemID) { case 0x1016: @@ -80,6 +83,7 @@ namespace Server.Items --c.ItemID; break; } + } callback?.Invoke(this, from, hue); } diff --git a/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs b/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs index d874fc3c5..9c1887628 100644 --- a/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs +++ b/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs @@ -68,7 +68,9 @@ namespace Server.Items public void StartWorking(Mobile from) { if (IsWorking) + { return; + } m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), FinishWorking_Callback, from); UpdateStage(); @@ -107,8 +109,12 @@ namespace Server.Items var itemTable = m_StageTable[i]; for (var j = 0; j < itemTable.Length; ++j) + { if (itemTable[j] == itemID) + { return itemTable; + } + } } return null; @@ -117,11 +123,17 @@ namespace Server.Items public void UpdateStage() { if (IsWorking) + { UpdateStage(FlourMillStage.Working); + } else if (HasFlour) + { UpdateStage(FlourMillStage.Filled); + } else + { UpdateStage(FlourMillStage.Empty); + } } public void UpdateStage(FlourMillStage stage) @@ -133,23 +145,33 @@ namespace Server.Items for (var i = 0; i < components.Count; ++i) { if (!(components[i] is AddonComponent component)) + { continue; + } var itemTable = FindItemTable(component.ItemID); if (itemTable != null) + { component.ItemID = itemTable[(int)stage]; + } } } public override void OnComponentUsed(AddonComponent c, Mobile from) { if (!from.InRange(GetWorldLocation(), 4) || !from.InLOS(this)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (!IsFull) - from.SendLocalizedMessage(500997); // You need more wheat to make a sack of flour. + { + @from.SendLocalizedMessage(500997); // You need more wheat to make a sack of flour. + } else - StartWorking(from); + { + StartWorking(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs b/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs index ba99f4987..c2e4cb54b 100644 --- a/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs +++ b/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs @@ -55,7 +55,9 @@ namespace Server.Items public void StartWorking(Mobile from) { if (IsWorking) + { return; + } m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), FinishWorking_Callback, from); UpdateStage(); @@ -96,8 +98,12 @@ namespace Server.Items var itemTable = m_StageTable[i]; for (var j = 0; j < itemTable.Length; ++j) + { if (itemTable[j] == itemID) + { return itemTable; + } + } } return null; @@ -106,11 +112,17 @@ namespace Server.Items public void UpdateStage() { if (IsWorking) + { UpdateStage(FlourMillStage.Working); + } else if (HasFlour) + { UpdateStage(FlourMillStage.Filled); + } else + { UpdateStage(FlourMillStage.Empty); + } } public void UpdateStage(FlourMillStage stage) @@ -122,23 +134,33 @@ namespace Server.Items for (var i = 0; i < components.Count; ++i) { if (!(components[i] is AddonComponent component)) + { continue; + } var itemTable = FindItemTable(component.ItemID); if (itemTable != null) + { component.ItemID = itemTable[(int)stage]; + } } } public override void OnComponentUsed(AddonComponent c, Mobile from) { if (!from.InRange(GetWorldLocation(), 4) || !from.InLOS(this)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (!IsFull) - from.SendLocalizedMessage(500997); // You need more wheat to make a sack of flour. + { + @from.SendLocalizedMessage(500997); // You need more wheat to make a sack of flour. + } else - StartWorking(from); + { + StartWorking(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Addons/GiantWebs.cs b/Projects/UOContent/Items/Addons/GiantWebs.cs index 179edc728..07470da09 100644 --- a/Projects/UOContent/Items/Addons/GiantWebs.cs +++ b/Projects/UOContent/Items/Addons/GiantWebs.cs @@ -9,12 +9,14 @@ namespace Server.Items var count = 5; for (var i = 0; i < count; ++i) + { AddComponent( new AddonComponent(itemID++), count - 1 - i, -(count - 1 - i), 0 ); + } } public GiantWeb1(Serial serial) @@ -46,12 +48,14 @@ namespace Server.Items var count = 5; for (var i = 0; i < count; ++i) + { AddComponent( new AddonComponent(itemID++), i, -i, 0 ); + } } public GiantWeb2(Serial serial) @@ -83,12 +87,14 @@ namespace Server.Items var count = 4; for (var i = 0; i < count; ++i) + { AddComponent( new AddonComponent(itemID++), i, -i, 0 ); + } } public GiantWeb3(Serial serial) @@ -120,12 +126,14 @@ namespace Server.Items var count = 4; for (var i = 0; i < count; ++i) + { AddComponent( new AddonComponent(itemID++), count - 1 - i, -(count - 1 - i), 0 ); + } } public GiantWeb4(Serial serial) @@ -157,12 +165,14 @@ namespace Server.Items var count = 4; for (var i = 0; i < count; ++i) + { AddComponent( new AddonComponent(itemID++), i, -i, 0 ); + } } public GiantWeb5(Serial serial) @@ -194,12 +204,14 @@ namespace Server.Items var count = 4; for (var i = 0; i < count; ++i) + { AddComponent( new AddonComponent(itemID++), count - 1 - i, -(count - 1 - i), 0 ); + } } public GiantWeb6(Serial serial) diff --git a/Projects/UOContent/Items/Addons/JackOLantern.cs b/Projects/UOContent/Items/Addons/JackOLantern.cs index 5893b5ab4..7c34f121b 100644 --- a/Projects/UOContent/Items/Addons/JackOLantern.cs +++ b/Projects/UOContent/Items/Addons/JackOLantern.cs @@ -59,7 +59,9 @@ namespace Server.Items if (version <= 1) + { Timer.DelayCall(Fix, version); + } } private void Fix(int version) @@ -77,7 +79,10 @@ namespace Server.Items case 0: { if (ac.Hue == 2118) + { ac.Hue = 1161; + } + break; } } diff --git a/Projects/UOContent/Items/Addons/PickpocketDips.cs b/Projects/UOContent/Items/Addons/PickpocketDips.cs index 90faf2897..c181497eb 100644 --- a/Projects/UOContent/Items/Addons/PickpocketDips.cs +++ b/Projects/UOContent/Items/Addons/PickpocketDips.cs @@ -75,18 +75,28 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 1)) - SendLocalizedMessageTo(from, 501816); // You are too far away to do that. + { + SendLocalizedMessageTo(@from, 501816); // You are too far away to do that. + } else if (Swinging) - SendLocalizedMessageTo(from, 501815); // You have to wait until it stops swinging. + { + SendLocalizedMessageTo(@from, 501815); // You have to wait until it stops swinging. + } else if (from.Skills.Stealing.Base >= MaxSkill) + { SendLocalizedMessageTo( - from, + @from, 501830 ); // Your ability to steal cannot improve any further by simply practicing on a dummy. + } else if (from.Mounted) - SendLocalizedMessageTo(from, 501829); // You can't practice on this while on a mount. + { + SendLocalizedMessageTo(@from, 501829); // You can't practice on this while on a mount. + } else - Use(from); + { + Use(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs b/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs index ec953aa69..45470a798 100644 --- a/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs +++ b/Projects/UOContent/Items/Addons/RejuvinationAnkhs.cs @@ -89,13 +89,17 @@ namespace Server.Items base.OnMovement(m, oldLocation); if (m.Player && Utility.InRange(Location, m.Location, 3) && !Utility.InRange(Location, oldLocation, 3)) + { if (DateTime.UtcNow >= m_NextMessage) { if (Components.Count > 0) + { Components[0].SendLocalizedMessageTo(m, 1010061); // An overwhelming sense of peace fills you. + } m_NextMessage = DateTime.UtcNow + TimeSpan.FromSeconds(25.0); } + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Addons/SHTeleporter.cs b/Projects/UOContent/Items/Addons/SHTeleporter.cs index 489ef80fd..002fd7920 100644 --- a/Projects/UOContent/Items/Addons/SHTeleporter.cs +++ b/Projects/UOContent/Items/Addons/SHTeleporter.cs @@ -37,7 +37,9 @@ namespace Server.Items m_Active = value; if (Addon is SHTeleporter sourceAddon) + { sourceAddon.ChangeActive(value); + } } } @@ -60,7 +62,9 @@ namespace Server.Items m_TeleDest = value; if (Addon is SHTeleporter sourceAddon) + { sourceAddon.ChangeDest(value); + } } } @@ -69,7 +73,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile m) { if (!m_Active || m_TeleDest?.Deleted != false || m_TeleDest.Map == Map.Internal) + { return; + } if (m.InRange(this, 3)) { @@ -205,7 +211,9 @@ namespace Server.Items public void ChangeActive(bool active) { if (m_Changing) + { return; + } m_Changing = true; @@ -220,7 +228,9 @@ namespace Server.Items public void ChangeDest(SHTeleComponent dest) { if (m_Changing) + { return; + } m_Changing = true; @@ -247,7 +257,9 @@ namespace Server.Items public void ChangeDest(SHTeleporter destAddon) { if (m_Changing) + { return; + } m_Changing = true; diff --git a/Projects/UOContent/Items/Addons/SolenAntHole.cs b/Projects/UOContent/Items/Addons/SolenAntHole.cs index 52cb7ea09..8347e228a 100644 --- a/Projects/UOContent/Items/Addons/SolenAntHole.cs +++ b/Projects/UOContent/Items/Addons/SolenAntHole.cs @@ -84,17 +84,23 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (!m.Player || !m.Alive || m.Hidden || !SpawnKilled()) + { return; + } if (Utility.InRange(Location, m.Location, 3) && !Utility.InRange(Location, oldLocation, 3)) { var count = 1 + Utility.Random(4); for (var i = 0; i < count; i++) + { SpawnAnt(); + } if (Utility.RandomDouble() < 0.05) + { SpawnAnt(new Beetle()); + } } } @@ -113,16 +119,24 @@ namespace Server.Items if (map == Map.Trammel) { if (random < 2) + { SpawnAnt(new RedSolenWorker()); + } else + { SpawnAnt(new RedSolenWarrior()); + } } else if (map == Map.Felucca) { if (random < 2) + { SpawnAnt(new BlackSolenWorker()); + } else + { SpawnAnt(new BlackSolenWarrior()); + } } } @@ -134,8 +148,12 @@ namespace Server.Items var p = Location; for (var i = 0; i < 5; i++) + { if (SpellHelper.FindValidSpawnLocation(map, ref p, false)) + { break; + } + } ant.MoveToWorld(p, map); ant.Home = Location; @@ -145,8 +163,12 @@ namespace Server.Items public bool SpawnKilled() { for (var i = m_Spawned.Count - 1; i >= 0; i--) + { if (!m_Spawned[i].Alive || m_Spawned[i].Deleted) + { m_Spawned.RemoveAt(i); + } + } return m_Spawned.Count < 2; } diff --git a/Projects/UOContent/Items/Addons/SpinningwheelEastAddon.cs b/Projects/UOContent/Items/Addons/SpinningwheelEastAddon.cs index 247af640d..afdde123d 100644 --- a/Projects/UOContent/Items/Addons/SpinningwheelEastAddon.cs +++ b/Projects/UOContent/Items/Addons/SpinningwheelEastAddon.cs @@ -34,6 +34,7 @@ namespace Server.Items m_Timer.Start(); foreach (var c in Components) + { switch (c.ItemID) { case 0x1015: @@ -43,6 +44,7 @@ namespace Server.Items ++c.ItemID; break; } + } } public override void Serialize(IGenericWriter writer) @@ -79,6 +81,7 @@ namespace Server.Items m_Timer = null; foreach (var c in Components) + { switch (c.ItemID) { case 0x1016: @@ -88,6 +91,7 @@ namespace Server.Items --c.ItemID; break; } + } callback?.Invoke(this, from, hue); } diff --git a/Projects/UOContent/Items/Addons/SpinningwheelSouthAddon.cs b/Projects/UOContent/Items/Addons/SpinningwheelSouthAddon.cs index f6b5ea13b..a6a23d515 100644 --- a/Projects/UOContent/Items/Addons/SpinningwheelSouthAddon.cs +++ b/Projects/UOContent/Items/Addons/SpinningwheelSouthAddon.cs @@ -26,6 +26,7 @@ namespace Server.Items m_Timer.Start(); foreach (var c in Components) + { switch (c.ItemID) { case 0x1015: @@ -35,6 +36,7 @@ namespace Server.Items ++c.ItemID; break; } + } } public override void Serialize(IGenericWriter writer) @@ -71,6 +73,7 @@ namespace Server.Items m_Timer = null; foreach (var c in Components) + { switch (c.ItemID) { case 0x1016: @@ -80,6 +83,7 @@ namespace Server.Items --c.ItemID; break; } + } callback?.Invoke(this, from, hue); } diff --git a/Projects/UOContent/Items/Addons/TrainingDummies.cs b/Projects/UOContent/Items/Addons/TrainingDummies.cs index 7ebbee488..3acbc40a4 100644 --- a/Projects/UOContent/Items/Addons/TrainingDummies.cs +++ b/Projects/UOContent/Items/Addons/TrainingDummies.cs @@ -72,20 +72,32 @@ namespace Server.Items var weapon = from.Weapon as BaseWeapon; if (weapon is BaseRanged) - SendLocalizedMessageTo(from, 501822); // You can't practice ranged weapons on this. + { + SendLocalizedMessageTo(@from, 501822); // You can't practice ranged weapons on this. + } else if (weapon == null || !from.InRange(GetWorldLocation(), weapon.MaxRange)) - SendLocalizedMessageTo(from, 501816); // You are too far away to do that. + { + SendLocalizedMessageTo(@from, 501816); // You are too far away to do that. + } else if (Swinging) - SendLocalizedMessageTo(from, 501815); // You have to wait until it stops swinging. + { + SendLocalizedMessageTo(@from, 501815); // You have to wait until it stops swinging. + } else if (from.Skills[weapon.Skill].Base >= MaxSkill) + { SendLocalizedMessageTo( - from, + @from, 501828 ); // Your skill cannot improve any further by simply practicing with a dummy. + } else if (from.Mounted) - SendLocalizedMessageTo(from, 501829); // You can't practice on this while on a mount. + { + SendLocalizedMessageTo(@from, 501829); // You can't practice on this while on a mount. + } else - Use(from, weapon); + { + Use(@from, weapon); + } } public override void Serialize(IGenericWriter writer) @@ -138,9 +150,13 @@ namespace Server.Items protected override void OnTick() { if (m_Delay) + { m_Dummy.OnHit(); + } else + { m_Dummy.EndSwing(); + } m_Delay = !m_Delay; } diff --git a/Projects/UOContent/Items/Aquarium/Aquarium.cs b/Projects/UOContent/Items/Aquarium/Aquarium.cs index 189ba7205..3c3f713d4 100644 --- a/Projects/UOContent/Items/Aquarium/Aquarium.cs +++ b/Projects/UOContent/Items/Aquarium/Aquarium.cs @@ -44,10 +44,14 @@ namespace Server.Items Movable = false; if (itemID == 0x3060) + { AddComponent(new AddonContainerComponent(0x3061), -1, 0, 0); + } if (itemID == 0x3062) + { AddComponent(new AddonContainerComponent(0x3063), 0, -1, 0); + } MaxItems = 30; @@ -84,13 +88,17 @@ namespace Server.Items var dead = 0; for (var i = 0; i < Items.Count; i++) + { if (Items[i] is BaseFish) { var fish = (BaseFish)Items[i]; if (fish.Dead) + { dead += 1; + } } + } return dead; } @@ -168,7 +176,10 @@ namespace Server.Items get { if (ItemID == 0x3062) + { return new AquariumEastDeed(); + } + return new AquariumNorthDeed(); } } @@ -218,7 +229,9 @@ namespace Server.Items if (dropped is FishBowl bowl) { if (bowl.Empty || !AddFish(from, bowl.Fish)) + { return false; + } bowl.InvalidateProperties(); @@ -227,7 +240,9 @@ namespace Server.Items else if (dropped is BaseFish fish) { if (!AddFish(from, fish)) + { return false; + } } else if (dropped is VacationWafer) { @@ -272,7 +287,9 @@ namespace Server.Items InvalidateProperties(); if (takeItem) - from.PlaySound(0x42); + { + @from.PlaySound(0x42); + } return takeItem; } @@ -288,14 +305,18 @@ namespace Server.Items item.MoveToWorld(loc, Map); if (item is BaseFish fish && !fish.Dead) + { fish.StartTimer(); + } } } public override bool CheckItemUse(Mobile from, Item item) { if (item != this) + { return false; + } return base.CheckItemUse(from, item); } @@ -314,53 +335,77 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (Deleted || !from.CanSee(this)) + { return; + } base.OnSingleClick(from); if (m_VacationLeft > 0) - LabelTo(from, 1074430, m_VacationLeft.ToString()); // Vacation days left: ~1_DAYS + { + LabelTo(@from, 1074430, m_VacationLeft.ToString()); // Vacation days left: ~1_DAYS + } if (Events.Count > 0) - LabelTo(from, 1074426, Events.Count.ToString()); // ~1_NUM~ event(s) to view! + { + LabelTo(@from, 1074426, Events.Count.ToString()); // ~1_NUM~ event(s) to view! + } if (m_RewardAvailable) - LabelTo(from, 1074362); // A reward is available! + { + LabelTo(@from, 1074362); // A reward is available! + } LabelTo(from, 1074247, $"{LiveCreatures}\t{MaxLiveCreatures}"); // Live Creatures: ~1_NUM~ / ~2_MAX~ if (DeadCreatures > 0) - LabelTo(from, 1074248, DeadCreatures.ToString()); // Dead Creatures: ~1_NUM~ + { + LabelTo(@from, 1074248, DeadCreatures.ToString()); // Dead Creatures: ~1_NUM~ + } var decorations = Items.Count - LiveCreatures - DeadCreatures; if (decorations > 0) - LabelTo(from, 1074249, (Items.Count - LiveCreatures - DeadCreatures).ToString()); // Decorations: ~1_NUM~ + { + LabelTo(@from, 1074249, (Items.Count - LiveCreatures - DeadCreatures).ToString()); // Decorations: ~1_NUM~ + } LabelTo(from, 1074250, $"#{FoodNumber()}"); // Food state: ~1_STATE~ LabelTo(from, 1074251, $"#{WaterNumber()}"); // Water state: ~1_STATE~ if (m_Food.State == (int)FoodState.Dead) - LabelTo(from, 1074577, $"{m_Food.Added}\t{m_Food.Improve}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~ + { + LabelTo(@from, 1074577, $"{m_Food.Added}\t{m_Food.Improve}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~ + } else if (m_Food.State == (int)FoodState.Overfed) - LabelTo(from, 1074577, $"{m_Food.Added}\t{m_Food.Maintain}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~ + { + LabelTo(@from, 1074577, $"{m_Food.Added}\t{m_Food.Maintain}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~ + } else + { LabelTo( - from, + @from, 1074253, $"{m_Food.Added}\t{m_Food.Maintain}\t{m_Food.Improve}" ); // Food Added: ~1_CUR~ Feed: ~2_NEED~ Improve: ~3_GROW~ + } if (m_Water.State == (int)WaterState.Dead) - LabelTo(from, 1074578, $"{m_Water.Added}\t{m_Water.Improve}"); // Water Added: ~1_CUR~ Needed: ~2_NEED~ + { + LabelTo(@from, 1074578, $"{m_Water.Added}\t{m_Water.Improve}"); // Water Added: ~1_CUR~ Needed: ~2_NEED~ + } else if (m_Water.State == (int)WaterState.Strong) - LabelTo(from, 1074578, $"{m_Water.Added}\t{m_Water.Maintain}"); // Water Added: ~1_CUR~ Needed: ~2_NEED~ + { + LabelTo(@from, 1074578, $"{m_Water.Added}\t{m_Water.Maintain}"); // Water Added: ~1_CUR~ Needed: ~2_NEED~ + } else + { LabelTo( - from, + @from, 1074254, $"{m_Water.Added}\t{m_Water.Maintain}\t{m_Water.Improve}" ); // Water Added: ~1_CUR~ Maintain: ~2_NEED~ Improve: ~3_GROW~ + } } public override void AddNameProperties(ObjectPropertyList list) @@ -368,34 +413,49 @@ namespace Server.Items base.AddNameProperties(list); if (m_VacationLeft > 0) + { list.Add(1074430, m_VacationLeft.ToString()); // Vacation days left: ~1_DAYS + } if (Events.Count > 0) + { list.Add(1074426, Events.Count.ToString()); // ~1_NUM~ event(s) to view! + } if (m_RewardAvailable) + { list.Add(1074362); // A reward is available! + } list.Add(1074247, "{0}\t{1}", LiveCreatures, MaxLiveCreatures); // Live Creatures: ~1_NUM~ / ~2_MAX~ var dead = DeadCreatures; if (dead > 0) + { list.Add(1074248, dead.ToString()); // Dead Creatures: ~1_NUM~ + } var decorations = Items.Count - LiveCreatures - dead; if (decorations > 0) + { list.Add(1074249, decorations.ToString()); // Decorations: ~1_NUM~ + } list.Add(1074250, "#{0}", FoodNumber()); // Food state: ~1_STATE~ list.Add(1074251, "#{0}", WaterNumber()); // Water state: ~1_STATE~ if (m_Food.State == (int)FoodState.Dead) + { list.Add(1074577, "{0}\t{1}", m_Food.Added, m_Food.Improve); // Food Added: ~1_CUR~ Needed: ~2_NEED~ + } else if (m_Food.State == (int)FoodState.Overfed) + { list.Add(1074577, "{0}\t{1}", m_Food.Added, m_Food.Maintain); // Food Added: ~1_CUR~ Needed: ~2_NEED~ + } else + { list.Add( 1074253, "{0}\t{1}\t{2}", @@ -403,12 +463,18 @@ namespace Server.Items m_Food.Maintain, m_Food.Improve ); // Food Added: ~1_CUR~ Feed: ~2_NEED~ Improve: ~3_GROW~ + } if (m_Water.State == (int)WaterState.Dead) + { list.Add(1074578, "{0}\t{1}", m_Water.Added, m_Water.Improve); // Water Added: ~1_CUR~ Needed: ~2_NEED~ + } else if (m_Water.State == (int)WaterState.Strong) + { list.Add(1074578, "{0}\t{1}", m_Water.Added, m_Water.Maintain); // Water Added: ~1_CUR~ Needed: ~2_NEED~ + } else + { list.Add( 1074254, "{0}\t{1}\t{2}", @@ -416,6 +482,7 @@ namespace Server.Items m_Water.Maintain, m_Water.Improve ); // Water Added: ~1_CUR~ Maintain: ~2_NEED~ Improve: ~3_GROW~ + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -429,13 +496,19 @@ namespace Server.Items if (HasAccess(from)) { if (m_RewardAvailable) + { list.Add(new CollectRewardEntry(this)); + } if (Events.Count > 0) + { list.Add(new ViewEventEntry(this)); + } if (m_VacationLeft > 0) + { list.Add(new CancelVacationMode(this)); + } } } @@ -457,9 +530,13 @@ namespace Server.Items // version 1 if (m_Timer != null) + { writer.Write(m_Timer.Next); + } else + { writer.Write(DateTime.UtcNow + EvaluationInterval); + } // version 0 writer.Write(LiveCreatures); @@ -471,7 +548,9 @@ namespace Server.Items writer.Write(Events.Count); for (var i = 0; i < Events.Count; i++) + { writer.Write(Events[i]); + } writer.Write(m_RewardAvailable); } @@ -491,7 +570,9 @@ namespace Server.Items var next = reader.ReadDateTime(); if (next < DateTime.UtcNow) + { next = DateTime.UtcNow; + } m_Timer = Timer.DelayCall(next - DateTime.UtcNow, EvaluationInterval, Evaluate); @@ -513,7 +594,9 @@ namespace Server.Items var count = reader.ReadInt(); for (var i = 0; i < count; i++) + { Events.Add(reader.ReadInt()); + } m_RewardAvailable = reader.ReadBool(); @@ -528,7 +611,9 @@ namespace Server.Items } if (version < 3) + { ValidationQueue.Add(this); + } } private void RecountLiveCreatures() @@ -540,7 +625,9 @@ namespace Server.Items fish => { if (!fish.Dead) + { ++LiveCreatures; + } } ); } @@ -553,10 +640,14 @@ namespace Server.Items public int FoodNumber() { if (m_Food.State == (int)FoodState.Full) + { return 1074240; + } if (m_Food.State == (int)FoodState.Overfed) + { return 1074239; + } return 1074236 + m_Food.State; } @@ -568,13 +659,17 @@ namespace Server.Items var toKill = new List(); for (var i = 0; i < Items.Count; i++) + { if (Items[i] is BaseFish) { var fish = (BaseFish)Items[i]; if (!fish.Dead) + { toKill.Add(fish); + } } + } while (amount > 0 && toKill.Count > 0) { @@ -607,32 +702,43 @@ namespace Server.Items m_Food.Added < m_Food.Maintain && m_Food.State != (int)FoodState.Overfed && m_Food.State != (int)FoodState.Dead || m_Food.Added >= m_Food.Improve && m_Food.State == (int)FoodState.Full) + { Events.Add(1074368); // The tank looks worse than it did yesterday. + } if ( m_Food.Added >= m_Food.Improve && m_Food.State != (int)FoodState.Full && m_Food.State != (int)FoodState.Overfed || m_Food.Added < m_Food.Maintain && m_Food.State == (int)FoodState.Overfed) + { Events.Add(1074367); // The tank looks healthier today. + } // water events if (m_Water.Added < m_Water.Maintain && m_Water.State != (int)WaterState.Dead) + { Events.Add(1074370); // This tank can use more water. + } if (m_Water.Added >= m_Water.Improve && m_Water.State != (int)WaterState.Strong) + { Events.Add(1074369); // The water looks clearer today. + } UpdateFoodState(); UpdateWaterState(); // reward if (LiveCreatures > 0) + { m_RewardAvailable = true; + } } else { // new fish if (OptimalState && LiveCreatures < MaxLiveCreatures) + { if (Utility.RandomDouble() < 0.005 * LiveCreatures) { BaseFish fish; @@ -679,21 +785,32 @@ namespace Server.Items } if (Utility.RandomDouble() < 0.05) + { fish.Hue = FishHues.RandomElement(); + } else if (Utility.RandomDouble() < 0.5) + { fish.Hue = Utility.RandomMinMax(0x100, 0x3E5); + } if (AddFish(fish)) + { Events.Add(message); + } else + { fish.Delete(); + } } + } // kill fish *grins* if (LiveCreatures < MaxLiveCreatures) { if (Utility.RandomDouble() < 0.01) + { KillFish(1); + } } else { @@ -708,14 +825,18 @@ namespace Server.Items public virtual void GiveReward(Mobile to) { if (!m_RewardAvailable) + { return; + } var max = (int)((double)LiveCreatures / 30 * m_Decorations.Length); var random = max <= 0 ? 0 : Utility.Random(max); if (random >= m_Decorations.Length) + { random = m_Decorations.Length - 1; + } Item item; @@ -729,7 +850,9 @@ namespace Server.Items } if (item == null) + { return; + } if (!to.PlaceInBackpack(item)) { @@ -749,16 +872,24 @@ namespace Server.Items public virtual void UpdateFoodState() { if (m_Food.Added < m_Food.Maintain) + { m_Food.State = m_Food.State <= 0 ? 0 : m_Food.State - 1; + } else if (m_Food.Added >= m_Food.Improve) + { m_Food.State = m_Food.State >= (int)FoodState.Overfed ? (int)FoodState.Overfed : m_Food.State + 1; + } m_Food.Maintain = Utility.Random((int)FoodState.Overfed + 1 - m_Food.State, 2); if (m_Food.State == (int)FoodState.Overfed) + { m_Food.Improve = 0; + } else + { m_Food.Improve = m_Food.Maintain + 2; + } m_Food.Added = 0; } @@ -766,16 +897,24 @@ namespace Server.Items public virtual void UpdateWaterState() { if (m_Water.Added < m_Water.Maintain) + { m_Water.State = m_Water.State <= 0 ? 0 : m_Water.State - 1; + } else if (m_Water.Added >= m_Water.Improve) + { m_Water.State = m_Water.State >= (int)WaterState.Strong ? (int)WaterState.Strong : m_Water.State + 1; + } m_Water.Maintain = Utility.Random((int)WaterState.Strong + 2 - m_Water.State, 2); if (m_Water.State == (int)WaterState.Strong) + { m_Water.Improve = 0; + } else + { m_Water.Improve = m_Water.Maintain + 2; + } m_Water.Added = 0; } @@ -783,7 +922,9 @@ namespace Server.Items public virtual bool RemoveItem(Mobile from, int at) { if (at < 0 || at >= Items.Count) + { return false; + } var item = Items[at]; @@ -815,7 +956,9 @@ namespace Server.Items } if (!fish.Dead) + { LiveCreatures -= 1; + } } else { @@ -851,7 +994,9 @@ namespace Server.Items public virtual bool AddFish(Mobile from, BaseFish fish) { if (fish == null) + { return false; + } if (IsFull || LiveCreatures >= MaxLiveCreatures || fish.Dead) { @@ -879,7 +1024,9 @@ namespace Server.Items public virtual bool AddDecoration(Mobile from, Item item) { if (item == null) + { return false; + } if (IsFull) { @@ -916,13 +1063,19 @@ namespace Server.Items public static bool Accepts(Item item) { if (item == null) + { return false; + } var type = item.GetType(); for (var i = 0; i < m_Decorations.Length; i++) + { if (type == m_Decorations[i]) + { return true; + } + } return false; } @@ -938,7 +1091,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted) + { return; + } m_Aquarium.ExamineAquarium(Owner.From); } @@ -955,7 +1110,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted || !m_Aquarium.HasAccess(Owner.From)) + { return; + } m_Aquarium.GiveReward(Owner.From); } @@ -972,12 +1129,16 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted || !m_Aquarium.HasAccess(Owner.From) || m_Aquarium.Events.Count == 0) + { return; + } Owner.From.SendLocalizedMessage(m_Aquarium.Events[0]); if (m_Aquarium.Events[0] == 1074366) + { Owner.From.PlaySound(0x5A2); + } m_Aquarium.Events.RemoveAt(0); m_Aquarium.InvalidateProperties(); @@ -995,7 +1156,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted || !m_Aquarium.HasAccess(Owner.From)) + { return; + } Owner.From.SendLocalizedMessage(1074429); // Vacation mode has been cancelled. m_Aquarium.VacationLeft = 0; @@ -1015,7 +1178,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted) + { return; + } m_Aquarium.Food.Added += 1; m_Aquarium.InvalidateProperties(); @@ -1033,7 +1198,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted) + { return; + } m_Aquarium.Water.Added += 1; m_Aquarium.InvalidateProperties(); @@ -1051,7 +1218,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted) + { return; + } m_Aquarium.Evaluate(); } @@ -1068,7 +1237,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted) + { return; + } Owner.From.SendGump(new AquariumGump(m_Aquarium, true)); } @@ -1085,7 +1256,9 @@ namespace Server.Items public override void OnClick() { if (m_Aquarium.Deleted) + { return; + } m_Aquarium.Food.Added = m_Aquarium.Food.Maintain; m_Aquarium.Water.Added = m_Aquarium.Water.Maintain; diff --git a/Projects/UOContent/Items/Aquarium/AquariumFishingNet.cs b/Projects/UOContent/Items/Aquarium/AquariumFishingNet.cs index 075ba5066..7f099f5b5 100644 --- a/Projects/UOContent/Items/Aquarium/AquariumFishingNet.cs +++ b/Projects/UOContent/Items/Aquarium/AquariumFishingNet.cs @@ -8,7 +8,9 @@ namespace Server.Items ItemID = 0xDC8; if (Hue == 0x8A0) + { Hue = 0x240; + } } public AquariumFishNet(Serial serial) : base(serial) @@ -66,9 +68,13 @@ namespace Server.Items if (!from.PlaceInBackpack(this)) { if (from.Map == null || from.Map == Map.Internal) + { Delete(); + } else - MoveToWorld(from.Location, from.Map); + { + MoveToWorld(@from.Location, @from.Map); + } } } @@ -81,7 +87,9 @@ namespace Server.Items var max = (int)skill / 5; if (max > 20) + { max = 20; + } return Utility.Random(max) switch { diff --git a/Projects/UOContent/Items/Aquarium/AquariumGump.cs b/Projects/UOContent/Items/Aquarium/AquariumGump.cs index 2d267c63b..84ad52488 100644 --- a/Projects/UOContent/Items/Aquarium/AquariumGump.cs +++ b/Projects/UOContent/Items/Aquarium/AquariumGump.cs @@ -21,10 +21,14 @@ namespace Server.Items AddImage(0, 0, 0x2C96); if (m_Aquarium.Items.Count == 0) + { return; + } for (var i = 1; i <= m_Aquarium.Items.Count; i++) + { DisplayPage(i, edit); + } } public void DisplayPage(int page, bool edit) @@ -35,13 +39,19 @@ namespace Server.Items // item name if (item.LabelNumber != 0) + { AddHtmlLocalized(20, 217, 250, 20, item.LabelNumber, 0xFFFFFF); // Name + } // item details if (item is BaseFish fish) + { AddHtmlLocalized(20, 239, 315, 20, fish.GetDescription(), 0xFFFFFF); + } else + { AddHtmlLocalized(20, 239, 315, 20, 1073634, 0xFFFFFF); // An aquarium decoration + } // item image AddItem(150, 80, item.ItemID, item.Hue); @@ -75,15 +85,21 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Aquarium?.Deleted != false) + { return; + } var edit = m_Aquarium.HasAccess(sender.Mobile); if (info.ButtonID > 0 && info.ButtonID <= m_Aquarium.Items.Count && edit) + { m_Aquarium.RemoveItem(sender.Mobile, info.ButtonID - 1); + } if (info.ButtonID > 0) + { sender.Mobile.SendGump(new AquariumGump(m_Aquarium, edit)); + } } } } diff --git a/Projects/UOContent/Items/Aquarium/BaseFish.cs b/Projects/UOContent/Items/Aquarium/BaseFish.cs index 1ab92eabe..be75c513c 100644 --- a/Projects/UOContent/Items/Aquarium/BaseFish.cs +++ b/Projects/UOContent/Items/Aquarium/BaseFish.cs @@ -56,9 +56,14 @@ namespace Server.Items { // TODO: This will never return "very unusual dead aquarium creature" due to the way it is killed if (ItemID > 0x3B0F) + { return Dead ? 1074424 : 1074422; // A very unusual [dead/live] aquarium creature + } + if (Hue != 0) + { return Dead ? 1074425 : 1074423; // A [dead/live] aquarium creature of unusual color + } return Dead ? 1073623 : 1073622; // A [dead/live] aquarium creature } @@ -70,7 +75,9 @@ namespace Server.Items list.Add(GetDescription()); if (!Dead && m_Timer != null) + { list.Add(1074507); // Gasping for air + } } public override void Serialize(IGenericWriter writer) @@ -87,7 +94,9 @@ namespace Server.Items var version = reader.ReadInt(); if (!(Parent is Aquarium) && !(Parent is FishBowl)) + { StartTimer(); + } } } } diff --git a/Projects/UOContent/Items/Aquarium/FishBowl.cs b/Projects/UOContent/Items/Aquarium/FishBowl.cs index 51442eade..edec4fa70 100644 --- a/Projects/UOContent/Items/Aquarium/FishBowl.cs +++ b/Projects/UOContent/Items/Aquarium/FishBowl.cs @@ -28,7 +28,9 @@ namespace Server.Items get { if (Empty) + { return null; + } return Items[0] as BaseFish; } @@ -43,7 +45,9 @@ namespace Server.Items public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) { if (!CheckHold(from, dropped, sendFullMessage, true)) + { return false; + } DropItem(dropped); return true; @@ -77,7 +81,9 @@ namespace Server.Items public override bool CheckItemUse(Mobile from, Item item) { if (item != this) + { return false; + } return base.CheckItemUse(from, item); } @@ -102,7 +108,9 @@ namespace Server.Items var fish = Fish; if (fish != null) + { list.Add(1074494, "#{0}", fish.LabelNumber); // Contains: ~1_CREATURE~ + } } } @@ -111,7 +119,9 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (!Empty && IsAccessibleTo(from)) + { list.Add(new RemoveCreature(this)); + } } public override void Serialize(IGenericWriter writer) @@ -128,7 +138,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0) + { Weight = DefaultWeight; + } } private class RemoveCreature : ContextMenuEntry @@ -142,12 +154,16 @@ namespace Server.Items public override void OnClick() { if (m_Bowl?.Deleted != false || !m_Bowl.IsAccessibleTo(Owner.From)) + { return; + } var fish = m_Bowl.Fish; if (fish == null) + { return; + } if (fish.IsLockedDown) // for legacy fish bowls { diff --git a/Projects/UOContent/Items/Aquarium/VacationWafer.cs b/Projects/UOContent/Items/Aquarium/VacationWafer.cs index 66589123b..a39a7da20 100644 --- a/Projects/UOContent/Items/Aquarium/VacationWafer.cs +++ b/Projects/UOContent/Items/Aquarium/VacationWafer.cs @@ -36,7 +36,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && ItemID == 0x971) + { ItemID = 0x973; + } } } } diff --git a/Projects/UOContent/Items/Armor/Artifacts/GauntletsOfNobility.cs b/Projects/UOContent/Items/Armor/Artifacts/GauntletsOfNobility.cs index 1124a43e9..69695cb89 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/GauntletsOfNobility.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/GauntletsOfNobility.cs @@ -40,7 +40,9 @@ namespace Server.Items if (version < 1) { if (Hue == 0x562) + { Hue = 0x4FE; + } PhysicalBonus = 0; PoisonBonus = 0; diff --git a/Projects/UOContent/Items/Armor/Artifacts/HelmOfInsight.cs b/Projects/UOContent/Items/Armor/Artifacts/HelmOfInsight.cs index 9e3bfaba9..59660e885 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/HelmOfInsight.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/HelmOfInsight.cs @@ -38,7 +38,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1) + { EnergyBonus = 0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Artifacts/HolyKnightsBreastplate.cs b/Projects/UOContent/Items/Armor/Artifacts/HolyKnightsBreastplate.cs index c2f84aadd..4eab9dd38 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/HolyKnightsBreastplate.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/HolyKnightsBreastplate.cs @@ -36,7 +36,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1) + { PhysicalBonus = 0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Artifacts/JackalsCollar.cs b/Projects/UOContent/Items/Armor/Artifacts/JackalsCollar.cs index 4e6f08f00..2a452629d 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/JackalsCollar.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/JackalsCollar.cs @@ -39,7 +39,9 @@ namespace Server.Items if (version < 1) { if (Hue == 0x54B) + { Hue = 0x6D1; + } FireBonus = 0; ColdBonus = 0; diff --git a/Projects/UOContent/Items/Armor/Artifacts/LeggingsOfBane.cs b/Projects/UOContent/Items/Armor/Artifacts/LeggingsOfBane.cs index 1f6bdeb5d..0b58b2209 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/LeggingsOfBane.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/LeggingsOfBane.cs @@ -39,16 +39,24 @@ namespace Server.Items var version = reader.ReadInt(); if (version <= 1) + { if (HitPoints > 255 || MaxHitPoints > 255) + { HitPoints = MaxHitPoints = 255; + } + } if (version < 1) { if (Hue == 0x559) + { Hue = 0x4F5; + } if (ArmorAttributes.DurabilityBonus == 0) + { ArmorAttributes.DurabilityBonus = 100; + } PoisonBonus = 0; } diff --git a/Projects/UOContent/Items/Armor/Artifacts/MidnightBracers.cs b/Projects/UOContent/Items/Armor/Artifacts/MidnightBracers.cs index 5bfc46f07..5e35cd644 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/MidnightBracers.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/MidnightBracers.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1) + { PhysicalBonus = 0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Artifacts/OrnateCrownOfTheHarrower.cs b/Projects/UOContent/Items/Armor/Artifacts/OrnateCrownOfTheHarrower.cs index 0ab3f2896..9de7f2256 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/OrnateCrownOfTheHarrower.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/OrnateCrownOfTheHarrower.cs @@ -39,7 +39,9 @@ namespace Server.Items if (version < 1) { if (Hue == 0x55A) + { Hue = 0x4F6; + } PoisonBonus = 0; } diff --git a/Projects/UOContent/Items/Armor/Artifacts/ShadowDancerLeggings.cs b/Projects/UOContent/Items/Armor/Artifacts/ShadowDancerLeggings.cs index 80bfbeee8..e081e8f33 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/ShadowDancerLeggings.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/ShadowDancerLeggings.cs @@ -41,7 +41,9 @@ namespace Server.Items if (version < 1) { if (ItemID == 0x13CB) + { ItemID = 0x13D2; + } PhysicalBonus = 0; PoisonBonus = 0; diff --git a/Projects/UOContent/Items/Armor/Artifacts/TunicOfFire.cs b/Projects/UOContent/Items/Armor/Artifacts/TunicOfFire.cs index 3d0202d8d..feef1b59f 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/TunicOfFire.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/TunicOfFire.cs @@ -40,10 +40,14 @@ namespace Server.Items if (version < 1) { if (Hue == 0x54E) + { Hue = 0x54F; + } if (Attributes.NightSight == 0) + { Attributes.NightSight = 1; + } PhysicalBonus = 0; FireBonus = 0; diff --git a/Projects/UOContent/Items/Armor/Artifacts/VoiceOfTheFallenKing.cs b/Projects/UOContent/Items/Armor/Artifacts/VoiceOfTheFallenKing.cs index 6174ea716..6b034bbd3 100644 --- a/Projects/UOContent/Items/Armor/Artifacts/VoiceOfTheFallenKing.cs +++ b/Projects/UOContent/Items/Armor/Artifacts/VoiceOfTheFallenKing.cs @@ -40,7 +40,9 @@ namespace Server.Items if (version < 1) { if (Hue == 0x551) + { Hue = 0x76D; + } ColdBonus = 0; EnergyBonus = 0; diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index f11b5840a..e843a85f7 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -107,7 +107,10 @@ namespace Server.Items get { if (m_ArmorBase == -1) + { return ArmorBase; + } + return m_ArmorBase; } set @@ -126,7 +129,9 @@ namespace Server.Items var ar = BaseArmorRating; if (m_Protection != ArmorProtectionLevel.Regular) + { ar += 10 + 5 * (int)m_Protection; + } switch (m_Resource) { @@ -264,7 +269,10 @@ namespace Server.Items m_Resource = value; - if (CraftItem.RetainsColor(GetType())) Hue = CraftResources.GetHue(m_Resource); + if (CraftItem.RetainsColor(GetType())) + { + Hue = CraftResources.GetHue(m_Resource); + } Invalidate(); InvalidateProperties(); @@ -283,7 +291,9 @@ namespace Server.Items var pos = (int)BodyPosition; if (pos >= 0 && pos < ArmorScalars.Length) + { return ArmorScalars[pos]; + } return 1.0; } @@ -481,7 +491,9 @@ namespace Server.Items Quality = (ArmorQuality)quality; if (makersMark) - Crafter = from; + { + Crafter = @from; + } var resourceType = typeRes ?? craftItem.Resources[0].ItemType; @@ -491,22 +503,27 @@ namespace Server.Items var context = craftSystem.GetContext(from); if (context?.DoNotColor == true) + { Hue = 0; + } if (Quality == ArmorQuality.Exceptional) { if (!(Core.ML && this is BaseShield) ) // Guessed Core.ML removed exceptional resist bonuses from crafted shields + { DistributeBonuses( tool is BaseRunicTool ? 6 : Core.SE ? 15 : 14 ); // Not sure since when, but right now 15 points are added, not 14. + } if (Core.ML && !(this is BaseShield)) { var bonus = (int)(from.Skills.ArmsLore.Value / 20); for (var i = 0; i < bonus; i++) + { switch (Utility.Random(5)) { case 0: @@ -525,13 +542,16 @@ namespace Server.Items m_PoisonBonus++; break; } + } from.CheckSkill(SkillName.ArmsLore, 0, 100); } } if (Core.AOS) + { (tool as BaseRunicTool)?.ApplyAttributesTo(this); + } return quality; } @@ -544,7 +564,9 @@ namespace Server.Items m_FactionState = value; if (m_FactionState == null) + { Hue = CraftResources.GetHue(Resource); + } LootType = m_FactionState == null ? LootType.Regular : LootType.Blessed; } @@ -569,17 +591,19 @@ namespace Server.Items var item = system.CraftItems.SearchFor(GetType()); if (item?.Resources.Count == 1 && item.Resources[0].Amount >= 2) + { try { var res = (Item)ActivatorUtil.CreateInstance(CraftResources.GetInfo(m_Resource).ResourceTypes[0]); - ScissorHelper(from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1); + ScissorHelper(@from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1); return true; } catch { // ignored } + } from.SendLocalizedMessage(502440); // Scissors can not be used on that to produce anything. return false; @@ -609,9 +633,13 @@ namespace Server.Items m_HitPoints = value; if (m_HitPoints < 0) + { Delete(); + } else if (m_HitPoints > MaxHitPoints) + { m_HitPoints = MaxHitPoints; + } InvalidateProperties(); } @@ -648,7 +676,9 @@ namespace Server.Items damageTaken = Math.Min(absorbed, damageTaken); if (absorbed < 2) + { absorbed = 2; + } if (Utility.Random(100) < 25) // 25% chance to lower durability { @@ -661,9 +691,13 @@ namespace Server.Items int wear; if (weapon.Type == WeaponType.Bashing) + { wear = absorbed / 2; + } else + { wear = Utility.Random(2); + } if (wear > 0 && m_MaxHitPoints > 0) { @@ -685,11 +719,13 @@ namespace Server.Items MaxHitPoints -= wear; if (Parent is Mobile mobile) + { mobile.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged. + } } else { @@ -706,7 +742,9 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseArmor armor)) + { return; + } armor.Attributes = new AosAttributes(newItem, Attributes); armor.ArmorAttributes = new AosArmorAttributes(newItem, ArmorAttributes); @@ -718,11 +756,17 @@ namespace Server.Items int v; if (type == StatType.Str) + { v = StrRequirement; + } else if (type == StatType.Dex) + { v = DexRequirement; + } else + { v = IntRequirement; + } return AOS.Scale(v, 100 - GetLowerStatReq()); } @@ -730,15 +774,22 @@ namespace Server.Items public int ComputeStatBonus(StatType type) { if (type == StatType.Str) + { return StrBonus + Attributes.BonusStr; + } + if (type == StatType.Dex) + { return DexBonus + Attributes.BonusDex; + } + return IntBonus + Attributes.BonusInt; } public void DistributeBonuses(int amount) { for (var i = 0; i < amount; ++i) + { switch (Utility.Random(5)) { case 0: @@ -757,6 +808,7 @@ namespace Server.Items ++m_EnergyBonus; break; } + } InvalidateProperties(); } @@ -766,7 +818,9 @@ namespace Server.Items var info = CraftResources.GetInfo(m_Resource); if (info == null) + { return CraftAttributeInfo.Blank; + } return info.AttributeInfo; } @@ -788,7 +842,9 @@ namespace Server.Items var bonus = 0; if (m_Quality == ArmorQuality.Exceptional) + { bonus += 20; + } switch (m_Durability) { @@ -817,10 +873,14 @@ namespace Server.Items CraftAttributeInfo attrInfo = null; if (resInfo != null) + { attrInfo = resInfo.AttributeInfo; + } if (attrInfo != null) + { bonus += attrInfo.ArmorDurability; + } } return bonus; @@ -831,7 +891,9 @@ namespace Server.Items for (var i = m.Items.Count - 1; i >= 0; --i) { if (i >= m.Items.Count) + { continue; + } var item = m.Items[i]; @@ -840,27 +902,39 @@ namespace Server.Items if (armor.RequiredRace != null && m.Race != armor.RequiredRace) { if (armor.RequiredRace == Race.Elf) + { m.SendLocalizedMessage(1072203); // Only Elves may use this. + } else + { m.SendMessage("Only {0} may use this.", armor.RequiredRace.PluralName); + } m.AddToBackpack(armor); } else if (!armor.AllowMaleWearer && !m.Female && m.AccessLevel < AccessLevel.GameMaster) { if (armor.AllowFemaleWearer) + { m.SendLocalizedMessage(1010388); // Only females can wear this. + } else + { m.SendMessage("You may not wear this."); + } m.AddToBackpack(armor); } else if (!armor.AllowFemaleWearer && m.Female && m.AccessLevel < AccessLevel.GameMaster) { if (armor.AllowMaleWearer) + { m.SendLocalizedMessage(1063343); // Only males can wear this. + } else + { m.SendMessage("You may not wear this."); + } m.AddToBackpack(armor); } @@ -871,7 +945,9 @@ namespace Server.Items public int GetLowerStatReq() { if (!Core.AOS) + { return 0; + } var v = ArmorAttributes.LowerStatReq; @@ -880,10 +956,14 @@ namespace Server.Items var attrInfo = info?.AttributeInfo; if (attrInfo != null) + { v += attrInfo.ArmorLowerRequirements; + } if (v > 100) + { v = 100; + } return v; } @@ -893,7 +973,9 @@ namespace Server.Items if (parent is Mobile from) { if (Core.AOS) - SkillBonuses.AddTo(from); + { + SkillBonuses.AddTo(@from); + } from.Delta(MobileDelta.Armor); // Tell them armor rating has changed } @@ -904,7 +986,9 @@ namespace Server.Items var scale = 100; if (m_MaxHitPoints > 0 && m_HitPoints < m_MaxHitPoints) + { scale = 50 + 50 * m_HitPoints / m_MaxHitPoints; + } return armor * scale / 100; } @@ -917,7 +1001,9 @@ namespace Server.Items private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) + { flags |= toSet; + } } private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; @@ -959,73 +1045,119 @@ namespace Server.Items writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) + { ArmorAttributes.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) + { writer.WriteEncodedInt(m_PhysicalBonus); + } if (GetSaveFlag(flags, SaveFlag.FireBonus)) + { writer.WriteEncodedInt(m_FireBonus); + } if (GetSaveFlag(flags, SaveFlag.ColdBonus)) + { writer.WriteEncodedInt(m_ColdBonus); + } if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) + { writer.WriteEncodedInt(m_PoisonBonus); + } if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) + { writer.WriteEncodedInt(m_EnergyBonus); + } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) + { writer.WriteEncodedInt(m_MaxHitPoints); + } if (GetSaveFlag(flags, SaveFlag.HitPoints)) + { writer.WriteEncodedInt(m_HitPoints); + } if (GetSaveFlag(flags, SaveFlag.Crafter)) + { writer.Write(m_Crafter); + } if (GetSaveFlag(flags, SaveFlag.Quality)) + { writer.WriteEncodedInt((int)m_Quality); + } if (GetSaveFlag(flags, SaveFlag.Durability)) + { writer.WriteEncodedInt((int)m_Durability); + } if (GetSaveFlag(flags, SaveFlag.Protection)) + { writer.WriteEncodedInt((int)m_Protection); + } if (GetSaveFlag(flags, SaveFlag.Resource)) + { writer.WriteEncodedInt((int)m_Resource); + } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) + { writer.WriteEncodedInt(m_ArmorBase); + } if (GetSaveFlag(flags, SaveFlag.StrBonus)) + { writer.WriteEncodedInt(m_StrBonus); + } if (GetSaveFlag(flags, SaveFlag.DexBonus)) + { writer.WriteEncodedInt(m_DexBonus); + } if (GetSaveFlag(flags, SaveFlag.IntBonus)) + { writer.WriteEncodedInt(m_IntBonus); + } if (GetSaveFlag(flags, SaveFlag.StrReq)) + { writer.WriteEncodedInt(m_StrReq); + } if (GetSaveFlag(flags, SaveFlag.DexReq)) + { writer.WriteEncodedInt(m_DexReq); + } if (GetSaveFlag(flags, SaveFlag.IntReq)) + { writer.WriteEncodedInt(m_IntReq); + } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) + { writer.WriteEncodedInt((int)m_Meditate); + } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + { SkillBonuses.Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -1043,56 +1175,90 @@ namespace Server.Items var flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes = new AosAttributes(this, reader); + } else + { Attributes = new AosAttributes(this); + } if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) + { ArmorAttributes = new AosArmorAttributes(this, reader); + } else + { ArmorAttributes = new AosArmorAttributes(this); + } if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) + { m_PhysicalBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.FireBonus)) + { m_FireBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.ColdBonus)) + { m_ColdBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) + { m_PoisonBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) + { m_EnergyBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.Identified)) + { m_Identified = version >= 7 || reader.ReadBool(); + } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) + { m_MaxHitPoints = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.HitPoints)) + { m_HitPoints = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.Crafter)) + { m_Crafter = reader.ReadMobile(); + } if (GetSaveFlag(flags, SaveFlag.Quality)) + { m_Quality = (ArmorQuality)reader.ReadEncodedInt(); + } else + { m_Quality = ArmorQuality.Regular; + } if (version == 5 && m_Quality == ArmorQuality.Low) + { m_Quality = ArmorQuality.Regular; + } if (GetSaveFlag(flags, SaveFlag.Durability)) { m_Durability = (ArmorDurabilityLevel)reader.ReadEncodedInt(); if (m_Durability > ArmorDurabilityLevel.Indestructible) + { m_Durability = ArmorDurabilityLevel.Durable; + } } if (GetSaveFlag(flags, SaveFlag.Protection)) @@ -1100,62 +1266,106 @@ namespace Server.Items m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); if (m_Protection > ArmorProtectionLevel.Invulnerability) + { m_Protection = ArmorProtectionLevel.Defense; + } } if (GetSaveFlag(flags, SaveFlag.Resource)) + { m_Resource = (CraftResource)reader.ReadEncodedInt(); + } else + { m_Resource = DefaultResource; + } if (m_Resource == CraftResource.None) + { m_Resource = DefaultResource; + } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) + { m_ArmorBase = reader.ReadEncodedInt(); + } else + { m_ArmorBase = -1; + } if (GetSaveFlag(flags, SaveFlag.StrBonus)) + { m_StrBonus = reader.ReadEncodedInt(); + } else + { m_StrBonus = -1; + } if (GetSaveFlag(flags, SaveFlag.DexBonus)) + { m_DexBonus = reader.ReadEncodedInt(); + } else + { m_DexBonus = -1; + } if (GetSaveFlag(flags, SaveFlag.IntBonus)) + { m_IntBonus = reader.ReadEncodedInt(); + } else + { m_IntBonus = -1; + } if (GetSaveFlag(flags, SaveFlag.StrReq)) + { m_StrReq = reader.ReadEncodedInt(); + } else + { m_StrReq = -1; + } if (GetSaveFlag(flags, SaveFlag.DexReq)) + { m_DexReq = reader.ReadEncodedInt(); + } else + { m_DexReq = -1; + } if (GetSaveFlag(flags, SaveFlag.IntReq)) + { m_IntReq = reader.ReadEncodedInt(); + } else + { m_IntReq = -1; + } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) + { m_Meditate = (AMA)reader.ReadEncodedInt(); + } else + { m_Meditate = (AMA)(-1); + } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + { SkillBonuses = new AosSkillBonuses(this, reader); + } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) + { PlayerConstructed = true; + } break; } @@ -1193,7 +1403,9 @@ namespace Server.Items var mat = (AMT)reader.ReadInt(); if (m_ArmorBase == RevertArmorBase) + { m_ArmorBase = -1; + } /*m_BodyPos = (ArmorBodyType)*/ reader.ReadInt(); @@ -1205,7 +1417,9 @@ namespace Server.Items } if (version < 3 && m_Quality == ArmorQuality.Exceptional) + { DistributeBonuses(6); + } if (version >= 2) { @@ -1238,44 +1452,70 @@ namespace Server.Items m_IntReq = reader.ReadInt(); if (m_StrBonus == OldStrBonus) + { m_StrBonus = -1; + } if (m_DexBonus == OldDexBonus) + { m_DexBonus = -1; + } if (m_IntBonus == OldIntBonus) + { m_IntBonus = -1; + } if (m_StrReq == OldStrReq) + { m_StrReq = -1; + } if (m_DexReq == OldDexReq) + { m_DexReq = -1; + } if (m_IntReq == OldIntReq) + { m_IntReq = -1; + } m_Meditate = (AMA)reader.ReadInt(); if (m_Meditate == OldMedAllowance) + { m_Meditate = (AMA)(-1); + } if (m_Resource == CraftResource.None) { if (mat == ArmorMaterialType.Studded || mat == ArmorMaterialType.Leather) + { m_Resource = CraftResource.RegularLeather; + } else if (mat == ArmorMaterialType.Spined) + { m_Resource = CraftResource.SpinedLeather; + } else if (mat == ArmorMaterialType.Horned) + { m_Resource = CraftResource.HornedLeather; + } else if (mat == ArmorMaterialType.Barbed) + { m_Resource = CraftResource.BarbedLeather; + } else + { m_Resource = CraftResource.Iron; + } } if (m_MaxHitPoints == 0 && m_HitPoints == 0) + { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); + } break; } @@ -1286,7 +1526,9 @@ namespace Server.Items var m = Parent as Mobile; if (Core.AOS && m != null) + { SkillBonuses.AddTo(m); + } var strBonus = ComputeStatBonus(StatType.Str); var dexBonus = ComputeStatBonus(StatType.Dex); @@ -1297,25 +1539,35 @@ namespace Server.Items var modName = Serial.ToString(); if (strBonus != 0) + { m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) + { m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) + { m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } m?.CheckStatTimers(); if (version < 7) + { PlayerConstructed = true; // we don't know, so, assume it's crafted + } } public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { if (!Ethic.CheckTrade(from, to, newOwner, this)) + { return false; + } return base.AllowSecureTrade(from, to, newOwner, accepted); } @@ -1323,16 +1575,22 @@ namespace Server.Items public override bool CanEquip(Mobile from) { if (!Ethic.CheckEquip(from, this)) + { return false; + } if (from.AccessLevel < AccessLevel.GameMaster) { if (RequiredRace != null && from.Race != RequiredRace) { if (RequiredRace == Race.Elf) - from.SendLocalizedMessage(1072203); // Only Elves may use this. + { + @from.SendLocalizedMessage(1072203); // Only Elves may use this. + } else - from.SendMessage("Only {0} may use this.", RequiredRace.PluralName); + { + @from.SendMessage("Only {0} may use this.", RequiredRace.PluralName); + } return false; } @@ -1340,9 +1598,13 @@ namespace Server.Items if (!AllowMaleWearer && !from.Female) { if (AllowFemaleWearer) - from.SendLocalizedMessage(1010388); // Only females can wear this. + { + @from.SendLocalizedMessage(1010388); // Only females can wear this. + } else - from.SendMessage("You may not wear this."); + { + @from.SendMessage("You may not wear this."); + } return false; } @@ -1350,9 +1612,13 @@ namespace Server.Items if (!AllowFemaleWearer && from.Female) { if (AllowMaleWearer) - from.SendLocalizedMessage(1063343); // Only males can wear this. + { + @from.SendLocalizedMessage(1063343); // Only males can wear this. + } else - from.SendMessage("You may not wear this."); + { + @from.SendMessage("You may not wear this."); + } return false; } @@ -1386,13 +1652,19 @@ namespace Server.Items public override bool CheckPropertyConflict(Mobile m) { if (base.CheckPropertyConflict(m)) + { return true; + } if (Layer == Layer.Pants) + { return m.FindItemOnLayer(Layer.InnerLegs) != null; + } if (Layer == Layer.Shirt) + { return m.FindItemOnLayer(Layer.InnerTorso) != null; + } return false; } @@ -1410,13 +1682,19 @@ namespace Server.Items var modName = Serial.ToString(); if (strBonus != 0) - from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) - from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) - from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } return base.OnEquip(from); @@ -1433,7 +1711,9 @@ namespace Server.Items m.RemoveStatMod($"{modName}Int"); if (Core.AOS) + { SkillBonuses.Remove(); + } m.Delta(MobileDelta.Armor); // Tell them armor rating has changed m.CheckStatTimers(); @@ -1471,25 +1751,37 @@ namespace Server.Items if (m_Quality == ArmorQuality.Exceptional) { if (oreType != 0) + { list.Add(1053100, "#{0}\t{1}", oreType, GetNameString()); // exceptional ~1_oretype~ ~2_armortype~ + } else + { list.Add(1050040, GetNameString()); // exceptional ~1_ITEMNAME~ + } } else { if (oreType != 0) + { list.Add(1053099, "#{0}\t{1}", oreType, GetNameString()); // ~1_oretype~ ~2_armortype~ + } else if (Name == null) + { list.Add(LabelNumber); + } else + { list.Add(Name); + } } } public override bool AllowEquippedCast(Mobile from) { if (base.AllowEquippedCast(from)) + { return true; + } return Attributes.SpellChanneling != 0; } @@ -1501,7 +1793,9 @@ namespace Server.Items var attrInfo = resInfo?.AttributeInfo; if (attrInfo == null) + { return 0; + } return attrInfo.ArmorLuck; } @@ -1511,112 +1805,180 @@ namespace Server.Items base.GetProperties(list); if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } if (m_FactionState != null) + { list.Add(1041350); // faction item + } if (RequiredRace == Race.Elf) + { list.Add(1075086); // Elves Only + } SkillBonuses.GetProperties(list); int prop; if ((prop = ArtifactRarity) > 0) + { list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~ + } if ((prop = Attributes.WeaponDamage) != 0) + { list.Add(1060401, prop.ToString()); // damage increase ~1_val~% + } if ((prop = Attributes.DefendChance) != 0) + { list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% + } if ((prop = Attributes.BonusDex) != 0) + { list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ + } if ((prop = Attributes.EnhancePotions) != 0) + { list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% + } if ((prop = Attributes.CastRecovery) != 0) + { list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ + } if ((prop = Attributes.CastSpeed) != 0) + { list.Add(1060413, prop.ToString()); // faster casting ~1_val~ + } if ((prop = Attributes.AttackChance) != 0) + { list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% + } if ((prop = Attributes.BonusHits) != 0) + { list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ + } if ((prop = Attributes.BonusInt) != 0) + { list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ + } if ((prop = Attributes.LowerManaCost) != 0) + { list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% + } if ((prop = Attributes.LowerRegCost) != 0) + { list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% + } if ((prop = GetLowerStatReq()) != 0) + { list.Add(1060435, prop.ToString()); // lower requirements ~1_val~% + } if ((prop = GetLuckBonus() + Attributes.Luck) != 0) + { list.Add(1060436, prop.ToString()); // luck ~1_val~ + } if (ArmorAttributes.MageArmor != 0) + { list.Add(1060437); // mage armor + } if ((prop = Attributes.BonusMana) != 0) + { list.Add(1060439, prop.ToString()); // mana increase ~1_val~ + } if ((prop = Attributes.RegenMana) != 0) + { list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ + } if (Attributes.NightSight != 0) + { list.Add(1060441); // night sight + } if ((prop = Attributes.ReflectPhysical) != 0) + { list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% + } if ((prop = Attributes.RegenStam) != 0) + { list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ + } if ((prop = Attributes.RegenHits) != 0) + { list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ + } if ((prop = ArmorAttributes.SelfRepair) != 0) + { list.Add(1060450, prop.ToString()); // self repair ~1_val~ + } if (Attributes.SpellChanneling != 0) + { list.Add(1060482); // spell channeling + } if ((prop = Attributes.SpellDamage) != 0) + { list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% + } if ((prop = Attributes.BonusStam) != 0) + { list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ + } if ((prop = Attributes.BonusStr) != 0) + { list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ + } if ((prop = Attributes.WeaponSpeed) != 0) + { list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% + } if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) + { list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% + } AddResistanceProperties(list); if ((prop = GetDurabilityBonus()) > 0) + { list.Add(1060410, prop.ToString()); // durability ~1_val~% + } if ((prop = ComputeStatReq(StatType.Str)) > 0) + { list.Add(1061170, prop.ToString()); // strength requirement ~1_val~ + } if (m_HitPoints >= 0 && m_MaxHitPoints > 0) + { list.Add(1060639, "{0}\t{1}", m_HitPoints, m_MaxHitPoints); // durability ~1_val~ / ~2_val~ + } } public override void OnSingleClick(Mobile from) @@ -1626,24 +1988,36 @@ namespace Server.Items if (DisplayLootType) { if (LootType == LootType.Blessed) + { attrs.Add(new EquipInfoAttribute(1038021)); // blessed + } else if (LootType == LootType.Cursed) + { attrs.Add(new EquipInfoAttribute(1049643)); // cursed + } } if (m_FactionState != null) + { attrs.Add(new EquipInfoAttribute(1041350)); // faction item + } if (m_Quality == ArmorQuality.Exceptional) + { attrs.Add(new EquipInfoAttribute(1018305 - (int)m_Quality)); + } if (m_Identified || from.AccessLevel >= AccessLevel.GameMaster) { if (m_Durability != ArmorDurabilityLevel.Regular) + { attrs.Add(new EquipInfoAttribute(1038000 + (int)m_Durability)); + } if (m_Protection > ArmorProtectionLevel.Regular && m_Protection <= ArmorProtectionLevel.Invulnerability) + { attrs.Add(new EquipInfoAttribute(1038005 + (int)m_Protection)); + } } else if (m_Durability != ArmorDurabilityLevel.Regular || m_Protection > ArmorProtectionLevel.Regular && m_Protection <= ArmorProtectionLevel.Invulnerability) @@ -1664,7 +2038,9 @@ namespace Server.Items } if (attrs.Count == 0 && Crafter == null && Name != null) + { return; + } var eqInfo = new EquipmentInfo(number, m_Crafter, false, attrs.ToArray()); diff --git a/Projects/UOContent/Items/Armor/Bone/BoneArms.cs b/Projects/UOContent/Items/Armor/Bone/BoneArms.cs index 905926843..97aa911a0 100644 --- a/Projects/UOContent/Items/Armor/Bone/BoneArms.cs +++ b/Projects/UOContent/Items/Armor/Bone/BoneArms.cs @@ -36,7 +36,9 @@ namespace Server.Items writer.Write(0); if (Weight == 1.0) + { Weight = 2.0; + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Items/Armor/Bone/BoneChest.cs b/Projects/UOContent/Items/Armor/Bone/BoneChest.cs index c276cb920..e14184cdc 100644 --- a/Projects/UOContent/Items/Armor/Bone/BoneChest.cs +++ b/Projects/UOContent/Items/Armor/Bone/BoneChest.cs @@ -36,7 +36,9 @@ namespace Server.Items writer.Write(0); if (Weight == 1.0) + { Weight = 6.0; + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Items/Armor/Bone/BoneGloves.cs b/Projects/UOContent/Items/Armor/Bone/BoneGloves.cs index cb00114e8..09e68207d 100644 --- a/Projects/UOContent/Items/Armor/Bone/BoneGloves.cs +++ b/Projects/UOContent/Items/Armor/Bone/BoneGloves.cs @@ -36,7 +36,9 @@ namespace Server.Items writer.Write(0); if (Weight == 1.0) + { Weight = 2.0; + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Items/Armor/DaemonBone/DaemonArms.cs b/Projects/UOContent/Items/Armor/DaemonBone/DaemonArms.cs index 0f77c01fb..51d43ea44 100644 --- a/Projects/UOContent/Items/Armor/DaemonBone/DaemonArms.cs +++ b/Projects/UOContent/Items/Armor/DaemonBone/DaemonArms.cs @@ -44,7 +44,9 @@ namespace Server.Items writer.Write(0); if (Weight == 1.0) + { Weight = 2.0; + } } public override void Deserialize(IGenericReader reader) @@ -54,7 +56,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ArmorAttributes.SelfRepair == 0) + { ArmorAttributes.SelfRepair = 1; + } } } } diff --git a/Projects/UOContent/Items/Armor/DaemonBone/DaemonChest.cs b/Projects/UOContent/Items/Armor/DaemonBone/DaemonChest.cs index f5e98e98a..a580e032d 100644 --- a/Projects/UOContent/Items/Armor/DaemonBone/DaemonChest.cs +++ b/Projects/UOContent/Items/Armor/DaemonBone/DaemonChest.cs @@ -51,10 +51,14 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 6.0; + } if (ArmorAttributes.SelfRepair == 0) + { ArmorAttributes.SelfRepair = 1; + } } } } diff --git a/Projects/UOContent/Items/Armor/DaemonBone/DaemonGloves.cs b/Projects/UOContent/Items/Armor/DaemonBone/DaemonGloves.cs index 73ad8ffc9..6ffdef93d 100644 --- a/Projects/UOContent/Items/Armor/DaemonBone/DaemonGloves.cs +++ b/Projects/UOContent/Items/Armor/DaemonBone/DaemonGloves.cs @@ -51,10 +51,14 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } if (ArmorAttributes.SelfRepair == 0) + { ArmorAttributes.SelfRepair = 1; + } } } } diff --git a/Projects/UOContent/Items/Armor/DaemonBone/DaemonLegs.cs b/Projects/UOContent/Items/Armor/DaemonBone/DaemonLegs.cs index 32c771118..8e1737ee8 100644 --- a/Projects/UOContent/Items/Armor/DaemonBone/DaemonLegs.cs +++ b/Projects/UOContent/Items/Armor/DaemonBone/DaemonLegs.cs @@ -49,7 +49,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ArmorAttributes.SelfRepair == 0) + { ArmorAttributes.SelfRepair = 1; + } } } } diff --git a/Projects/UOContent/Items/Armor/Dragon/DragonArms.cs b/Projects/UOContent/Items/Armor/Dragon/DragonArms.cs index 400efed19..3cc6a90b0 100644 --- a/Projects/UOContent/Items/Armor/Dragon/DragonArms.cs +++ b/Projects/UOContent/Items/Armor/Dragon/DragonArms.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 15.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Dragon/DragonChest.cs b/Projects/UOContent/Items/Armor/Dragon/DragonChest.cs index 175f703c8..b5f0b61f8 100644 --- a/Projects/UOContent/Items/Armor/Dragon/DragonChest.cs +++ b/Projects/UOContent/Items/Armor/Dragon/DragonChest.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 15.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Dragon/DragonGloves.cs b/Projects/UOContent/Items/Armor/Dragon/DragonGloves.cs index 3417b34ea..4fb01fbd4 100644 --- a/Projects/UOContent/Items/Armor/Dragon/DragonGloves.cs +++ b/Projects/UOContent/Items/Armor/Dragon/DragonGloves.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Dragon/DragonHelm.cs b/Projects/UOContent/Items/Armor/Dragon/DragonHelm.cs index 5cabc6ed9..692bf5aec 100644 --- a/Projects/UOContent/Items/Armor/Dragon/DragonHelm.cs +++ b/Projects/UOContent/Items/Armor/Dragon/DragonHelm.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/AnthropomorphistGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/AnthropomorphistGlasses.cs index da5e120a8..5fdeb4ac4 100644 --- a/Projects/UOContent/Items/Armor/Glasses/AnthropomorphistGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/AnthropomorphistGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x80; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/ArtsGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/ArtsGlasses.cs index 0a0d52735..222ba9804 100644 --- a/Projects/UOContent/Items/Armor/Glasses/ArtsGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/ArtsGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x73; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/ElvenGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/ElvenGlasses.cs index cb2aabc25..3299b5937 100644 --- a/Projects/UOContent/Items/Armor/Glasses/ElvenGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/ElvenGlasses.cs @@ -45,55 +45,87 @@ namespace Server.Items int prop; if ((prop = WeaponAttributes.HitColdArea) != 0) + { list.Add(1060416, prop.ToString()); // hit cold area ~1_val~% + } if ((prop = WeaponAttributes.HitDispel) != 0) + { list.Add(1060417, prop.ToString()); // hit dispel ~1_val~% + } if ((prop = WeaponAttributes.HitEnergyArea) != 0) + { list.Add(1060418, prop.ToString()); // hit energy area ~1_val~% + } if ((prop = WeaponAttributes.HitFireArea) != 0) + { list.Add(1060419, prop.ToString()); // hit fire area ~1_val~% + } if ((prop = WeaponAttributes.HitFireball) != 0) + { list.Add(1060420, prop.ToString()); // hit fireball ~1_val~% + } if ((prop = WeaponAttributes.HitHarm) != 0) + { list.Add(1060421, prop.ToString()); // hit harm ~1_val~% + } if ((prop = WeaponAttributes.HitLeechHits) != 0) + { list.Add(1060422, prop.ToString()); // hit life leech ~1_val~% + } if ((prop = WeaponAttributes.HitLightning) != 0) + { list.Add(1060423, prop.ToString()); // hit lightning ~1_val~% + } if ((prop = WeaponAttributes.HitLowerAttack) != 0) + { list.Add(1060424, prop.ToString()); // hit lower attack ~1_val~% + } if ((prop = WeaponAttributes.HitLowerDefend) != 0) + { list.Add(1060425, prop.ToString()); // hit lower defense ~1_val~% + } if ((prop = WeaponAttributes.HitMagicArrow) != 0) + { list.Add(1060426, prop.ToString()); // hit magic arrow ~1_val~% + } if ((prop = WeaponAttributes.HitLeechMana) != 0) + { list.Add(1060427, prop.ToString()); // hit mana leech ~1_val~% + } if ((prop = WeaponAttributes.HitPhysicalArea) != 0) + { list.Add(1060428, prop.ToString()); // hit physical area ~1_val~% + } if ((prop = WeaponAttributes.HitPoisonArea) != 0) + { list.Add(1060429, prop.ToString()); // hit poison area ~1_val~% + } if ((prop = WeaponAttributes.HitLeechStam) != 0) + { list.Add(1060430, prop.ToString()); // hit stamina leech ~1_val~% + } } private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) + { flags |= toSet; + } } private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; @@ -111,7 +143,9 @@ namespace Server.Items writer.Write((int)flags); if (GetSaveFlag(flags, SaveFlag.WeaponAttributes)) + { WeaponAttributes.Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -123,9 +157,13 @@ namespace Server.Items var flags = (SaveFlag)reader.ReadInt(); if (GetSaveFlag(flags, SaveFlag.WeaponAttributes)) + { WeaponAttributes = new AosWeaponAttributes(this, reader); + } else + { WeaponAttributes = new AosWeaponAttributes(this); + } } [Flags] diff --git a/Projects/UOContent/Items/Armor/Glasses/FoldedSteelGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/FoldedSteelGlasses.cs index fc75a1485..1d4fbc6f1 100644 --- a/Projects/UOContent/Items/Armor/Glasses/FoldedSteelGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/FoldedSteelGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x47E; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/LightOfWayGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/LightOfWayGlasses.cs index 474b81183..9e4c30ded 100644 --- a/Projects/UOContent/Items/Armor/Glasses/LightOfWayGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/LightOfWayGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x256; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/LyricalGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/LyricalGlasses.cs index 07050de9b..05075752a 100644 --- a/Projects/UOContent/Items/Armor/Glasses/LyricalGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/LyricalGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x47F; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/MaceShieldGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/MaceShieldGlasses.cs index 4b7d61edb..ccb2cc5d7 100644 --- a/Projects/UOContent/Items/Armor/Glasses/MaceShieldGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/MaceShieldGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x1DD; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/MaritimeGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/MaritimeGlasses.cs index 9c7152618..263b27584 100644 --- a/Projects/UOContent/Items/Armor/Glasses/MaritimeGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/MaritimeGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x581; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/NecromanticGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/NecromanticGlasses.cs index fb59b6d60..673c9ceb8 100644 --- a/Projects/UOContent/Items/Armor/Glasses/NecromanticGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/NecromanticGlasses.cs @@ -38,7 +38,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x22D; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/PoisonedGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/PoisonedGlasses.cs index cd121ae37..8dcfafa7a 100644 --- a/Projects/UOContent/Items/Armor/Glasses/PoisonedGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/PoisonedGlasses.cs @@ -38,7 +38,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x113; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/TreasureTrinketGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/TreasureTrinketGlasses.cs index 339ab9883..6b9770581 100644 --- a/Projects/UOContent/Items/Armor/Glasses/TreasureTrinketGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/TreasureTrinketGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x1C2; + } } } } diff --git a/Projects/UOContent/Items/Armor/Glasses/WizardsGlasses.cs b/Projects/UOContent/Items/Armor/Glasses/WizardsGlasses.cs index f2bba6eda..6d491d2a1 100644 --- a/Projects/UOContent/Items/Armor/Glasses/WizardsGlasses.cs +++ b/Projects/UOContent/Items/Armor/Glasses/WizardsGlasses.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Hue == 0) + { Hue = 0x2B0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/Bascinet.cs b/Projects/UOContent/Items/Armor/Helmets/Bascinet.cs index 396f12ff1..1411f64bc 100644 --- a/Projects/UOContent/Items/Armor/Helmets/Bascinet.cs +++ b/Projects/UOContent/Items/Armor/Helmets/Bascinet.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/BoneHelm.cs b/Projects/UOContent/Items/Armor/Helmets/BoneHelm.cs index ecaff7ed0..5afb8b76d 100644 --- a/Projects/UOContent/Items/Armor/Helmets/BoneHelm.cs +++ b/Projects/UOContent/Items/Armor/Helmets/BoneHelm.cs @@ -32,7 +32,9 @@ namespace Server.Items writer.Write(0); if (Weight == 1.0) + { Weight = 3.0; + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Items/Armor/Helmets/CloseHelm.cs b/Projects/UOContent/Items/Armor/Helmets/CloseHelm.cs index 07c99b956..6d08d8337 100644 --- a/Projects/UOContent/Items/Armor/Helmets/CloseHelm.cs +++ b/Projects/UOContent/Items/Armor/Helmets/CloseHelm.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/DaemonHelm.cs b/Projects/UOContent/Items/Armor/Helmets/DaemonHelm.cs index acad9de44..111b7579b 100644 --- a/Projects/UOContent/Items/Armor/Helmets/DaemonHelm.cs +++ b/Projects/UOContent/Items/Armor/Helmets/DaemonHelm.cs @@ -49,10 +49,14 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 3.0; + } if (ArmorAttributes.SelfRepair == 0) + { ArmorAttributes.SelfRepair = 1; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/Helmet.cs b/Projects/UOContent/Items/Armor/Helmets/Helmet.cs index 2486bcb5b..17c9b3d9e 100644 --- a/Projects/UOContent/Items/Armor/Helmets/Helmet.cs +++ b/Projects/UOContent/Items/Armor/Helmets/Helmet.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/LeatherCap.cs b/Projects/UOContent/Items/Armor/Helmets/LeatherCap.cs index 27b7d0f45..7d0b895b4 100644 --- a/Projects/UOContent/Items/Armor/Helmets/LeatherCap.cs +++ b/Projects/UOContent/Items/Armor/Helmets/LeatherCap.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/NorseHelm.cs b/Projects/UOContent/Items/Armor/Helmets/NorseHelm.cs index 8f88763ef..3cfd0af47 100644 --- a/Projects/UOContent/Items/Armor/Helmets/NorseHelm.cs +++ b/Projects/UOContent/Items/Armor/Helmets/NorseHelm.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/OrcHelm.cs b/Projects/UOContent/Items/Armor/Helmets/OrcHelm.cs index 8b28ef918..4c74a64b3 100644 --- a/Projects/UOContent/Items/Armor/Helmets/OrcHelm.cs +++ b/Projects/UOContent/Items/Armor/Helmets/OrcHelm.cs @@ -43,7 +43,10 @@ namespace Server.Items base.Deserialize(reader); var version = reader.ReadInt(); - if (version == 0 && (Weight == 1 || Weight == 5)) Weight = -1; + if (version == 0 && (Weight == 1 || Weight == 5)) + { + Weight = -1; + } } } } diff --git a/Projects/UOContent/Items/Armor/Helmets/PlateHelm.cs b/Projects/UOContent/Items/Armor/Helmets/PlateHelm.cs index 7318496c1..46ac753db 100644 --- a/Projects/UOContent/Items/Armor/Helmets/PlateHelm.cs +++ b/Projects/UOContent/Items/Armor/Helmets/PlateHelm.cs @@ -39,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs b/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs index 0698898ec..5db633aa7 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs @@ -93,7 +93,9 @@ namespace Server.Items m_MaxArcaneCharges = reader.ReadInt(); if (Hue == 2118) + { Hue = ArcaneGem.DefaultArcaneHue; + } } break; @@ -104,12 +106,18 @@ namespace Server.Items public void Update() { if (IsArcane) + { ItemID = 0x26B0; // TODO: Check + } else if (ItemID == 0x26B0) + { ItemID = 0x2FC6; + } if (IsArcane && CurArcaneCharges == 0) + { Hue = 0; + } } public override void GetProperties(ObjectPropertyList list) @@ -117,7 +125,9 @@ namespace Server.Items base.GetProperties(list); if (IsArcane) + { list.Add(1061837, "{0}\t{1}", m_CurArcaneCharges, m_MaxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ + } } public override void OnSingleClick(Mobile from) @@ -125,15 +135,21 @@ namespace Server.Items base.OnSingleClick(from); if (IsArcane) - LabelTo(from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + { + LabelTo(@from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + } } public void Flip() { if (ItemID == 0x2FC6) + { ItemID = 0x317C; + } else if (ItemID == 0x317C) + { ItemID = 0x2FC6; + } } } } diff --git a/Projects/UOContent/Items/Armor/Leather/LeatherArms.cs b/Projects/UOContent/Items/Armor/Leather/LeatherArms.cs index 897cb5761..8ca4c88fb 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeatherArms.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeatherArms.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Leather/LeatherChest.cs b/Projects/UOContent/Items/Armor/Leather/LeatherChest.cs index 56405a3d0..88087a407 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeatherChest.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeatherChest.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 6.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs b/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs index e1ad83327..75829f65d 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs @@ -92,7 +92,9 @@ namespace Server.Items m_MaxArcaneCharges = reader.ReadInt(); if (Hue == 2118) + { Hue = ArcaneGem.DefaultArcaneHue; + } } break; @@ -103,12 +105,18 @@ namespace Server.Items public void Update() { if (IsArcane) + { ItemID = 0x26B0; + } else if (ItemID == 0x26B0) + { ItemID = 0x13C6; + } if (IsArcane && CurArcaneCharges == 0) + { Hue = 0; + } } public override void GetProperties(ObjectPropertyList list) @@ -116,7 +124,9 @@ namespace Server.Items base.GetProperties(list); if (IsArcane) + { list.Add(1061837, "{0}\t{1}", m_CurArcaneCharges, m_MaxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ + } } public override void OnSingleClick(Mobile from) @@ -124,15 +134,21 @@ namespace Server.Items base.OnSingleClick(from); if (IsArcane) - LabelTo(from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + { + LabelTo(@from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + } } public void Flip() { if (ItemID == 0x13C6) + { ItemID = 0x13CE; + } else if (ItemID == 0x13CE) + { ItemID = 0x13C6; + } } } } diff --git a/Projects/UOContent/Items/Armor/Leather/LeatherSkirt.cs b/Projects/UOContent/Items/Armor/Leather/LeatherSkirt.cs index 7f159e55c..17b0d2cef 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeatherSkirt.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeatherSkirt.cs @@ -37,7 +37,9 @@ namespace Server.Items writer.Write(0); if (Weight == 3.0) + { Weight = 1.0; + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Items/Armor/Plate/FemalePlateChest.cs b/Projects/UOContent/Items/Armor/Plate/FemalePlateChest.cs index 5ae1975d6..e3291630f 100644 --- a/Projects/UOContent/Items/Armor/Plate/FemalePlateChest.cs +++ b/Projects/UOContent/Items/Armor/Plate/FemalePlateChest.cs @@ -42,7 +42,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 4.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Plate/PlateArms.cs b/Projects/UOContent/Items/Armor/Plate/PlateArms.cs index a394475cf..50763b151 100644 --- a/Projects/UOContent/Items/Armor/Plate/PlateArms.cs +++ b/Projects/UOContent/Items/Armor/Plate/PlateArms.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Plate/PlateChest.cs b/Projects/UOContent/Items/Armor/Plate/PlateChest.cs index 6912181c8..9dc54e4f9 100644 --- a/Projects/UOContent/Items/Armor/Plate/PlateChest.cs +++ b/Projects/UOContent/Items/Armor/Plate/PlateChest.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 10.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Plate/PlateGloves.cs b/Projects/UOContent/Items/Armor/Plate/PlateGloves.cs index 6c3dbf72c..783a4f304 100644 --- a/Projects/UOContent/Items/Armor/Plate/PlateGloves.cs +++ b/Projects/UOContent/Items/Armor/Plate/PlateGloves.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Plate/WoodlandGorget.cs b/Projects/UOContent/Items/Armor/Plate/WoodlandGorget.cs index d4a2a577c..de3aa38ab 100644 --- a/Projects/UOContent/Items/Armor/Plate/WoodlandGorget.cs +++ b/Projects/UOContent/Items/Armor/Plate/WoodlandGorget.cs @@ -43,7 +43,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0) + { Weight = -1; + } } } } diff --git a/Projects/UOContent/Items/Armor/Ranger/RangerArms.cs b/Projects/UOContent/Items/Armor/Ranger/RangerArms.cs index 70fb1e87e..c369c2288 100644 --- a/Projects/UOContent/Items/Armor/Ranger/RangerArms.cs +++ b/Projects/UOContent/Items/Armor/Ranger/RangerArms.cs @@ -45,7 +45,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 4.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Ranger/RangerChest.cs b/Projects/UOContent/Items/Armor/Ranger/RangerChest.cs index ff6dc1189..8b21b6e9b 100644 --- a/Projects/UOContent/Items/Armor/Ranger/RangerChest.cs +++ b/Projects/UOContent/Items/Armor/Ranger/RangerChest.cs @@ -45,7 +45,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 8.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Ranger/RangerLegs.cs b/Projects/UOContent/Items/Armor/Ranger/RangerLegs.cs index a51f90a43..58c953874 100644 --- a/Projects/UOContent/Items/Armor/Ranger/RangerLegs.cs +++ b/Projects/UOContent/Items/Armor/Ranger/RangerLegs.cs @@ -45,7 +45,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Ring/RingmailArms.cs b/Projects/UOContent/Items/Armor/Ring/RingmailArms.cs index b12c4f04f..814c9ca3d 100644 --- a/Projects/UOContent/Items/Armor/Ring/RingmailArms.cs +++ b/Projects/UOContent/Items/Armor/Ring/RingmailArms.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 15.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Ring/RingmailChest.cs b/Projects/UOContent/Items/Armor/Ring/RingmailChest.cs index 211343652..d1a0b5d79 100644 --- a/Projects/UOContent/Items/Armor/Ring/RingmailChest.cs +++ b/Projects/UOContent/Items/Armor/Ring/RingmailChest.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 15.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Ring/RingmailGloves.cs b/Projects/UOContent/Items/Armor/Ring/RingmailGloves.cs index 6cab3074a..43d25497c 100644 --- a/Projects/UOContent/Items/Armor/Ring/RingmailGloves.cs +++ b/Projects/UOContent/Items/Armor/Ring/RingmailGloves.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/FemaleStuddedChest.cs b/Projects/UOContent/Items/Armor/Studded/FemaleStuddedChest.cs index b28a2c370..f4be23cce 100644 --- a/Projects/UOContent/Items/Armor/Studded/FemaleStuddedChest.cs +++ b/Projects/UOContent/Items/Armor/Studded/FemaleStuddedChest.cs @@ -43,7 +43,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 6.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/HideGorget.cs b/Projects/UOContent/Items/Armor/Studded/HideGorget.cs index 3b192547d..1858e8675 100644 --- a/Projects/UOContent/Items/Armor/Studded/HideGorget.cs +++ b/Projects/UOContent/Items/Armor/Studded/HideGorget.cs @@ -43,7 +43,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/StuddedArms.cs b/Projects/UOContent/Items/Armor/Studded/StuddedArms.cs index 712ebb779..b1b8257a3 100644 --- a/Projects/UOContent/Items/Armor/Studded/StuddedArms.cs +++ b/Projects/UOContent/Items/Armor/Studded/StuddedArms.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 4.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/StuddedChest.cs b/Projects/UOContent/Items/Armor/Studded/StuddedChest.cs index 2fae92e92..cead23e26 100644 --- a/Projects/UOContent/Items/Armor/Studded/StuddedChest.cs +++ b/Projects/UOContent/Items/Armor/Studded/StuddedChest.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 8.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/StuddedGloves.cs b/Projects/UOContent/Items/Armor/Studded/StuddedGloves.cs index f0e014222..88b436891 100644 --- a/Projects/UOContent/Items/Armor/Studded/StuddedGloves.cs +++ b/Projects/UOContent/Items/Armor/Studded/StuddedGloves.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/StuddedGorget.cs b/Projects/UOContent/Items/Armor/Studded/StuddedGorget.cs index 6579d6317..2df3a7655 100644 --- a/Projects/UOContent/Items/Armor/Studded/StuddedGorget.cs +++ b/Projects/UOContent/Items/Armor/Studded/StuddedGorget.cs @@ -40,7 +40,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Armor/Studded/StuddedLegs.cs b/Projects/UOContent/Items/Armor/Studded/StuddedLegs.cs index 031835191..851950131 100644 --- a/Projects/UOContent/Items/Armor/Studded/StuddedLegs.cs +++ b/Projects/UOContent/Items/Armor/Studded/StuddedLegs.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Body Parts/BonePile.cs b/Projects/UOContent/Items/Body Parts/BonePile.cs index 72bedc69d..fbfc83af1 100644 --- a/Projects/UOContent/Items/Body Parts/BonePile.cs +++ b/Projects/UOContent/Items/Body Parts/BonePile.cs @@ -17,7 +17,9 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { if (Deleted || !from.CanSee(this)) + { return false; + } ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15)); diff --git a/Projects/UOContent/Items/Body Parts/Head.cs b/Projects/UOContent/Items/Body Parts/Head.cs index 59522d0db..2aa25b47c 100644 --- a/Projects/UOContent/Items/Body Parts/Head.cs +++ b/Projects/UOContent/Items/Body Parts/Head.cs @@ -38,7 +38,9 @@ namespace Server.Items get { if (PlayerName == null) + { return base.DefaultName; + } return HeadType switch { @@ -78,7 +80,9 @@ namespace Server.Items if (format != null) { if (format.StartsWith("the head of ")) + { format = format.Substring("the head of ".Length); + } if (format.EndsWith(", taken in a duel")) { diff --git a/Projects/UOContent/Items/Body Parts/RibCage.cs b/Projects/UOContent/Items/Body Parts/RibCage.cs index bee865e3f..e6711f9ad 100644 --- a/Projects/UOContent/Items/Body Parts/RibCage.cs +++ b/Projects/UOContent/Items/Body Parts/RibCage.cs @@ -17,7 +17,9 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { if (Deleted || !from.CanSee(this)) + { return false; + } ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5)); diff --git a/Projects/UOContent/Items/Books/BaseBook.cs b/Projects/UOContent/Items/Books/BaseBook.cs index f1165cb0b..b02b6d620 100644 --- a/Projects/UOContent/Items/Books/BaseBook.cs +++ b/Projects/UOContent/Items/Books/BaseBook.cs @@ -22,7 +22,9 @@ namespace Server.Items Lines = new string[length]; for (var i = 0; i < Lines.Length; ++i) + { Lines[i] = Utility.Intern(reader.ReadString()); + } } public string[] Lines { get; set; } @@ -32,7 +34,9 @@ namespace Server.Items writer.Write(Lines.Length); for (var i = 0; i < Lines.Length; ++i) + { writer.Write(Lines[i]); + } } } @@ -60,7 +64,9 @@ namespace Server.Items Pages = new BookPageInfo[pageCount]; for (var i = 0; i < Pages.Length; ++i) + { Pages[i] = new BookPageInfo(); + } } else { @@ -116,8 +122,12 @@ namespace Server.Items var sb = new StringBuilder(); foreach (var bpi in Pages) + { foreach (var line in bpi.Lines) + { sb.AppendLine(line); + } + } return sb.ToString(); } @@ -129,7 +139,10 @@ namespace Server.Items { var lines = new List(); - foreach (var bpi in Pages) lines.AddRange(bpi.Lines); + foreach (var bpi in Pages) + { + lines.AddRange(bpi.Lines); + } return lines.ToArray(); } @@ -153,16 +166,24 @@ namespace Server.Items var flags = SaveFlags.None; if (m_Title != content?.Title) + { flags |= SaveFlags.Title; + } if (m_Author != content?.Author) + { flags |= SaveFlags.Author; + } if (Writable) + { flags |= SaveFlags.Writable; + } if (content?.IsMatch(Pages) != true) + { flags |= SaveFlags.Content; + } writer.Write(4); // version @@ -171,17 +192,23 @@ namespace Server.Items writer.Write((byte)flags); if ((flags & SaveFlags.Title) != 0) + { writer.Write(m_Title); + } if ((flags & SaveFlags.Author) != 0) + { writer.Write(m_Author); + } if ((flags & SaveFlags.Content) != 0) { writer.WriteEncodedInt(Pages.Length); for (var i = 0; i < Pages.Length; ++i) + { Pages[i].Serialize(writer); + } } } @@ -206,14 +233,22 @@ namespace Server.Items var flags = (SaveFlags)reader.ReadByte(); if ((flags & SaveFlags.Title) != 0) + { m_Title = Utility.Intern(reader.ReadString()); + } else if (content != null) + { m_Title = content.Title; + } if ((flags & SaveFlags.Author) != 0) + { m_Author = reader.ReadString(); + } else if (content != null) + { m_Author = content.Author; + } Writable = (flags & SaveFlags.Writable) != 0; @@ -222,14 +257,20 @@ namespace Server.Items Pages = new BookPageInfo[reader.ReadEncodedInt()]; for (var i = 0; i < Pages.Length; ++i) + { Pages[i] = new BookPageInfo(reader); + } } else { if (content != null) + { Pages = content.Copy(); + } else + { Pages = Array.Empty(); + } } break; @@ -246,16 +287,22 @@ namespace Server.Items Pages = new BookPageInfo[reader.ReadInt()]; for (var i = 0; i < Pages.Length; ++i) + { Pages[i] = new BookPageInfo(reader); + } } else { var content = DefaultContent; if (content != null) + { Pages = content.Copy(); + } else + { Pages = Array.Empty(); + } } break; @@ -263,15 +310,21 @@ namespace Server.Items } if (version < 3 && (Weight == 1 || Weight == 2)) + { Weight = -1; + } } public override void AddNameProperty(ObjectPropertyList list) { if (!string.IsNullOrEmpty(m_Title)) + { list.Add(m_Title); + } else + { base.AddNameProperty(list); + } } /*public override void GetProperties( ObjectPropertyList list ) @@ -319,7 +372,9 @@ namespace Server.Items if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBook book) || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) + { return; + } pvSrc.Seek(4, SeekOrigin.Current); // Skip flags and page count @@ -336,21 +391,27 @@ namespace Server.Items if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBook book) || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) + { return; + } pvSrc.Seek(4, SeekOrigin.Current); // Skip flags and page count int titleLength = pvSrc.ReadUInt16(); if (titleLength > 60) + { return; + } var title = pvSrc.ReadUTF8StringSafe(titleLength); int authorLength = pvSrc.ReadUInt16(); if (authorLength > 30) + { return; + } var author = pvSrc.ReadUTF8StringSafe(authorLength); @@ -364,12 +425,16 @@ namespace Server.Items if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBook book) || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) + { return; + } int pageCount = pvSrc.ReadUInt16(); if (pageCount > book.PagesCount) + { return; + } for (var i = 0; i < pageCount; ++i) { @@ -386,8 +451,12 @@ namespace Server.Items var lines = new string[lineCount]; for (var j = 0; j < lineCount; ++j) + { if ((lines[j] = pvSrc.ReadUTF8StringSafe()).Length >= 80) + { return; + } + } book.Pages[index].Lines = lines; } diff --git a/Projects/UOContent/Items/Books/Defined/BookContent.cs b/Projects/UOContent/Items/Books/Defined/BookContent.cs index 18d6395cc..dfc3684a9 100644 --- a/Projects/UOContent/Items/Books/Defined/BookContent.cs +++ b/Projects/UOContent/Items/Books/Defined/BookContent.cs @@ -20,7 +20,9 @@ namespace Server.Items var copy = new BookPageInfo[Pages.Length]; for (var i = 0; i < copy.Length; ++i) + { copy[i] = new BookPageInfo(Pages[i].Lines); + } return copy; } @@ -28,19 +30,30 @@ namespace Server.Items public bool IsMatch(BookPageInfo[] cmp) { if (cmp.Length != Pages.Length) + { return false; + } for (var i = 0; i < cmp.Length; ++i) { var a = Pages[i].Lines; var b = cmp[i].Lines; - if (a.Length != b.Length) return false; + if (a.Length != b.Length) + { + return false; + } if (a != b) + { for (var j = 0; j < a.Length; ++j) + { if (a[j] != b[j]) + { return false; + } + } + } } return true; diff --git a/Projects/UOContent/Items/Champion Artifacts/Unique/AcidProofRobe.cs b/Projects/UOContent/Items/Champion Artifacts/Unique/AcidProofRobe.cs index 3ed25653d..202241f2a 100644 --- a/Projects/UOContent/Items/Champion Artifacts/Unique/AcidProofRobe.cs +++ b/Projects/UOContent/Items/Champion Artifacts/Unique/AcidProofRobe.cs @@ -35,7 +35,10 @@ namespace Server.Items var version = reader.ReadInt(); - if (version < 1 && Hue == 1) Hue = 0x455; + if (version < 1 && Hue == 1) + { + Hue = 0x455; + } } } } diff --git a/Projects/UOContent/Items/Champion Artifacts/Unique/OrcChieftainHelm.cs b/Projects/UOContent/Items/Champion Artifacts/Unique/OrcChieftainHelm.cs index be47d808a..2552b27c1 100644 --- a/Projects/UOContent/Items/Champion Artifacts/Unique/OrcChieftainHelm.cs +++ b/Projects/UOContent/Items/Champion Artifacts/Unique/OrcChieftainHelm.cs @@ -11,9 +11,13 @@ namespace Server.Items Attributes.RegenHits = 3; if (Utility.RandomBool()) + { Attributes.BonusHits = 30; + } else + { Attributes.AttackChance = 30; + } } public OrcChieftainHelm(Serial serial) : base(serial) @@ -46,7 +50,10 @@ namespace Server.Items var version = reader.ReadInt(); - if (version < 1 && Hue == 0x3f) /* Pigmented? */ Hue = 0x2a3; + if (version < 1 && Hue == 0x3f) /* Pigmented? */ + { + Hue = 0x2a3; + } } } } diff --git a/Projects/UOContent/Items/Clothing/BaseClothing.cs b/Projects/UOContent/Items/Clothing/BaseClothing.cs index f6ebbd219..903055ccc 100644 --- a/Projects/UOContent/Items/Clothing/BaseClothing.cs +++ b/Projects/UOContent/Items/Clothing/BaseClothing.cs @@ -151,7 +151,9 @@ namespace Server.Items Quality = (ClothingQuality)quality; if (makersMark) - Crafter = from; + { + Crafter = @from; + } if (DefaultResource != CraftResource.None) { @@ -169,7 +171,9 @@ namespace Server.Items var context = craftSystem.GetContext(from); if (context?.DoNotColor == true) + { Hue = 0; + } return quality; } @@ -177,9 +181,14 @@ namespace Server.Items public virtual bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } + if (RootParent is Mobile && from != RootParent) + { return false; + } Hue = sender.DyedHue; @@ -194,7 +203,9 @@ namespace Server.Items m_FactionState = value; if (m_FactionState == null) + { Hue = 0; + } LootType = m_FactionState == null ? LootType.Regular : LootType.Blessed; } @@ -219,6 +230,7 @@ namespace Server.Items var item = system.CraftItems.SearchFor(GetType()); if (item?.Resources.Count == 1 && item.Resources[0].Amount >= 2) + { try { var info = CraftResources.GetInfo(m_Resource); @@ -227,7 +239,7 @@ namespace Server.Items var res = (Item)ActivatorUtil.CreateInstance(resourceType); - ScissorHelper(from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1); + ScissorHelper(@from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1); res.LootType = LootType.Regular; @@ -237,6 +249,7 @@ namespace Server.Items { // ignored } + } from.SendLocalizedMessage(502440); // Scissors can not be used on that to produce anything. return false; @@ -266,9 +279,13 @@ namespace Server.Items m_HitPoints = value; if (m_HitPoints < 0) + { Delete(); + } else if (m_HitPoints > MaxHitPoints) + { m_HitPoints = MaxHitPoints; + } InvalidateProperties(); } @@ -296,9 +313,13 @@ namespace Server.Items int wear; if (weapon.Type == WeaponType.Bashing) + { wear = absorbed / 2; + } else + { wear = Utility.Random(2); + } if (wear > 0 && m_MaxHitPoints > 0) { @@ -363,16 +384,22 @@ namespace Server.Items public override bool CanEquip(Mobile from) { if (!Ethic.CheckEquip(from, this)) + { return false; + } if (from.AccessLevel < AccessLevel.GameMaster) { if (RequiredRace != null && from.Race != RequiredRace) { if (RequiredRace == Race.Elf) - from.SendLocalizedMessage(1072203); // Only Elves may use this. + { + @from.SendLocalizedMessage(1072203); // Only Elves may use this. + } else - from.SendMessage("Only {0} may use this.", RequiredRace.PluralName); + { + @from.SendMessage("Only {0} may use this.", RequiredRace.PluralName); + } return false; } @@ -380,9 +407,13 @@ namespace Server.Items if (!AllowMaleWearer && !from.Female) { if (AllowFemaleWearer) - from.SendLocalizedMessage(1010388); // Only females can wear this. + { + @from.SendLocalizedMessage(1010388); // Only females can wear this. + } else - from.SendMessage("You may not wear this."); + { + @from.SendMessage("You may not wear this."); + } return false; } @@ -390,9 +421,13 @@ namespace Server.Items if (!AllowFemaleWearer && from.Female) { if (AllowMaleWearer) - from.SendLocalizedMessage(1063343); // Only males can wear this. + { + @from.SendLocalizedMessage(1063343); // Only males can wear this. + } else - from.SendMessage("You may not wear this."); + { + @from.SendMessage("You may not wear this."); + } return false; } @@ -431,25 +466,35 @@ namespace Server.Items public virtual void AddStatBonuses(Mobile parent) { if (parent == null) + { return; + } var strBonus = ComputeStatBonus(StatType.Str); var dexBonus = ComputeStatBonus(StatType.Dex); var intBonus = ComputeStatBonus(StatType.Int); if (strBonus == 0 && dexBonus == 0 && intBonus == 0) + { return; + } var modName = Serial.ToString(); if (strBonus != 0) + { parent.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) + { parent.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) + { parent.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } public static void ValidateMobile(Mobile m) @@ -457,7 +502,9 @@ namespace Server.Items for (var i = m.Items.Count - 1; i >= 0; --i) { if (i >= m.Items.Count) + { continue; + } var item = m.Items[i]; @@ -466,27 +513,39 @@ namespace Server.Items if (clothing.RequiredRace != null && m.Race != clothing.RequiredRace) { if (clothing.RequiredRace == Race.Elf) + { m.SendLocalizedMessage(1072203); // Only Elves may use this. + } else + { m.SendMessage("Only {0} may use this.", clothing.RequiredRace.PluralName); + } m.AddToBackpack(clothing); } else if (!clothing.AllowMaleWearer && !m.Female && m.AccessLevel < AccessLevel.GameMaster) { if (clothing.AllowFemaleWearer) + { m.SendLocalizedMessage(1010388); // Only females can wear this. + } else + { m.SendMessage("You may not wear this."); + } m.AddToBackpack(clothing); } else if (!clothing.AllowFemaleWearer && m.Female && m.AccessLevel < AccessLevel.GameMaster) { if (clothing.AllowMaleWearer) + { m.SendLocalizedMessage(1063343); // Only males can wear this. + } else + { m.SendMessage("You may not wear this."); + } m.AddToBackpack(clothing); } @@ -497,7 +556,9 @@ namespace Server.Items public int GetLowerStatReq() { if (!Core.AOS) + { return 0; + } return ClothingAttributes.LowerStatReq; } @@ -507,7 +568,9 @@ namespace Server.Items if (parent is Mobile mob) { if (Core.AOS) + { SkillBonuses.AddTo(mob); + } AddStatBonuses(mob); mob.CheckStatTimers(); @@ -521,7 +584,9 @@ namespace Server.Items if (parent is Mobile mob) { if (Core.AOS) + { SkillBonuses.Remove(); + } var modName = Serial.ToString(); @@ -538,7 +603,9 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseClothing clothing)) + { return; + } clothing.Attributes = new AosAttributes(newItem, Attributes); clothing.Resistances = new AosElementAttributes(newItem, Resistances); @@ -552,7 +619,9 @@ namespace Server.Items public override bool CheckPropertyConflict(Mobile m) { if (base.CheckPropertyConflict(m)) + { return true; + } return Layer switch { @@ -589,11 +658,17 @@ namespace Server.Items }; if (oreType != 0) + { list.Add(1053099, "#{0}\t{1}", oreType, GetNameString()); // ~1_oretype~ ~2_armortype~ + } else if (Name == null) + { list.Add(LabelNumber); + } else + { list.Add(Name); + } } public override void GetProperties(ObjectPropertyList list) @@ -601,115 +676,185 @@ namespace Server.Items base.GetProperties(list); if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } if (m_FactionState != null) + { list.Add(1041350); // faction item + } if (m_Quality == ClothingQuality.Exceptional) + { list.Add(1060636); // exceptional + } if (RequiredRace == Race.Elf) + { list.Add(1075086); // Elves Only + } SkillBonuses?.GetProperties(list); int prop; if ((prop = ArtifactRarity) > 0) + { list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~ + } if ((prop = Attributes.WeaponDamage) != 0) + { list.Add(1060401, prop.ToString()); // damage increase ~1_val~% + } if ((prop = Attributes.DefendChance) != 0) + { list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% + } if ((prop = Attributes.BonusDex) != 0) + { list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ + } if ((prop = Attributes.EnhancePotions) != 0) + { list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% + } if ((prop = Attributes.CastRecovery) != 0) + { list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ + } if ((prop = Attributes.CastSpeed) != 0) + { list.Add(1060413, prop.ToString()); // faster casting ~1_val~ + } if ((prop = Attributes.AttackChance) != 0) + { list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% + } if ((prop = Attributes.BonusHits) != 0) + { list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ + } if ((prop = Attributes.BonusInt) != 0) + { list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ + } if ((prop = Attributes.LowerManaCost) != 0) + { list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% + } if ((prop = Attributes.LowerRegCost) != 0) + { list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% + } if ((prop = ClothingAttributes.LowerStatReq) != 0) + { list.Add(1060435, prop.ToString()); // lower requirements ~1_val~% + } if ((prop = Attributes.Luck) != 0) + { list.Add(1060436, prop.ToString()); // luck ~1_val~ + } if ((prop = ClothingAttributes.MageArmor) != 0) + { list.Add(1060437); // mage armor + } if ((prop = Attributes.BonusMana) != 0) + { list.Add(1060439, prop.ToString()); // mana increase ~1_val~ + } if ((prop = Attributes.RegenMana) != 0) + { list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ + } if ((prop = Attributes.NightSight) != 0) + { list.Add(1060441); // night sight + } if ((prop = Attributes.ReflectPhysical) != 0) + { list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% + } if ((prop = Attributes.RegenStam) != 0) + { list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ + } if ((prop = Attributes.RegenHits) != 0) + { list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ + } if ((prop = ClothingAttributes.SelfRepair) != 0) + { list.Add(1060450, prop.ToString()); // self repair ~1_val~ + } if ((prop = Attributes.SpellChanneling) != 0) + { list.Add(1060482); // spell channeling + } if ((prop = Attributes.SpellDamage) != 0) + { list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% + } if ((prop = Attributes.BonusStam) != 0) + { list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ + } if ((prop = Attributes.BonusStr) != 0) + { list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ + } if ((prop = Attributes.WeaponSpeed) != 0) + { list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% + } if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) + { list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% + } AddResistanceProperties(list); if ((prop = ClothingAttributes.DurabilityBonus) > 0) + { list.Add(1060410, prop.ToString()); // durability ~1_val~% + } if ((prop = ComputeStatReq(StatType.Str)) > 0) + { list.Add(1061170, prop.ToString()); // strength requirement ~1_val~ + } if (m_HitPoints >= 0 && m_MaxHitPoints > 0) + { list.Add(1060639, "{0}\t{1}", m_HitPoints, m_MaxHitPoints); // durability ~1_val~ / ~2_val~ + } } public override void OnSingleClick(Mobile from) @@ -731,7 +876,9 @@ namespace Server.Items } if (attrs.Count == 0 && Crafter == null && Name != null) + { return; + } var eqInfo = new EquipmentInfo(number, m_Crafter, false, attrs.ToArray()); @@ -743,21 +890,30 @@ namespace Server.Items if (DisplayLootType) { if (LootType == LootType.Blessed) + { attrs.Add(new EquipInfoAttribute(1038021)); // blessed + } else if (LootType == LootType.Cursed) + { attrs.Add(new EquipInfoAttribute(1049643)); // cursed + } } if (m_FactionState != null) + { attrs.Add(new EquipInfoAttribute(1041350)); // faction item + } if (m_Quality == ClothingQuality.Exceptional) + { attrs.Add(new EquipInfoAttribute(1018305 - (int)m_Quality)); + } } public void DistributeBonuses(int amount) { for (var i = 0; i < amount; ++i) + { switch (Utility.Random(5)) { case 0: @@ -776,6 +932,7 @@ namespace Server.Items ++Resistances.Energy; break; } + } InvalidateProperties(); } @@ -783,7 +940,9 @@ namespace Server.Items private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) + { flags |= toSet; + } } private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; @@ -811,34 +970,54 @@ namespace Server.Items writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Resource)) + { writer.WriteEncodedInt((int)m_Resource); + } if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) + { ClothingAttributes.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + { SkillBonuses.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.Resistances)) + { Resistances.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) + { writer.WriteEncodedInt(m_MaxHitPoints); + } if (GetSaveFlag(flags, SaveFlag.HitPoints)) + { writer.WriteEncodedInt(m_HitPoints); + } if (GetSaveFlag(flags, SaveFlag.Crafter)) + { writer.Write(m_Crafter); + } if (GetSaveFlag(flags, SaveFlag.Quality)) + { writer.WriteEncodedInt((int)m_Quality); + } if (GetSaveFlag(flags, SaveFlag.StrReq)) + { writer.WriteEncodedInt(m_StrReq); + } } public override void Deserialize(IGenericReader reader) @@ -854,51 +1033,87 @@ namespace Server.Items var flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Resource)) + { m_Resource = (CraftResource)reader.ReadEncodedInt(); + } else + { m_Resource = DefaultResource; + } if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes = new AosAttributes(this, reader); + } else + { Attributes = new AosAttributes(this); + } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) + { ClothingAttributes = new AosArmorAttributes(this, reader); + } else + { ClothingAttributes = new AosArmorAttributes(this); + } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + { SkillBonuses = new AosSkillBonuses(this, reader); + } else + { SkillBonuses = new AosSkillBonuses(this); + } if (GetSaveFlag(flags, SaveFlag.Resistances)) + { Resistances = new AosElementAttributes(this, reader); + } else + { Resistances = new AosElementAttributes(this); + } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) + { m_MaxHitPoints = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.HitPoints)) + { m_HitPoints = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.Crafter)) + { m_Crafter = reader.ReadMobile(); + } if (GetSaveFlag(flags, SaveFlag.Quality)) + { m_Quality = (ClothingQuality)reader.ReadEncodedInt(); + } else + { m_Quality = ClothingQuality.Regular; + } if (GetSaveFlag(flags, SaveFlag.StrReq)) + { m_StrReq = reader.ReadEncodedInt(); + } else + { m_StrReq = -1; + } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) + { PlayerConstructed = true; + } break; } @@ -937,7 +1152,9 @@ namespace Server.Items } if (version < 2) + { PlayerConstructed = true; // we don't know, so, assume it's crafted + } if (version < 3) { @@ -948,15 +1165,21 @@ namespace Server.Items } if (version < 4) + { m_Resource = DefaultResource; + } if (m_MaxHitPoints == 0 && m_HitPoints == 0) + { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); + } if (Parent is Mobile parent) { if (Core.AOS) + { SkillBonuses.AddTo(parent); + } AddStatBonuses(parent); parent.CheckStatTimers(); diff --git a/Projects/UOContent/Items/Clothing/Cloaks.cs b/Projects/UOContent/Items/Clothing/Cloaks.cs index d98e890fe..5bd152b51 100644 --- a/Projects/UOContent/Items/Clothing/Cloaks.cs +++ b/Projects/UOContent/Items/Clothing/Cloaks.cs @@ -100,7 +100,9 @@ namespace Server.Items m_MaxArcaneCharges = reader.ReadInt(); if (Hue == 2118) + { Hue = ArcaneGem.DefaultArcaneHue; + } } break; @@ -108,18 +110,26 @@ namespace Server.Items } if (Weight == 4.0) + { Weight = 5.0; + } } public void Update() { if (IsArcane) + { ItemID = 0x26AD; + } else if (ItemID == 0x26AD) + { ItemID = 0x1515; + } if (IsArcane && CurArcaneCharges == 0) + { Hue = 0; + } } public override void GetProperties(ObjectPropertyList list) @@ -127,7 +137,9 @@ namespace Server.Items base.GetProperties(list); if (IsArcane) + { list.Add(1061837, "{0}\t{1}", m_CurArcaneCharges, m_MaxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ + } } public override void OnSingleClick(Mobile from) @@ -135,15 +147,21 @@ namespace Server.Items base.OnSingleClick(from); if (IsArcane) - LabelTo(from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + { + LabelTo(@from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + } } public void Flip() { if (ItemID == 0x1515) + { ItemID = 0x1530; + } else if (ItemID == 0x1530) + { ItemID = 0x1515; + } } } @@ -181,7 +199,9 @@ namespace Server.Items get { if (m_LabelNumber > 0) + { return m_LabelNumber; + } return base.LabelNumber; } @@ -197,7 +217,9 @@ namespace Server.Items base.OnAdded(parent); if (parent is Mobile mobile) + { mobile.VirtualArmorMod += 2; + } } public override void OnRemoved(IEntity parent) @@ -205,7 +227,9 @@ namespace Server.Items base.OnRemoved(parent); if (parent is Mobile mobile) + { mobile.VirtualArmorMod -= 2; + } } public override bool Dye(Mobile from, DyeTub sender) @@ -219,18 +243,22 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add( RewardSystem.GetRewardYearLabel( this, new object[] { Hue, m_LabelNumber } ) ); // X Year Veteran Reward + } } public override bool CanEquip(Mobile m) { if (!base.CanEquip(m)) + { return false; + } return !IsRewardItem || RewardSystem.CheckIsUsableBy(m, this, new object[] { Hue, m_LabelNumber }); } @@ -262,7 +290,9 @@ namespace Server.Items } if (Parent is Mobile mobile) + { mobile.VirtualArmorMod += 2; + } } } diff --git a/Projects/UOContent/Items/Clothing/Hats.cs b/Projects/UOContent/Items/Clothing/Hats.cs index 306a8dcaa..0fc0c9bd0 100644 --- a/Projects/UOContent/Items/Clothing/Hats.cs +++ b/Projects/UOContent/Items/Clothing/Hats.cs @@ -49,7 +49,9 @@ namespace Server.Items base.AddEquipInfoAttributes(from, attrs); if (IsShipwreckedItem) + { attrs.Add(new EquipInfoAttribute(1041645)); // recovered from a shipwreck + } } public override void AddNameProperties(ObjectPropertyList list) @@ -57,7 +59,9 @@ namespace Server.Items base.AddNameProperties(list); if (IsShipwreckedItem) + { list.Add(1041645); // recovered from a shipwreck + } } public override int OnCraft( @@ -68,10 +72,12 @@ namespace Server.Items Quality = (ClothingQuality)quality; if (Quality == ClothingQuality.Exceptional) + { DistributeBonuses( tool is BaseRunicTool ? 6 : Core.SE ? 15 : 14 ); // BLAME OSI. (We can't confirm it's an OSI bug yet.) + } return base.OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, craftItem, resHue); } @@ -595,7 +601,9 @@ namespace Server.Items public override bool CanEquip(Mobile m) { if (!base.CanEquip(m)) + { return false; + } if (m.BodyMod == 183 || m.BodyMod == 184) { @@ -611,7 +619,9 @@ namespace Server.Items base.OnAdded(parent); if (parent is Mobile mobile) + { Titles.AwardKarma(mobile, -20, true); + } } public override void Serialize(IGenericWriter writer) @@ -660,7 +670,9 @@ namespace Server.Items var v = Utility.RandomBirdHue(); if (v == 2101) + { v = 0; + } return v; } diff --git a/Projects/UOContent/Items/Clothing/MiddleTorso.cs b/Projects/UOContent/Items/Clothing/MiddleTorso.cs index 18c2d62e2..a209eaf9a 100644 --- a/Projects/UOContent/Items/Clothing/MiddleTorso.cs +++ b/Projects/UOContent/Items/Clothing/MiddleTorso.cs @@ -124,7 +124,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 6.0; + } } } @@ -170,7 +172,9 @@ namespace Server.Items writer.Write(0); // version if (Weight == 2.0) + { Weight = 1.0; + } } public override void Deserialize(IGenericReader reader) diff --git a/Projects/UOContent/Items/Clothing/OuterLegs.cs b/Projects/UOContent/Items/Clothing/OuterLegs.cs index 9beb4542b..3a72e4dea 100644 --- a/Projects/UOContent/Items/Clothing/OuterLegs.cs +++ b/Projects/UOContent/Items/Clothing/OuterLegs.cs @@ -49,7 +49,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 4.0) + { Weight = 3.0; + } } } diff --git a/Projects/UOContent/Items/Clothing/OuterTorso.cs b/Projects/UOContent/Items/Clothing/OuterTorso.cs index f39647aab..0724e71ec 100644 --- a/Projects/UOContent/Items/Clothing/OuterTorso.cs +++ b/Projects/UOContent/Items/Clothing/OuterTorso.cs @@ -153,7 +153,9 @@ namespace Server.Items writer.Write(m_DecayTimer != null); if (m_DecayTimer != null) + { writer.WriteDeltaTime(m_DecayTime); + } } public override void Deserialize(IGenericReader reader) @@ -178,13 +180,18 @@ namespace Server.Items case 0: { if (Parent == null) + { BeginDecay(m_DefaultDecayTime); + } + break; } } if (version < 1 && Hue == 0) + { Hue = 2301; + } } private class InternalTimer : Timer @@ -200,9 +207,13 @@ namespace Server.Items protected override void OnTick() { if (m_Robe.Parent != null || m_Robe.IsLockedDown) + { Stop(); + } else + { m_Robe.Delete(); + } } } } @@ -241,7 +252,9 @@ namespace Server.Items get { if (m_LabelNumber > 0) + { return m_LabelNumber; + } return base.LabelNumber; } @@ -257,7 +270,9 @@ namespace Server.Items base.OnAdded(parent); if (parent is Mobile mobile) + { mobile.VirtualArmorMod += 2; + } } public override void OnRemoved(IEntity parent) @@ -265,7 +280,9 @@ namespace Server.Items base.OnRemoved(parent); if (parent is Mobile mobile) + { mobile.VirtualArmorMod -= 2; + } } public override bool Dye(Mobile from, DyeTub sender) @@ -279,18 +296,22 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add( RewardSystem.GetRewardYearLabel( this, new object[] { Hue, m_LabelNumber } ) ); // X Year Veteran Reward + } } public override bool CanEquip(Mobile m) { if (!base.CanEquip(m)) + { return false; + } return !IsRewardItem || RewardSystem.CheckIsUsableBy(m, this, new object[] { Hue, m_LabelNumber }); } @@ -322,7 +343,9 @@ namespace Server.Items } if (Parent is Mobile mobile) + { mobile.VirtualArmorMod += 2; + } } } @@ -360,7 +383,9 @@ namespace Server.Items get { if (m_LabelNumber > 0) + { return m_LabelNumber; + } return base.LabelNumber; } @@ -376,7 +401,9 @@ namespace Server.Items base.OnAdded(parent); if (parent is Mobile mobile) + { mobile.VirtualArmorMod += 2; + } } public override void OnRemoved(IEntity parent) @@ -384,7 +411,9 @@ namespace Server.Items base.OnRemoved(parent); if (parent is Mobile mobile) + { mobile.VirtualArmorMod -= 2; + } } public override bool Dye(Mobile from, DyeTub sender) @@ -398,18 +427,22 @@ namespace Server.Items base.GetProperties(list); if (IsRewardItem) + { list.Add( RewardSystem.GetRewardYearLabel( this, new object[] { Hue, m_LabelNumber } ) ); // X Year Veteran Reward + } } public override bool CanEquip(Mobile m) { if (!base.CanEquip(m)) + { return false; + } return !IsRewardItem || RewardSystem.CheckIsUsableBy(m, this, new object[] { Hue, m_LabelNumber }); } @@ -441,7 +474,9 @@ namespace Server.Items } if (Parent is Mobile mobile) + { mobile.VirtualArmorMod += 2; + } } } @@ -518,7 +553,9 @@ namespace Server.Items m_MaxArcaneCharges = reader.ReadInt(); if (Hue == 2118) + { Hue = ArcaneGem.DefaultArcaneHue; + } } break; @@ -529,12 +566,18 @@ namespace Server.Items public void Update() { if (IsArcane) + { ItemID = 0x26AE; + } else if (ItemID == 0x26AE) + { ItemID = 0x1F04; + } if (IsArcane && CurArcaneCharges == 0) + { Hue = 0; + } } public override void GetProperties(ObjectPropertyList list) @@ -542,7 +585,9 @@ namespace Server.Items base.GetProperties(list); if (IsArcane) + { list.Add(1061837, "{0}\t{1}", m_CurArcaneCharges, m_MaxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ + } } public override void OnSingleClick(Mobile from) @@ -550,15 +595,21 @@ namespace Server.Items base.OnSingleClick(from); if (IsArcane) - LabelTo(from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + { + LabelTo(@from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + } } public void Flip() { if (ItemID == 0x1F03) + { ItemID = 0x1F04; + } else if (ItemID == 0x1F04) + { ItemID = 0x1F03; + } } } @@ -623,7 +674,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 2.0; + } } } diff --git a/Projects/UOContent/Items/Clothing/Shirts.cs b/Projects/UOContent/Items/Clothing/Shirts.cs index 014fb0494..8c504a923 100644 --- a/Projects/UOContent/Items/Clothing/Shirts.cs +++ b/Projects/UOContent/Items/Clothing/Shirts.cs @@ -74,7 +74,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } diff --git a/Projects/UOContent/Items/Clothing/Shoes.cs b/Projects/UOContent/Items/Clothing/Shoes.cs index 2c611fbcb..7bd0a4bbd 100644 --- a/Projects/UOContent/Items/Clothing/Shoes.cs +++ b/Projects/UOContent/Items/Clothing/Shoes.cs @@ -13,7 +13,9 @@ namespace Server.Items public override bool Scissor(Mobile from, Scissors scissors) { if (DefaultResource == CraftResource.None) - return base.Scissor(from, scissors); + { + return base.Scissor(@from, scissors); + } from.SendLocalizedMessage(502440); // Scissors can not be used on that to produce anything. return false; @@ -176,7 +178,9 @@ namespace Server.Items m_MaxArcaneCharges = reader.ReadInt(); if (Hue == 2118) + { Hue = ArcaneGem.DefaultArcaneHue; + } } break; @@ -189,18 +193,26 @@ namespace Server.Items base.OnSingleClick(from); if (IsArcane) - LabelTo(from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + { + LabelTo(@from, 1061837, $"{m_CurArcaneCharges}\t{m_MaxArcaneCharges}"); + } } public void Update() { if (IsArcane) + { ItemID = 0x26AF; + } else if (ItemID == 0x26AF) + { ItemID = 0x1711; + } if (IsArcane && CurArcaneCharges == 0) + { Hue = 0; + } } public override void GetProperties(ObjectPropertyList list) @@ -208,15 +220,21 @@ namespace Server.Items base.GetProperties(list); if (IsArcane) + { list.Add(1061837, "{0}\t{1}", m_CurArcaneCharges, m_MaxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ + } } public void Flip() { if (ItemID == 0x1711) + { ItemID = 0x1712; + } else if (ItemID == 0x1712) + { ItemID = 0x1711; + } } } diff --git a/Projects/UOContent/Items/Construction/Ankhs.cs b/Projects/UOContent/Items/Construction/Ankhs.cs index c63736a0f..1cc6e0728 100644 --- a/Projects/UOContent/Items/Construction/Ankhs.cs +++ b/Projects/UOContent/Items/Construction/Ankhs.cs @@ -14,18 +14,24 @@ namespace Server.Items public static void GetContextMenuEntries(Mobile from, Item item, List list) { if (from is PlayerMobile mobile) + { list.Add(new LockKarmaEntry(mobile)); + } list.Add(new ResurrectEntry(from, item)); if (Core.AOS) - list.Add(new TitheEntry(from)); + { + list.Add(new TitheEntry(@from)); + } } public static void Resurrect(Mobile m, Item item) { if (m.Alive) + { return; + } if (!m.InRange(item.GetWorldLocation(), ResurrectRange)) { @@ -73,11 +79,15 @@ namespace Server.Items m_Mobile.KarmaLocked = !m_Mobile.KarmaLocked; if (m_Mobile.KarmaLocked) + { m_Mobile.SendLocalizedMessage( 1060192 ); // Your karma has been locked. Your karma can no longer be raised. + } else + { m_Mobile.SendLocalizedMessage(1060191); // Your karma has been unlocked. Your karma can be raised again. + } } } @@ -95,7 +105,9 @@ namespace Server.Items public override void OnClick() { if (m_Mobile.CheckAlive()) + { m_Mobile.SendGump(new TithingGump(m_Mobile, 0)); + } } } } @@ -126,14 +138,19 @@ namespace Server.Items set { base.Hue = value; - if (m_Item.Hue != value) m_Item.Hue = value; + if (m_Item.Hue != value) + { + m_Item.Hue = value; + } } } public override void OnMovement(Mobile m, Point3D oldLocation) { if (Parent == null && Utility.InRange(Location, m.Location, 1) && !Utility.InRange(Location, oldLocation, 1)) + { Ankhs.Resurrect(m, this); + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -150,13 +167,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -209,20 +230,27 @@ namespace Server.Items set { base.Hue = value; - if (m_Item.Hue != value) m_Item.Hue = value; + if (m_Item.Hue != value) + { + m_Item.Hue = value; + } } } public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -235,7 +263,9 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (Parent == null && Utility.InRange(Location, m.Location, 1) && !Utility.InRange(Location, oldLocation, 1)) + { Ankhs.Resurrect(m, this); + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -297,14 +327,19 @@ namespace Server.Items set { base.Hue = value; - if (m_Item.Hue != value) m_Item.Hue = value; + if (m_Item.Hue != value) + { + m_Item.Hue = value; + } } } public override void OnMovement(Mobile m, Point3D oldLocation) { if (Parent == null && Utility.InRange(Location, m.Location, 1) && !Utility.InRange(Location, oldLocation, 1)) + { Ankhs.Resurrect(m, this); + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -321,13 +356,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -382,20 +421,27 @@ namespace Server.Items set { base.Hue = value; - if (m_Item.Hue != value) m_Item.Hue = value; + if (m_Item.Hue != value) + { + m_Item.Hue = value; + } } } public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -408,7 +454,9 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (Parent == null && Utility.InRange(Location, m.Location, 1) && !Utility.InRange(Location, oldLocation, 1)) + { Ankhs.Resurrect(m, this); + } } public override void GetContextMenuEntries(Mobile from, List list) diff --git a/Projects/UOContent/Items/Construction/Chairs/Chairs.cs b/Projects/UOContent/Items/Construction/Chairs/Chairs.cs index 469490b42..e8ee50fd3 100644 --- a/Projects/UOContent/Items/Construction/Chairs/Chairs.cs +++ b/Projects/UOContent/Items/Construction/Chairs/Chairs.cs @@ -25,7 +25,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 20.0; + } } } @@ -54,7 +56,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 20.0; + } } } @@ -83,7 +87,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 20.0; + } } } @@ -112,7 +118,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 20.0; + } } } diff --git a/Projects/UOContent/Items/Construction/Chairs/Stools.cs b/Projects/UOContent/Items/Construction/Chairs/Stools.cs index 6895f34a1..b52ed63ab 100644 --- a/Projects/UOContent/Items/Construction/Chairs/Stools.cs +++ b/Projects/UOContent/Items/Construction/Chairs/Stools.cs @@ -24,7 +24,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 10.0; + } } } @@ -52,7 +54,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 10.0; + } } } } diff --git a/Projects/UOContent/Items/Construction/Chairs/Thrones.cs b/Projects/UOContent/Items/Construction/Chairs/Thrones.cs index a5e396877..c840793f4 100644 --- a/Projects/UOContent/Items/Construction/Chairs/Thrones.cs +++ b/Projects/UOContent/Items/Construction/Chairs/Thrones.cs @@ -25,7 +25,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 1.0; + } } } @@ -54,7 +56,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 15.0; + } } } } diff --git a/Projects/UOContent/Items/Construction/Decorative/DecorativeWeapon.cs b/Projects/UOContent/Items/Construction/Decorative/DecorativeWeapon.cs index 9d0a678a8..8a48e59ad 100644 --- a/Projects/UOContent/Items/Construction/Decorative/DecorativeWeapon.cs +++ b/Projects/UOContent/Items/Construction/Decorative/DecorativeWeapon.cs @@ -119,13 +119,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -171,13 +175,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -226,13 +234,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -278,13 +290,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -333,13 +349,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -385,13 +405,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -440,13 +464,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -492,13 +520,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() diff --git a/Projects/UOContent/Items/Construction/Decorative/Tapestry.cs b/Projects/UOContent/Items/Construction/Decorative/Tapestry.cs index baeda8976..ac6168dd5 100644 --- a/Projects/UOContent/Items/Construction/Decorative/Tapestry.cs +++ b/Projects/UOContent/Items/Construction/Decorative/Tapestry.cs @@ -19,13 +19,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -71,13 +75,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -126,13 +134,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -178,13 +190,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -233,13 +249,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -285,13 +305,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -340,13 +364,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 2, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -392,13 +420,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 2, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -447,13 +479,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 2, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -499,13 +535,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 2, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -554,13 +594,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -606,13 +650,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -661,13 +709,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -713,13 +765,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -768,13 +824,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -820,13 +880,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -875,13 +939,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -927,13 +995,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -982,13 +1054,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -1034,13 +1110,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -1089,13 +1169,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -1141,13 +1225,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() diff --git a/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs b/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs index 7e2461e2b..daaa408d6 100644 --- a/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs +++ b/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs @@ -59,16 +59,24 @@ namespace Server.Items ItemID = m_Open ? OpenedID : ClosedID; if (m_Open) + { Location = new Point3D(X + Offset.X, Y + Offset.Y, Z + Offset.Z); + } else + { Location = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z); + } Effects.PlaySound(this, Map, m_Open ? OpenedSound : ClosedSound); if (m_Open) + { m_Timer.Start(); + } else + { m_Timer.Stop(); + } } } } @@ -94,7 +102,9 @@ namespace Server.Items get { if (m_Link?.Deleted == true) + { m_Link = null; + } return m_Link; } @@ -184,7 +194,9 @@ namespace Server.Items if (list.Count >= 2) { for (var i = 0; i < list.Count; ++i) + { list[i].Link = list[(i + 1) % list.Count]; + } from.SendMessage("The chain of doors have been linked."); } @@ -208,16 +220,23 @@ namespace Server.Items from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list); if (list.Count == 1) - from.SendMessage("Target the second door to link."); + { + @from.SendMessage("Target the second door to link."); + } else - from.SendMessage("Target another door to link. To complete the chain, retarget the first door."); + { + @from.SendMessage("Target another door to link. To complete the chain, retarget the first door."); + } } } } private static void EventSink_OpenDoorMacroUsed(Mobile m) { - if (m.Map == null) return; + if (m.Map == null) + { + return; + } int x = m.X, y = m.Y; @@ -256,6 +275,7 @@ namespace Server.Items var sector = m.Map.GetSector(x, y); foreach (var item in sector.Items) + { if (item.Location.X == x && item.Location.Y == y && item.Z + item.ItemData.Height > m.Z && m.Z + 16 > item.Z && item is BaseDoor && m.CanSee(item) && m.InLOS(item)) { @@ -267,6 +287,7 @@ namespace Server.Items break; } + } } public static Point3D GetOffset(DoorFacing facing) => m_Offsets[(int)facing]; @@ -274,12 +295,16 @@ namespace Server.Items public bool CanClose() { if (!m_Open) + { return true; + } var map = Map; if (map == null) + { return false; + } var p = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z); @@ -289,7 +314,9 @@ namespace Server.Items private bool CheckFit(Map map, Point3D p, int height) { if (map == Map.Internal) + { return false; + } var x = p.X; var y = p.Y; @@ -311,7 +338,9 @@ namespace Server.Items var impassable = id.Impassable; if ((surface || impassable) && item.Z + id.CalcHeight > z && z + height > item.Z) + { return false; + } } } @@ -322,13 +351,19 @@ namespace Server.Items if (m.Location.X == x && m.Location.Y == y) { if (m.Hidden && m.AccessLevel > AccessLevel.Player) + { continue; + } if (!m.Alive) + { continue; + } if (m.Z + 16 > z && z + height > m.Z) + { return false; + } } } @@ -352,14 +387,18 @@ namespace Server.Items public bool IsFreeToClose() { if (!UseChainedFunctionality) + { return CanClose(); + } var list = GetChain(); var freeToClose = true; for (var i = 0; freeToClose && i < list.Count; ++i) + { freeToClose = list[i].CanClose(); + } return freeToClose; } @@ -400,21 +439,31 @@ namespace Server.Items else { if (Hue == 0x44E && Map == Map.Malas) // doom door into healer room in doom - SendLocalizedMessageTo(from, 1060014); // Only the dead may pass. + { + SendLocalizedMessageTo(@from, 1060014); // Only the dead may pass. + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502503); // That is locked. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502503); // That is locked. + } return; } } if (m_Open && !IsFreeToClose()) + { return; + } if (m_Open) - OnClosed(from); + { + OnClosed(@from); + } else - OnOpened(from); + { + OnOpened(@from); + } if (UseChainedFunctionality) { @@ -423,7 +472,9 @@ namespace Server.Items var list = GetChain(); for (var i = 0; i < list.Count; ++i) + { list[i].Open = open; + } } else { @@ -432,7 +483,9 @@ namespace Server.Items var link = Link; if (m_Open && link?.Open == false) + { link.Open = true; + } } } @@ -447,9 +500,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (from.AccessLevel == AccessLevel.Player && !from.InRange(GetWorldLocation(), 2)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else - Use(from); + { + Use(@from); + } } public override void Serialize(IGenericWriter writer) @@ -493,7 +550,9 @@ namespace Server.Items m_Timer = new InternalTimer(this); if (m_Open) + { m_Timer.Start(); + } break; } @@ -513,7 +572,9 @@ namespace Server.Items protected override void OnTick() { if (m_Door.Open && m_Door.IsFreeToClose()) + { m_Door.Open = false; + } } } } diff --git a/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs b/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs index ea97a4a59..2326c5db7 100644 --- a/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs +++ b/Projects/UOContent/Items/Construction/Doors/HouseDoors.cs @@ -136,9 +136,13 @@ namespace Server.Items Point3D loc; if (Open) + { loc = new Point3D(X - Offset.X, Y - Offset.Y, Z - Offset.Z); + } else + { loc = Location; + } return BaseHouse.FindHouseAt(loc, Map, 20); } @@ -148,13 +152,19 @@ namespace Server.Items var house = FindHouse(); if (house == null) + { return false; + } if (!house.IsAosRules) + { return true; + } if (house.Public ? house.IsBanned(m) : !house.HasAccess(m)) + { return false; + } return house.HasSecureAccess(m, Level); } @@ -164,10 +174,14 @@ namespace Server.Items var house = FindHouse(); if (house?.IsFriend(from) == true && from.AccessLevel == AccessLevel.Player && house.RefreshDecay()) - from.SendLocalizedMessage(1043293); // Your house's age and contents have been refreshed. + { + @from.SendLocalizedMessage(1043293); // Your house's age and contents have been refreshed. + } if (house?.Public == true && !house.IsFriend(from)) + { house.Visits++; + } } public override bool UseLocks() => FindHouse()?.IsAosRules != true; @@ -175,9 +189,13 @@ namespace Server.Items public override void Use(Mobile from) { if (!CheckAccess(from)) - from.SendLocalizedMessage(1061637); // You are not allowed to access this. + { + @from.SendLocalizedMessage(1061637); // You are not allowed to access this. + } else - base.Use(from); + { + base.Use(@from); + } } public override void Serialize(IGenericWriter writer) @@ -207,7 +225,9 @@ namespace Server.Items case 0: { if (version < 1) + { Level = SecureLevel.Anyone; + } Facing = (DoorFacing)reader.ReadInt(); break; diff --git a/Projects/UOContent/Items/Construction/Misc/Easel.cs b/Projects/UOContent/Items/Construction/Misc/Easel.cs index 452c37347..510529164 100644 --- a/Projects/UOContent/Items/Construction/Misc/Easel.cs +++ b/Projects/UOContent/Items/Construction/Misc/Easel.cs @@ -25,7 +25,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 10.0) + { Weight = 25.0; + } } } } diff --git a/Projects/UOContent/Items/Construction/Misc/MusicStand.cs b/Projects/UOContent/Items/Construction/Misc/MusicStand.cs index 48f6e86ce..af0cbda0a 100644 --- a/Projects/UOContent/Items/Construction/Misc/MusicStand.cs +++ b/Projects/UOContent/Items/Construction/Misc/MusicStand.cs @@ -25,7 +25,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 8.0) + { Weight = 10.0; + } } } @@ -54,7 +56,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 10.0; + } } } } diff --git a/Projects/UOContent/Items/Construction/Misc/Vines.cs b/Projects/UOContent/Items/Construction/Misc/Vines.cs index 0233ea30b..e45923ebd 100644 --- a/Projects/UOContent/Items/Construction/Misc/Vines.cs +++ b/Projects/UOContent/Items/Construction/Misc/Vines.cs @@ -11,7 +11,9 @@ namespace Server.Items public Vines(int v) : base(0xCEB) { if (v < 0 || v > 7) + { v = 0; + } ItemID += v; Weight = 1.0; diff --git a/Projects/UOContent/Items/Construction/Signs/SubtextSign.cs b/Projects/UOContent/Items/Construction/Signs/SubtextSign.cs index 1f2f7572b..017183650 100644 --- a/Projects/UOContent/Items/Construction/Signs/SubtextSign.cs +++ b/Projects/UOContent/Items/Construction/Signs/SubtextSign.cs @@ -35,7 +35,9 @@ namespace Server.Items base.OnSingleClick(from); if (!string.IsNullOrEmpty(m_Subtext)) - LabelTo(from, m_Subtext); + { + LabelTo(@from, m_Subtext); + } } public override void AddNameProperties(ObjectPropertyList list) @@ -43,7 +45,9 @@ namespace Server.Items base.AddNameProperties(list); if (!string.IsNullOrEmpty(m_Subtext)) + { list.Add(m_Subtext); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Construction/Tables/Tables.cs b/Projects/UOContent/Items/Construction/Tables/Tables.cs index afa113ce9..eef852237 100644 --- a/Projects/UOContent/Items/Construction/Tables/Tables.cs +++ b/Projects/UOContent/Items/Construction/Tables/Tables.cs @@ -75,7 +75,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 4.0) + { Weight = 1.0; + } } } @@ -104,7 +106,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 4.0) + { Weight = 1.0; + } } } @@ -133,7 +137,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 4.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Construction/Tables/WritingTable.cs b/Projects/UOContent/Items/Construction/Tables/WritingTable.cs index 48064100c..a711392b7 100644 --- a/Projects/UOContent/Items/Construction/Tables/WritingTable.cs +++ b/Projects/UOContent/Items/Construction/Tables/WritingTable.cs @@ -25,7 +25,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 4.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Containers/BaseTreasureChest.cs b/Projects/UOContent/Items/Containers/BaseTreasureChest.cs index a3cc06630..12023115a 100644 --- a/Projects/UOContent/Items/Containers/BaseTreasureChest.cs +++ b/Projects/UOContent/Items/Containers/BaseTreasureChest.cs @@ -51,7 +51,9 @@ namespace Server.Items base.Locked = value; if (!value) + { StartResetTimer(); + } } } } @@ -63,7 +65,9 @@ namespace Server.Items get { if (Locked) + { return "a locked treasure chest"; + } return "a treasure chest"; } @@ -90,7 +94,9 @@ namespace Server.Items MaxSpawnTime = reader.ReadShort(); if (!Locked) + { StartResetTimer(); + } } protected virtual void SetLockLevel() @@ -110,9 +116,13 @@ namespace Server.Items private void StartResetTimer() { if (m_ResetTimer == null) + { m_ResetTimer = new TreasureResetTimer(this); + } else + { m_ResetTimer.Delay = TimeSpan.FromMinutes(Utility.Random(MinSpawnTime, MaxSpawnTime)); + } m_ResetTimer.Start(); } @@ -161,15 +171,23 @@ namespace Server.Items public void ClearContents() { for (var i = Items.Count - 1; i >= 0; --i) + { if (i < Items.Count) + { Items[i].Delete(); + } + } } public void Reset() { if (m_ResetTimer != null) + { if (m_ResetTimer.Running) + { m_ResetTimer.Stop(); + } + } Locked = true; ClearContents(); diff --git a/Projects/UOContent/Items/Containers/Container.cs b/Projects/UOContent/Items/Containers/Container.cs index 231363b4a..7d1a6d4a4 100644 --- a/Projects/UOContent/Items/Containers/Container.cs +++ b/Projects/UOContent/Items/Containers/Container.cs @@ -21,7 +21,9 @@ namespace Server.Items get { if (IsSecure) + { return 0; + } return base.DefaultMaxWeight; } @@ -30,7 +32,9 @@ namespace Server.Items public override bool IsAccessibleTo(Mobile m) { if (!BaseHouse.CheckAccessible(m, this)) + { return false; + } return base.IsAccessibleTo(m); } @@ -38,7 +42,9 @@ namespace Server.Items public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { if (IsSecure && !BaseHouse.CheckHold(m, this, item, message, checkItems, plusItems, plusWeight)) + { return false; + } return base.CheckHold(m, item, message, checkItems, plusItems, plusWeight); } @@ -46,7 +52,9 @@ namespace Server.Items public override bool CheckItemUse(Mobile from, Item item) { if (IsDecoContainer && item is BaseBook) + { return true; + } return base.CheckItemUse(from, item); } @@ -60,7 +68,9 @@ namespace Server.Items public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) { if (!CheckHold(from, dropped, sendFullMessage, true)) + { return false; + } var house = BaseHouse.FindHouseAt(this); @@ -74,7 +84,9 @@ namespace Server.Items } if (!house.LockDown(from, dropped, false)) + { return false; + } } var list = Items; @@ -84,7 +96,9 @@ namespace Server.Items var item = list[i]; if (!(item is Container) && item.StackWith(from, dropped, false)) + { return true; + } } DropItem(dropped); @@ -95,7 +109,9 @@ namespace Server.Items public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { if (!CheckHold(from, item, true, true)) + { return false; + } var house = BaseHouse.FindHouseAt(this); @@ -109,7 +125,9 @@ namespace Server.Items } if (!house.LockDown(from, item, false)) + { return false; + } } item.Location = new Point3D(p.X, p.Y, 0); @@ -125,15 +143,21 @@ namespace Server.Items base.UpdateTotal(sender, type, delta); if (type == TotalType.Weight) + { (RootParent as Mobile)?.InvalidateProperties(); + } } public override void OnDoubleClick(Mobile from) { if (from.AccessLevel > AccessLevel.Player || from.InRange(GetWorldLocation(), 2) || RootParent is PlayerVendor) - Open(from); + { + Open(@from); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public virtual void Open(Mobile from) @@ -171,15 +195,21 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (Name != null) + { list.Add(1075257, Name); // Contents of ~1_PETNAME~'s pack. + } else + { base.AddNameProperty(list); + } } public override void OnItemRemoved(Item item) { if (Items.Count == 0) + { Delete(); + } base.OnItemRemoved(item); } @@ -187,7 +217,9 @@ namespace Server.Items public override bool OnDragLift(Mobile from) { if (from.AccessLevel > AccessLevel.Player) + { return true; + } from.SendLocalizedMessage(500169); // You cannot pick that up. return false; @@ -211,7 +243,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0) + { Weight = 13.0; + } } } @@ -251,7 +285,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0) + { Weight = 13.0; + } } } @@ -273,7 +309,9 @@ namespace Server.Items get { if (Core.ML && Parent is Mobile m && m.Player && m.Backpack == this) + { return 550; + } return base.DefaultMaxWeight; } @@ -281,7 +319,10 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { - if (Deleted) return false; + if (Deleted) + { + return false; + } Hue = sender.DyedHue; @@ -302,7 +343,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && ItemID == 0x9B2) + { ItemID = 0xE75; + } } } @@ -341,7 +384,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -426,7 +471,10 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { - if (Deleted) return false; + if (Deleted) + { + return false; + } Hue = sender.DyedHue; @@ -471,7 +519,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 0.0) + { Weight = 25.0; + } } } @@ -598,7 +648,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 4.0) + { Weight = 2.0; + } } } @@ -627,7 +679,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 2.0; + } } } @@ -656,7 +710,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 8.0) + { Weight = 1.0; + } } } @@ -687,7 +743,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 3) + { Weight = -1; + } } } @@ -718,7 +776,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 25) + { Weight = -1; + } } } @@ -749,7 +809,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 25) + { Weight = -1; + } } } @@ -778,7 +840,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 15.0) + { Weight = 2.0; + } } } @@ -809,7 +873,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 15) + { Weight = -1; + } } } @@ -840,7 +906,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 15) + { Weight = -1; + } } } @@ -871,7 +939,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 15) + { Weight = -1; + } } } @@ -900,10 +970,14 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 15) + { Weight = -1; + } if (version < 2) + { GumpID = 0x10B; + } } } @@ -934,7 +1008,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 15) + { Weight = -1; + } } } } diff --git a/Projects/UOContent/Items/Containers/FillableContainers.cs b/Projects/UOContent/Items/Containers/FillableContainers.cs index 26b48ae61..5a70d216d 100644 --- a/Projects/UOContent/Items/Containers/FillableContainers.cs +++ b/Projects/UOContent/Items/Containers/FillableContainers.cs @@ -44,13 +44,19 @@ namespace Server.Items set { if (m_Content == value) + { return; + } m_Content = value; for (var i = Items.Count - 1; i >= 0; --i) + { if (i < Items.Count) + { Items[i].Delete(); + } + } Respawn(); } @@ -71,12 +77,16 @@ namespace Server.Items public virtual void AcquireContent() { if (m_Content != null) + { return; + } m_Content = FillableContent.Acquire(GetWorldLocation(), Map); if (m_Content != null) + { Respawn(); + } } public override void OnItemRemoved(Item item) @@ -99,7 +109,10 @@ namespace Server.Items { var count = 0; - foreach (var item in Items) count += item.Amount; + foreach (var item in Items) + { + count += item.Amount; + } return count; } @@ -136,7 +149,9 @@ namespace Server.Items } if (m_Content == null || Deleted) + { return; + } GenerateContent(); @@ -154,9 +169,13 @@ namespace Server.Items if (IsTrappable && (m_Content.Level > 1 || Utility.Random(5) < 4)) { if (m_Content.Level > Utility.Random(5)) + { TrapType = TrapType.PoisonTrap; + } else + { TrapType = TrapType.ExplosionTrap; + } TrapPower = m_Content.Level * Utility.RandomMinMax(10, 30); TrapLevel = m_Content.Level; @@ -176,7 +195,9 @@ namespace Server.Items var itemsCount = GetItemsCount(); if (itemsCount > SpawnThreshold) + { return 0; + } var maxSpawnCount = (1 + SpawnThreshold - itemsCount) * 2; @@ -186,7 +207,9 @@ namespace Server.Items public virtual void GenerateContent() { if (m_Content == null || Deleted) + { return; + } var toSpawn = GetSpawnCount(); @@ -195,7 +218,9 @@ namespace Server.Items var item = m_Content.Construct(); if (item == null) + { continue; + } var list = Items; @@ -204,11 +229,15 @@ namespace Server.Items var subItem = list[j]; if (!(subItem is Container) && subItem.StackWith(null, item, false)) + { break; + } } if (!item.Deleted) + { DropItem(item); + } } } @@ -285,12 +314,16 @@ namespace Server.Items public override void AcquireContent() { if (m_Content != null) + { return; + } m_Content = FillableContent.Library; if (m_Content != null) + { Respawn(); + } } public override void Serialize(IGenericWriter writer) @@ -307,7 +340,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0 && m_Content == null) + { Timer.DelayCall(AcquireContent); + } } } @@ -423,7 +458,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0 && Weight == 3) + { Weight = -1; + } } } @@ -456,7 +493,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0 && Weight == 25) + { Weight = -1; + } } } @@ -488,7 +527,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 25) + { Weight = -1; + } } } @@ -520,7 +561,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 25) + { Weight = -1; + } } } @@ -552,7 +595,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 2) + { Weight = -1; + } } } @@ -588,7 +633,9 @@ namespace Server.Items m_Types = new Type[count]; for (var i = 0; i < m_Types.Length; ++i) + { m_Types[i] = types[offset + i]; + } } public Type[] Types => m_Types; @@ -599,16 +646,22 @@ namespace Server.Items var item = Loot.Construct(m_Types); if (item is Key key) + { key.ItemID = Utility.RandomList( (int)KeyType.Copper, (int)KeyType.Gold, (int)KeyType.Iron, (int)KeyType.Rusty ); + } else if (item is Arrow || item is Bolt) + { item.Amount = Utility.RandomMinMax(2, 6); + } else if (item is Bandage || item is Lockpick) + { item.Amount = Utility.RandomMinMax(1, 3); + } return item; } @@ -1481,7 +1534,9 @@ namespace Server.Items m_Entries = entries; for (var i = 0; i < entries.Length; ++i) + { m_Weight += entries[i].Weight; + } } public int Level { get; } @@ -1499,7 +1554,9 @@ namespace Server.Items var entry = m_Entries[i]; if (index < entry.Weight) + { return entry.Construct(); + } index -= entry.Weight; } @@ -1512,7 +1569,9 @@ namespace Server.Items var v = (int)type; if (v >= 0 && v < m_ContentTypes.Length) + { return m_ContentTypes[v]; + } return null; } @@ -1520,7 +1579,9 @@ namespace Server.Items public static FillableContentType Lookup(FillableContent content) { if (content == null) + { return FillableContentType.None; + } return (FillableContentType)Array.IndexOf(m_ContentTypes, content); } @@ -1528,7 +1589,9 @@ namespace Server.Items public static FillableContent Acquire(Point3D loc, Map map) { if (map == null || map == Map.Internal) + { return null; + } if (m_AcquireTable == null) { @@ -1539,7 +1602,9 @@ namespace Server.Items var fill = m_ContentTypes[i]; for (var j = 0; j < fill.Vendors.Length; ++j) + { m_AcquireTable[fill.Vendors[j]] = fill; + } } } @@ -1550,7 +1615,9 @@ namespace Server.Items { if (nearest != null && mob.GetDistanceToSqrt(loc) > nearest.GetDistanceToSqrt(loc) && !(nearest is Cobbler && mob is Provisioner)) + { continue; + } if (m_AcquireTable.TryGetValue(mob.GetType(), out var check)) { diff --git a/Projects/UOContent/Items/Containers/LockableContainer.cs b/Projects/UOContent/Items/Containers/LockableContainer.cs index 779962de9..f93f86195 100644 --- a/Projects/UOContent/Items/Containers/LockableContainer.cs +++ b/Projects/UOContent/Items/Containers/LockableContainer.cs @@ -43,15 +43,23 @@ namespace Server.Items MaxLockLevel = level + 35; if (LockLevel == 0) + { LockLevel = -1; + } else if (LockLevel > 95) + { LockLevel = 95; + } if (RequiredSkill > 95) + { RequiredSkill = 95; + } if (MaxLockLevel > 95) + { MaxLockLevel = 95; + } } else { @@ -70,7 +78,9 @@ namespace Server.Items m_Locked = value; if (m_Locked) + { Picker = null; + } InvalidateProperties(); } @@ -96,7 +106,10 @@ namespace Server.Items Locked = false; Picker = from; - if (TrapOnLockpick && ExecuteTrap(from)) TrapOnLockpick = false; + if (TrapOnLockpick && ExecuteTrap(from)) + { + TrapOnLockpick = false; + } } [CommandProperty(AccessLevel.GameMaster)] @@ -168,7 +181,9 @@ namespace Server.Items case 0: { if (version < 3) + { MaxLockLevel = 100; + } if (version < 4) { @@ -218,10 +233,14 @@ namespace Server.Items public override bool CheckLift(Mobile from, Item item, ref LRReason reject) { if (!base.CheckLift(from, item, ref reject)) + { return false; + } if (item != this && from.AccessLevel < AccessLevel.GameMaster && m_Locked) + { return false; + } return true; } @@ -229,7 +248,9 @@ namespace Server.Items public override bool CheckItemUse(Mobile from, Item item) { if (!base.CheckItemUse(from, item)) + { return false; + } if (item != this && from.AccessLevel < AccessLevel.GameMaster && m_Locked) { @@ -285,7 +306,9 @@ namespace Server.Items public override void OnDoubleClickSecureTrade(Mobile from) { if (CheckLocked(from)) + { return; + } base.OnDoubleClickSecureTrade(from); } @@ -293,7 +316,9 @@ namespace Server.Items public override void Open(Mobile from) { if (CheckLocked(from)) + { return; + } base.Open(from); } @@ -301,7 +326,9 @@ namespace Server.Items public override void OnSnoop(Mobile from) { if (CheckLocked(from)) + { return; + } base.OnSnoop(from); } @@ -311,7 +338,9 @@ namespace Server.Items base.AddNameProperties(list); if (IsShipwreckedItem) + { list.Add(1041645); // recovered from a shipwreck + } } public override void OnSingleClick(Mobile from) @@ -319,7 +348,9 @@ namespace Server.Items base.OnSingleClick(from); if (IsShipwreckedItem) - LabelTo(from, 1041645); // recovered from a shipwreck + { + LabelTo(@from, 1041645); // recovered from a shipwreck + } } } } diff --git a/Projects/UOContent/Items/Containers/MarkContainer.cs b/Projects/UOContent/Items/Containers/MarkContainer.cs index 0aa4f495b..e905e9032 100644 --- a/Projects/UOContent/Items/Containers/MarkContainer.cs +++ b/Projects/UOContent/Items/Containers/MarkContainer.cs @@ -14,13 +14,17 @@ namespace Server.Items Movable = false; if (bone) + { Hue = 1102; + } m_AutoLock = locked; Locked = locked; if (locked) + { LockLevel = -255; + } } public MarkContainer(Serial serial) : base(serial) @@ -36,9 +40,13 @@ namespace Server.Items m_AutoLock = value; if (!m_AutoLock) + { StopTimer(); + } else if (!Locked && m_RelockTimer == null) + { m_RelockTimer = new InternalTimer(this); + } } } @@ -77,7 +85,9 @@ namespace Server.Items StopTimer(); if (!Locked) + { m_RelockTimer = new InternalTimer(this); + } } } } @@ -121,7 +131,9 @@ namespace Server.Items var location = new Point3D(x, y, z); if (FindMarkContainer(location, Map.Malas)) + { return; + } var cont = new MarkContainer(bone, locked) { @@ -182,7 +194,9 @@ namespace Server.Items writer.Write(m_AutoLock); if (!Locked && m_AutoLock) + { writer.WriteDeltaTime(m_RelockTimer.RelockTime); + } writer.Write(TargetMap); writer.Write(Target); @@ -198,7 +212,9 @@ namespace Server.Items m_AutoLock = reader.ReadBool(); if (!Locked && m_AutoLock) + { m_RelockTimer = new InternalTimer(this, reader.ReadDeltaTime() - DateTime.UtcNow); + } TargetMap = reader.ReadMap(); Target = reader.ReadPoint3D(); diff --git a/Projects/UOContent/Items/Containers/ParagonChest.cs b/Projects/UOContent/Items/Containers/ParagonChest.cs index 1758d3b6a..94debdc29 100644 --- a/Projects/UOContent/Items/Containers/ParagonChest.cs +++ b/Projects/UOContent/Items/Containers/ParagonChest.cs @@ -112,16 +112,22 @@ namespace Server.Items DropItem(new Gold(level * 200)); for (var i = 0; i < level; ++i) + { DropItem(Loot.RandomScroll(0, 63, SpellbookType.Regular)); + } for (var i = 0; i < level * 2; ++i) { Item item; if (Core.AOS) + { item = Loot.RandomArmorOrShieldOrWeaponOrJewelry(); + } else + { item = Loot.RandomArmorOrShieldOrWeapon(); + } if (item is BaseWeapon weapon) { diff --git a/Projects/UOContent/Items/Containers/SalvageBag.cs b/Projects/UOContent/Items/Containers/SalvageBag.cs index 5fb665eea..3cd10f24f 100644 --- a/Projects/UOContent/Items/Containers/SalvageBag.cs +++ b/Projects/UOContent/Items/Containers/SalvageBag.cs @@ -50,22 +50,30 @@ namespace Server.Items try { if (CraftResources.GetType(resource) != CraftResourceType.Metal) + { return false; + } var info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) + { return false; + } var craftItem = DefBlacksmithy.CraftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) + { return false; + } var craftResource = craftItem.Resources[0]; if (craftResource.Amount < 2) + { return false; // Not enough metal to resmelt + } var difficulty = resource switch { @@ -89,12 +97,19 @@ namespace Server.Items { var mining = from.Skills.Mining.Value; if (mining > 100.0) + { mining = 100.0; + } + var amount = ((4 + mining) * craftResource.Amount - 4) * 0.0068; if (amount < 2) + { ingot.Amount = 2; + } else + { ingot.Amount = (int)amount; + } } else { @@ -129,10 +144,12 @@ namespace Server.Items private bool Resmeltables() // Where context menu checks for metal items and dragon barding deeds { foreach (var i in Items) + { return i?.Deleted == false && ( i is BaseWeapon weapon && CraftResources.GetType(weapon.Resource) == CraftResourceType.Metal || i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Metal || i is DragonBardingDeed); + } return false; } @@ -142,11 +159,15 @@ namespace Server.Items foreach (var i in Items) { if (!(i is IScissorable) || i.Deleted) + { continue; + } if (i is BaseClothing || i is Cloth || i is BoltOfCloth || i is Hides || i is BonePile || i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather) + { return true; + } } return false; @@ -178,14 +199,20 @@ namespace Server.Items foreach (var item in smeltables) { if (item?.Deleted != false) + { continue; + } if (item is BaseArmor armor && Resmelt(from, armor, armor.Resource) || item is BaseWeapon weapon && Resmelt(from, weapon, weapon.Resource) || item is DragonBardingDeed) + { salvaged++; + } else + { notSalvaged++; + } } if (m_Failure) @@ -224,12 +251,18 @@ namespace Server.Items var item = scissorables[i]; if (!(item is IScissorable scissorable)) + { continue; + } if (Scissors.CanScissor(from, scissorable) && scissorable.Scissor(from, scissors)) + { ++salvaged; + } else + { ++notSalvaged; + } } from.SendLocalizedMessage( @@ -245,7 +278,10 @@ namespace Server.Items } ); - for (var i = 0; i < items.Length; i++) from.AddToBackpack(items[i]); + for (var i = 0; i < items.Length; i++) + { + @from.AddToBackpack(items[i]); + } } private void SalvageAll(Mobile from) @@ -279,18 +315,24 @@ namespace Server.Items m_Bag = bag; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_Bag.Deleted) + { return; + } var from = Owner.From; if (from.CheckAlive()) - m_Bag.SalvageAll(from); + { + m_Bag.SalvageAll(@from); + } } } @@ -304,18 +346,24 @@ namespace Server.Items m_Bag = bag; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_Bag.Deleted) + { return; + } var from = Owner.From; if (from.CheckAlive()) - m_Bag.SalvageIngots(from); + { + m_Bag.SalvageIngots(@from); + } } } @@ -329,18 +377,24 @@ namespace Server.Items m_Bag = bag; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_Bag.Deleted) + { return; + } var from = Owner.From; if (from.CheckAlive()) - m_Bag.SalvageCloth(from); + { + m_Bag.SalvageCloth(@from); + } } } } diff --git a/Projects/UOContent/Items/Containers/Strongbox.cs b/Projects/UOContent/Items/Containers/Strongbox.cs index b4493fd58..3b545bda0 100644 --- a/Projects/UOContent/Items/Containers/Strongbox.cs +++ b/Projects/UOContent/Items/Containers/Strongbox.cs @@ -45,7 +45,9 @@ namespace Server.Items public void OnChop(Mobile from) { if (m_House?.Deleted != false || m_Owner?.Deleted != false || from == m_Owner || m_House.IsOwner(from)) - Chop(from); + { + Chop(@from); + } } public override void Serialize(IGenericWriter writer) @@ -90,9 +92,13 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (m_Owner != null) + { list.Add(1042887, m_Owner.Name); // a strong box owned by ~1_OWNER_NAME~ + } else + { base.AddNameProperty(list); + } } public override void OnSingleClick(Mobile from) @@ -102,7 +108,9 @@ namespace Server.Items LabelTo(from, 1042887, m_Owner.Name); // a strong box owned by ~1_OWNER_NAME~ if (CheckContentDisplay(from)) - LabelTo(from, "({0} items, {1} stones)", TotalItems, TotalWeight); + { + LabelTo(@from, "({0} items, {1} stones)", TotalItems, TotalWeight); + } } else { @@ -127,7 +135,10 @@ namespace Server.Items Container metalBox = new MetalBox(); var subItems = new List(Items); - foreach (var subItem in subItems) metalBox.AddItem(subItem); + foreach (var subItem in subItems) + { + metalBox.AddItem(subItem); + } Delete(); diff --git a/Projects/UOContent/Items/Containers/TrappableContainer.cs b/Projects/UOContent/Items/Containers/TrappableContainer.cs index 73bb0e86f..9736a4208 100644 --- a/Projects/UOContent/Items/Containers/TrappableContainer.cs +++ b/Projects/UOContent/Items/Containers/TrappableContainer.cs @@ -38,13 +38,18 @@ namespace Server.Items Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5022); Effects.PlaySound(Location, Map, 0x1F5); - if (TrapOnOpen) ExecuteTrap(from); + if (TrapOnOpen) + { + ExecuteTrap(@from); + } } private void SendMessageTo(Mobile to, int number, int hue) { if (Deleted || !to.CanSee(this)) + { return; + } to.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, "", "")); } @@ -52,7 +57,9 @@ namespace Server.Items private void SendMessageTo(Mobile to, string text, int hue) { if (Deleted || !to.CanSee(this)) + { return; + } to.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, hue, 3, "ENU", "", text)); } @@ -81,9 +88,13 @@ namespace Server.Items int damage; if (TrapLevel > 0) + { damage = Utility.RandomMinMax(10, 30) * TrapLevel; + } else + { damage = TrapPower; + } AOS.Damage(from, damage, 0, 100, 0, 0, 0); @@ -99,7 +110,9 @@ namespace Server.Items case TrapType.MagicTrap: { if (from.InRange(loc, 1)) - from.Damage(TrapPower); + { + @from.Damage(TrapPower); + } // AOS.Damage( from, m_TrapPower, 0, 100, 0, 0, 0 ); Effects.PlaySound(loc, Map, 0x307); @@ -123,9 +136,13 @@ namespace Server.Items int damage; if (TrapLevel > 0) + { damage = Utility.RandomMinMax(5, 15) * TrapLevel; + } else + { damage = TrapPower; + } AOS.Damage(from, damage, 100, 0, 0, 0, 0); @@ -180,7 +197,9 @@ namespace Server.Items public override void Open(Mobile from) { if (!TrapOnOpen || !ExecuteTrap(from)) - base.Open(from); + { + base.Open(@from); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Containers/TreasureMapChest.cs b/Projects/UOContent/Items/Containers/TreasureMapChest.cs index f1e371fd8..0a93fc68c 100644 --- a/Projects/UOContent/Items/Containers/TreasureMapChest.cs +++ b/Projects/UOContent/Items/Containers/TreasureMapChest.cs @@ -152,7 +152,9 @@ namespace Server.Items cont.DropItem(new Gold(Utility.RandomMinMax(50, 100))); if (Utility.RandomDouble() < 0.75) + { cont.DropItem(new TreasureMap(0, Map.Trammel)); + } } else { @@ -181,9 +183,12 @@ namespace Server.Items cont.DropItem(new Gold(level * 1000)); for (var i = 0; i < level * 5; ++i) + { cont.DropItem(Loot.RandomScroll(0, 63, SpellbookType.Regular)); + } if (Core.SE) + { numberItems = level switch { 1 => 5, @@ -194,17 +199,24 @@ namespace Server.Items 6 => 60, _ => 0 }; + } else + { numberItems = level * 6; + } for (var i = 0; i < numberItems; ++i) { Item item; if (Core.AOS) + { item = Loot.RandomArmorOrShieldOrWeaponOrJewelry(); + } else + { item = Loot.RandomArmorOrShieldOrWeapon(); + } if (item is BaseWeapon weapon) { @@ -259,9 +271,13 @@ namespace Server.Items int reagents; if (level == 0) + { reagents = 12; + } else + { reagents = level * 3; + } for (var i = 0; i < reagents; i++) { @@ -272,9 +288,13 @@ namespace Server.Items int gems; if (level == 0) + { gems = 2; + } else + { gems = level * 3; + } for (var i = 0; i < gems; i++) { @@ -283,24 +303,30 @@ namespace Server.Items } if (level == 6 && Core.AOS) + { cont.DropItem((Item)ActivatorUtil.CreateInstance(Artifacts.RandomElement())); + } } public override bool CheckLocked(Mobile from) { if (!Locked) + { return false; + } if (Level == 0 && from.AccessLevel < AccessLevel.GameMaster) { foreach (var m in Guardians) + { if (m.Alive) { - from.SendLocalizedMessage( + @from.SendLocalizedMessage( 1046448 ); // You must first kill the guardians before you may open this chest. return true; } + } LockPick(from); return false; @@ -312,22 +338,32 @@ namespace Server.Items private bool CheckLoot(Mobile m, bool criminalAction) { if (Temporary) + { return false; + } if (m.AccessLevel >= AccessLevel.GameMaster || Owner == null || m == Owner) + { return true; + } if (Party.Get(Owner)?.Contains(m) == true) + { return true; + } var map = Map; if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) { if (criminalAction) + { m.CriminalAction(true); + } else + { m.SendLocalizedMessage(1010630); // Taking someone else's treasure is a criminal offense! + } return true; } @@ -353,7 +389,9 @@ namespace Server.Items m_Lifted.Add(item); if (Utility.RandomDouble() <= 0.1) // 10% chance to spawn a new monster - TreasureMap.Spawn(Level, GetWorldLocation(), Map, from, false); + { + TreasureMap.Spawn(Level, GetWorldLocation(), Map, @from, false); + } } base.OnItemLifted(from, item); @@ -414,7 +452,9 @@ namespace Server.Items m_Lifted = reader.ReadStrongItemList(); if (version < 2) + { Guardians = new List(); + } break; } @@ -445,13 +485,17 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (from.Alive) - list.Add(new RemoveEntry(from, this)); + { + list.Add(new RemoveEntry(@from, this)); + } } public void BeginRemove(Mobile from) { if (!from.Alive) + { return; + } from.CloseGump(); from.SendGump(new RemoveGump(from, this)); @@ -460,7 +504,9 @@ namespace Server.Items public void EndRemove(Mobile from) { if (Deleted || from != Owner || !from.InRange(GetWorldLocation(), 3)) + { return; + } from.SendLocalizedMessage(1048124, "", 0x8A5); // The old, rusted chest crumbles when you hit it. Delete(); @@ -503,7 +549,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 1) + { m_Chest.EndRemove(m_From); + } } } @@ -523,7 +571,9 @@ namespace Server.Items public override void OnClick() { if (m_Chest.Deleted || m_From != m_Chest.Owner || !m_From.CheckAlive()) + { return; + } m_Chest.BeginRemove(m_From); } diff --git a/Projects/UOContent/Items/Decoration Artifacts/SEDecorationArtifacts.cs b/Projects/UOContent/Items/Decoration Artifacts/SEDecorationArtifacts.cs index 07d3ae445..b9a43810b 100644 --- a/Projects/UOContent/Items/Decoration Artifacts/SEDecorationArtifacts.cs +++ b/Projects/UOContent/Items/Decoration Artifacts/SEDecorationArtifacts.cs @@ -1371,7 +1371,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0) + { Light = LightType.Circle225; + } } } diff --git a/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs b/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs index fe70cd6c1..871cd9c5c 100644 --- a/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs +++ b/Projects/UOContent/Items/Decoration Artifacts/StealableArtifactsSpawner.cs @@ -20,7 +20,9 @@ namespace Server.Items m_Table = new Dictionary(Entries.Length); for (var i = 0; i < Entries.Length; i++) + { m_Artifacts[i] = new StealableInstance(Entries[i]); + } m_RespawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn); } @@ -144,7 +146,9 @@ namespace Server.Items m_TypesOfEntries = new Type[Entries.Length]; for (var i = 0; i < Entries.Length; i++) + { m_TypesOfEntries[i] = Entries[i].Type; + } } return m_TypesOfEntries; @@ -158,7 +162,9 @@ namespace Server.Items private static int GetLampPostHue() { if (Utility.RandomDouble() < 0.9) + { return 0; + } return Utility.RandomList(0x455, 0x47E, 0x482, 0x486, 0x48F, 0x4F2, 0x58C, 0x66C); } @@ -176,9 +182,13 @@ namespace Server.Items var from = args.Mobile; if (Create()) - from.SendMessage("Stealable artifacts spawner generated."); + { + @from.SendMessage("Stealable artifacts spawner generated."); + } else - from.SendMessage("Stealable artifacts spawner already present."); + { + @from.SendMessage("Stealable artifacts spawner already present."); + } } [Usage("RemoveStealArties")] @@ -188,15 +198,21 @@ namespace Server.Items var from = args.Mobile; if (Remove()) - from.SendMessage("Stealable artifacts spawner removed."); + { + @from.SendMessage("Stealable artifacts spawner removed."); + } else - from.SendMessage("Stealable artifacts spawner not present."); + { + @from.SendMessage("Stealable artifacts spawner not present."); + } } public static bool Create() { if (Instance?.Deleted == false) + { return false; + } Instance = new StealableArtifactsSpawner(); return true; @@ -205,7 +221,9 @@ namespace Server.Items public static bool Remove() { if (Instance == null) + { return false; + } Instance.Delete(); Instance = null; @@ -215,7 +233,9 @@ namespace Server.Items public static StealableInstance GetStealableInstance(Item item) { if (Instance == null) + { return null; + } Instance.m_Table.TryGetValue(item, out var value); return value; @@ -231,7 +251,10 @@ namespace Server.Items m_RespawnTimer = null; } - foreach (var si in m_Artifacts) si.Item?.Delete(); + foreach (var si in m_Artifacts) + { + si.Item?.Delete(); + } Instance = null; } @@ -239,7 +262,9 @@ namespace Server.Items public void CheckRespawn() { foreach (var si in m_Artifacts) + { si.CheckRespawn(); + } } public override void Serialize(IGenericWriter writer) @@ -281,11 +306,16 @@ namespace Server.Items m_Artifacts[i] = si; if (si.Item != null) + { m_Table[si.Item] = si; + } } } - for (var i = length; i < Entries.Length; i++) m_Artifacts[i] = new StealableInstance(Entries[i]); + for (var i = length; i < Entries.Length; i++) + { + m_Artifacts[i] = new StealableInstance(Entries[i]); + } m_RespawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn); } @@ -319,7 +349,9 @@ namespace Server.Items var item = (Item)ActivatorUtil.CreateInstance(Type); if (Hue > 0) + { item.Hue = Hue; + } item.Movable = false; item.MoveToWorld(Location, Map); @@ -359,10 +391,14 @@ namespace Server.Items if (Instance != null) { if (m_Item != null) + { Instance.m_Table.Remove(m_Item); + } if (value != null) + { Instance.m_Table[value] = this; + } } m_Item = value; @@ -374,10 +410,14 @@ namespace Server.Items public void CheckRespawn() { if (Item != null && (Item.Deleted || Item.Movable || Item.Parent != null)) + { Item = null; + } if (Item == null && DateTime.UtcNow >= NextRespawn) + { Item = Entry.CreateInstance(); + } } } } diff --git a/Projects/UOContent/Items/Deeds/ClothingBlessDeed.cs b/Projects/UOContent/Items/Deeds/ClothingBlessDeed.cs index 7785529a6..598c17bab 100644 --- a/Projects/UOContent/Items/Deeds/ClothingBlessDeed.cs +++ b/Projects/UOContent/Items/Deeds/ClothingBlessDeed.cs @@ -11,7 +11,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object target) // Override the protected OnTarget() for our feature { if (m_Deed.Deleted || m_Deed.RootParent != from) + { return; + } if (target is BaseClothing item) { diff --git a/Projects/UOContent/Items/Deeds/CommodityDeed.cs b/Projects/UOContent/Items/Deeds/CommodityDeed.cs index a6c653c81..7d3e7e628 100644 --- a/Projects/UOContent/Items/Deeds/CommodityDeed.cs +++ b/Projects/UOContent/Items/Deeds/CommodityDeed.cs @@ -67,7 +67,11 @@ namespace Server.Items { case 0: { - if (Commodity != null) Hue = 0x592; + if (Commodity != null) + { + Hue = 0x592; + } + break; } } @@ -107,10 +111,14 @@ namespace Server.Items string args; if (Commodity.Name == null) + { args = $"#{(Commodity is ICommodity commodity ? commodity.DescriptionNumber : Commodity.LabelNumber)}\t{Commodity.Amount}"; + } else + { args = $"{Commodity.Name}\t{Commodity.Amount}"; + } LabelTo(from, 1060658, args); // ~1_val~: ~2_val~ } @@ -154,9 +162,13 @@ namespace Server.Items else { if (Core.ML) + { number = 1080526; // That must be in your bank box or commodity deed box to use it. + } else + { number = 1047024; // To claim the resources .... + } } } else if (cox?.IsSecure == false) @@ -166,9 +178,13 @@ namespace Server.Items else if ((box == null || !IsChildOf(box)) && cox == null) { if (Core.ML) + { number = 1080526; // That must be in your bank box or commodity deed box to use it. + } else + { number = 1047026; // That must be in your bank box to use it. + } } else { @@ -189,7 +205,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Deed.Deleted) + { return; + } int number; diff --git a/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs b/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs index 0b699164e..bc0de0d85 100644 --- a/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs +++ b/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs @@ -62,7 +62,9 @@ namespace Server.Items Exceptional = quality >= 2; if (makersMark) - Crafter = from; + { + Crafter = @from; + } var resourceType = typeRes ?? craftItem.Resources[0].ItemType; @@ -71,7 +73,9 @@ namespace Server.Items var context = craftSystem.GetContext(from); if (context?.DoNotColor == true) + { Hue = 0; + } return quality; } @@ -81,7 +85,9 @@ namespace Server.Items base.GetProperties(list); if (m_Exceptional && m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } } public override void OnDoubleClick(Mobile from) @@ -100,7 +106,9 @@ namespace Server.Items public virtual void OnTarget(Mobile from, object obj) { if (Deleted) + { return; + } if (!(obj is SwampDragon pet) || pet.HasBarding) { @@ -157,7 +165,9 @@ namespace Server.Items m_Crafter = reader.ReadMobile(); if (version < 1) + { reader.ReadInt(); + } m_Resource = (CraftResource)reader.ReadInt(); break; diff --git a/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs b/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs index 834cf8530..4a9841fc0 100644 --- a/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs +++ b/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs @@ -35,9 +35,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!IsChildOf(from.Backpack)) - from.SendLocalizedMessage(1042001); // That must be in your pack... + { + @from.SendLocalizedMessage(1042001); // That must be in your pack... + } else - from.SendGump(new InternalGump(from, this)); + { + @from.SendGump(new InternalGump(@from, this)); + } } private class InternalGump : Gump @@ -133,13 +137,19 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_From?.Alive != true) + { return; + } if (m_Deed.Deleted) + { return; + } if (info.ButtonID < 1 || info.ButtonID > 10) + { return; + } var RacialData = m_From.Race == Race.Human ? HumanArray : ElvenArray; diff --git a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs index 97889782f..54431138a 100644 --- a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs +++ b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs @@ -41,7 +41,9 @@ namespace Server.Items public bool ValidatePlacement(Mobile from, Point3D loc) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (!from.InRange(GetWorldLocation(), 1)) { @@ -60,7 +62,9 @@ namespace Server.Items var map = from.Map; if (map == null) + { return false; + } var house = BaseHouse.FindHouseAt(loc, map, 20); @@ -87,7 +91,9 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted, HolidayTreeType type) { if (!(targeted is IPoint3D p)) + { return; + } var loc = new Point3D(p); @@ -96,11 +102,15 @@ namespace Server.Items * A side affect is that you can only place on floors (due to the CanFit call). * That functionality may be desired. And so, it's included in this script. */ + { loc.Z -= TileData.ItemTable[target.ItemID] .CalcHeight; + } if (ValidatePlacement(from, loc)) - EndPlace(from, type, loc); + { + EndPlace(@from, type, loc); + } } public void EndPlace(Mobile from, HolidayTreeType type, Point3D loc) @@ -142,7 +152,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Items/Deeds/NameChangeDeed.cs b/Projects/UOContent/Items/Deeds/NameChangeDeed.cs index a203cd43b..05a7d3628 100644 --- a/Projects/UOContent/Items/Deeds/NameChangeDeed.cs +++ b/Projects/UOContent/Items/Deeds/NameChangeDeed.cs @@ -92,7 +92,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Sender?.Deleted != false || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile) + { return; + } var m = sender.Mobile; var nameEntry = info.GetTextEntry(0); diff --git a/Projects/UOContent/Items/Deeds/NewPlayerTicket.cs b/Projects/UOContent/Items/Deeds/NewPlayerTicket.cs index 3d8325366..f246133db 100644 --- a/Projects/UOContent/Items/Deeds/NewPlayerTicket.cs +++ b/Projects/UOContent/Items/Deeds/NewPlayerTicket.cs @@ -58,7 +58,9 @@ namespace Server.Items } if (Name == "a young player ticket") + { Name = null; + } } public override void OnDoubleClick(Mobile from) @@ -162,7 +164,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Ticket.Deleted) + { return; + } var number = 0; @@ -206,7 +210,9 @@ namespace Server.Items m_From.AddToBackpack(item); if (item2 != null) + { m_From.AddToBackpack(item2); + } } } } diff --git a/Projects/UOContent/Items/Deeds/VendorRentalContract.cs b/Projects/UOContent/Items/Deeds/VendorRentalContract.cs index 12b97fca9..aed5e43cc 100644 --- a/Projects/UOContent/Items/Deeds/VendorRentalContract.cs +++ b/Projects/UOContent/Items/Deeds/VendorRentalContract.cs @@ -37,7 +37,9 @@ namespace Server.Items set { if (value != null) + { m_Duration = value; + } } } @@ -75,7 +77,9 @@ namespace Server.Items base.GetProperties(list); if (Offeree != null) + { list.Add(1062368, Offeree.Name); // Being Offered To ~1_NAME~ + } } public bool IsLandlord(Mobile m) @@ -85,7 +89,9 @@ namespace Server.Items var house = BaseHouse.FindHouseAt(this); if (house != null && house.DecayType != DecayType.Condemned) + { return house.IsOwner(m); + } } return false; @@ -94,25 +100,33 @@ namespace Server.Items public bool IsUsableBy(Mobile from, bool byLandlord, bool byBackpack, bool noOfferee, bool sendMessage) { if (Deleted || !from.CheckAlive(sendMessage)) + { return false; + } if (noOfferee && Offeree != null) { if (sendMessage) - from.SendLocalizedMessage(1062343); // That item is currently in use. + { + @from.SendLocalizedMessage(1062343); // That item is currently in use. + } return false; } if (byBackpack && IsChildOf(from.Backpack)) + { return true; + } if (byLandlord && IsLandlord(from)) { if (from.Map != Map || !from.InRange(this, 5)) { if (sendMessage) - from.SendLocalizedMessage(501853); // Target is too far away. + { + @from.SendLocalizedMessage(501853); // Target is too far away. + } return false; } @@ -191,7 +205,10 @@ namespace Server.Items { base.GetContextMenuEntries(from, list); - if (IsUsableBy(from, true, true, true, false)) list.Add(new ContractOptionEntry(this)); + if (IsUsableBy(from, true, true, true, false)) + { + list.Add(new ContractOptionEntry(this)); + } } public override void Serialize(IGenericWriter writer) @@ -214,9 +231,13 @@ namespace Server.Items var durationID = reader.ReadEncodedInt(); if (durationID < VendorRentalDuration.Instances.Length) + { m_Duration = VendorRentalDuration.Instances[durationID]; + } else + { m_Duration = VendorRentalDuration.Instances[0]; + } Price = reader.ReadInt(); LandlordRenew = reader.ReadBool(); @@ -249,10 +270,14 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (!m_Contract.IsUsableBy(from, false, true, true, true)) + { return; + } if (!(targeted is IPoint3D location)) + { return; + } var pLocation = new Point3D(location); var map = from.Map; @@ -309,7 +334,10 @@ namespace Server.Items { m_Contract.MoveToWorld(pLocation, map); - if (!house.LockDown(from, m_Contract)) from.AddToBackpack(m_Contract); + if (!house.LockDown(from, m_Contract)) + { + @from.AddToBackpack(m_Contract); + } } } } diff --git a/Projects/UOContent/Items/Farming/FarmableCrop.cs b/Projects/UOContent/Items/Farming/FarmableCrop.cs index a4b1b73df..af476a701 100644 --- a/Projects/UOContent/Items/Farming/FarmableCrop.cs +++ b/Projects/UOContent/Items/Farming/FarmableCrop.cs @@ -22,12 +22,18 @@ namespace Server.Items var loc = Location; if (Parent != null || Movable || IsLockedDown || IsSecure || map == null || map == Map.Internal) + { return; + } if (!from.InRange(loc, 2) || !from.InLOS(this)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (!m_Picked) - OnPicked(from, loc, map); + { + OnPicked(@from, loc, map); + } } public virtual void OnPicked(Mobile from, Point3D loc, Map map) diff --git a/Projects/UOContent/Items/Food/Asian.cs b/Projects/UOContent/Items/Food/Asian.cs index 1b621b602..98b35e0c3 100644 --- a/Projects/UOContent/Items/Food/Asian.cs +++ b/Projects/UOContent/Items/Food/Asian.cs @@ -94,7 +94,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyBentoBox()); return true; diff --git a/Projects/UOContent/Items/Food/Bowls.cs b/Projects/UOContent/Items/Food/Bowls.cs index c631c5598..d4b485d51 100644 --- a/Projects/UOContent/Items/Food/Bowls.cs +++ b/Projects/UOContent/Items/Food/Bowls.cs @@ -65,7 +65,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyWoodenBowl()); return true; @@ -103,7 +105,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyWoodenBowl()); return true; @@ -141,7 +145,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyWoodenBowl()); return true; @@ -179,7 +185,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyWoodenBowl()); return true; @@ -217,7 +225,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyPewterBowl()); return true; @@ -255,7 +265,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyPewterBowl()); return true; @@ -293,7 +305,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyPewterBowl()); return true; @@ -331,7 +345,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyPewterBowl()); return true; @@ -369,7 +385,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyPewterBowl()); return true; @@ -457,7 +475,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyWoodenTub()); return true; @@ -495,7 +515,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new EmptyWoodenTub()); return true; diff --git a/Projects/UOContent/Items/Food/CookableFood.cs b/Projects/UOContent/Items/Food/CookableFood.cs index bb220f2a5..0582491b9 100644 --- a/Projects/UOContent/Items/Food/CookableFood.cs +++ b/Projects/UOContent/Items/Food/CookableFood.cs @@ -47,26 +47,52 @@ namespace Server.Items int itemID; if (targeted is Item item) + { itemID = item.ItemID; + } else if (targeted is StaticTarget target) + { itemID = target.ItemID; + } else + { return false; + } if (itemID >= 0xDE3 && itemID <= 0xDE9) + { return true; // Campfire + } + if (itemID >= 0x461 && itemID <= 0x48E) + { return true; // Sandstone oven/fireplace + } + if (itemID >= 0x92B && itemID <= 0x96C) + { return true; // Stone oven/fireplace + } + if (itemID == 0xFAC) + { return true; // Firepit + } + if (itemID >= 0x184A && itemID <= 0x184C) + { return true; // Heating stand (left) + } + if (itemID >= 0x184E && itemID <= 0x1850) + { return true; // Heating stand (right) + } + if (itemID >= 0x398C && itemID <= 0x399F) + { return true; // Fire field + } return false; } @@ -79,7 +105,10 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Item.Deleted) return; + if (m_Item.Deleted) + { + return; + } if (IsHeatSource(targeted)) { @@ -131,7 +160,9 @@ namespace Server.Items var cookedFood = m_CookableFood.Cook(); if (m_From.AddToBackpack(cookedFood)) + { m_From.PlaySound(0x57); + } } else { @@ -202,7 +233,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 1) + { Weight = -1; + } } public override Food Cook() => new LambLeg(); @@ -443,10 +476,14 @@ namespace Server.Items var version = reader.ReadInt(); if (ItemID == 0x1040) + { ItemID = 0x1083; + } if (Hue == 51) + { Hue = 0; + } } public override Food Cook() => new CheesePizza(); @@ -543,7 +580,9 @@ namespace Server.Items Stackable = true; if (Weight == 0.5) + { Weight = 1.0; + } } } diff --git a/Projects/UOContent/Items/Food/Cooking.cs b/Projects/UOContent/Items/Food/Cooking.cs index f23329665..f5a104064 100644 --- a/Projects/UOContent/Items/Food/Cooking.cs +++ b/Projects/UOContent/Items/Food/Cooking.cs @@ -54,10 +54,15 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Item.Deleted) return; + if (m_Item.Deleted) + { + return; + } if (!(targeted is Item targetItem) || targetItem.Deleted) + { return; + } m_Item.Consume(); @@ -123,7 +128,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 51) + { Hue = 150; + } } private class InternalTarget : Target @@ -134,7 +141,10 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Item.Deleted) return; + if (m_Item.Deleted) + { + return; + } m_Item.Consume(); @@ -174,7 +184,9 @@ namespace Server.Items if (m_From.CheckSkill(SkillName.Cooking, 0, 10)) { if (m_From.AddToBackpack(new Muffins())) + { m_From.PlaySound(0x57); + } } else { @@ -230,7 +242,10 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Item.Deleted) return; + if (m_Item.Deleted) + { + return; + } m_Item.Consume(); @@ -387,9 +402,13 @@ namespace Server.Items m_Quantity = Math.Min(20, Math.Max(0, value)); if (m_Quantity == 0) + { Delete(); + } else if (m_Quantity < 20 && (ItemID == 0x1039 || ItemID == 0x1045)) + { ++ItemID; + } } } @@ -424,16 +443,22 @@ namespace Server.Items } if (version < 2 && Weight == 1.0) + { Weight = 5.0; + } } public override void OnDoubleClick(Mobile from) { if (!Movable) + { return; + } if (ItemID == 0x1039 || ItemID == 0x1045) + { ++ItemID; + } } } @@ -479,7 +504,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!Movable) + { return; + } from.BeginTarget(4, false, TargetFlags.None, OnTarget); } @@ -487,14 +514,18 @@ namespace Server.Items public virtual void OnTarget(Mobile from, object obj) { if (obj is AddonComponent addon) + { obj = addon.Addon; + } if (obj is IFlourMill mill) { var needs = mill.MaxFlour - mill.CurFlour; if (needs > Amount) + { needs = Amount; + } mill.CurFlour += needs; Consume(needs); diff --git a/Projects/UOContent/Items/Food/Food.cs b/Projects/UOContent/Items/Food/Food.cs index 93b11fe71..d00c10197 100644 --- a/Projects/UOContent/Items/Food/Food.cs +++ b/Projects/UOContent/Items/Food/Food.cs @@ -30,15 +30,22 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (from.Alive) - list.Add(new EatEntry(from, this)); + { + list.Add(new EatEntry(@from, this)); + } } public override void OnDoubleClick(Mobile from) { if (!Movable) + { return; + } - if (from.InRange(GetWorldLocation(), 1)) Eat(from); + if (from.InRange(GetWorldLocation(), 1)) + { + Eat(@from); + } } public virtual bool Eat(Mobile from) @@ -50,10 +57,14 @@ namespace Server.Items from.PlaySound(Utility.Random(0x3A, 3)); if (from.Body.IsHuman && !from.Mounted) - from.Animate(34, 5, 1, true, false, 0); + { + @from.Animate(34, 5, 1, true, false, 0); + } if (Poison != null) - from.ApplyPoison(Poisoner, Poison); + { + @from.ApplyPoison(Poisoner, Poison); + } Consume(); @@ -76,7 +87,9 @@ namespace Server.Items var iHunger = from.Hunger + fillFactor; if (from.Stam < from.StamMax) - from.Stam += Utility.Random(6, 3) + fillFactor / 5; + { + @from.Stam += Utility.Random(6, 3) + fillFactor / 5; + } if (iHunger >= 20) { @@ -88,13 +101,21 @@ namespace Server.Items from.Hunger = iHunger; if (iHunger < 5) - from.SendLocalizedMessage(500868); // You eat the food, but are still extremely hungry. + { + @from.SendLocalizedMessage(500868); // You eat the food, but are still extremely hungry. + } else if (iHunger < 10) - from.SendLocalizedMessage(500869); // You eat the food, and begin to feel more satiated. + { + @from.SendLocalizedMessage(500869); // You eat the food, and begin to feel more satiated. + } else if (iHunger < 15) - from.SendLocalizedMessage(500870); // After eating the food, you feel much less hungry. + { + @from.SendLocalizedMessage(500870); // After eating the food, you feel much less hungry. + } else - from.SendLocalizedMessage(500871); // You feel quite full after consuming the food. + { + @from.SendLocalizedMessage(500871); // You feel quite full after consuming the food. + } } return true; diff --git a/Projects/UOContent/Items/Food/Fruits.cs b/Projects/UOContent/Items/Food/Fruits.cs index 7299d18f1..7f6c377fb 100644 --- a/Projects/UOContent/Items/Food/Fruits.cs +++ b/Projects/UOContent/Items/Food/Fruits.cs @@ -17,7 +17,9 @@ namespace Server.Items public override bool Eat(Mobile from) { if (!base.Eat(from)) + { return false; + } from.AddToBackpack(new Basket()); return true; @@ -461,10 +463,14 @@ namespace Server.Items if (version < 1) { if (FillFactor == 2) + { FillFactor = 5; + } if (Weight == 2.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Food/Vegetables.cs b/Projects/UOContent/Items/Food/Vegetables.cs index 16a3d5ca1..3c45febff 100644 --- a/Projects/UOContent/Items/Food/Vegetables.cs +++ b/Projects/UOContent/Items/Food/Vegetables.cs @@ -146,10 +146,14 @@ namespace Server.Items if (version < 1) { if (FillFactor == 4) + { FillFactor = 8; + } if (Weight == 5.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Games/BaseBoard.cs b/Projects/UOContent/Items/Games/BaseBoard.cs index 991e7045f..a29c1c4a8 100644 --- a/Projects/UOContent/Items/Games/BaseBoard.cs +++ b/Projects/UOContent/Items/Games/BaseBoard.cs @@ -34,8 +34,12 @@ namespace Server.Items public void Reset() { for (var i = Items.Count - 1; i >= 0; --i) + { if (i < Items.Count) + { Items[i].Delete(); + } + } CreatePieces(); } @@ -60,10 +64,14 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 1) + { Level = (SecureLevel)reader.ReadInt(); + } if (Weight == 1.0) + { Weight = 5.0; + } } public override bool OnDragDrop(Mobile from, Item dropped) => @@ -78,10 +86,16 @@ namespace Server.Items p.Acquire(); if (RootParent == from) - from.Send(p); + { + @from.Send(p); + } else + { foreach (var state in GetClientsInRange(2)) + { state.Send(p); + } + } p.Release(); @@ -96,7 +110,9 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (ValidateDefault(from, this)) - list.Add(new DefaultEntry(from, this)); + { + list.Add(new DefaultEntry(@from, this)); + } SetSecureLevelEntry.AddTo(from, this, list); } @@ -124,7 +140,9 @@ namespace Server.Items public override void OnClick() { if (ValidateDefault(m_From, m_Board)) + { m_Board.Reset(); + } } } } diff --git a/Projects/UOContent/Items/Games/BasePiece.cs b/Projects/UOContent/Items/Games/BasePiece.cs index 59198e09a..6826effcb 100644 --- a/Projects/UOContent/Items/Games/BasePiece.cs +++ b/Projects/UOContent/Items/Games/BasePiece.cs @@ -35,7 +35,9 @@ namespace Server.Items Board = (BaseBoard)reader.ReadItem(); if (Board == null || Parent == null) + { Delete(); + } break; } @@ -45,11 +47,17 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (Board?.Deleted != false) + { Delete(); + } else if (!IsChildOf(Board)) + { Board.DropItem(this); + } else - base.OnSingleClick(from); + { + base.OnSingleClick(@from); + } } public override bool OnDragLift(Mobile from) diff --git a/Projects/UOContent/Items/Games/Dices.cs b/Projects/UOContent/Items/Games/Dices.cs index f4398e90b..e277a8e54 100644 --- a/Projects/UOContent/Items/Games/Dices.cs +++ b/Projects/UOContent/Items/Games/Dices.cs @@ -22,7 +22,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) + { return; + } Roll(from); } diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs index dfcf16343..9f022e998 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs @@ -34,7 +34,10 @@ namespace Server.Engines.Mahjong public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) { if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down) + { return new MahjongPieceDim(position, 40, 20); + } + return new MahjongPieceDim(position, 20, 40); } @@ -43,7 +46,9 @@ namespace Server.Engines.Mahjong var dim = GetDimensions(position, direction); if (!dim.IsValid()) + { return; + } Position = position; Direction = direction; diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongDices.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongDices.cs index 876f30057..fae380cef 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongDices.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongDices.cs @@ -33,10 +33,12 @@ namespace Server.Engines.Mahjong Game.Players.SendGeneralPacket(true, true); if (from != null) + { Game.Players.SendLocalizedMessage( 1062695, - $"{from.Name}\t{First}\t{Second}" + $"{@from.Name}\t{First}\t{Second}" ); // ~1_name~ rolls the dice and gets a ~2_number~ and a ~3_number~! + } } public void Save(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs index 248446fde..1f6e2ce94 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs @@ -51,12 +51,16 @@ namespace Server.Engines.Mahjong set { if (m_ShowScores == value) + { return; + } m_ShowScores = value; if (value) + { Players.SendPlayersPacket(true, true); + } Players.SendGeneralPacket(true, true); @@ -71,12 +75,16 @@ namespace Server.Engines.Mahjong set { if (m_SpectatorVision == value) + { return; + } m_SpectatorVision = value; if (Players.IsInGamePlayer(Players.DealerPosition)) + { Players.Dealer.Send(new MahjongGeneralInfo(this)); + } Players.SendTilesPacket(false, true); @@ -159,9 +167,13 @@ namespace Server.Engines.Mahjong base.GetProperties(list); if (m_SpectatorVision) + { list.Add(1062717); // Spectator Vision Enabled + } else + { list.Add(1062718); // Spectator Vision Disabled + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -171,7 +183,9 @@ namespace Server.Engines.Mahjong Players.CheckPlayers(); if (from.Alive && IsAccessibleTo(from) && Players.GetInGameMobiles(true, false).Count == 0) + { list.Add(new ResetGameEntry(this)); + } SetSecureLevelEntry.AddTo(from, this, list); } @@ -186,12 +200,16 @@ namespace Server.Engines.Mahjong public void ResetGame(Mobile from) { if (DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds(5.0)) + { return; + } m_LastReset = DateTime.UtcNow; if (from != null) - Players.SendLocalizedMessage(1062771, from.Name); // ~1_name~ has reset the game. + { + Players.SendLocalizedMessage(1062771, @from.Name); // ~1_name~ has reset the game. + } Players.SendRelievePacket(true, true); @@ -205,7 +223,9 @@ namespace Server.Engines.Mahjong public void ResetWalls(Mobile from) { if (DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds(5.0)) + { return; + } m_LastReset = DateTime.UtcNow; @@ -214,15 +234,22 @@ namespace Server.Engines.Mahjong Players.SendTilesPacket(true, true); if (from != null) + { Players.SendLocalizedMessage(1062696); // The dealer rebuilds the wall. + } } public int GetStackLevel(MahjongPieceDim dim) { var level = -1; foreach (var tile in Tiles) + { if (tile.StackLevel > level && dim.IsOverlapping(tile.Dimensions)) + { level = tile.StackLevel; + } + } + return level; } @@ -237,7 +264,9 @@ namespace Server.Engines.Mahjong writer.Write(Tiles.Length); for (var i = 0; i < Tiles.Length; i++) + { Tiles[i].Save(writer); + } DealerIndicator.Save(writer); @@ -268,13 +297,17 @@ namespace Server.Engines.Mahjong case 0: { if (version < 1) + { Level = SecureLevel.CoOwners; + } var length = reader.ReadInt(); Tiles = new MahjongTile[length]; for (var i = 0; i < length; i++) + { Tiles[i] = new MahjongTile(this, reader); + } DealerIndicator = new MahjongDealerIndicator(this, reader); @@ -306,7 +339,9 @@ namespace Server.Engines.Mahjong if (from.CheckAlive() && !m_Game.Deleted && m_Game.IsAccessibleTo(from) && m_Game.Players.GetInGameMobiles(true, false).Count == 0) - m_Game.ResetGame(from); + { + m_Game.ResetGame(@from); + } } } } diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongPacketHandlers.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongPacketHandlers.cs index fac66c5b9..ce2cc2725 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongPacketHandlers.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongPacketHandlers.cs @@ -15,7 +15,10 @@ namespace Server.Engines.Mahjong public static OnMahjongPacketReceive GetSubCommandDelegate(int cmd) { - if (cmd >= 0 && cmd < 0x100) return m_SubCommandDelegates[cmd]; + if (cmd >= 0 && cmd < 0x100) + { + return m_SubCommandDelegates[cmd]; + } return null; } @@ -51,9 +54,13 @@ namespace Server.Engines.Mahjong var onReceive = GetSubCommandDelegate(cmd); if (onReceive != null) + { onReceive(game, state, pvSrc); + } else + { pvSrc.Trace(state); + } } private static MahjongPieceDirection GetDirection(int value) @@ -81,7 +88,9 @@ namespace Server.Engines.Mahjong public static void ExitGame(MahjongGame game, NetState state, PacketReader pvSrc) { if (game == null) + { return; + } var from = state.Mobile; @@ -91,7 +100,9 @@ namespace Server.Engines.Mahjong public static void GivePoints(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGamePlayer(state.Mobile) != true) + { return; + } int to = pvSrc.ReadByte(); var amount = pvSrc.ReadInt32(); @@ -102,7 +113,9 @@ namespace Server.Engines.Mahjong public static void RollDice(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGamePlayer(state.Mobile) != true) + { return; + } game.Dices.RollDices(state.Mobile); } @@ -110,7 +123,9 @@ namespace Server.Engines.Mahjong public static void BuildWalls(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } game.ResetWalls(state.Mobile); } @@ -118,7 +133,9 @@ namespace Server.Engines.Mahjong public static void ResetScores(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } game.Players.ResetScores(MahjongGame.BaseScore); } @@ -126,7 +143,9 @@ namespace Server.Engines.Mahjong public static void AssignDealer(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } int position = pvSrc.ReadByte(); @@ -136,12 +155,16 @@ namespace Server.Engines.Mahjong public static void OpenSeat(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } int position = pvSrc.ReadByte(); if (game.Players.GetPlayer(position) == state.Mobile) + { return; + } game.Players.OpenSeat(position); } @@ -149,7 +172,9 @@ namespace Server.Engines.Mahjong public static void ChangeOption(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } pvSrc.ReadInt16(); pvSrc.ReadByte(); @@ -163,7 +188,9 @@ namespace Server.Engines.Mahjong public static void MoveWallBreakIndicator(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } int y = pvSrc.ReadInt16(); int x = pvSrc.ReadInt16(); @@ -174,7 +201,9 @@ namespace Server.Engines.Mahjong public static void TogglePublicHand(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGamePlayer(state.Mobile) != true) + { return; + } pvSrc.ReadInt16(); pvSrc.ReadByte(); @@ -187,12 +216,16 @@ namespace Server.Engines.Mahjong public static void MoveTile(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGamePlayer(state.Mobile) != true) + { return; + } int number = pvSrc.ReadByte(); if (number < 0 || number >= game.Tiles.Length) + { return; + } pvSrc.ReadByte(); // Current direction @@ -218,7 +251,9 @@ namespace Server.Engines.Mahjong public static void MoveDealerIndicator(MahjongGame game, NetState state, PacketReader pvSrc) { if (game?.Players.IsInGameDealer(state.Mobile) != true) + { return; + } var direction = GetDirection(pvSrc.ReadByte()); diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongPieceDim.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongPieceDim.cs index e58b2fe1d..932f941b3 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongPieceDim.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongPieceDim.cs @@ -25,16 +25,24 @@ namespace Server.Engines.Mahjong public int GetHandArea() { if (Position.X + Width > 150 && Position.X < 520 && Position.Y < 35) + { return 0; + } if (Position.X + Width > 635 && Position.Y + Height > 150 && Position.Y < 520) + { return 1; + } if (Position.X + Width > 150 && Position.X < 520 && Position.Y + Height > 635) + { return 2; + } if (Position.X < 35 && Position.Y + Height > 150 && Position.Y < 520) + { return 3; + } return -1; } diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongPlayers.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongPlayers.cs index 40c8ba452..172ffe56c 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongPlayers.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongPlayers.cs @@ -21,7 +21,9 @@ namespace Server.Engines.Mahjong m_Scores = new int[maxPlayers]; for (var i = 0; i < m_Scores.Length; i++) + { m_Scores[i] = baseScore; + } } public MahjongPlayers(MahjongGame game, IGenericReader reader) @@ -56,29 +58,43 @@ namespace Server.Engines.Mahjong public Mobile GetPlayer(int index) { if (index < 0 || index >= m_Players.Length) + { return null; + } + return m_Players[index]; } public int GetPlayerIndex(Mobile mobile) { for (var i = 0; i < m_Players.Length; i++) + { if (m_Players[i] == mobile) + { return i; + } + } + return -1; } public bool IsInGameDealer(Mobile mobile) { if (Dealer != mobile) + { return false; + } + return m_InGame[DealerPosition]; } public bool IsInGamePlayer(int index) { if (index < 0 || index >= m_Players.Length || m_Players[index] == null) + { return false; + } + return m_InGame[index]; } @@ -94,28 +110,38 @@ namespace Server.Engines.Mahjong public int GetScore(int index) { if (index < 0 || index >= m_Scores.Length) + { return 0; + } + return m_Scores[index]; } public bool IsPublic(int index) { if (index < 0 || index >= m_PublicHand.Length) + { return false; + } + return m_PublicHand[index]; } public void SetPublic(int index, bool value) { if (index < 0 || index >= m_PublicHand.Length || m_PublicHand[index] == value) + { return; + } m_PublicHand[index] = value; SendTilesPacket(true, !Game.SpectatorVision); if (IsInGamePlayer(index)) + { m_Players[index].SendLocalizedMessage(value ? 1062775 : 1062776); // Your hand is [not] publicly viewable. + } } public List GetInGameMobiles(bool players, bool spectators) @@ -123,12 +149,20 @@ namespace Server.Engines.Mahjong var list = new List(); if (players) + { for (var i = 0; i < m_Players.Length; i++) + { if (IsInGamePlayer(i)) + { list.Add(m_Players[i]); + } + } + } if (spectators) + { list.AddRange(m_Spectators); + } return list; } @@ -142,7 +176,9 @@ namespace Server.Engines.Mahjong var player = m_Players[i]; if (player == null) + { continue; + } if (player.Deleted) { @@ -201,46 +237,66 @@ namespace Server.Engines.Mahjong } if (removed && !UpdateSpectators()) + { SendPlayersPacket(true, true); + } } private void UpdateDealer(bool message) { if (IsInGamePlayer(DealerPosition)) + { return; + } for (var i = DealerPosition + 1; i < m_Players.Length; i++) + { if (IsInGamePlayer(i)) { DealerPosition = i; if (message) + { SendDealerChangedMessage(); + } return; } + } for (var i = 0; i < DealerPosition; i++) + { if (IsInGamePlayer(i)) { DealerPosition = i; if (message) + { SendDealerChangedMessage(); + } return; } + } } private int GetNextSeat() { for (var i = DealerPosition; i < m_Players.Length; i++) + { if (m_Players[i] == null) + { return i; + } + } for (var i = 0; i < DealerPosition; i++) + { if (m_Players[i] == null) + { return i; + } + } return -1; } @@ -248,7 +304,9 @@ namespace Server.Engines.Mahjong private bool UpdateSpectators() { if (m_Spectators.Count == 0) + { return false; + } var nextSeat = GetNextSeat(); @@ -276,7 +334,9 @@ namespace Server.Engines.Mahjong UpdateDealer(false); if (sendJoinGame) + { player.Send(new MahjongJoinGame(Game)); + } SendPlayersPacket(true, true); @@ -284,14 +344,21 @@ namespace Server.Engines.Mahjong player.Send(new MahjongTilesInfo(Game, player)); if (DealerPosition == index) + { SendLocalizedMessage(1062773, player.Name); // ~1_name~ has entered the game as the dealer. + } else + { SendLocalizedMessage(1062772, player.Name); // ~1_name~ has entered the game as a player. + } } private void AddSpectator(Mobile mobile) { - if (!IsSpectator(mobile)) m_Spectators.Add(mobile); + if (!IsSpectator(mobile)) + { + m_Spectators.Add(mobile); + } mobile.Send(new MahjongJoinGame(Game)); mobile.Send(new MahjongPlayersInfo(Game, mobile)); @@ -312,9 +379,13 @@ namespace Server.Engines.Mahjong var nextSeat = GetNextSeat(); if (nextSeat >= 0) + { AddPlayer(mobile, nextSeat, true); + } else + { AddSpectator(mobile); + } } } @@ -338,7 +409,10 @@ namespace Server.Engines.Mahjong public void ResetScores(int value) { - for (var i = 0; i < m_Scores.Length; i++) m_Scores[i] = value; + for (var i = 0; i < m_Scores.Length; i++) + { + m_Scores[i] = value; + } SendPlayersPacket(true, Game.ShowScores); @@ -351,7 +425,9 @@ namespace Server.Engines.Mahjong var to = GetPlayer(toPosition); if (fromPosition < 0 || to == null || m_Scores[fromPosition] < amount) + { return; + } m_Scores[fromPosition] -= amount; m_Scores[toPosition] += amount; @@ -376,10 +452,14 @@ namespace Server.Engines.Mahjong { var player = GetPlayer(index); if (player == null) + { return; + } if (m_InGame[index]) + { player.Send(new MahjongRelieve(Game)); + } m_Players[index] = null; @@ -388,7 +468,9 @@ namespace Server.Engines.Mahjong UpdateDealer(true); if (!UpdateSpectators()) + { SendPlayersPacket(true, true); + } } public void AssignDealer(int index) @@ -396,14 +478,18 @@ namespace Server.Engines.Mahjong var to = GetPlayer(index); if (to == null || !m_InGame[index]) + { return; + } var oldDealer = DealerPosition; DealerPosition = index; if (IsInGamePlayer(oldDealer)) + { m_Players[oldDealer].Send(new MahjongPlayersInfo(Game, m_Players[oldDealer])); + } to.Send(new MahjongPlayersInfo(Game, to)); @@ -413,7 +499,9 @@ namespace Server.Engines.Mahjong private void SendDealerChangedMessage() { if (Dealer != null) + { SendLocalizedMessage(1062698, Dealer.Name); // ~1_name~ is assigned the dealer. + } } private void SendPlayerExitMessage(Mobile who) @@ -424,7 +512,9 @@ namespace Server.Engines.Mahjong public void SendPlayersPacket(bool players, bool spectators) { foreach (var mobile in GetInGameMobiles(players, spectators)) + { mobile.Send(new MahjongPlayersInfo(Game, mobile)); + } } public void SendGeneralPacket(bool players, bool spectators) @@ -432,14 +522,18 @@ namespace Server.Engines.Mahjong var mobiles = GetInGameMobiles(players, spectators); if (mobiles.Count == 0) + { return; + } var generalInfo = new MahjongGeneralInfo(Game); generalInfo.Acquire(); foreach (var mobile in mobiles) + { mobile.Send(generalInfo); + } generalInfo.Release(); } @@ -447,13 +541,17 @@ namespace Server.Engines.Mahjong public void SendTilesPacket(bool players, bool spectators) { foreach (var mobile in GetInGameMobiles(players, spectators)) + { mobile.Send(new MahjongTilesInfo(Game, mobile)); + } } public void SendTilePacket(MahjongTile tile, bool players, bool spectators) { foreach (var mobile in GetInGameMobiles(players, spectators)) + { mobile.Send(new MahjongTileInfo(tile, mobile)); + } } public void SendRelievePacket(bool players, bool spectators) @@ -461,14 +559,18 @@ namespace Server.Engines.Mahjong var mobiles = GetInGameMobiles(players, spectators); if (mobiles.Count == 0) + { return; + } var relieve = new MahjongRelieve(Game); relieve.Acquire(); foreach (var mobile in mobiles) + { mobile.Send(relieve); + } relieve.Release(); } @@ -476,13 +578,17 @@ namespace Server.Engines.Mahjong public void SendLocalizedMessage(int number) { foreach (var mobile in GetInGameMobiles(true, true)) + { mobile.SendLocalizedMessage(number); + } } public void SendLocalizedMessage(int number, string args) { foreach (var mobile in GetInGameMobiles(true, true)) + { mobile.SendLocalizedMessage(number, args); + } } public void Save(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs index 6099bc317..ddc373d55 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs @@ -52,7 +52,10 @@ namespace Server.Engines.Mahjong public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) { if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down) + { return new MahjongPieceDim(position, 20, 30); + } + return new MahjongPieceDim(position, 30, 20); } @@ -64,7 +67,9 @@ namespace Server.Engines.Mahjong if (!IsMovable || !dim.IsValid() || validHandArea >= 0 && (curHandArea >= 0 && curHandArea != validHandArea || newHandArea >= 0 && newHandArea != validHandArea)) + { return; + } m_Position = position; Direction = direction; diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongWallBreakIndicator.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongWallBreakIndicator.cs index d6df87963..a11839823 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongWallBreakIndicator.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongWallBreakIndicator.cs @@ -30,7 +30,9 @@ namespace Server.Engines.Mahjong var dim = GetDimensions(position); if (!dim.IsValid()) + { return; + } Position = position; diff --git a/Projects/UOContent/Items/Games/Mahjong/Packets.cs b/Projects/UOContent/Items/Games/Mahjong/Packets.cs index 5ddf03e1e..e71ecb304 100644 --- a/Projects/UOContent/Items/Games/Mahjong/Packets.cs +++ b/Projects/UOContent/Items/Games/Mahjong/Packets.cs @@ -42,9 +42,13 @@ namespace Server.Engines.Mahjong Stream.Write((byte)i); if (game.ShowScores || mobile == to) + { Stream.Write(players.GetScore(i)); + } else + { Stream.Write(0); + } Stream.Write((short)0); Stream.Write((byte)0); @@ -137,9 +141,13 @@ namespace Server.Engines.Mahjong if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to || game.SpectatorVision && players.IsSpectator(to)) + { Stream.Write((byte)tile.Value); + } else + { Stream.Write((byte)0); + } } else { @@ -177,9 +185,13 @@ namespace Server.Engines.Mahjong if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to || game.SpectatorVision && players.IsSpectator(to)) + { Stream.Write((byte)tile.Value); + } else + { Stream.Write((byte)0); + } } else { diff --git a/Projects/UOContent/Items/Guilds/GuildDeed.cs b/Projects/UOContent/Items/Guilds/GuildDeed.cs index 28992c601..a28b4d942 100644 --- a/Projects/UOContent/Items/Guilds/GuildDeed.cs +++ b/Projects/UOContent/Items/Guilds/GuildDeed.cs @@ -29,13 +29,17 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 0.0) + { Weight = 1.0; + } } public override void OnDoubleClick(Mobile from) { if (Guild.NewGuildSystem) + { return; + } if (!IsChildOf(from.Backpack)) { @@ -78,7 +82,9 @@ namespace Server.Items public override void OnResponse(Mobile from, string text) { if (m_Deed.Deleted) + { return; + } if (!m_Deed.IsChildOf(from.Backpack)) { @@ -109,7 +115,9 @@ namespace Server.Items m_Deed.Delete(); if (text.Length > 40) + { text = text.Substring(0, 40); + } var guild = new Guild(from, text, "none"); diff --git a/Projects/UOContent/Items/Guilds/GuildTeleporter.cs b/Projects/UOContent/Items/Guilds/GuildTeleporter.cs index 4c0a78f66..e6f7ddb58 100644 --- a/Projects/UOContent/Items/Guilds/GuildTeleporter.cs +++ b/Projects/UOContent/Items/Guilds/GuildTeleporter.cs @@ -51,13 +51,17 @@ namespace Server.Items } if (Weight == 0.0) + { Weight = 1.0; + } } public override void OnDoubleClick(Mobile from) { if (Guild.NewGuildSystem) + { return; + } var stone = m_Stone as Guildstone; diff --git a/Projects/UOContent/Items/Guilds/Guildstone.cs b/Projects/UOContent/Items/Guilds/Guildstone.cs index 1f86178f4..fafa20327 100644 --- a/Projects/UOContent/Items/Guilds/Guildstone.cs +++ b/Projects/UOContent/Items/Guilds/Guildstone.cs @@ -64,7 +64,9 @@ namespace Server.Items public void OnChop(Mobile from) { if (!Guild.NewGuildSystem) + { return; + } var house = BaseHouse.FindHouseAt(this); @@ -79,12 +81,16 @@ namespace Server.Items Delete(); if (contains) + { house.Addons.Remove(this); + } var deed = Deed; if (deed != null) - from.AddToBackpack(deed); + { + @from.AddToBackpack(deed); + } } } @@ -141,16 +147,24 @@ namespace Server.Items } if (Guild.NewGuildSystem && ItemID == 0xED4) + { ItemID = 0xED6; + } if (version <= 2) + { m_BeforeChangeover = true; + } if (Guild.NewGuildSystem && m_BeforeChangeover) + { Timer.DelayCall(AddToHouse); + } if (!Guild.NewGuildSystem && Guild == null) + { Delete(); + } } private void AddToHouse() @@ -174,10 +188,14 @@ namespace Server.Items string abbr; if ((name = Guild.Name) == null || (name = name.Trim()).Length <= 0) + { name = "(unnamed)"; + } if ((abbr = Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0) + { abbr = ""; + } // list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~ list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]"); @@ -197,7 +215,9 @@ namespace Server.Items string name; if ((name = Guild.Name) == null || (name = name.Trim()).Length <= 0) + { name = "(unnamed)"; + } LabelTo(from, name); } @@ -210,13 +230,17 @@ namespace Server.Items public override void OnAfterDelete() { if (!Guild.NewGuildSystem && Guild?.Disbanded == false) + { Guild.Disband(); + } } public override void OnDoubleClick(Mobile from) { if (Guild.NewGuildSystem) + { return; + } if (Guild?.Disbanded != false) { @@ -235,10 +259,14 @@ namespace Server.Items var targetFaction = targetState?.Faction; if (guildFaction != targetFaction || targetState?.IsLeaving == true) + { return; + } if (guildState != null && targetState != null) + { targetState.Leaving = guildState.Leaving; + } Guild.Accepted.Remove(from); Guild.AddMember(from); @@ -365,10 +393,14 @@ namespace Server.Items string abbr; if ((name = Guild.Name) == null || (name = name.Trim()).Length <= 0) + { name = "(unnamed)"; + } if ((abbr = Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0) + { abbr = ""; + } // list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~ list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]"); @@ -404,7 +436,9 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted) { if (!(targeted is IPoint3D p) || Deleted) + { return; + } var loc = new Point3D(p); diff --git a/Projects/UOContent/Items/Jewels/Artifacts/OrnamentOfTheMagician.cs b/Projects/UOContent/Items/Jewels/Artifacts/OrnamentOfTheMagician.cs index 48a400415..623f99815 100644 --- a/Projects/UOContent/Items/Jewels/Artifacts/OrnamentOfTheMagician.cs +++ b/Projects/UOContent/Items/Jewels/Artifacts/OrnamentOfTheMagician.cs @@ -34,7 +34,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 0x12B) + { Hue = 0x554; + } } } } diff --git a/Projects/UOContent/Items/Jewels/Artifacts/RingOfTheVile.cs b/Projects/UOContent/Items/Jewels/Artifacts/RingOfTheVile.cs index bf17145bd..4a361064b 100644 --- a/Projects/UOContent/Items/Jewels/Artifacts/RingOfTheVile.cs +++ b/Projects/UOContent/Items/Jewels/Artifacts/RingOfTheVile.cs @@ -33,7 +33,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 0x4F4) + { Hue = 0x4F7; + } } } } diff --git a/Projects/UOContent/Items/Jewels/BaseJewel.cs b/Projects/UOContent/Items/Jewels/BaseJewel.cs index 21c40d228..a12d6bf2a 100644 --- a/Projects/UOContent/Items/Jewels/BaseJewel.cs +++ b/Projects/UOContent/Items/Jewels/BaseJewel.cs @@ -63,9 +63,13 @@ namespace Server.Items m_HitPoints = value; if (m_HitPoints < 0) + { Delete(); + } else if (m_HitPoints > MaxHitPoints) + { m_HitPoints = MaxHitPoints; + } InvalidateProperties(); } @@ -117,7 +121,9 @@ namespace Server.Items get { if (m_GemType == GemType.None) + { return base.LabelNumber; + } return BaseGemTypeNumber + (int)m_GemType - 1; } @@ -137,30 +143,50 @@ namespace Server.Items var context = craftSystem.GetContext(from); if (context?.DoNotColor == true) + { Hue = 0; + } if (craftItem.Resources.Count > 1) { resourceType = craftItem.Resources[1].ItemType; if (resourceType == typeof(StarSapphire)) + { GemType = GemType.StarSapphire; + } else if (resourceType == typeof(Emerald)) + { GemType = GemType.Emerald; + } else if (resourceType == typeof(Sapphire)) + { GemType = GemType.Sapphire; + } else if (resourceType == typeof(Ruby)) + { GemType = GemType.Ruby; + } else if (resourceType == typeof(Citrine)) + { GemType = GemType.Citrine; + } else if (resourceType == typeof(Amethyst)) + { GemType = GemType.Amethyst; + } else if (resourceType == typeof(Tourmaline)) + { GemType = GemType.Tourmaline; + } else if (resourceType == typeof(Amber)) + { GemType = GemType.Amber; + } else if (resourceType == typeof(Diamond)) + { GemType = GemType.Diamond; + } } return 1; @@ -169,7 +195,9 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseJewel jewel)) + { return; + } jewel.Attributes = new AosAttributes(newItem, Attributes); jewel.Resistances = new AosElementAttributes(newItem, Resistances); @@ -191,13 +219,19 @@ namespace Server.Items var modName = Serial.ToString(); if (strBonus != 0) - from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) - from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) - from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } from.CheckStatTimers(); @@ -229,84 +263,136 @@ namespace Server.Items int prop; if ((prop = ArtifactRarity) > 0) + { list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~ + } if ((prop = Attributes.WeaponDamage) != 0) + { list.Add(1060401, prop.ToString()); // damage increase ~1_val~% + } if ((prop = Attributes.DefendChance) != 0) + { list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% + } if ((prop = Attributes.BonusDex) != 0) + { list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ + } if ((prop = Attributes.EnhancePotions) != 0) + { list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% + } if ((prop = Attributes.CastRecovery) != 0) + { list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ + } if ((prop = Attributes.CastSpeed) != 0) + { list.Add(1060413, prop.ToString()); // faster casting ~1_val~ + } if ((prop = Attributes.AttackChance) != 0) + { list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% + } if ((prop = Attributes.BonusHits) != 0) + { list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ + } if ((prop = Attributes.BonusInt) != 0) + { list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ + } if ((prop = Attributes.LowerManaCost) != 0) + { list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% + } if ((prop = Attributes.LowerRegCost) != 0) + { list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% + } if ((prop = Attributes.Luck) != 0) + { list.Add(1060436, prop.ToString()); // luck ~1_val~ + } if ((prop = Attributes.BonusMana) != 0) + { list.Add(1060439, prop.ToString()); // mana increase ~1_val~ + } if ((prop = Attributes.RegenMana) != 0) + { list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ + } if (Attributes.NightSight != 0) + { list.Add(1060441); // night sight + } if ((prop = Attributes.ReflectPhysical) != 0) + { list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% + } if ((prop = Attributes.RegenStam) != 0) + { list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ + } if ((prop = Attributes.RegenHits) != 0) + { list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ + } if (Attributes.SpellChanneling != 0) + { list.Add(1060482); // spell channeling + } if ((prop = Attributes.SpellDamage) != 0) + { list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% + } if ((prop = Attributes.BonusStam) != 0) + { list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ + } if ((prop = Attributes.BonusStr) != 0) + { list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ + } if ((prop = Attributes.WeaponSpeed) != 0) + { list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% + } if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) + { list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% + } AddResistanceProperties(list); if (m_HitPoints >= 0 && m_MaxHitPoints > 0) + { list.Add(1060639, "{0}\t{1}", m_HitPoints, m_MaxHitPoints); // durability ~1_val~ / ~2_val~ + } } public override void Serialize(IGenericWriter writer) @@ -357,7 +443,9 @@ namespace Server.Items var m = Parent as Mobile; if (Core.AOS && m != null) + { SkillBonuses.AddTo(m); + } var strBonus = Attributes.BonusStr; var dexBonus = Attributes.BonusDex; @@ -368,13 +456,19 @@ namespace Server.Items var modName = Serial.ToString(); if (strBonus != 0) + { m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) + { m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) + { m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } m?.CheckStatTimers(); diff --git a/Projects/UOContent/Items/Lights/BaseEquippableLight.cs b/Projects/UOContent/Items/Lights/BaseEquippableLight.cs index 69014e04e..3894733cd 100644 --- a/Projects/UOContent/Items/Lights/BaseEquippableLight.cs +++ b/Projects/UOContent/Items/Lights/BaseEquippableLight.cs @@ -16,9 +16,13 @@ namespace Server.Items if (holder.EquipItem(this)) { if (this is Candle) + { holder.SendLocalizedMessage(502969); // You put the candle in your left hand. + } else if (this is Torch) + { holder.SendLocalizedMessage(502971); // You put the torch in your left hand. + } base.Ignite(); } @@ -36,7 +40,9 @@ namespace Server.Items public override void OnAdded(IEntity parent) { if (Burning && parent is Container) + { Douse(); + } base.OnAdded(parent); } diff --git a/Projects/UOContent/Items/Lights/BaseLight.cs b/Projects/UOContent/Items/Lights/BaseLight.cs index c14a26f53..a181b1551 100644 --- a/Projects/UOContent/Items/Lights/BaseLight.cs +++ b/Projects/UOContent/Items/Lights/BaseLight.cs @@ -53,7 +53,10 @@ namespace Server.Items { get { - if (m_Duration != TimeSpan.Zero && m_Burning) return m_End - DateTime.UtcNow; + if (m_Duration != TimeSpan.Zero && m_Burning) + { + return m_End - DateTime.UtcNow; + } return m_Duration; } @@ -75,7 +78,9 @@ namespace Server.Items var sound = UnlitSound; if (BurntOut && BurntOutSound != 0) + { sound = BurntOutSound; + } if (sound != 0) { @@ -101,14 +106,22 @@ namespace Server.Items m_Burning = false; if (BurntOut && BurntOutItemID != 0) + { ItemID = BurntOutItemID; + } else + { ItemID = UnlitItemID; + } if (BurntOut) + { m_Duration = TimeSpan.Zero; + } else if (m_Duration != TimeSpan.Zero) + { m_Duration = m_End - DateTime.UtcNow; + } m_Timer?.Stop(); @@ -128,7 +141,9 @@ namespace Server.Items m_Timer?.Stop(); if (delay == TimeSpan.Zero) + { return; + } m_End = DateTime.UtcNow + delay; @@ -139,18 +154,26 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (BurntOut) + { return; + } if (Protected && from.AccessLevel == AccessLevel.Player) + { return; + } if (!from.InRange(GetWorldLocation(), 2)) + { return; + } if (m_Burning) { if (UnlitItemID != 0) + { Douse(); + } } else { @@ -169,7 +192,9 @@ namespace Server.Items writer.Write(Protected); if (m_Burning && m_Duration != TimeSpan.Zero) + { writer.WriteDeltaTime(m_End); + } } public override void Deserialize(IGenericReader reader) @@ -188,7 +213,9 @@ namespace Server.Items Protected = reader.ReadBool(); if (m_Burning && m_Duration != TimeSpan.Zero) + { DoTimer(reader.ReadDeltaTime() - DateTime.UtcNow); + } break; } @@ -208,7 +235,9 @@ namespace Server.Items protected override void OnTick() { if (m_Light?.Deleted == false) + { m_Light.Burn(); + } } } } diff --git a/Projects/UOContent/Items/Lights/Candelabra.cs b/Projects/UOContent/Items/Lights/Candelabra.cs index 4d45c9fae..244bb1c94 100644 --- a/Projects/UOContent/Items/Lights/Candelabra.cs +++ b/Projects/UOContent/Items/Lights/Candelabra.cs @@ -51,7 +51,9 @@ namespace Server.Items base.AddNameProperties(list); if (IsShipwreckedItem) + { list.Add(1041645); // recovered from a shipwreck + } } public override void OnSingleClick(Mobile from) @@ -59,7 +61,9 @@ namespace Server.Items base.OnSingleClick(from); if (IsShipwreckedItem) - LabelTo(from, 1041645); // recovered from a shipwreck + { + LabelTo(@from, 1041645); // recovered from a shipwreck + } } } } diff --git a/Projects/UOContent/Items/Lights/Candle.cs b/Projects/UOContent/Items/Lights/Candle.cs index 24ab792b9..b38bcef4a 100644 --- a/Projects/UOContent/Items/Lights/Candle.cs +++ b/Projects/UOContent/Items/Lights/Candle.cs @@ -8,9 +8,13 @@ namespace Server.Items public Candle() : base(0xA28) { if (Burnout) + { Duration = TimeSpan.FromMinutes(20); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle150; diff --git a/Projects/UOContent/Items/Lights/CandleLarge.cs b/Projects/UOContent/Items/Lights/CandleLarge.cs index 7adbdb4d7..9cf17c014 100644 --- a/Projects/UOContent/Items/Lights/CandleLarge.cs +++ b/Projects/UOContent/Items/Lights/CandleLarge.cs @@ -8,9 +8,13 @@ namespace Server.Items public CandleLarge() : base(0xA26) { if (Burnout) + { Duration = TimeSpan.FromMinutes(25); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle150; diff --git a/Projects/UOContent/Items/Lights/CandleLong.cs b/Projects/UOContent/Items/Lights/CandleLong.cs index 5d905f370..540550be1 100644 --- a/Projects/UOContent/Items/Lights/CandleLong.cs +++ b/Projects/UOContent/Items/Lights/CandleLong.cs @@ -8,9 +8,13 @@ namespace Server.Items public CandleLong() : base(0x1433) { if (Burnout) + { Duration = TimeSpan.FromMinutes(30); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle150; diff --git a/Projects/UOContent/Items/Lights/CandleShort.cs b/Projects/UOContent/Items/Lights/CandleShort.cs index 9d92a54ee..fd0826f5a 100644 --- a/Projects/UOContent/Items/Lights/CandleShort.cs +++ b/Projects/UOContent/Items/Lights/CandleShort.cs @@ -8,9 +8,13 @@ namespace Server.Items public CandleShort() : base(0x142F) { if (Burnout) + { Duration = TimeSpan.FromMinutes(25); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle150; diff --git a/Projects/UOContent/Items/Lights/CandleSkull.cs b/Projects/UOContent/Items/Lights/CandleSkull.cs index d1a66fa90..f82c6fb0f 100644 --- a/Projects/UOContent/Items/Lights/CandleSkull.cs +++ b/Projects/UOContent/Items/Lights/CandleSkull.cs @@ -8,9 +8,13 @@ namespace Server.Items public CandleSkull() : base(0x1853) { if (Burnout) + { Duration = TimeSpan.FromMinutes(25); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle150; @@ -26,7 +30,9 @@ namespace Server.Items get { if (ItemID == 0x1583 || ItemID == 0x1854) + { return 0x1854; + } return 0x1858; } @@ -37,7 +43,9 @@ namespace Server.Items get { if (ItemID == 0x1853 || ItemID == 0x1584) + { return 0x1853; + } return 0x1857; } diff --git a/Projects/UOContent/Items/Lights/HeatingStand.cs b/Projects/UOContent/Items/Lights/HeatingStand.cs index c668affb3..bfc55fcb1 100644 --- a/Projects/UOContent/Items/Lights/HeatingStand.cs +++ b/Projects/UOContent/Items/Lights/HeatingStand.cs @@ -8,9 +8,13 @@ namespace Server.Items public HeatingStand() : base(0x1849) { if (Burnout) + { Duration = TimeSpan.FromMinutes(25); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Empty; @@ -29,9 +33,13 @@ namespace Server.Items base.Ignite(); if (ItemID == LitItemID) + { Light = LightType.Circle150; + } else if (ItemID == UnlitItemID) + { Light = LightType.Empty; + } } public override void Douse() @@ -39,9 +47,13 @@ namespace Server.Items base.Douse(); if (ItemID == LitItemID) + { Light = LightType.Circle150; + } else if (ItemID == UnlitItemID) + { Light = LightType.Empty; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Lights/Lantern.cs b/Projects/UOContent/Items/Lights/Lantern.cs index d42985206..a925cf884 100644 --- a/Projects/UOContent/Items/Lights/Lantern.cs +++ b/Projects/UOContent/Items/Lights/Lantern.cs @@ -8,9 +8,13 @@ namespace Server.Items public Lantern() : base(0xA25) { if (Burnout) + { Duration = TimeSpan.FromMinutes(20); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle300; @@ -26,7 +30,9 @@ namespace Server.Items get { if (ItemID == 0xA15 || ItemID == 0xA17) + { return ItemID; + } return 0xA22; } @@ -37,7 +43,9 @@ namespace Server.Items get { if (ItemID == 0xA18) + { return ItemID; + } return 0xA25; } diff --git a/Projects/UOContent/Items/Lights/RedHangingLantern.cs b/Projects/UOContent/Items/Lights/RedHangingLantern.cs index 54a50f38c..216fbd1be 100644 --- a/Projects/UOContent/Items/Lights/RedHangingLantern.cs +++ b/Projects/UOContent/Items/Lights/RedHangingLantern.cs @@ -24,7 +24,10 @@ namespace Server.Items get { if (ItemID == 0x24C2) + { return 0x24C1; + } + return 0x24C3; } } @@ -34,7 +37,10 @@ namespace Server.Items get { if (ItemID == 0x24C1) + { return 0x24C2; + } + return 0x24C4; } } diff --git a/Projects/UOContent/Items/Lights/Torch.cs b/Projects/UOContent/Items/Lights/Torch.cs index eb37e27bc..8e4eecbf5 100644 --- a/Projects/UOContent/Items/Lights/Torch.cs +++ b/Projects/UOContent/Items/Lights/Torch.cs @@ -9,9 +9,13 @@ namespace Server.Items public Torch() : base(0xF6B) { if (Burnout) + { Duration = TimeSpan.FromMinutes(30); + } else + { Duration = TimeSpan.Zero; + } Burning = false; Light = LightType.Circle300; @@ -33,7 +37,9 @@ namespace Server.Items base.OnAdded(parent); if (parent is Mobile mobile && Burning) + { MeerMage.StopEffect(mobile, true); + } } public override void Ignite() @@ -41,7 +47,9 @@ namespace Server.Items base.Ignite(); if (Parent is Mobile mobile && Burning) + { MeerMage.StopEffect(mobile, true); + } } public override void Serialize(IGenericWriter writer) @@ -56,7 +64,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Lights/WallSconce.cs b/Projects/UOContent/Items/Lights/WallSconce.cs index ae260cadb..6967d91f0 100644 --- a/Projects/UOContent/Items/Lights/WallSconce.cs +++ b/Projects/UOContent/Items/Lights/WallSconce.cs @@ -24,7 +24,10 @@ namespace Server.Items get { if (ItemID == 0x9FB) + { return 0x9FD; + } + return 0xA02; } } @@ -34,7 +37,10 @@ namespace Server.Items get { if (ItemID == 0x9FD) + { return 0x9FB; + } + return 0xA00; } } @@ -42,9 +48,13 @@ namespace Server.Items public void Flip() { if (Light == LightType.WestBig) + { Light = LightType.NorthBig; + } else if (Light == LightType.NorthBig) + { Light = LightType.WestBig; + } ItemID = ItemID switch { diff --git a/Projects/UOContent/Items/Lights/WallTorch.cs b/Projects/UOContent/Items/Lights/WallTorch.cs index 870797101..084ac8ce5 100644 --- a/Projects/UOContent/Items/Lights/WallTorch.cs +++ b/Projects/UOContent/Items/Lights/WallTorch.cs @@ -24,7 +24,10 @@ namespace Server.Items get { if (ItemID == 0xA05) + { return 0xA07; + } + return 0xA0C; } } @@ -34,7 +37,10 @@ namespace Server.Items get { if (ItemID == 0xA07) + { return 0xA05; + } + return 0xA0A; } } @@ -42,9 +48,13 @@ namespace Server.Items public void Flip() { if (Light == LightType.WestBig) + { Light = LightType.NorthBig; + } else if (Light == LightType.NorthBig) + { Light = LightType.WestBig; + } ItemID = ItemID switch { diff --git a/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs b/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs index fa3919abe..ee21e7458 100644 --- a/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs +++ b/Projects/UOContent/Items/Lights/WhiteHangingLantern.cs @@ -24,7 +24,10 @@ namespace Server.Items get { if (ItemID == 0x24C6) + { return 0x24C5; + } + return 0x24C7; } } @@ -34,7 +37,10 @@ namespace Server.Items get { if (ItemID == 0x24C5) + { return 0x24C6; + } + return 0x24C8; } } diff --git a/Projects/UOContent/Items/Maps/CityMap.cs b/Projects/UOContent/Items/Maps/CityMap.cs index 16031a02f..f5c34b81b 100644 --- a/Projects/UOContent/Items/Maps/CityMap.cs +++ b/Projects/UOContent/Items/Maps/CityMap.cs @@ -20,14 +20,20 @@ namespace Server.Items var dist = 64 + (int)(skillValue * 4); if (dist < 200) + { dist = 200; + } var size = 32 + (int)(skillValue * 2); if (size < 200) + { size = 200; + } else if (size > 400) + { size = 400; + } SetDisplay(from.X - dist, from.Y - dist, from.X + dist, from.Y + dist, size, size); } diff --git a/Projects/UOContent/Items/Maps/IndecipherableMap.cs b/Projects/UOContent/Items/Maps/IndecipherableMap.cs index b6332e7ca..2eae61a5a 100644 --- a/Projects/UOContent/Items/Maps/IndecipherableMap.cs +++ b/Projects/UOContent/Items/Maps/IndecipherableMap.cs @@ -6,9 +6,13 @@ namespace Server.Items public IndecipherableMap() { if (Utility.RandomDouble() < 0.2) + { Hue = 0x965; + } else + { Hue = 0x961; + } } public IndecipherableMap(Serial serial) : base(serial) diff --git a/Projects/UOContent/Items/Maps/MapItem.cs b/Projects/UOContent/Items/Maps/MapItem.cs index b90375bb1..827dddc86 100644 --- a/Projects/UOContent/Items/Maps/MapItem.cs +++ b/Projects/UOContent/Items/Maps/MapItem.cs @@ -61,16 +61,24 @@ namespace Server.Items Height = h; if (x1 < 0) + { x1 = 0; + } if (y1 < 0) + { y1 = 0; + } if (x2 >= 5120) + { x2 = 5119; + } if (y2 >= 4096) + { y2 = 4095; + } Bounds = new Rectangle2D(x1, y1, x2 - x1, y2 - y1); } @@ -78,9 +86,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 2)) - DisplayTo(from); + { + DisplayTo(@from); + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } public virtual void DisplayTo(Mobile from) @@ -105,7 +117,9 @@ namespace Server.Items from.Send(new MapDisplay(this)); for (var i = 0; i < Pins.Count; ++i) - from.Send(new MapAddPin(this, Pins[i])); + { + @from.Send(new MapAddPin(this, Pins[i])); + } from.Send(new MapSetEditable(this, ValidateEdit(from))); } @@ -113,9 +127,14 @@ namespace Server.Items public virtual void OnAddPin(Mobile from, int x, int y) { if (!ValidateEdit(from)) + { return; + } + if (Pins.Count >= MaxUserPins) + { return; + } Validate(ref x, ref y); AddPin(x, y); @@ -124,7 +143,9 @@ namespace Server.Items public virtual void OnRemovePin(Mobile from, int number) { if (!ValidateEdit(from)) + { return; + } RemovePin(number); } @@ -132,7 +153,9 @@ namespace Server.Items public virtual void OnChangePin(Mobile from, int number, int x, int y) { if (!ValidateEdit(from)) + { return; + } Validate(ref x, ref y); ChangePin(number, x, y); @@ -141,9 +164,14 @@ namespace Server.Items public virtual void OnInsertPin(Mobile from, int number, int x, int y) { if (!ValidateEdit(from)) + { return; + } + if (Pins.Count >= MaxUserPins) + { return; + } Validate(ref x, ref y); InsertPin(number, x, y); @@ -152,7 +180,9 @@ namespace Server.Items public virtual void OnClearPins(Mobile from) { if (!ValidateEdit(from)) + { return; + } ClearPins(); } @@ -160,7 +190,9 @@ namespace Server.Items public virtual void OnToggleEditable(Mobile from) { if (Validate(from)) + { m_Editable = !m_Editable; + } from.Send(new MapSetEditable(this, Validate(from) && m_Editable)); } @@ -176,11 +208,19 @@ namespace Server.Items public virtual bool Validate(Mobile from) { if (!from.CanSee(this) || from.Map != Map || !from.Alive || InSecureTrade) + { return false; + } + if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } + if (!Movable || Protected || !from.InRange(GetWorldLocation(), 2)) + { return false; + } return !(RootParent is Mobile && RootParent != from); } @@ -211,21 +251,29 @@ namespace Server.Items public virtual void RemovePin(int index) { if (index > 0 && index < Pins.Count) + { Pins.RemoveAt(index); + } } public virtual void InsertPin(int index, int x, int y) { if (index < 0 || index >= Pins.Count) + { Pins.Add(new Point2D(x, y)); + } else + { Pins.Insert(index, new Point2D(x, y)); + } } public virtual void ChangePin(int index, int x, int y) { if (index >= 0 && index < Pins.Count) + { Pins[index] = new Point2D(x, y); + } } public virtual void ClearPins() @@ -248,7 +296,9 @@ namespace Server.Items writer.Write(Pins.Count); for (var i = 0; i < Pins.Count; ++i) + { writer.Write(Pins[i]); + } } public override void Deserialize(IGenericReader reader) @@ -270,7 +320,9 @@ namespace Server.Items var count = reader.ReadInt(); for (var i = 0; i < count; i++) + { Pins.Add(reader.ReadPoint2D()); + } break; } @@ -287,7 +339,9 @@ namespace Server.Items var from = state.Mobile; if (!(World.FindItem(pvSrc.ReadUInt32()) is MapItem map)) + { return; + } int command = pvSrc.ReadByte(); int number = pvSrc.ReadByte(); diff --git a/Projects/UOContent/Items/Maps/PresetMap.cs b/Projects/UOContent/Items/Maps/PresetMap.cs index 54128d472..e5bc63fa9 100644 --- a/Projects/UOContent/Items/Maps/PresetMap.cs +++ b/Projects/UOContent/Items/Maps/PresetMap.cs @@ -10,7 +10,9 @@ namespace Server.Items var v = (int)type; if (v >= 0 && v < PresetMapEntry.Table.Length) + { InitEntry(PresetMapEntry.Table[v]); + } } public PresetMap(PresetMapEntry entry) diff --git a/Projects/UOContent/Items/Maps/SeaChart.cs b/Projects/UOContent/Items/Maps/SeaChart.cs index a3465d6b4..3be85b596 100644 --- a/Projects/UOContent/Items/Maps/SeaChart.cs +++ b/Projects/UOContent/Items/Maps/SeaChart.cs @@ -20,14 +20,20 @@ namespace Server.Items var dist = 64 + (int)(skillValue * 10); if (dist < 200) + { dist = 200; + } var size = 24 + (int)(skillValue * 3.3); if (size < 200) + { size = 200; + } else if (size > 400) + { size = 400; + } SetDisplay(from.X - dist, from.Y - dist, from.X + dist, from.Y + dist, size, size); } diff --git a/Projects/UOContent/Items/Maps/TreasureMap.cs b/Projects/UOContent/Items/Maps/TreasureMap.cs index d348eac91..94e4316c9 100644 --- a/Projects/UOContent/Items/Maps/TreasureMap.cs +++ b/Projects/UOContent/Items/Maps/TreasureMap.cs @@ -42,9 +42,13 @@ namespace Server.Items m_Map = map; if (level == 0) + { ChestLocation = GetRandomHavenLocation(); + } else + { ChestLocation = GetRandomLocation(); + } Width = 300; Height = 300; @@ -56,19 +60,27 @@ namespace Server.Items var y1 = ChestLocation.Y - Utility.RandomMinMax(height / 4, height / 4 * 3); if (x1 < 0) + { x1 = 0; + } if (y1 < 0) + { y1 = 0; + } var x2 = x1 + width; var y2 = y1 + height; if (x2 >= 5120) + { x2 = 5119; + } if (y2 >= 4096) + { y2 = 4095; + } x1 = x2 - width; y1 = y2 - height; @@ -148,12 +160,18 @@ namespace Server.Items if (m_Decoder != null) { if (m_Level == 6) + { return 1063453; + } + return 1041516 + m_Level; } if (m_Level == 6) + { return 1063452; + } + return 1041510 + m_Level; } } @@ -161,7 +179,9 @@ namespace Server.Items public static Point2D GetRandomLocation() { if (m_Locations == null) + { LoadLocations(); + } return m_Locations?.RandomElement() ?? Point2D.Zero; } @@ -169,7 +189,9 @@ namespace Server.Items public static Point2D GetRandomHavenLocation() { if (m_HavenLocations == null) + { LoadLocations(); + } return m_HavenLocations?.RandomElement() ?? Point2D.Zero; } @@ -187,6 +209,7 @@ namespace Server.Items string line; while ((line = ip.ReadLine()) != null) + { try { var split = line.Split(' '); @@ -197,12 +220,15 @@ namespace Server.Items list.Add(loc); if (IsInHavenIsland(loc)) + { havenList.Add(loc); + } } catch { // ignored } + } } m_Locations = list.ToArray(); @@ -244,7 +270,9 @@ namespace Server.Items public static BaseCreature Spawn(int level, Point3D p, Map map, Mobile target, bool guardian) { if (map == null) + { return null; + } var c = Spawn(level, p, guardian); @@ -281,7 +309,9 @@ namespace Server.Items } if (target != null) + { c.Combatant = target; + } return c; } @@ -340,18 +370,26 @@ namespace Server.Items } if (!m_Completed && m_Decoder == null) - Decode(from); + { + Decode(@from); + } else - DisplayTo(from); + { + DisplayTo(@from); + } } private bool CheckYoung(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (from is PlayerMobile mobile && mobile.Young) + { return true; + } if (from == Decoder) { @@ -382,7 +420,9 @@ namespace Server.Items public void Decode(Mobile from) { if (m_Completed || m_Decoder != null) + { return; + } if (m_Level == 0) { @@ -397,7 +437,9 @@ namespace Server.Items var minSkill = GetMinSkillLevel(); if (from.Skills.Cartography.Value < minSkill) - from.SendLocalizedMessage(503013); // The map is too difficult to attempt to decode. + { + @from.SendLocalizedMessage(503013); // The map is too difficult to attempt to decode. + } var maxSkill = minSkill + 60.0; @@ -412,7 +454,9 @@ namespace Server.Items Decoder = from; if (Core.AOS) + { LootType = LootType.Blessed; + } DisplayTo(from); } @@ -474,7 +518,9 @@ namespace Server.Items list.Add(m_Map == Map.Felucca ? 1041502 : 1041503); // for somewhere in Felucca : for somewhere in Trammel if (m_Completed) + { list.Add(1041507, m_CompletedBy == null ? "someone" : m_CompletedBy.Name); // completed by ~1_val~ + } } public override void OnSingleClick(Mobile from) @@ -499,16 +545,24 @@ namespace Server.Items else if (m_Decoder != null) { if (m_Level == 6) - LabelTo(from, 1063453); + { + LabelTo(@from, 1063453); + } else - LabelTo(from, 1041516 + m_Level); + { + LabelTo(@from, 1041516 + m_Level); + } } else { if (m_Level == 6) - LabelTo(from, 1041522, $"#{1063452}\t \t#{(m_Map == Map.Felucca ? 1041502 : 1041503)}"); + { + LabelTo(@from, 1041522, $"#{1063452}\t \t#{(m_Map == Map.Felucca ? 1041502 : 1041503)}"); + } else - LabelTo(from, 1041522, $"#{1041510 + m_Level}\t \t#{(m_Map == Map.Felucca ? 1041502 : 1041503)}"); + { + LabelTo(@from, 1041522, $"#{1041510 + m_Level}\t \t#{(m_Map == Map.Felucca ? 1041502 : 1041503)}"); + } } } @@ -550,14 +604,18 @@ namespace Server.Items ChestLocation = reader.ReadPoint2D(); if (version == 0 && m_Completed) + { m_CompletedBy = m_Decoder; + } break; } } if (Core.AOS && m_Decoder != null && LootType == LootType.Regular) + { LootType = LootType.Blessed; + } } private class DigTarget : Target @@ -569,7 +627,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Map.Deleted) + { return; + } var map = m_Map.m_Map; @@ -611,13 +671,21 @@ namespace Server.Items var skillValue = from.Skills.Mining.Value; if (skillValue >= 100.0) + { maxRange = 4; + } else if (skillValue >= 81.0) + { maxRange = 3; + } else if (skillValue >= 51.0) + { maxRange = 2; + } else + { maxRange = 1; + } var loc = m_Map.ChestLocation; int x = loc.X, y = loc.Y; @@ -637,21 +705,31 @@ namespace Server.Items var z = map.GetAverageZ(x, y); if (!map.CanFit(x, y, z, 16, true)) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 503021 ); // You have found the treasure chest but something is keeping it from being dug up. + } else if (from.BeginAction()) - new DigTimer(from, m_Map, new Point3D(x, y, z), map).Start(); + { + new DigTimer(@from, m_Map, new Point3D(x, y, z), map).Start(); + } else - from.SendLocalizedMessage(503020); // You are already digging treasure. + { + @from.SendLocalizedMessage(503020); // You are already digging treasure. + } } } else if (m_Map.Level > 0) { if (Utility.InRange(targ3D, chest3D0, 8)) // We're close, but not quite - from.SendLocalizedMessage(503032); // You dig and dig but no treasure seems to be here. + { + @from.SendLocalizedMessage(503032); // You dig and dig but no treasure seems to be here. + } else - from.SendLocalizedMessage(503035); // You dig and dig but fail to find any treasure. + { + @from.SendLocalizedMessage(503035); // You dig and dig but fail to find any treasure. + } } else { @@ -756,9 +834,13 @@ namespace Server.Items var height = 16; if (z > m_Location.Z) + { height -= z - m_Location.Z; + } else + { z = m_Location.Z; + } if (!m_Map.CanFit(m_Location.X, m_Location.Y, z, height, true, true, false)) { @@ -828,13 +910,17 @@ namespace Server.Items var bc = Spawn(m_TreasureMap.Level, m_Chest.Location, m_Chest.Map, null, true); if (bc != null) + { m_Chest.Guardians.Add(bc); + } } } else { if (m_From.Body.IsHuman && !m_From.Mounted) + { m_From.Animate(11, 5, 1, true, false, 0); + } new SoundTimer(m_From, 0x125 + m_Count % 2).Start(); } @@ -869,7 +955,9 @@ namespace Server.Items public override void OnClick() { if (!m_Map.Deleted) + { m_Map.Decode(Owner.From); + } } } @@ -882,7 +970,9 @@ namespace Server.Items public override void OnClick() { if (!m_Map.Deleted) + { m_Map.DisplayTo(Owner.From); + } } } @@ -895,20 +985,28 @@ namespace Server.Items m_Map = map; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_Map.Deleted) + { return; + } var from = Owner.From; if (HasDiggingTool(from)) - m_Map.OnBeginDig(from); + { + m_Map.OnBeginDig(@from); + } else - from.SendMessage("You must have a digging tool to dig for treasure."); + { + @from.SendMessage("You must have a digging tool to dig for treasure."); + } } } } diff --git a/Projects/UOContent/Items/Maps/WorldMap.cs b/Projects/UOContent/Items/Maps/WorldMap.cs index 0eff29b64..455ca7822 100644 --- a/Projects/UOContent/Items/Maps/WorldMap.cs +++ b/Projects/UOContent/Items/Maps/WorldMap.cs @@ -23,9 +23,13 @@ namespace Server.Items var size = 25 + (int)(skillValue * 6.6); if (size < 200) + { size = 200; + } else if (size > 400) + { size = 400; + } SetDisplay(1344 - x20, 1600 - x20, 1472 + x20, 1728 + x20, size, size); } diff --git a/Projects/UOContent/Items/Minor Artifacts/CaptainQuacklebushsCutlass.cs b/Projects/UOContent/Items/Minor Artifacts/CaptainQuacklebushsCutlass.cs index d1179d14f..beb139858 100644 --- a/Projects/UOContent/Items/Minor Artifacts/CaptainQuacklebushsCutlass.cs +++ b/Projects/UOContent/Items/Minor Artifacts/CaptainQuacklebushsCutlass.cs @@ -36,7 +36,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Attributes.AttackChance == 50) + { Attributes.AttackChance = 10; + } } } } diff --git a/Projects/UOContent/Items/Minor Artifacts/GhostShipAnchor.cs b/Projects/UOContent/Items/Minor Artifacts/GhostShipAnchor.cs index b912778d8..19ce5f3ba 100644 --- a/Projects/UOContent/Items/Minor Artifacts/GhostShipAnchor.cs +++ b/Projects/UOContent/Items/Minor Artifacts/GhostShipAnchor.cs @@ -25,7 +25,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ItemID == 0x1F47) + { ItemID = 0x14F7; + } } } } diff --git a/Projects/UOContent/Items/Minor Artifacts/ML/BloodwoodSpirit.cs b/Projects/UOContent/Items/Minor Artifacts/ML/BloodwoodSpirit.cs index 2c677446d..dc2d1d2cc 100644 --- a/Projects/UOContent/Items/Minor Artifacts/ML/BloodwoodSpirit.cs +++ b/Projects/UOContent/Items/Minor Artifacts/ML/BloodwoodSpirit.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Protection?.IsEmpty != false) + { Protection = GetRandomProtection(false); + } } } } diff --git a/Projects/UOContent/Items/Minor Artifacts/ML/TotemOfVoid.cs b/Projects/UOContent/Items/Minor Artifacts/ML/TotemOfVoid.cs index bf972d20f..2fbf75f39 100644 --- a/Projects/UOContent/Items/Minor Artifacts/ML/TotemOfVoid.cs +++ b/Projects/UOContent/Items/Minor Artifacts/ML/TotemOfVoid.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Protection?.IsEmpty != false) + { Protection = GetRandomProtection(false); + } } } } diff --git a/Projects/UOContent/Items/Minor Artifacts/PolarBearMask.cs b/Projects/UOContent/Items/Minor Artifacts/PolarBearMask.cs index a52118574..351df2025 100644 --- a/Projects/UOContent/Items/Minor Artifacts/PolarBearMask.cs +++ b/Projects/UOContent/Items/Minor Artifacts/PolarBearMask.cs @@ -45,7 +45,9 @@ namespace Server.Items } if (Attributes.NightSight == 0) + { Attributes.NightSight = 1; + } } } } diff --git a/Projects/UOContent/Items/Misc/AcidSlime.cs b/Projects/UOContent/Items/Misc/AcidSlime.cs index 363ac49e3..c40f5836f 100644 --- a/Projects/UOContent/Items/Misc/AcidSlime.cs +++ b/Projects/UOContent/Items/Misc/AcidSlime.cs @@ -62,11 +62,17 @@ namespace Server.Items var toDamage = new List(); foreach (var m in GetMobilesInRange(0)) + { if (m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned)) + { toDamage.Add(m); + } + } for (var i = 0; i < toDamage.Count; i++) + { Damage(toDamage[i]); + } } } @@ -80,9 +86,13 @@ namespace Server.Items { var damage = Utility.RandomMinMax(m_MinDamage, m_MaxDamage); if (Core.AOS) + { AOS.Damage(m, damage, 0, 0, 0, 100, 0); + } else + { m.Damage(damage); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Misc/ArcaneGem.cs b/Projects/UOContent/Items/Misc/ArcaneGem.cs index 0f1769cb0..eb179aa15 100644 --- a/Projects/UOContent/Items/Misc/ArcaneGem.cs +++ b/Projects/UOContent/Items/Misc/ArcaneGem.cs @@ -37,9 +37,14 @@ namespace Server.Items var v = (int)(m.Skills.Tailoring.Value / 5); if (v < 16) + { return 16; + } + if (v > 24) + { return 24; + } return v; } @@ -91,17 +96,28 @@ namespace Server.Items else { if (eq.CurArcaneCharges <= 0) + { item.Hue = DefaultArcaneHue; + } if (eq.CurArcaneCharges + charges > eq.MaxArcaneCharges) + { eq.CurArcaneCharges = eq.MaxArcaneCharges; + } else + { eq.CurArcaneCharges += charges; + } from.SendMessage("You recharge the item."); if (Amount <= 1) + { Delete(); - else Amount--; + } + else + { + Amount--; + } } } else if (from.Skills.Tailoring.Value >= 80.0) @@ -138,8 +154,13 @@ namespace Server.Items from.SendMessage("You enhance the item with your gem."); if (Amount <= 1) + { Delete(); - else Amount--; + } + else + { + Amount--; + } } else { @@ -169,11 +190,15 @@ namespace Server.Items var obj = items[i]; if (obj is IArcaneEquip eq && eq.IsArcane) + { avail += eq.CurArcaneCharges; + } } if (avail < amount) + { return false; + } for (var i = 0; i < items.Count; ++i) { diff --git a/Projects/UOContent/Items/Misc/BankCheck.cs b/Projects/UOContent/Items/Misc/BankCheck.cs index 7ad316356..32c9535a1 100644 --- a/Projects/UOContent/Items/Misc/BankCheck.cs +++ b/Projects/UOContent/Items/Misc/BankCheck.cs @@ -76,9 +76,13 @@ namespace Server.Items string worth; if (Core.ML) + { worth = m_Worth.ToString("N0", CultureInfo.GetCultureInfo("en-US")); + } else + { worth = m_Worth.ToString(); + } list.Add(1060738, worth); // value: ~1_val~ } @@ -87,7 +91,10 @@ namespace Server.Items { base.OnAdded(parent); - if (!AccountGold.Enabled) return; + if (!AccountGold.Enabled) + { + return; + } Mobile owner = null; SecureTradeInfo tradeInfo = null; @@ -95,7 +102,9 @@ namespace Server.Items var root = parent as Container; while (root?.Parent is Container container) + { root = container; + } parent = root ?? parent; @@ -117,7 +126,10 @@ namespace Server.Items owner = box.Owner; } - if (owner?.Account?.DepositGold(Worth) != true) return; + if (owner?.Account?.DepositGold(Worth) != true) + { + return; + } if (tradeInfo != null) { @@ -234,14 +246,20 @@ namespace Server.Items { QuestObjective obj = qs.FindObjective(); - if (obj?.Completed == false) obj.Complete(); + if (obj?.Completed == false) + { + obj.Complete(); + } } if (qs is UzeraanTurmoilQuest) { var obj = qs.FindObjective(typeof(Engines.Quests.Haven.CashBankCheckObjective)); - if (obj?.Completed == false) obj.Complete(); + if (obj?.Completed == false) + { + obj.Complete(); + } } } } diff --git a/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesFermentedWine.cs b/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesFermentedWine.cs index 0bb4ed972..8ba41b13e 100644 --- a/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesFermentedWine.cs +++ b/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesFermentedWine.cs @@ -19,7 +19,9 @@ namespace Server.Items public override void Drink(Mobile from) { if (MondainsLegacy.CheckML(from)) - base.Drink(from); + { + base.Drink(@from); + } } public override void GetProperties(ObjectPropertyList list) diff --git a/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesHairDye.cs b/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesHairDye.cs index f1c04b797..f2e406b4c 100644 --- a/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesHairDye.cs +++ b/Projects/UOContent/Items/Misc/Blighted Grove/MelisandesHairDye.cs @@ -18,7 +18,9 @@ namespace Server.Items if (IsChildOf(from.Backpack)) { if (MondainsLegacy.CheckML(from)) - from.SendGump(new ConfirmGump(this)); + { + @from.SendGump(new ConfirmGump(this)); + } } else { diff --git a/Projects/UOContent/Items/Misc/Blocker.cs b/Projects/UOContent/Items/Misc/Blocker.cs index 5f95fbe33..828ec12e7 100644 --- a/Projects/UOContent/Items/Misc/Blocker.cs +++ b/Projects/UOContent/Items/Misc/Blocker.cs @@ -18,7 +18,9 @@ namespace Server.Items var mob = state.Mobile; if (mob?.AccessLevel >= AccessLevel.GameMaster) + { return new GMItemPacket(this); + } return base.GetWorldPacketFor(state); } @@ -59,43 +61,61 @@ namespace Server.Items var direction = (int)item.Direction; if (amount != 0) + { serial |= 0x80000000; + } else + { serial &= 0x7FFFFFFF; + } Stream.Write(serial); Stream.Write((short)(itemID & 0x7FFF)); if (amount != 0) + { Stream.Write((short)amount); + } x &= 0x7FFF; if (direction != 0) + { x |= 0x8000; + } Stream.Write((short)x); y &= 0x3FFF; if (hue != 0) + { y |= 0x8000; + } if (flags != 0) + { y |= 0x4000; + } Stream.Write((short)y); if (direction != 0) + { Stream.Write((byte)direction); + } Stream.Write((sbyte)loc.Z); if (hue != 0) + { Stream.Write((ushort)hue); + } if (flags != 0) + { Stream.Write((byte)flags); + } } } } diff --git a/Projects/UOContent/Items/Misc/Bola.cs b/Projects/UOContent/Items/Misc/Bola.cs index 37b108b31..75c35316b 100644 --- a/Projects/UOContent/Items/Misc/Bola.cs +++ b/Projects/UOContent/Items/Misc/Bola.cs @@ -64,30 +64,43 @@ namespace Server.Items private static void FinishThrow(Mobile from, Mobile to) { if (Core.AOS) + { new Bola().MoveToWorld(to.Location, to.Map); + } if (to is ChaosDragoon || to is ChaosDragoonElite) - from.SendLocalizedMessage(1042047); // You fail to knock the rider from its mount. + { + @from.SendLocalizedMessage(1042047); // You fail to knock the rider from its mount. + } var mt = to.Mount; if (mt != null && !(to is ChaosDragoon || to is ChaosDragoonElite)) + { mt.Rider = null; + } if (to is PlayerMobile mobile) { if (AnimalForm.UnderTransformation(mobile)) - mobile.SendLocalizedMessage(1114066, from.Name); // ~1_NAME~ knocked you out of animal form! - else if (mobile.Mounted) mobile.SendLocalizedMessage(1040023); // You have been knocked off of your mount! + { + mobile.SendLocalizedMessage(1114066, @from.Name); // ~1_NAME~ knocked you out of animal form! + } + else if (mobile.Mounted) + { + mobile.SendLocalizedMessage(1040023); // You have been knocked off of your mount! + } mobile.SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds(Core.ML ? 10 : 3), true); } if (Core.AOS) /* only failsafe, attacker should already be dismounted */ - (from as PlayerMobile)?.SetMountBlock( + { + (@from as PlayerMobile)?.SetMountBlock( BlockMountType.BolaRecovery, TimeSpan.FromSeconds(Core.ML ? 10 : 3), true ); + } to.Damage(1); @@ -159,7 +172,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object obj) { if (m_Bola.Deleted) + { return; + } if (obj is Mobile to) { diff --git a/Projects/UOContent/Items/Misc/BulletinBoards.cs b/Projects/UOContent/Items/Misc/BulletinBoards.cs index 68eb99b37..f7a005808 100644 --- a/Projects/UOContent/Items/Misc/BulletinBoards.cs +++ b/Projects/UOContent/Items/Misc/BulletinBoards.cs @@ -65,9 +65,15 @@ namespace Server.Items var minutes = totalSeconds / 60; if (minutes != 0 && seconds != 0) + { return $"{minutes} minute{(minutes == 1 ? "" : "s")} and {seconds} second{(seconds == 1 ? "" : "s")}"; + } + if (minutes != 0) + { return $"{minutes} minute{(minutes == 1 ? "" : "s")}"; + } + return $"{seconds} second{(seconds == 1 ? "" : "s")}"; } @@ -78,10 +84,14 @@ namespace Server.Items for (var i = items.Count - 1; i >= 0; --i) { if (i >= items.Count) + { continue; + } if (!(items[i] is BulletinMessage msg)) + { continue; + } if (msg.Thread == null && CheckTime(msg.LastPostTime, ThreadDeletionTime)) { @@ -99,10 +109,14 @@ namespace Server.Items for (var i = items.Count - 1; i >= 0; --i) { if (i >= items.Count) + { continue; + } if (!(items[i] is BulletinMessage check)) + { continue; + } if (check.Thread == msg) { @@ -112,7 +126,9 @@ namespace Server.Items } for (var i = 0; i < found.Count; ++i) + { RecurseDelete((BulletinMessage)found[i]); + } } public virtual bool GetLastPostTime(Mobile poster, bool onlyCheckRoot, ref DateTime lastPostTime) @@ -123,10 +139,14 @@ namespace Server.Items for (var i = 0; i < items.Count; ++i) { if (!(items[i] is BulletinMessage msg) || msg.Poster != poster) + { continue; + } if (onlyCheckRoot && msg.Thread != null) + { continue; + } if (msg.Time > lastPostTime) { @@ -148,9 +168,13 @@ namespace Server.Items state.Send(new BBDisplayBoard(this)); if (state.ContainerGridLines) - state.Send(new ContainerContent6017(from, this)); + { + state.Send(new ContainerContent6017(@from, this)); + } else - state.Send(new ContainerContent(from, this)); + { + state.Send(new ContainerContent(@from, this)); + } } else { @@ -161,7 +185,9 @@ namespace Server.Items public virtual bool CheckRange(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } return from.Map == Map && from.InRange(GetWorldLocation(), 2); } @@ -169,7 +195,9 @@ namespace Server.Items public void PostMessage(Mobile from, BulletinMessage thread, string subject, string[] lines) { if (thread != null) + { thread.LastPostTime = DateTime.UtcNow; + } AddItem(new BulletinMessage(from, thread, subject, lines)); } @@ -211,7 +239,9 @@ namespace Server.Items int packetID = pvSrc.ReadByte(); if (!(World.FindItem(pvSrc.ReadUInt32()) is BaseBulletinBoard board) || !board.CheckRange(from)) + { return; + } switch (packetID) { @@ -233,7 +263,9 @@ namespace Server.Items public static void BBRequestContent(Mobile from, BaseBulletinBoard board, PacketReader pvSrc) { if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board) + { return; + } from.Send(new BBMessageContent(board, msg)); } @@ -241,7 +273,9 @@ namespace Server.Items public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, PacketReader pvSrc) { if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board) + { return; + } from.Send(new BBMessageHeader(board, msg)); } @@ -251,38 +285,54 @@ namespace Server.Items var thread = World.FindItem(pvSrc.ReadUInt32()) as BulletinMessage; if (thread != null && thread.Parent != board) + { thread = null; + } var breakout = 0; while (thread?.Thread != null && breakout++ < 10) + { thread = thread.Thread; + } var lastPostTime = DateTime.MinValue; if (board.GetLastPostTime(from, thread == null, ref lastPostTime)) + { if (!CheckTime(lastPostTime, thread == null ? ThreadCreateTime : ThreadReplyTime)) { if (thread == null) - from.SendMessage("You must wait {0} before creating a new thread.", FormatTS(ThreadCreateTime)); + { + @from.SendMessage("You must wait {0} before creating a new thread.", FormatTS(ThreadCreateTime)); + } else - from.SendMessage("You must wait {0} before replying to another thread.", FormatTS(ThreadReplyTime)); + { + @from.SendMessage("You must wait {0} before replying to another thread.", FormatTS(ThreadReplyTime)); + } return; } + } var subject = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte()); if (subject.Length == 0) + { return; + } var lines = new string[pvSrc.ReadByte()]; if (lines.Length == 0) + { return; + } for (var i = 0; i < lines.Length; ++i) + { lines[i] = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte()); + } board.PostMessage(from, thread, subject, lines); } @@ -290,10 +340,14 @@ namespace Server.Items public static void BBRemoveMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc) { if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board) + { return; + } if (from.AccessLevel < AccessLevel.GameMaster && msg.Poster != from) + { return; + } msg.Delete(); } @@ -334,7 +388,9 @@ namespace Server.Items var item = poster.Items[i]; if (item.Layer >= Layer.OneHanded && item.Layer <= Layer.Mount) + { list.Add(new BulletinEquip(item.ItemID, item.Hue)); + } } PostedEquip = list.ToArray(); @@ -397,7 +453,9 @@ namespace Server.Items writer.Write(Lines.Length); for (var i = 0; i < Lines.Length; ++i) + { writer.Write(Lines[i]); + } } public override void Deserialize(IGenericReader reader) @@ -432,13 +490,19 @@ namespace Server.Items Lines = new string[reader.ReadInt()]; for (var i = 0; i < Lines.Length; ++i) + { Lines[i] = reader.ReadString(); + } if (hasThread && Thread == null) + { Delete(); + } if (version == 0) + { ValidationQueue.Add(this); + } break; } @@ -448,7 +512,9 @@ namespace Server.Items public void Validate() { if ((Parent as BulletinBoard)?.Items.Contains(this) == false) + { Delete(); + } } } @@ -494,9 +560,13 @@ namespace Server.Items var thread = msg.Thread; if (thread == null) + { Stream.Write(0); // Thread serial--root + } else + { Stream.Write(thread.Serial); // Thread serial--parent + } WriteString(poster); WriteString(subject); @@ -509,7 +579,9 @@ namespace Server.Items var len = buffer.Length + 1; if (len > 255) + { len = 255; + } Stream.Write((byte)len); Stream.Write(buffer, 0, len - 1); @@ -543,7 +615,9 @@ namespace Server.Items var len = msg.PostedEquip.Length; if (len > 255) + { len = 255; + } Stream.Write((byte)len); @@ -558,12 +632,16 @@ namespace Server.Items len = msg.Lines.Length; if (len > 255) + { len = 255; + } Stream.Write((byte)len); for (var i = 0; i < len; ++i) + { WriteString(msg.Lines[i], true); + } } public void WriteString(string v) @@ -578,21 +656,29 @@ namespace Server.Items var len = buffer.Length + tail; if (len > 255) + { len = 255; + } Stream.Write((byte)len); Stream.Write(buffer, 0, len - tail); if (padding) + { Stream.Write((short)0); // padding compensates for a client bug + } else + { Stream.Write((byte)0); + } } public string SafeString(string v) { if (v == null) + { return string.Empty; + } return v; } diff --git a/Projects/UOContent/Items/Misc/ClockworkAssembly.cs b/Projects/UOContent/Items/Misc/ClockworkAssembly.cs index a43ebb6dd..605360cff 100644 --- a/Projects/UOContent/Items/Misc/ClockworkAssembly.cs +++ b/Projects/UOContent/Items/Misc/ClockworkAssembly.cs @@ -42,20 +42,32 @@ namespace Server.Items double scalar; if (tinkerSkill >= 100.0) + { scalar = 1.0; + } else if (tinkerSkill >= 90.0) + { scalar = 0.9; + } else if (tinkerSkill >= 80.0) + { scalar = 0.8; + } else if (tinkerSkill >= 70.0) + { scalar = 0.7; + } else + { scalar = 0.6; + } var pack = from.Backpack; if (pack == null) + { return; + } var res = pack.ConsumeTotal( new[] diff --git a/Projects/UOContent/Items/Misc/CommunicationCrystals.cs b/Projects/UOContent/Items/Misc/CommunicationCrystals.cs index 3f03798ab..cca418f13 100644 --- a/Projects/UOContent/Items/Misc/CommunicationCrystals.cs +++ b/Projects/UOContent/Items/Misc/CommunicationCrystals.cs @@ -32,8 +32,12 @@ namespace Server.Items public static CrystalRechargeInfo Get(Type type) { foreach (var info in Table) + { if (info.Type == type) + { return info; + } + } return null; } @@ -96,7 +100,9 @@ namespace Server.Items list.Add(1060741, Charges.ToString()); // charges: ~1_val~ if (Receivers.Count > 0) + { list.Add(1060746, Receivers.Count.ToString()); // links: ~1_val~ + } } public override void OnSingleClick(Mobile from) @@ -108,28 +114,35 @@ namespace Server.Items LabelTo(from, 1060741, Charges.ToString()); // charges: ~1_val~ if (Receivers.Count > 0) - LabelTo(from, 1060746, Receivers.Count.ToString()); // links: ~1_val~ + { + LabelTo(@from, 1060746, Receivers.Count.ToString()); // links: ~1_val~ + } } public override void OnSpeech(SpeechEventArgs e) { if (!Active || Receivers.Count == 0 || RootParent != null && !(RootParent is Mobile)) + { return; + } if (e.Type == MessageType.Emote) + { return; + } var from = e.Mobile; var speech = e.Speech; foreach (var receiver in new List(Receivers)) + { if (receiver.Deleted) { Receivers.Remove(receiver); } else if (Charges > 0) { - receiver.TransmitMessage(from, speech); + receiver.TransmitMessage(@from, speech); Charges--; } else @@ -137,6 +150,7 @@ namespace Server.Items Active = false; break; } + } } public override void OnDoubleClick(Mobile from) @@ -179,7 +193,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (!m_Crystal.IsAccessibleTo(from)) + { return; + } if (from.Map != m_Crystal.Map || !from.InRange(m_Crystal.GetWorldLocation(), 2)) { @@ -231,7 +247,10 @@ namespace Server.Items } else if (targeted == from) { - foreach (var rc in new List(m_Crystal.Receivers)) rc.Sender = null; + foreach (var rc in new List(m_Crystal.Receivers)) + { + rc.Sender = null; + } from.SendLocalizedMessage(1010046); // You unlink the broadcast crystal from all of its receivers. } @@ -338,16 +357,24 @@ namespace Server.Items public void TransmitMessage(Mobile from, string message) { if (!Active) + { return; + } var text = $"{from.Name} says {message}"; if (RootParent is Mobile mobile) + { mobile.SendMessage(0x2B2, $"Crystal: {text}"); + } else if (RootParent is Item item) + { item.PublicOverheadMessage(MessageType.Regular, 0x2B2, false, $"Crystal: {text}"); + } else + { PublicOverheadMessage(MessageType.Regular, 0x2B2, false, text); + } } public override void OnDoubleClick(Mobile from) @@ -388,7 +415,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (!m_Crystal.IsAccessibleTo(from)) + { return; + } if (from.Map != m_Crystal.Map || !from.InRange(m_Crystal.GetWorldLocation(), 2)) { diff --git a/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs b/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs index f3267c8b9..33306fa2e 100644 --- a/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs +++ b/Projects/UOContent/Items/Misc/Corpses/DecayedCorpse.cs @@ -62,7 +62,9 @@ namespace Server.Items writer.Write(m_DecayTimer != null); if (m_DecayTimer != null) + { writer.WriteDeltaTime(m_DecayTime); + } } public override void Deserialize(IGenericReader reader) @@ -82,7 +84,9 @@ namespace Server.Items case 1: { if (reader.ReadBool()) + { BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + } break; } diff --git a/Projects/UOContent/Items/Misc/Corpses/Packets.cs b/Projects/UOContent/Items/Misc/Corpses/Packets.cs index 10cf3197e..9651ee1c0 100644 --- a/Projects/UOContent/Items/Misc/Corpses/Packets.cs +++ b/Projects/UOContent/Items/Misc/Corpses/Packets.cs @@ -11,9 +11,14 @@ namespace Server.Network var count = list.Count; if (beheld.Hair?.ItemID > 0) + { count++; + } + if (beheld.FacialHair?.ItemID > 0) + { count++; + } EnsureCapacity(8 + count * 5); @@ -55,9 +60,14 @@ namespace Server.Network var count = items.Count; if (beheld.Hair?.ItemID > 0) + { count++; + } + if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0) + { count++; + } EnsureCapacity(5 + count * 19); @@ -128,9 +138,14 @@ namespace Server.Network var count = items.Count; if (beheld.Hair?.ItemID > 0) + { count++; + } + if (beheld.FacialHair?.ItemID > 0) + { count++; + } EnsureCapacity(5 + count * 20); diff --git a/Projects/UOContent/Items/Misc/DeceitBrazier.cs b/Projects/UOContent/Items/Misc/DeceitBrazier.cs index 95077d219..c3ae59212 100644 --- a/Projects/UOContent/Items/Misc/DeceitBrazier.cs +++ b/Projects/UOContent/Items/Misc/DeceitBrazier.cs @@ -102,10 +102,16 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (NextSpawn < DateTime.UtcNow) // means we haven't spawned anything if the next spawn is below + { if (Utility.InRange(m.Location, Location, 1) && !Utility.InRange(oldLocation, Location, 1) && m.Player && !(m.AccessLevel > AccessLevel.Player || m.Hidden)) + { if (m_Timer?.Running != true) + { m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2), HeedWarning); + } + } + } base.OnMovement(m, oldLocation); } @@ -115,7 +121,9 @@ namespace Server.Items var map = Map; if (map == null) + { return Location; + } // Try 10 times to find a Spawnable location. for (var i = 0; i < 10; i++) @@ -125,9 +133,14 @@ namespace Server.Items var z = Map.GetAverageZ(x, y); if (Map.CanSpawnMobile(new Point2D(x, y), Z)) + { return new Point3D(x, y, Z); + } + if (Map.CanSpawnMobile(new Point2D(x, y), z)) + { return new Point3D(x, y, z); + } } return Location; @@ -155,6 +168,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(from.Location, Location, 2)) + { try { if (NextSpawn < DateTime.UtcNow) @@ -184,8 +198,11 @@ namespace Server.Items { // ignored } + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } } } diff --git a/Projects/UOContent/Items/Misc/EffectController.cs b/Projects/UOContent/Items/Misc/EffectController.cs index a0bfe05eb..29dc3ff0d 100644 --- a/Projects/UOContent/Items/Misc/EffectController.cs +++ b/Projects/UOContent/Items/Misc/EffectController.cs @@ -75,7 +75,10 @@ namespace Server.Items get => m_Source == null; set { - if (value) m_Source = null; + if (value) + { + m_Source = null; + } } } @@ -99,7 +102,10 @@ namespace Server.Items get => m_Target == null; set { - if (value) m_Target = null; + if (value) + { + m_Target = null; + } } } @@ -155,7 +161,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (TriggerType == EffectTriggerType.DoubleClick) - DoEffect(from); + { + DoEffect(@from); + } } public override void OnMovement(Mobile m, Point3D oldLocation) @@ -163,7 +171,9 @@ namespace Server.Items if (m.Location != oldLocation && TriggerType == EffectTriggerType.InRange && Utility.InRange(GetWorldLocation(), m.Location, TriggerRange) && !Utility.InRange(GetWorldLocation(), oldLocation, TriggerRange)) + { DoEffect(m); + } } public override void Serialize(IGenericWriter writer) @@ -177,14 +187,22 @@ namespace Server.Items writer.Write(SoundDelay); if (m_Source is Item srcItem) + { writer.Write(srcItem); + } else + { writer.Write(m_Source as Mobile); + } if (m_Target is Item targItem) + { writer.Write(targItem); + } else + { writer.Write(m_Target as Mobile); + } writer.Write(Sequence); @@ -264,19 +282,29 @@ namespace Server.Items public void DoEffect(IEntity trigger) { if (Deleted || TriggerType == EffectTriggerType.None) + { return; + } if (trigger is Mobile mobile && mobile.Hidden && mobile.AccessLevel > AccessLevel.Player) + { return; + } if (SoundID > 0) + { Timer.DelayCall(SoundDelay, PlaySound, trigger); + } if (Sequence != null) + { Timer.DelayCall(TriggerDelay, Sequence.DoEffect, trigger); + } if (EffectType != ECEffectType.None) + { Timer.DelayCall(EffectDelay, InternalDoEffect, trigger); + } } public void InternalDoEffect(IEntity trigger) @@ -308,10 +336,14 @@ namespace Server.Items case ECEffectType.Moving: { if (from == this) - from = EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration); + { + @from = EffectItem.Create(@from.Location, @from.Map, EffectItem.DefaultDuration); + } if (to == this) + { to = EffectItem.Create(to.Location, to.Map, EffectItem.DefaultDuration); + } Effects.SendMovingParticles( from, diff --git a/Projects/UOContent/Items/Misc/EffectItem.cs b/Projects/UOContent/Items/Misc/EffectItem.cs index 434e7ebfe..8ad1fb5fc 100644 --- a/Projects/UOContent/Items/Misc/EffectItem.cs +++ b/Projects/UOContent/Items/Misc/EffectItem.cs @@ -30,13 +30,19 @@ namespace Server.Items m_Free.RemoveAt(i); if (!free.Deleted && free.Map == Map.Internal) + { item = free; + } } if (item == null) + { item = new EffectItem(); + } else + { item.ItemID = 1; + } item.MoveToWorld(p, map); item.BeginFree(duration); diff --git a/Projects/UOContent/Items/Misc/Firebomb.cs b/Projects/UOContent/Items/Misc/Firebomb.cs index ecf821903..845ce1c4e 100644 --- a/Projects/UOContent/Items/Misc/Firebomb.cs +++ b/Projects/UOContent/Items/Misc/Firebomb.cs @@ -69,7 +69,9 @@ namespace Server.Items m_Users ??= new List(); if (!m_Users.Contains(from)) - m_Users.Add(from); + { + m_Users.Add(@from); + } from.Target = new ThrowTarget(this); } @@ -83,7 +85,9 @@ namespace Server.Items } if (Map == Map.Internal && HeldBy == null) + { return; + } switch (m_Ticks) { @@ -94,11 +98,17 @@ namespace Server.Items ++m_Ticks; if (HeldBy != null) + { HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); + } else if (RootParent == null) + { PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); + } else if (RootParent is Mobile mobile) + { mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); + } break; } @@ -109,8 +119,12 @@ namespace Server.Items if (m_Users != null) { foreach (var m in m_Users) + { if (m.Target is ThrowTarget targ && targ.Bomb == this) + { Target.Cancel(m); + } + } m_Users.Clear(); m_Users = null; @@ -154,10 +168,14 @@ namespace Server.Items private void OnFirebombTarget(Mobile from, object obj) { if (Deleted || Map == Map.Internal || !IsChildOf(from.Backpack)) + { return; + } if (!(obj is IPoint3D p)) + { return; + } SpellHelper.GetSurfaceTop(ref p); @@ -174,7 +192,9 @@ namespace Server.Items private void FirebombReposition_OnTick(IPoint3D p, Map map) { if (Deleted) + { return; + } MoveToWorld(new Point3D(p), map); } @@ -234,7 +254,9 @@ namespace Server.Items m.PlaySound(0x208); if (!m_Burning.Contains(m)) + { m_Burning.Add(m); + } } return true; diff --git a/Projects/UOContent/Items/Misc/FlippableAddonAttribute.cs b/Projects/UOContent/Items/Misc/FlippableAddonAttribute.cs index 934a95ba3..0ac1247a3 100644 --- a/Projects/UOContent/Items/Misc/FlippableAddonAttribute.cs +++ b/Projects/UOContent/Items/Misc/FlippableAddonAttribute.cs @@ -20,6 +20,7 @@ namespace Server.Items public virtual void Flip(Mobile from, Item addon) { if (Directions?.Length > 1) + { try { var flipMethod = addon.GetType().GetMethod(m_MethodName, m_Params); @@ -29,18 +30,22 @@ namespace Server.Items var index = 0; for (var i = 0; i < Directions.Length; i++) + { if (addon.Direction == Directions[i]) { index = i + 1; break; } + } if (index >= Directions.Length) + { index = 0; + } ClearComponents(addon); - flipMethod.Invoke(addon, new object[] { from, Directions[index] }); + flipMethod.Invoke(addon, new object[] { @from, Directions[index] }); BaseHouse house = null; var result = AddonFitResult.Valid; @@ -48,33 +53,51 @@ namespace Server.Items addon.Map = Map.Internal; if (addon is BaseAddon baseAddon) - result = baseAddon.CouldFit(baseAddon.Location, from.Map, from, ref house); + { + result = baseAddon.CouldFit(baseAddon.Location, @from.Map, @from, ref house); + } else if (addon is BaseAddonContainer container) - result = container.CouldFit(container.Location, from.Map, from, ref house); + { + result = container.CouldFit(container.Location, @from.Map, @from, ref house); + } - addon.Map = from.Map; + addon.Map = @from.Map; if (result != AddonFitResult.Valid) { if (index == 0) + { index = Directions.Length - 1; + } else + { index -= 1; + } ClearComponents(addon); - flipMethod.Invoke(addon, new object[2] { from, Directions[index] }); + flipMethod.Invoke(addon, new object[2] { @from, Directions[index] }); if (result == AddonFitResult.Blocked) - from.SendLocalizedMessage(500269); // You cannot build that there. + { + @from.SendLocalizedMessage(500269); // You cannot build that there. + } else if (result == AddonFitResult.NotInHouse) - from.SendLocalizedMessage(500274); // You can only place this in a house that you own! + { + @from.SendLocalizedMessage(500274); // You can only place this in a house that you own! + } else if (result == AddonFitResult.DoorsNotClosed) - from.SendMessage("You must close all house doors before placing this."); + { + @from.SendMessage("You must close all house doors before placing this."); + } else if (result == AddonFitResult.DoorTooClose) - from.SendLocalizedMessage(500271); // You cannot build near the door. + { + @from.SendLocalizedMessage(500271); // You cannot build near the door. + } else if (result == AddonFitResult.NoWall) - from.SendLocalizedMessage(500268); // This object needs to be mounted on something. + { + @from.SendLocalizedMessage(500268); // This object needs to be mounted on something. + } } addon.Direction = Directions[index]; @@ -84,6 +107,7 @@ namespace Server.Items { // ignored } + } } private void ClearComponents(Item item) diff --git a/Projects/UOContent/Items/Misc/FlippableAttribute.cs b/Projects/UOContent/Items/Misc/FlippableAttribute.cs index 1b7686308..bf9f72d80 100644 --- a/Projects/UOContent/Items/Misc/FlippableAttribute.cs +++ b/Projects/UOContent/Items/Misc/FlippableAttribute.cs @@ -29,14 +29,19 @@ namespace Server.Items if (targeted is Item item) { if (item.Movable == false && from.AccessLevel == AccessLevel.Player) + { return; + } var type = item.GetType(); var AttributeArray = (FlippableAttribute[])type.GetCustomAttributes(typeof(FlippableAttribute), false); - if (AttributeArray.Length == 0) return; + if (AttributeArray.Length == 0) + { + return; + } var fa = AttributeArray[0]; @@ -75,14 +80,18 @@ namespace Server.Items { var index = 0; for (var i = 0; i < ItemIDs.Length; i++) + { if (item.ItemID == ItemIDs[i]) { index = i + 1; break; } + } if (index > ItemIDs.Length - 1) + { index = 0; + } item.ItemID = ItemIDs[index]; } diff --git a/Projects/UOContent/Items/Misc/Gold.cs b/Projects/UOContent/Items/Misc/Gold.cs index a920a1c70..faa7283d1 100644 --- a/Projects/UOContent/Items/Misc/Gold.cs +++ b/Projects/UOContent/Items/Misc/Gold.cs @@ -26,9 +26,15 @@ namespace Server.Items public override int GetDropSound() { if (Amount <= 1) + { return 0x2E4; + } + if (Amount <= 5) + { return 0x2E5; + } + return 0x2E6; } @@ -43,7 +49,10 @@ namespace Server.Items { base.OnAdded(parent); - if (!AccountGold.Enabled) return; + if (!AccountGold.Enabled) + { + return; + } Mobile owner = null; SecureTradeInfo tradeInfo = null; @@ -51,7 +60,9 @@ namespace Server.Items var root = parent as Container; while (root?.Parent is Container container) + { root = container; + } parent = root ?? parent; @@ -73,7 +84,10 @@ namespace Server.Items owner = box.Owner; } - if (owner?.Account?.DepositGold(Amount) != true) return; + if (owner?.Account?.DepositGold(Amount) != true) + { + return; + } if (tradeInfo != null) { @@ -100,7 +114,9 @@ namespace Server.Items var baseTotal = base.GetTotal(type); if (type == TotalType.Gold) + { baseTotal += Amount; + } return baseTotal; } diff --git a/Projects/UOContent/Items/Misc/Guillotine.cs b/Projects/UOContent/Items/Misc/Guillotine.cs index 6d73e1a64..c6339e733 100644 --- a/Projects/UOContent/Items/Misc/Guillotine.cs +++ b/Projects/UOContent/Items/Misc/Guillotine.cs @@ -59,7 +59,9 @@ namespace Server.Items var f = Map; if (f == null) + { return; + } new Blood(4650).MoveToWorld(p, f); @@ -74,7 +76,9 @@ namespace Server.Items z = f.GetAverageZ(x, y); if (!f.CanFit(x, y, z, 1, false, false)) + { continue; + } } var loc = f.GetRandomNearbyLocation(p, 2, -2, 4, 1); @@ -86,9 +90,13 @@ namespace Server.Items private void BackUp() { if (ItemID == 4678 || ItemID == 4679) + { ItemID = 4656; + } else if (ItemID == 4712 || ItemID == 4713) + { ItemID = 4702; + } } public override void Serialize(IGenericWriter writer) @@ -105,9 +113,13 @@ namespace Server.Items int version = reader.ReadByte(); if (ItemID == 4678 || ItemID == 4679) + { ItemID = 4656; + } else if (ItemID == 4712 || ItemID == 4713) + { ItemID = 4702; + } } } } diff --git a/Projects/UOContent/Items/Misc/HairDye.cs b/Projects/UOContent/Items/Misc/HairDye.cs index b1615becb..ebaa47689 100644 --- a/Projects/UOContent/Items/Misc/HairDye.cs +++ b/Projects/UOContent/Items/Misc/HairDye.cs @@ -99,7 +99,9 @@ namespace Server.Items public override void OnResponse(NetState from, RelayInfo info) { if (m_HairDye.Deleted) + { return; + } var m = from.Mobile; var switches = info.Switches; diff --git a/Projects/UOContent/Items/Misc/InteriorDecorator.cs b/Projects/UOContent/Items/Misc/InteriorDecorator.cs index f1cd3483a..18d9bfb70 100644 --- a/Projects/UOContent/Items/Misc/InteriorDecorator.cs +++ b/Projects/UOContent/Items/Misc/InteriorDecorator.cs @@ -46,7 +46,9 @@ namespace Server.Items base.GetProperties(list); if (m_Command != DecorateCommand.None) + { list.Add(1018322 + (int)m_Command); // Turn/Up/Down + } } public override void Serialize(IGenericWriter writer) @@ -66,13 +68,19 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!CheckUse(this, from)) + { return; + } if (!from.HasGump()) - from.SendGump(new InternalGump(this)); + { + @from.SendGump(new InternalGump(this)); + } if (m_Command != DecorateCommand.None) - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } } public static bool InHouse(Mobile from) @@ -88,9 +96,13 @@ namespace Server.Items from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. else*/ if (!InHouse(from)) - from.SendLocalizedMessage(502092); // You must be in your house to do this. + { + @from.SendLocalizedMessage(502092); // You must be in your house to do this. + } else + { return true; + } return false; } @@ -183,7 +195,9 @@ namespace Server.Items if (addon != null) { if (count == 1 && Core.SE) + { isDecorableComponent = true; + } if (m_Decorator.Command == DecorateCommand.Turn) { @@ -192,7 +206,9 @@ namespace Server.Items .GetCustomAttributes(typeof(FlippableAddonAttribute), false); if (attributes.Length > 0) + { isDecorableComponent = true; + } } } @@ -207,11 +223,17 @@ namespace Server.Items else if (!house.HasLockedDownItem(item) && !house.HasSecureItem(item) && !isDecorableComponent) { if (item is AddonComponent && m_Decorator.Command == DecorateCommand.Up) - from.SendLocalizedMessage(1042274); // You cannot raise it up any higher. + { + @from.SendLocalizedMessage(1042274); // You cannot raise it up any higher. + } else if (item is AddonComponent && m_Decorator.Command == DecorateCommand.Down) - from.SendLocalizedMessage(1042275); // You cannot lower it down any further. + { + @from.SendLocalizedMessage(1042275); // You cannot lower it down any further. + } else - from.SendLocalizedMessage(1042271); // That is not locked down. + { + @from.SendLocalizedMessage(1042271); // That is not locked down. + } } else if (item is VendorRentalContract) { @@ -244,7 +266,9 @@ namespace Server.Items protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { if (cancelType == TargetCancelType.Canceled) - from.CloseGump(); + { + @from.CloseGump(); + } } private static void Turn(Item item, Mobile from) @@ -252,11 +276,17 @@ namespace Server.Items object addon = null; if (item is AddonComponent component) + { addon = component.Addon; + } else if (item is AddonContainerComponent containerComponent) + { addon = containerComponent.Addon; + } else if (item is BaseAddonContainer container) + { addon = container; + } if (addon != null) { @@ -275,9 +305,13 @@ namespace Server.Items (FlippableAttribute[])item.GetType().GetCustomAttributes(typeof(FlippableAttribute), false); if (attributes.Length > 0) + { attributes[0].Flip(item); + } else - from.SendLocalizedMessage(1042273); // You cannot turn that. + { + @from.SendLocalizedMessage(1042273); // You cannot turn that. + } } private static void Up(Item item, Mobile from) @@ -285,9 +319,13 @@ namespace Server.Items var floorZ = GetFloorZ(item); if (floorZ > int.MinValue && item.Z < floorZ + 15) // Confirmed : no height checks here + { item.Location = new Point3D(item.Location, item.Z + 1); + } else - from.SendLocalizedMessage(1042274); // You cannot raise it up any higher. + { + @from.SendLocalizedMessage(1042274); // You cannot raise it up any higher. + } } private static void Down(Item item, Mobile from) @@ -295,9 +333,13 @@ namespace Server.Items var floorZ = GetFloorZ(item); if (floorZ > int.MinValue && item.Z > GetFloorZ(item)) + { item.Location = new Point3D(item.Location, item.Z - 1); + } else - from.SendLocalizedMessage(1042275); // You cannot lower it down any further. + { + @from.SendLocalizedMessage(1042275); // You cannot lower it down any further. + } } private static int GetFloorZ(Item item) @@ -305,7 +347,9 @@ namespace Server.Items var map = item.Map; if (map == null) + { return int.MinValue; + } var tiles = map.Tiles.GetStaticTiles(item.X, item.Y, true); @@ -319,7 +363,9 @@ namespace Server.Items var top = tile.Z; // Confirmed : no height checks here if (id.Surface && !id.Impassable && top > z && top <= item.Z) + { z = top; + } } return z; diff --git a/Projects/UOContent/Items/Misc/LOSBlocker.cs b/Projects/UOContent/Items/Misc/LOSBlocker.cs index 0c3dc1ed0..2a5a755c4 100644 --- a/Projects/UOContent/Items/Misc/LOSBlocker.cs +++ b/Projects/UOContent/Items/Misc/LOSBlocker.cs @@ -23,7 +23,10 @@ namespace Server.Items { var mob = state.Mobile; - if (mob?.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this); + if (mob?.AccessLevel >= AccessLevel.GameMaster) + { + return new GMItemPacket(this); + } return base.GetWorldPacketFor(state); } @@ -42,7 +45,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && ItemID == 0x2199) + { ItemID = 0x21A2; + } } public sealed class GMItemPacket : Packet @@ -67,43 +72,61 @@ namespace Server.Items var direction = (int)item.Direction; if (amount != 0) + { serial |= 0x80000000; + } else + { serial &= 0x7FFFFFFF; + } Stream.Write(serial); Stream.Write((short)(itemID & 0x7FFF)); if (amount != 0) + { Stream.Write((short)amount); + } x &= 0x7FFF; if (direction != 0) + { x |= 0x8000; + } Stream.Write((short)x); y &= 0x3FFF; if (hue != 0) + { y |= 0x8000; + } if (flags != 0) + { y |= 0x4000; + } Stream.Write((short)y); if (direction != 0) + { Stream.Write((byte)direction); + } Stream.Write((sbyte)loc.Z); if (hue != 0) + { Stream.Write((ushort)hue); + } if (flags != 0) + { Stream.Write((byte)flags); + } } } } diff --git a/Projects/UOContent/Items/Misc/Labyrinth/MinotaurArtifact.cs b/Projects/UOContent/Items/Misc/Labyrinth/MinotaurArtifact.cs index 05831c3e4..7097d1325 100644 --- a/Projects/UOContent/Items/Misc/Labyrinth/MinotaurArtifact.cs +++ b/Projects/UOContent/Items/Misc/Labyrinth/MinotaurArtifact.cs @@ -6,7 +6,9 @@ namespace Server.Items public MinotaurArtifact() : base(Utility.RandomList(0xB46, 0xB48, 0x9ED)) { if (ItemID == 0x9ED) + { Weight = 30; + } LootType = LootType.Blessed; Hue = 0x100; diff --git a/Projects/UOContent/Items/Misc/Moonstone.cs b/Projects/UOContent/Items/Misc/Moonstone.cs index 045485230..b4adcecc8 100644 --- a/Projects/UOContent/Items/Misc/Moonstone.cs +++ b/Projects/UOContent/Items/Misc/Moonstone.cs @@ -191,7 +191,9 @@ namespace Server.Items var hue = m_Stone.Hue; if (hue == 0) + { hue = Utility.RandomBirdHue(); + } new MoonstoneGate(m_Location, m_TargetMap, m_Map, m_Caster, hue); new MoonstoneGate(m_Location, m_Map, m_TargetMap, m_Caster, hue); diff --git a/Projects/UOContent/Items/Misc/MoonstoneGate.cs b/Projects/UOContent/Items/Misc/MoonstoneGate.cs index d384679e9..a7ca5892b 100644 --- a/Projects/UOContent/Items/Misc/MoonstoneGate.cs +++ b/Projects/UOContent/Items/Misc/MoonstoneGate.cs @@ -27,25 +27,33 @@ namespace Server.Items public override void CheckGate(Mobile m, int range) { if (m.Kills >= 5) + { return; + } var casterParty = Party.Get(m_Caster); var userParty = Party.Get(m); if (m == m_Caster || casterParty != null && userParty == casterParty) + { base.CheckGate(m, range); + } } public override void UseGate(Mobile m) { if (m.Kills >= 5) + { return; + } var casterParty = Party.Get(m_Caster); var userParty = Party.Get(m); if (m == m_Caster || casterParty != null && userParty == casterParty) + { base.UseGate(m); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Misc/MorphItem.cs b/Projects/UOContent/Items/Misc/MorphItem.cs index a6f012ab9..1b401e1c0 100644 --- a/Projects/UOContent/Items/Misc/MorphItem.cs +++ b/Projects/UOContent/Items/Misc/MorphItem.cs @@ -57,19 +57,25 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (Utility.InRange(m.Location, Location, CurrentRange) || Utility.InRange(oldLocation, Location, CurrentRange)) + { Refresh(); + } } public override void OnMapChange() { if (!Deleted) + { Refresh(); + } } public override void OnLocationChange(Point3D oldLoc) { if (!Deleted) + { Refresh(); + } } public void Refresh() @@ -113,7 +119,9 @@ namespace Server.Items m_InsideRange = reader.ReadInt(); if (version < 1) + { m_OutsideRange = m_InsideRange; + } break; } diff --git a/Projects/UOContent/Items/Misc/OilCloth.cs b/Projects/UOContent/Items/Misc/OilCloth.cs index 7f39aa840..97f545949 100644 --- a/Projects/UOContent/Items/Misc/OilCloth.cs +++ b/Projects/UOContent/Items/Misc/OilCloth.cs @@ -21,7 +21,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -31,7 +33,9 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { if (Deleted || !from.CanSee(this)) + { return false; + } ScissorHelper(from, new Bandage(), 1); @@ -76,14 +80,22 @@ namespace Server.Items else { if (weapon.PoisonCharges < 2) + { weapon.PoisonCharges = 0; + } else + { weapon.PoisonCharges -= 2; + } if (weapon.PoisonCharges > 0) - from.SendLocalizedMessage(1005423); // You have removed some of the caustic substance, but not all. + { + @from.SendLocalizedMessage(1005423); // You have removed some of the caustic substance, but not all. + } else - from.SendLocalizedMessage(1010497); // You have cleaned the item. + { + @from.SendLocalizedMessage(1010497); // You have cleaned the item. + } } } else if (obj == from && obj is PlayerMobile pm) diff --git a/Projects/UOContent/Items/Misc/Origami.cs b/Projects/UOContent/Items/Misc/Origami.cs index 1a2ad546f..6b2799898 100644 --- a/Projects/UOContent/Items/Misc/Origami.cs +++ b/Projects/UOContent/Items/Misc/Origami.cs @@ -35,7 +35,9 @@ namespace Server.Items }; if (i != null) - from.AddToBackpack(i); + { + @from.AddToBackpack(i); + } from.SendLocalizedMessage(1070822); // You fold the paper into an interesting shape. } diff --git a/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs b/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs index b8936229c..04a1bc4bd 100644 --- a/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs +++ b/Projects/UOContent/Items/Misc/PlayerBulletinBoards.cs @@ -112,7 +112,9 @@ namespace Server.Items writer.WriteEncodedInt(Messages.Count); for (var i = 0; i < Messages.Count; ++i) + { Messages[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -131,19 +133,25 @@ namespace Server.Items case 0: { if (version < 1) + { Level = SecureLevel.Anyone; + } Title = reader.ReadString(); if (reader.ReadBool()) + { Greeting = new PlayerBBMessage(reader); + } var count = reader.ReadEncodedInt(); Messages = new List(count); for (var i = 0; i < count; ++i) + { Messages.Add(new PlayerBBMessage(reader)); + } break; } @@ -153,7 +161,9 @@ namespace Server.Items public static bool CheckAccess(BaseHouse house, Mobile from) { if (house.Public || !house.IsAosRules) - return !house.IsBanned(from); + { + return !house.IsBanned(@from); + } return house.HasAccess(from); } @@ -163,11 +173,17 @@ namespace Server.Items var house = BaseHouse.FindHouseAt(this); if (house?.HasLockedDownItem(this) != true) - from.SendLocalizedMessage(1062396); // This bulletin board must be locked down in a house to be usable. + { + @from.SendLocalizedMessage(1062396); // This bulletin board must be locked down in a house to be usable. + } else if (!from.InRange(GetWorldLocation(), 2) || !from.InLOS(this)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (CheckAccess(house, from)) - from.SendGump(new PlayerBBGump(from, house, this, 0)); + { + @from.SendGump(new PlayerBBGump(@from, house, this, 0)); + } } public class PostPrompt : Prompt @@ -214,12 +230,17 @@ namespace Server.Items return; } - if (m_Greeting && !house.IsOwner(from)) return; + if (m_Greeting && !house.IsOwner(from)) + { + return; + } text = text.Trim(); if (text.Length > 255) + { text = text.Substring(0, 255); + } if (text.Length > 0) { @@ -238,7 +259,9 @@ namespace Server.Items board.Messages.RemoveAt(0); if (page > 0) + { --page; + } } } } @@ -292,10 +315,14 @@ namespace Server.Items text = text.Trim(); if (text.Length > 255) + { text = text.Substring(0, 255); + } if (text.Length > 0) + { board.Title = text; + } from.SendGump(new PlayerBBGump(from, house, board, page)); } @@ -385,7 +412,9 @@ namespace Server.Items var title = board.Title; if (title != null) + { AddHtml(183, 68, 180, 23, title); + } AddHtmlLocalized(385, 89, 60, 20, 1062409, LabelColor); // Post @@ -396,7 +425,9 @@ namespace Server.Items var message = board.Greeting; if (page >= 1 && page <= board.Messages.Count) + { message = board.Messages[page - 1]; + } AddImageTiled(150, 220, 240, 1, 2700); // Separator @@ -424,7 +455,9 @@ namespace Server.Items } if (from.AccessLevel >= AccessLevel.GameMaster) + { AddButton(135, 242, 1209, 1210, 8); // Post props + } } } @@ -485,9 +518,13 @@ namespace Server.Items case 4: // Scroll up { if (page == 0) + { page = board.Messages.Count; + } else + { page -= 1; + } from.SendGump(new PlayerBBGump(from, house, board, page)); @@ -546,12 +583,16 @@ namespace Server.Items else { if (!house.Bans.Contains(poster)) + { house.Bans.Add(poster); + } from.SendLocalizedMessage(1062417); // That person has been banned from this house. if (house.IsInside(poster) && !BasePlayerBB.CheckAccess(house, poster)) + { poster.MoveToWorld(house.BanLocation, house.Map); + } } } @@ -565,7 +606,9 @@ namespace Server.Items if (house.IsOwner(from)) { if (page >= 1 && page <= board.Messages.Count) + { board.Messages.RemoveAt(page - 1); + } from.SendGump(new PlayerBBGump(from, house, board, 0)); } @@ -579,7 +622,9 @@ namespace Server.Items var message = board.Greeting; if (page >= 1 && page <= board.Messages.Count) + { message = board.Messages[page - 1]; + } from.SendGump(new PlayerBBGump(from, house, board, page)); from.SendGump(new PropertiesGump(from, message)); diff --git a/Projects/UOContent/Items/Misc/PoolOfAcid.cs b/Projects/UOContent/Items/Misc/PoolOfAcid.cs index 6f98fc6c6..d05f52abf 100644 --- a/Projects/UOContent/Items/Misc/PoolOfAcid.cs +++ b/Projects/UOContent/Items/Misc/PoolOfAcid.cs @@ -64,11 +64,17 @@ namespace Server.Items var toDamage = new List(); foreach (var m in GetMobilesInRange(0)) + { if (m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned)) + { toDamage.Add(m); + } + } for (var i = 0; i < toDamage.Count; i++) + { Damage(toDamage[i]); + } } } diff --git a/Projects/UOContent/Items/Misc/PowerCrystal.cs b/Projects/UOContent/Items/Misc/PowerCrystal.cs index fcb337581..b9ea45fb7 100644 --- a/Projects/UOContent/Items/Misc/PowerCrystal.cs +++ b/Projects/UOContent/Items/Misc/PowerCrystal.cs @@ -16,9 +16,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 3)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else - from.SendAsciiMessage("This looks like part of a larger contraption."); + { + @from.SendAsciiMessage("This looks like part of a larger contraption."); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Misc/PowerGenerator.cs b/Projects/UOContent/Items/Misc/PowerGenerator.cs index 1b562dfb9..e52440f57 100644 --- a/Projects/UOContent/Items/Misc/PowerGenerator.cs +++ b/Projects/UOContent/Items/Misc/PowerGenerator.cs @@ -82,9 +82,13 @@ namespace Server.Items set { if (value < 3) + { value = 3; + } else if (value > 6) + { value = 6; + } if (m_SideLength != value) { @@ -117,16 +121,24 @@ namespace Server.Items var count = 0; if (current.X > 0 && !visited[current.X - 1, current.Y]) + { choices[count++] = PathDirection.Left; + } if (current.Y > 0 && !visited[current.X, current.Y - 1]) + { choices[count++] = PathDirection.Up; + } if (current.X < SideLength - 1 && !visited[current.X + 1, current.Y]) + { choices[count++] = PathDirection.Right; + } if (current.Y < SideLength - 1 && !visited[current.X, current.Y + 1]) + { choices[count++] = PathDirection.Down; + } if (count > 0) { @@ -143,7 +155,9 @@ namespace Server.Items stack[stackSize++] = current; if (current.X == SideLength - 1 && current.Y == SideLength - 1) + { break; + } visited[current.X, current.Y] = true; } @@ -155,7 +169,10 @@ namespace Server.Items Path = new Node[stackSize]; - for (var i = 0; i < stackSize; i++) Path[i] = stack[i]; + for (var i = 0; i < stackSize; i++) + { + Path[i] = stack[i]; + } if (m_User != null) { @@ -175,7 +192,9 @@ namespace Server.Items if (m_User != null) { if (m_User == from) + { return; + } if (m_User.Deleted || m_User.Map != Map || !m_User.InRange(this, 3) || m_User.NetState == null || DateTime.UtcNow - m_LastUse >= m_UseTimeout) @@ -216,7 +235,9 @@ namespace Server.Items AOS.Damage(to, to, 60, 0, 0, 0, 0, 100); if (!to.Alive) + { return; + } if (!m_DamageTable.Contains(to)) { @@ -240,7 +261,10 @@ namespace Server.Items from.SendMessage("You scrounge some gems from the wreckage."); - for (var i = 0; i < SideLength; i++) from.AddToBackpack(new ArcaneGem()); + for (var i = 0; i < SideLength; i++) + { + @from.AddToBackpack(new ArcaneGem()); + } from.AddToBackpack(new Diamond(SideLength)); @@ -280,7 +304,10 @@ namespace Server.Items m_SideLength = reader.ReadEncodedInt(); Path = new Node[reader.ReadEncodedInt()]; - for (var i = 0; i < Path.Length; i++) Path[i] = new Node(reader.ReadEncodedInt(), reader.ReadEncodedInt()); + for (var i = 0; i < Path.Length; i++) + { + Path[i] = new Node(reader.ReadEncodedInt(), reader.ReadEncodedInt()); + } } public struct Node @@ -351,12 +378,20 @@ namespace Server.Items AddBackground(100, 125, 10 + 40 * sideLength, 10 + 40 * sideLength, 0x1400); for (var i = 0; i < sideLength; i++) + { for (var j = 0; j < sideLength - 1; j++) + { AddImage(120 + 40 * i, 162 + 40 * j, 0x13F9); + } + } for (var i = 0; i < sideLength - 1; i++) + { for (var j = 0; j < sideLength; j++) + { AddImage(138 + 40 * i, 147 + 40 * j, 0x13FD); + } + } var path = panel.Path; @@ -372,8 +407,12 @@ namespace Server.Items hues[lastNode.X, lastNode.Y] = NodeHue.Red; for (var i = 0; i < sideLength; i++) + { for (var j = 0; j < sideLength; j++) + { AddNode(110 + 40 * i, 135 + 40 * j, hues[i, j]); + } + } var curNode = path[step]; AddImage(118 + 40 * curNode.X, 143 + 40 * curNode.Y, 0x13A8); @@ -425,7 +464,9 @@ namespace Server.Items var lockpicking = m_From.Skills.Lockpicking.Value; if (lockpicking < 65.0) + { return; + } m_From.PlaySound(0x241); @@ -533,7 +574,10 @@ namespace Server.Items AOS.Damage(m_To, m_To, 20, 0, 0, 0, 0, 100); - if (++m_Step >= 3 || !m_To.Alive) End(); + if (++m_Step >= 3 || !m_To.Alive) + { + End(); + } } private void End() diff --git a/Projects/UOContent/Items/Misc/PromotionalToken.cs b/Projects/UOContent/Items/Misc/PromotionalToken.cs index ee1ff943d..d7e328ea6 100644 --- a/Projects/UOContent/Items/Misc/PromotionalToken.cs +++ b/Projects/UOContent/Items/Misc/PromotionalToken.cs @@ -48,9 +48,13 @@ namespace Server.Items Mobile m = null; if (parent is Item item) + { m = item.RootParent as Mobile; + } else if (parent is Mobile mobile) + { m = mobile; + } m?.CloseGump(); } @@ -98,7 +102,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID != 1) + { return; + } var from = sender.Mobile; @@ -141,7 +147,9 @@ namespace Server.Items public override Item CreateItemFor(Mobile from) { if (from?.Account != null) - return new SoulstoneFragment(from.Account.ToString()); + { + return new SoulstoneFragment(@from.Account.ToString()); + } return null; } diff --git a/Projects/UOContent/Items/Misc/PublicMoongate.cs b/Projects/UOContent/Items/Misc/PublicMoongate.cs index cc95fa4fe..3b515706d 100644 --- a/Projects/UOContent/Items/Misc/PublicMoongate.cs +++ b/Projects/UOContent/Items/Misc/PublicMoongate.cs @@ -28,19 +28,27 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.Player) + { return; + } if (from.InRange(GetWorldLocation(), 1)) - UseGate(from); + { + UseGate(@from); + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } public override bool OnMoveOver(Mobile m) { // Changed so criminals are not blocked by it. if (m.Player) + { UseGate(m); + } return true; } @@ -48,8 +56,12 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (m is PlayerMobile) + { if (!Utility.InRange(m.Location, Location, 1) && Utility.InRange(oldLocation, Location, 1)) + { m.CloseGump(); + } + } } public bool UseGate(Mobile m) @@ -76,7 +88,9 @@ namespace Server.Items m.SendGump(new MoongateGump(m, this)); if (!m.Hidden || m.AccessLevel == AccessLevel.Player) + { Effects.PlaySound(m.Location, m.Map, 0x20E); + } return true; } @@ -122,14 +136,22 @@ namespace Server.Items var list = new List(); foreach (var item in World.Items.Values) + { if (item is PublicMoongate) + { list.Add(item); + } + } foreach (var item in list) + { item.Delete(); + } if (list.Count > 0) + { World.Broadcast(0x35, true, "{0} moongates removed.", list.Count); + } } private static int MoonGen(PMList list) @@ -141,7 +163,9 @@ namespace Server.Items item.MoveToWorld(entry.Location, list.Map); if (entry.Number == 1060642) // Umbra + { item.Hue = 0x497; + } } return list.Entries.Length; @@ -304,13 +328,21 @@ namespace Server.Items var young = mobile is PlayerMobile playerMobile && playerMobile.Young; if (Core.SE && (flags & ClientFlags.Tokuno) != 0) + { checkLists = young ? PMList.SEListsYoung : PMList.SELists; + } else if (Core.AOS && (flags & ClientFlags.Malas) != 0) + { checkLists = young ? PMList.AOSListsYoung : PMList.AOSLists; + } else if ((flags & ClientFlags.Ilshenar) != 0) + { checkLists = young ? PMList.LBRListsYoung : PMList.LBRLists; + } else + { checkLists = young ? PMList.UORListsYoung : PMList.UORLists; + } } } else @@ -321,9 +353,12 @@ namespace Server.Items m_Lists = new PMList[checkLists.Length]; for (var i = 0; i < m_Lists.Length; ++i) + { m_Lists[i] = checkLists[i]; + } for (var i = 0; i < m_Lists.Length; ++i) + { if (m_Lists[i].Map == mobile.Map) { var temp = m_Lists[i]; @@ -333,6 +368,7 @@ namespace Server.Items break; } + } AddPage(0); @@ -353,7 +389,9 @@ namespace Server.Items } for (var i = 0; i < m_Lists.Length; ++i) + { RenderPage(i, Array.IndexOf(checkLists, m_Lists[i])); + } } private void RenderPage(int index, int offset) @@ -377,26 +415,37 @@ namespace Server.Items public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 0) // Cancel + { return; + } + if (m_Mobile.Deleted || m_Moongate.Deleted || m_Mobile.Map == null) + { return; + } var switches = info.Switches; if (switches.Length == 0) + { return; + } var switchID = switches[0]; var listIndex = switchID / 100; var listEntry = switchID % 100; if (listIndex < 0 || listIndex >= m_Lists.Length) + { return; + } var list = m_Lists[listIndex]; if (listEntry < 0 || listEntry >= list.Entries.Length) + { return; + } var entry = list.Entries[listEntry]; diff --git a/Projects/UOContent/Items/Misc/Rares.cs b/Projects/UOContent/Items/Misc/Rares.cs index a9a970ad6..30dbab085 100644 --- a/Projects/UOContent/Items/Misc/Rares.cs +++ b/Projects/UOContent/Items/Misc/Rares.cs @@ -57,7 +57,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && Weight == 2.0) + { Weight = 5.0; + } } } @@ -89,7 +91,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && Weight == 2.0) + { Weight = 5.0; + } } } @@ -121,7 +125,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && Weight == 2.0) + { Weight = 5.0; + } } } @@ -153,7 +159,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && Weight == 2.0) + { Weight = 5.0; + } } } diff --git a/Projects/UOContent/Items/Misc/Scales.cs b/Projects/UOContent/Items/Misc/Scales.cs index b8d8104cc..c08be8fc9 100644 --- a/Projects/UOContent/Items/Misc/Scales.cs +++ b/Projects/UOContent/Items/Misc/Scales.cs @@ -62,9 +62,13 @@ namespace Server.Items var weight = item.Weight; if (weight <= 0.0) + { message += "It is lighter than a feather."; + } else + { message += $"It weighs {weight} stones."; + } } else { diff --git a/Projects/UOContent/Items/Misc/SerpentPillar.cs b/Projects/UOContent/Items/Misc/SerpentPillar.cs index a52ff980d..5157d4e39 100644 --- a/Projects/UOContent/Items/Misc/SerpentPillar.cs +++ b/Projects/UOContent/Items/Misc/SerpentPillar.cs @@ -42,7 +42,9 @@ namespace Server.Items var boat = BaseBoat.FindBoatAt(from, from.Map); if (boat == null) + { return; + } if (!Active) { diff --git a/Projects/UOContent/Items/Misc/SpecialBeardDye.cs b/Projects/UOContent/Items/Misc/SpecialBeardDye.cs index d82d36951..28cfd7695 100644 --- a/Projects/UOContent/Items/Misc/SpecialBeardDye.cs +++ b/Projects/UOContent/Items/Misc/SpecialBeardDye.cs @@ -96,7 +96,9 @@ namespace Server.Items public override void OnResponse(NetState from, RelayInfo info) { if (m_SpecialBeardDye.Deleted) + { return; + } var m = from.Mobile; var switches = info.Switches; diff --git a/Projects/UOContent/Items/Misc/SpecialHairDye.cs b/Projects/UOContent/Items/Misc/SpecialHairDye.cs index b89386e74..50aa93539 100644 --- a/Projects/UOContent/Items/Misc/SpecialHairDye.cs +++ b/Projects/UOContent/Items/Misc/SpecialHairDye.cs @@ -96,7 +96,9 @@ namespace Server.Items public override void OnResponse(NetState from, RelayInfo info) { if (m_SpecialHairDye.Deleted) + { return; + } var m = from.Mobile; var switches = info.Switches; diff --git a/Projects/UOContent/Items/Misc/Static.cs b/Projects/UOContent/Items/Misc/Static.cs index 8f352daad..d7700830d 100644 --- a/Projects/UOContent/Items/Misc/Static.cs +++ b/Projects/UOContent/Items/Misc/Static.cs @@ -30,7 +30,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 0) + { Weight = -1; + } } } diff --git a/Projects/UOContent/Items/Misc/Teleporter.cs b/Projects/UOContent/Items/Misc/Teleporter.cs index e561a6c27..98832ad41 100644 --- a/Projects/UOContent/Items/Misc/Teleporter.cs +++ b/Projects/UOContent/Items/Misc/Teleporter.cs @@ -158,15 +158,23 @@ namespace Server.Items base.GetProperties(list); if (m_Active) + { list.Add(1060742); // active + } else + { list.Add(1060743); // inactive + } if (m_MapDest != null) + { list.Add(1060658, "Map\t{0}", m_MapDest); + } if (m_PointDest != Point3D.Zero) + { list.Add(1060659, "Coords\t{0}", m_PointDest); + } list.Add(1060660, "Creatures\t{0}", m_Creatures ? "Yes" : "No"); } @@ -178,11 +186,17 @@ namespace Server.Items if (m_Active) { if (m_MapDest != null && m_PointDest != Point3D.Zero) - LabelTo(from, "{0} [{1}]", m_PointDest, m_MapDest); + { + LabelTo(@from, "{0} [{1}]", m_PointDest, m_MapDest); + } else if (m_MapDest != null) - LabelTo(from, "[{0}]", m_MapDest); + { + LabelTo(@from, "[{0}]", m_MapDest); + } else if (m_PointDest != Point3D.Zero) - LabelTo(from, m_PointDest.ToString()); + { + LabelTo(@from, m_PointDest.ToString()); + } } else { @@ -192,7 +206,10 @@ namespace Server.Items public virtual bool CanTeleport(Mobile m) { - if (!m_Creatures && !m.Player) return false; + if (!m_Creatures && !m.Player) + { + return false; + } if (m_CriminalCheck && m.Criminal) { @@ -212,9 +229,13 @@ namespace Server.Items public virtual void StartTeleport(Mobile m) { if (m_Delay == TimeSpan.Zero) + { DoTeleport(m); + } else + { Timer.DelayCall(m_Delay, DoTeleport, m); + } } public virtual void DoTeleport(Mobile m) @@ -222,27 +243,37 @@ namespace Server.Items var map = m_MapDest; if (map == null || map == Map.Internal) + { map = m.Map; + } var p = m_PointDest; if (p == Point3D.Zero) + { p = m.Location; + } BaseCreature.TeleportPets(m, p, map); var sendEffect = !m.Hidden || m.AccessLevel == AccessLevel.Player; if (m_SourceEffect && sendEffect) + { Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10, 10); + } m.MoveToWorld(p, map); if (m_DestEffect && sendEffect) + { Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10, 10); + } if (m_SoundID > 0 && sendEffect) + { Effects.PlaySound(m.Location, m.Map, m_SoundID); + } } public override bool OnMoveOver(Mobile m) @@ -386,7 +417,9 @@ namespace Server.Items public override bool CanTeleport(Mobile m) { if (!base.CanTeleport(m)) + { return false; + } var sk = m.Skills[m_Skill]; @@ -395,6 +428,7 @@ namespace Server.Items if (m.BeginAction(this)) { if (m_MessageString != null) + { m.Send( new UnicodeMessage( Serial, @@ -407,7 +441,9 @@ namespace Server.Items m_MessageString ) ); + } else if (m_MessageNumber != 0) + { m.Send( new MessageLocalized( Serial, @@ -420,6 +456,7 @@ namespace Server.Items "" ) ); + } Timer.DelayCall(TimeSpan.FromSeconds(5.0), m.EndAction, this); } @@ -438,16 +475,24 @@ namespace Server.Items string skillName; if (skillIndex >= 0 && skillIndex < SkillInfo.Table.Length) + { skillName = SkillInfo.Table[skillIndex].Name; + } else + { skillName = "(Invalid)"; + } list.Add(1060661, "{0}\t{1:F1}", skillName, m_Required); if (m_MessageString != null) + { list.Add(1060662, "Message\t{0}", m_MessageString); + } else if (m_MessageNumber != 0) + { list.Add(1060662, "Message\t#{0}", m_MessageNumber); + } } public override void Serialize(IGenericWriter writer) @@ -543,17 +588,25 @@ namespace Server.Items var m = e.Mobile; if (!m.InRange(GetWorldLocation(), m_Range)) + { return; + } var isMatch = false; if (m_Keyword >= 0 && e.HasKeyword(m_Keyword)) + { isMatch = true; + } else if (m_Substring != null && e.Speech.ToLower().IndexOf(m_Substring.ToLower()) >= 0) + { isMatch = true; + } if (!isMatch || !CanTeleport(m)) + { return; + } e.Handled = true; StartTeleport(m); @@ -563,7 +616,9 @@ namespace Server.Items public override void DoTeleport(Mobile m) { if (!m.InRange(GetWorldLocation(), m_Range) || m.Map != Map) + { return; + } base.DoTeleport(m); } @@ -577,10 +632,14 @@ namespace Server.Items list.Add(1060661, "Range\t{0}", m_Range); if (m_Keyword >= 0) + { list.Add(1060662, "Keyword\t{0}", m_Keyword); + } if (m_Substring != null) + { list.Add(1060663, "Substring\t{0}", m_Substring); + } } public override void Serialize(IGenericWriter writer) @@ -690,12 +749,18 @@ namespace Server.Items if (m.BeginAction(this)) { if (ProgressMessage != null) + { m.SendMessage(ProgressMessage); + } else if (ProgressNumber != 0) + { m.SendLocalizedMessage(ProgressNumber); + } if (ShowTimeRemaining) + { m.SendMessage("Time remaining: {0}", FormatTime(info.Timer.Next - DateTime.UtcNow)); + } Timer.DelayCall(TimeSpan.FromSeconds(5), EndLock, m); } @@ -707,14 +772,22 @@ namespace Server.Items } if (StartMessage != null) + { m.SendMessage(StartMessage); + } else if (StartNumber != 0) + { m.SendLocalizedMessage(StartNumber); + } if (Delay == TimeSpan.Zero) + { DoTeleport(m); + } else + { m_Table[m] = new TeleportingInfo(this, Timer.DelayCall(Delay, DoTeleport, m)); + } } public override void DoTeleport(Mobile m) @@ -794,7 +867,9 @@ namespace Server.Items private void StartTimer(Mobile m, TimeSpan delay) { if (m_Teleporting.TryGetValue(m, out var t)) + { t.Stop(); + } m_Teleporting[m] = Timer.DelayCall(delay, StartTeleport, m); } @@ -819,7 +894,9 @@ namespace Server.Items if (Active) { if (!CanTeleport(m)) + { return false; + } StartTimer(m); } @@ -1028,10 +1105,14 @@ namespace Server.Items public override bool CanTeleport(Mobile m) { if (!base.CanTeleport(m)) + { return false; + } if (GetFlag(ConditionFlag.StaffOnly) && m.AccessLevel < AccessLevel.Counselor) + { return false; + } if (GetFlag(ConditionFlag.DenyMounted) && m.Mounted) { @@ -1071,7 +1152,9 @@ namespace Server.Items } if (GetFlag(ConditionFlag.DenyEquipment)) + { foreach (var item in m.Items) + { switch (item.Layer) { case Layer.Hair: @@ -1088,6 +1171,8 @@ namespace Server.Items return false; } } + } + } if (GetFlag(ConditionFlag.DenyTransformed) && m.IsBodyMod) { @@ -1111,31 +1196,49 @@ namespace Server.Items var props = new StringBuilder(); if (GetFlag(ConditionFlag.DenyMounted)) + { props.Append("
Deny Mounted"); + } if (GetFlag(ConditionFlag.DenyFollowers)) + { props.Append("
Deny Followers"); + } if (GetFlag(ConditionFlag.DenyPackContents)) + { props.Append("
Deny Pack Contents"); + } if (GetFlag(ConditionFlag.DenyPackEthereals)) + { props.Append("
Deny Pack Ethereals"); + } if (GetFlag(ConditionFlag.DenyHolding)) + { props.Append("
Deny Holding"); + } if (GetFlag(ConditionFlag.DenyEquipment)) + { props.Append("
Deny Equipment"); + } if (GetFlag(ConditionFlag.DenyTransformed)) + { props.Append("
Deny Transformed"); + } if (GetFlag(ConditionFlag.StaffOnly)) + { props.Append("
Staff Only"); + } if (GetFlag(ConditionFlag.DeadOnly)) + { props.Append("
Dead Only"); + } if (props.Length != 0) { @@ -1167,9 +1270,13 @@ namespace Server.Items protected void SetFlag(ConditionFlag flag, bool value) { if (value) + { m_Flags |= flag; + } else + { m_Flags &= ~flag; + } } [Flags] diff --git a/Projects/UOContent/Items/Misc/TrashBarrel.cs b/Projects/UOContent/Items/Misc/TrashBarrel.cs index 6b6144d06..e06cbd52c 100644 --- a/Projects/UOContent/Items/Misc/TrashBarrel.cs +++ b/Projects/UOContent/Items/Misc/TrashBarrel.cs @@ -60,7 +60,9 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item dropped) { if (!base.OnDragDrop(from, dropped)) + { return false; + } if (TotalItems >= 50) { @@ -71,9 +73,13 @@ namespace Server.Items SendLocalizedMessageTo(from, 1010442); // The item will be deleted in three minutes if (m_Timer != null) + { m_Timer.Stop(); + } else + { m_Timer = new EmptyTimer(this); + } m_Timer.Start(); } @@ -84,7 +90,9 @@ namespace Server.Items public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { if (!base.OnDragDropInto(from, item, p)) + { return false; + } if (TotalItems >= 50) { @@ -95,9 +103,13 @@ namespace Server.Items SendLocalizedMessageTo(from, 1010442); // The item will be deleted in three minutes if (m_Timer != null) + { m_Timer.Stop(); + } else + { m_Timer = new EmptyTimer(this); + } m_Timer.Start(); } @@ -116,7 +128,9 @@ namespace Server.Items for (var i = items.Count - 1; i >= 0; --i) { if (i >= items.Count) + { continue; + } items[i].Delete(); } diff --git a/Projects/UOContent/Items/Misc/TrashChest.cs b/Projects/UOContent/Items/Misc/TrashChest.cs index f42ff7beb..c6ee92d55 100644 --- a/Projects/UOContent/Items/Misc/TrashChest.cs +++ b/Projects/UOContent/Items/Misc/TrashChest.cs @@ -33,7 +33,9 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item dropped) { if (!base.OnDragDrop(from, dropped)) + { return false; + } PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1042891, 8)); dropped.Delete(); @@ -44,7 +46,9 @@ namespace Server.Items public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { if (!base.OnDragDropInto(from, item, p)) + { return false; + } PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1042891, 8)); item.Delete(); diff --git a/Projects/UOContent/Items/Misc/TribalBerry.cs b/Projects/UOContent/Items/Misc/TribalBerry.cs index 79e052b34..e309d5a9f 100644 --- a/Projects/UOContent/Items/Misc/TribalBerry.cs +++ b/Projects/UOContent/Items/Misc/TribalBerry.cs @@ -31,7 +31,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 4) + { Hue = 6; + } } } } diff --git a/Projects/UOContent/Items/Misc/TribalPaint.cs b/Projects/UOContent/Items/Misc/TribalPaint.cs index eea4f7f8b..ee8cdfad6 100644 --- a/Projects/UOContent/Items/Misc/TribalPaint.cs +++ b/Projects/UOContent/Items/Misc/TribalPaint.cs @@ -58,7 +58,9 @@ namespace Server.Items from.HueMod = 0; if (from is PlayerMobile mobile) + { mobile.SavagePaintExpiration = TimeSpan.FromDays(7.0); + } from.SendLocalizedMessage( 1042537 diff --git a/Projects/UOContent/Items/Misc/UnholyBone.cs b/Projects/UOContent/Items/Misc/UnholyBone.cs index 80af85d0e..f97833b29 100644 --- a/Projects/UOContent/Items/Misc/UnholyBone.cs +++ b/Projects/UOContent/Items/Misc/UnholyBone.cs @@ -31,9 +31,13 @@ namespace Server.Items if (Utility.RandomDouble() < 0.3) { if (ItemID == 0xF7E) - from.SendMessage("You destroy the bone."); + { + @from.SendMessage("You destroy the bone."); + } else - from.SendMessage("You destroy the bone pile."); + { + @from.SendMessage("You destroy the bone pile."); + } var gold = new Gold(25, 100); @@ -46,9 +50,13 @@ namespace Server.Items else { if (ItemID == 0xF7E) - from.SendMessage("You damage the bone."); + { + @from.SendMessage("You damage the bone."); + } else - from.SendMessage("You damage the bone pile."); + { + @from.SendMessage("You damage the bone pile."); + } } } @@ -83,7 +91,9 @@ namespace Server.Items protected override void OnTick() { if (m_Item.Deleted) + { return; + } var spawn = Utility.Random(12) switch { diff --git a/Projects/UOContent/Items/Misc/WarningItem.cs b/Projects/UOContent/Items/Misc/WarningItem.cs index c7f706bad..b56794584 100644 --- a/Projects/UOContent/Items/Misc/WarningItem.cs +++ b/Projects/UOContent/Items/Misc/WarningItem.cs @@ -15,7 +15,9 @@ namespace Server.Items public WarningItem(int itemID, int range, int warning) : base(itemID) { if (range > 18) + { range = 18; + } Movable = false; @@ -27,7 +29,9 @@ namespace Server.Items public WarningItem(int itemID, int range, string warning) : base(itemID) { if (range > 18) + { range = 18; + } Movable = false; @@ -51,7 +55,11 @@ namespace Server.Items get => m_Range; set { - if (value > 18) value = 18; + if (value > 18) + { + value = 18; + } + m_Range = value; } } @@ -69,23 +77,33 @@ namespace Server.Items if (onlyToTriggerer) { if (messageString != null) + { triggerer.SendMessage(messageString); + } else + { triggerer.SendLocalizedMessage(messageNumber); + } } else { if (messageString != null) + { PublicOverheadMessage(MessageType.Regular, 0x3B2, false, messageString); + } else + { PublicOverheadMessage(MessageType.Regular, 0x3B2, messageNumber); + } } } public virtual void Broadcast(Mobile triggerer) { if (m_Broadcasting || DateTime.UtcNow < m_LastBroadcast + ResetDelay) + { return; + } m_LastBroadcast = DateTime.UtcNow; @@ -98,11 +116,17 @@ namespace Server.Items var list = new List(); foreach (var item in GetItemsInRange(NeighborRange)) + { if (item != this && item is WarningItem warningItem) + { list.Add(warningItem); + } + } for (var i = 0; i < list.Count; i++) + { list[i].Broadcast(triggerer); + } } Timer.DelayCall(StopBroadcasting); @@ -117,7 +141,9 @@ namespace Server.Items { if (m.Player && Utility.InRange(m.Location, Location, m_Range) && !Utility.InRange(oldLocation, Location, m_Range)) + { Broadcast(m); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Misc/Waypoint.cs b/Projects/UOContent/Items/Misc/Waypoint.cs index 171ccca40..270d0212d 100644 --- a/Projects/UOContent/Items/Misc/Waypoint.cs +++ b/Projects/UOContent/Items/Misc/Waypoint.cs @@ -14,7 +14,9 @@ namespace Server.Items Visible = false; // this.Movable = false; if (prev != null) + { prev.NextPoint = this; + } } public WayPoint(Serial serial) : base(serial) @@ -30,7 +32,9 @@ namespace Server.Items set { if (m_Next != this) + { m_Next = value; + } } } @@ -60,9 +64,13 @@ namespace Server.Items base.OnSingleClick(from); if (m_Next == null) - LabelTo(from, "(Unlinked)"); + { + LabelTo(@from, "(Unlinked)"); + } else - LabelTo(from, "(Linked: {0})", m_Next.Location); + { + LabelTo(@from, "(Linked: {0})", m_Next.Location); + } } public override void Deserialize(IGenericReader reader) @@ -100,9 +108,13 @@ namespace Server.Items protected override void OnTarget(Mobile from, object target) { if (target is WayPoint point && m_Point != null) + { m_Point.NextPoint = point; + } else - from.SendMessage("Target a way point."); + { + @from.SendMessage("Target a way point."); + } } } @@ -117,7 +129,9 @@ namespace Server.Items if (targeted is WayPoint wayPoint) { if (m_Last != null) + { m_Last.NextPoint = wayPoint; + } } else if (targeted is IPoint3D d) { diff --git a/Projects/UOContent/Items/Misc/WindChimes.cs b/Projects/UOContent/Items/Misc/WindChimes.cs index 56604fb27..2c10e417f 100644 --- a/Projects/UOContent/Items/Misc/WindChimes.cs +++ b/Projects/UOContent/Items/Misc/WindChimes.cs @@ -35,7 +35,9 @@ namespace Server.Items { if (m_TurnedOn && IsLockedDown && (!m.Hidden || m.AccessLevel == AccessLevel.Player) && Utility.InRange(m.Location, Location, 2) && !Utility.InRange(oldLocation, Location, 2)) + { Effects.PlaySound(Location, Map, Sounds.RandomElement()); + } base.OnMovement(m, oldLocation); } @@ -45,9 +47,13 @@ namespace Server.Items base.GetProperties(list); if (m_TurnedOn) + { list.Add(502695); // turned on + } else + { list.Add(502696); // turned off + } } public bool IsOwner(Mobile mob) => BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true; @@ -55,9 +61,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsOwner(from)) - from.SendGump(new OnOffGump(this)); + { + @from.SendGump(new OnOffGump(this)); + } else - from.SendLocalizedMessage(502691); // You must be the owner to use this. + { + @from.SendLocalizedMessage(502691); // You must be the owner to use this. + } } public override void Serialize(IGenericWriter writer) @@ -112,7 +122,9 @@ namespace Server.Items m_Chimes.TurnedOn = newValue; if (newValue && !m_Chimes.IsLockedDown) - from.SendLocalizedMessage(502693); // Remember, this only works when locked down. + { + @from.SendLocalizedMessage(502693); // Remember, this only works when locked down. + } } else { diff --git a/Projects/UOContent/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs b/Projects/UOContent/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs index 250b61ae9..aeb1ad7fe 100644 --- a/Projects/UOContent/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs +++ b/Projects/UOContent/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs @@ -6,7 +6,9 @@ namespace Server.Items public BagOfSmokeBombs(int amount = 20) { for (var i = 0; i < amount; ++i) + { DropItem(new SmokeBomb()); + } } public BagOfSmokeBombs(Serial serial) : base(serial) diff --git a/Projects/UOContent/Items/New Haven Quest Rewards/HammerOfHephaestus.cs b/Projects/UOContent/Items/New Haven Quest Rewards/HammerOfHephaestus.cs index 4cb37e286..c1c0667ea 100644 --- a/Projects/UOContent/Items/New Haven Quest Rewards/HammerOfHephaestus.cs +++ b/Projects/UOContent/Items/New Haven Quest Rewards/HammerOfHephaestus.cs @@ -35,11 +35,17 @@ namespace Server.Items { if (!IsChildOf(from.Backpack) && Parent != from ) // TODO: These checks don't match EA, but they match BaseTool for now - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } else if (UsesRemaining <= 0) - from.SendLocalizedMessage(1072306); // You must wait a moment for it to recharge. + { + @from.SendLocalizedMessage(1072306); // You must wait a moment for it to recharge. + } else - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } private void StartRechargeTimer() @@ -52,7 +58,9 @@ namespace Server.Items { // TODO: Stop timer at 20? Count downtime? Something more generic so we can use it for JacobsPickaxe too (both are IUsesRemaining)? if (UsesRemaining < 20) + { ++UsesRemaining; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Quivers/BaseQuiver.cs b/Projects/UOContent/Items/Quivers/BaseQuiver.cs index b93adcc98..b3f1c2b58 100644 --- a/Projects/UOContent/Items/Quivers/BaseQuiver.cs +++ b/Projects/UOContent/Items/Quivers/BaseQuiver.cs @@ -117,7 +117,9 @@ namespace Server.Items Quality = (ClothingQuality)quality; if (makersMark) - Crafter = from; + { + Crafter = @from; + } return quality; } @@ -125,7 +127,9 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseQuiver quiver)) + { return; + } quiver.Attributes = new AosAttributes(newItem, Attributes); } @@ -142,7 +146,9 @@ namespace Server.Items var total = base.GetTotal(type); if (type == TotalType.Weight) + { total -= total * m_WeightReduction / 100; + } return total; } @@ -155,13 +161,19 @@ namespace Server.Items if (ammo != null) { if (ammo.GetType() == type) + { return true; + } } else { for (var i = 0; i < m_Ammo.Length; i++) + { if (type == m_Ammo[i]) + { return true; + } + } } return false; @@ -170,12 +182,16 @@ namespace Server.Items public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { if (CheckType(item)) + { return Items.Count >= DefaultMaxItems && !checkItems && Ammo?.Deleted == false && Ammo.Amount + item.Amount <= m_Capacity || item.Amount <= m_Capacity && base.CheckHold(m, item, message, checkItems, plusItems, plusWeight); + } if (message) + { m.SendLocalizedMessage(1074836); // The container can not hold that type of object. + } return false; } @@ -196,12 +212,18 @@ namespace Server.Items public override void OnAdded(IEntity parent) { - if (parent is Mobile mob) Attributes.AddStatBonuses(mob); + if (parent is Mobile mob) + { + Attributes.AddStatBonuses(mob); + } } public override void OnRemoved(IEntity parent) { - if (parent is Mobile mob) Attributes.RemoveStatBonuses(mob); + if (parent is Mobile mob) + { + Attributes.RemoveStatBonuses(mob); + } } public override void GetProperties(ObjectPropertyList list) @@ -209,19 +231,27 @@ namespace Server.Items base.GetProperties(list); if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } if (m_Quality == ClothingQuality.Exceptional) + { list.Add(1063341); // exceptional + } var ammo = Ammo; if (ammo != null) { if (ammo is Arrow) + { list.Add(1075265, "{0}\t{1}", ammo.Amount, Capacity); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows + } else if (ammo is Bolt) + { list.Add(1075266, "{0}\t{1}", ammo.Amount, Capacity); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ bolts + } } else { @@ -231,7 +261,9 @@ namespace Server.Items int prop; if ((prop = m_DamageIncrease) != 0) + { list.Add(1074762, prop.ToString()); // Damage modifier: ~1_PERCENT~% + } int phys, fire, cold, pois, nrgy, chaos, direct; phys = fire = cold = pois = nrgy = chaos = direct = 0; @@ -239,93 +271,151 @@ namespace Server.Items AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct); if (phys != 0) + { list.Add(1060403, phys.ToString()); // physical damage ~1_val~% + } if (fire != 0) + { list.Add(1060405, fire.ToString()); // fire damage ~1_val~% + } if (cold != 0) + { list.Add(1060404, cold.ToString()); // cold damage ~1_val~% + } if (pois != 0) + { list.Add(1060406, pois.ToString()); // poison damage ~1_val~% + } if (nrgy != 0) + { list.Add(1060407, nrgy.ToString()); // energy damage ~1_val + } if (chaos != 0) + { list.Add(1072846, chaos.ToString()); // chaos damage ~1_val~% + } if (direct != 0) + { list.Add(1079978, direct.ToString()); // Direct Damage: ~1_PERCENT~% + } list.Add(1075085); // Requirement: Mondain's Legacy if ((prop = Attributes.DefendChance) != 0) + { list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% + } if ((prop = Attributes.BonusDex) != 0) + { list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ + } if ((prop = Attributes.EnhancePotions) != 0) + { list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% + } if ((prop = Attributes.CastRecovery) != 0) + { list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ + } if ((prop = Attributes.CastSpeed) != 0) + { list.Add(1060413, prop.ToString()); // faster casting ~1_val~ + } if ((prop = Attributes.AttackChance) != 0) + { list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% + } if ((prop = Attributes.BonusHits) != 0) + { list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ + } if ((prop = Attributes.BonusInt) != 0) + { list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ + } if ((prop = Attributes.LowerManaCost) != 0) + { list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% + } if ((prop = Attributes.LowerRegCost) != 0) + { list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% + } if ((prop = Attributes.Luck) != 0) + { list.Add(1060436, prop.ToString()); // luck ~1_val~ + } if ((prop = Attributes.BonusMana) != 0) + { list.Add(1060439, prop.ToString()); // mana increase ~1_val~ + } if ((prop = Attributes.RegenMana) != 0) + { list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ + } if ((prop = Attributes.NightSight) != 0) + { list.Add(1060441); // night sight + } if ((prop = Attributes.ReflectPhysical) != 0) + { list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% + } if ((prop = Attributes.RegenStam) != 0) + { list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ + } if ((prop = Attributes.RegenHits) != 0) + { list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ + } if ((prop = Attributes.SpellDamage) != 0) + { list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% + } if ((prop = Attributes.BonusStam) != 0) + { list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ + } if ((prop = Attributes.BonusStr) != 0) + { list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ + } if ((prop = Attributes.WeaponSpeed) != 0) + { list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% + } if ((prop = m_LowerAmmoCost) > 0) + { list.Add(1075208, prop.ToString()); // Lower Ammo Cost ~1_Percentage~% + } var weight = ammo != null ? ammo.Weight + ammo.Amount : 0; @@ -339,13 +429,17 @@ namespace Server.Items ); // Contents: ~1_COUNT~/~2_MAXCOUNT items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones if ((prop = m_WeightReduction) != 0) + { list.Add(1072210, prop.ToString()); // Weight reduction: ~1_PERCENTAGE~% + } } private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) + { flags |= toSet; + } } private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; @@ -369,25 +463,39 @@ namespace Server.Items writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) + { writer.Write(m_LowerAmmoCost); + } if (GetSaveFlag(flags, SaveFlag.WeightReduction)) + { writer.Write(m_WeightReduction); + } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) + { writer.Write(m_DamageIncrease); + } if (GetSaveFlag(flags, SaveFlag.Crafter)) + { writer.Write(m_Crafter); + } if (GetSaveFlag(flags, SaveFlag.Quality)) + { writer.Write((int)m_Quality); + } if (GetSaveFlag(flags, SaveFlag.Capacity)) + { writer.Write(m_Capacity); + } } public override void Deserialize(IGenericReader reader) @@ -399,27 +507,43 @@ namespace Server.Items var flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes = new AosAttributes(this, reader); + } else + { Attributes = new AosAttributes(this); + } if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) + { m_LowerAmmoCost = reader.ReadInt(); + } if (GetSaveFlag(flags, SaveFlag.WeightReduction)) + { m_WeightReduction = reader.ReadInt(); + } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) + { m_DamageIncrease = reader.ReadInt(); + } if (GetSaveFlag(flags, SaveFlag.Crafter)) + { m_Crafter = reader.ReadMobile(); + } if (GetSaveFlag(flags, SaveFlag.Quality)) + { m_Quality = (ClothingQuality)reader.ReadInt(); + } if (GetSaveFlag(flags, SaveFlag.Capacity)) + { m_Capacity = reader.ReadInt(); + } } public virtual void AlterBowDamage( @@ -431,7 +555,10 @@ namespace Server.Items public void InvalidateWeight() { - if (RootParent is Mobile m) m.UpdateTotals(); + if (RootParent is Mobile m) + { + m.UpdateTotals(); + } } [Flags] diff --git a/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs b/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs index 23a37bd2e..1291c619b 100644 --- a/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs +++ b/Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs @@ -35,7 +35,9 @@ namespace Server.Items get { if (m_Resource >= CraftResource.DullCopper && m_Resource <= CraftResource.Valorite) + { return 1042684 + (m_Resource - CraftResource.DullCopper); + } return 1042692; } @@ -91,9 +93,13 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (Amount > 1) + { list.Add(1050039, "{0}\t#{1}", Amount, 1027154); // ~1_NUMBER~ ~2_ITEMNAME~ + } else + { list.Add(1027154); // ingots + } } public override void GetProperties(ObjectPropertyList list) @@ -105,9 +111,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } } diff --git a/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs b/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs index 445bf5d77..269ec4ed2 100644 --- a/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs +++ b/Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs @@ -37,7 +37,9 @@ namespace Server.Items get { if (m_Resource >= CraftResource.DullCopper && m_Resource <= CraftResource.Valorite) + { return 1042845 + (m_Resource - CraftResource.DullCopper); + } return 1042853; // iron ore; } @@ -94,11 +96,20 @@ namespace Server.Items var rand = Utility.RandomDouble(); if (rand < 0.12) + { return 0x19B7; + } + if (rand < 0.18) + { return 0x19B8; + } + if (rand < 0.25) + { return 0x19BA; + } + return 0x19B9; } @@ -109,9 +120,13 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (Amount > 1) + { list.Add(1050039, "{0}\t#{1}", Amount, 1026583); // ~1_NUMBER~ ~2_ITEMNAME~ + } else + { list.Add(1026583); // ore + } } public override void GetProperties(ObjectPropertyList list) @@ -123,16 +138,22 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } public override void OnDoubleClick(Mobile from) { if (!Movable) + { return; + } if (RootParent is BaseCreature) { @@ -160,17 +181,25 @@ namespace Server.Items private bool IsForge(object obj) { if (Core.ML && obj is Mobile mobile && mobile.IsDeadBondedPet) + { return false; + } if (obj.GetType().IsDefined(typeof(ForgeAttribute), false)) + { return true; + } var itemID = 0; if (obj is Item item) + { itemID = item.ItemID; + } else if (obj is StaticTarget target) + { itemID = target.ItemID; + } return itemID == 4017 || itemID >= 6522 && itemID <= 6569; } @@ -178,7 +207,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Ore.Deleted) + { return; + } if (!from.InRange(m_Ore.GetWorldLocation(), 2)) { @@ -188,7 +219,11 @@ namespace Server.Items if (targeted is BaseOre ore) { - if (!ore.Movable) return; + if (!ore.Movable) + { + return; + } + if (m_Ore == ore) { from.SendLocalizedMessage(501972); // Select another pile or ore with which to combine this. @@ -205,20 +240,32 @@ namespace Server.Items var worth = ore.Amount; if (ore.ItemID == 0x19B9) + { worth *= 8; + } else if (ore.ItemID == 0x19B7) + { worth *= 2; + } else + { worth *= 4; + } var sourceWorth = m_Ore.Amount; if (m_Ore.ItemID == 0x19B9) + { sourceWorth *= 8; + } else if (m_Ore.ItemID == 0x19B7) + { sourceWorth *= 2; + } else + { sourceWorth *= 4; + } worth += sourceWorth; @@ -260,11 +307,17 @@ namespace Server.Items ore.ItemID = newID; if (ore.ItemID == 0x19B9) + { ore.Amount = worth / 8; + } else if (ore.ItemID == 0x19B7) + { ore.Amount = worth / 2; + } else + { ore.Amount = worth / 4; + } m_Ore.Delete(); return; @@ -315,7 +368,9 @@ namespace Server.Items else { if (toConsume > 30000) + { toConsume = 30000; + } int ingotAmount; @@ -324,7 +379,9 @@ namespace Server.Items ingotAmount = toConsume / 2; if (toConsume % 2 != 0) + { --toConsume; + } } else if (m_Ore.ItemID == 0x19B9) { @@ -352,9 +409,13 @@ namespace Server.Items if (m_Ore.Amount < 2) { if (m_Ore.ItemID == 0x19B9) + { m_Ore.ItemID = 0x19B8; + } else + { m_Ore.ItemID = 0x19B7; + } } else { @@ -380,7 +441,9 @@ namespace Server.Items public IronOre(bool fixedSize) : this() { if (fixedSize) + { ItemID = 0x19B8; + } } public IronOre(Serial serial) : base(serial) diff --git a/Projects/UOContent/Items/Resources/Fishing/BigFish.cs b/Projects/UOContent/Items/Resources/Fishing/BigFish.cs index 33c5f5806..ec48b32ec 100644 --- a/Projects/UOContent/Items/Resources/Fishing/BigFish.cs +++ b/Projects/UOContent/Items/Resources/Fishing/BigFish.cs @@ -45,7 +45,9 @@ namespace Server.Items if (Weight >= 20) { if (m_Fisher != null) + { list.Add(1070857, m_Fisher.Name); // Caught by ~1_fisherman~ + } list.Add(1070858, ((int)Weight).ToString()); // ~1_weight~ stones } diff --git a/Projects/UOContent/Items/Resources/Fishing/MagicFish.cs b/Projects/UOContent/Items/Resources/Fishing/MagicFish.cs index 1413bedf2..66718a5ef 100644 --- a/Projects/UOContent/Items/Resources/Fishing/MagicFish.cs +++ b/Projects/UOContent/Items/Resources/Fishing/MagicFish.cs @@ -22,7 +22,9 @@ namespace Server.Items var applied = SpellHelper.AddStatOffset(from, Type, Bonus, TimeSpan.FromMinutes(1.0)); if (!applied) - from.SendLocalizedMessage(502173); // You are already under a similar effect. + { + @from.SendLocalizedMessage(502173); // You are already under a similar effect. + } return applied; } @@ -87,7 +89,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 151) + { Hue = 51; + } } } @@ -121,7 +125,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 286) + { Hue = 86; + } } } @@ -155,7 +161,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 376) + { Hue = 76; + } } } @@ -192,7 +200,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 266) + { Hue = 66; + } } } } diff --git a/Projects/UOContent/Items/Resources/Masonry/Granite.cs b/Projects/UOContent/Items/Resources/Masonry/Granite.cs index 340270e05..6b473ac20 100644 --- a/Projects/UOContent/Items/Resources/Masonry/Granite.cs +++ b/Projects/UOContent/Items/Resources/Masonry/Granite.cs @@ -57,7 +57,9 @@ namespace Server.Items } if (version < 1) + { Stackable = Core.ML; + } } public override void GetProperties(ObjectPropertyList list) @@ -69,9 +71,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } } diff --git a/Projects/UOContent/Items/Resources/MiscMLResources.cs b/Projects/UOContent/Items/Resources/MiscMLResources.cs index b64e5ad1d..c783a2740 100644 --- a/Projects/UOContent/Items/Resources/MiscMLResources.cs +++ b/Projects/UOContent/Items/Resources/MiscMLResources.cs @@ -377,7 +377,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version <= 0 && ItemID == 0x318F) + { ItemID = 0x318C; + } } } diff --git a/Projects/UOContent/Items/Resources/Tailor/BoltOfCloth.cs b/Projects/UOContent/Items/Resources/Tailor/BoltOfCloth.cs index f8ad88024..c1450e397 100644 --- a/Projects/UOContent/Items/Resources/Tailor/BoltOfCloth.cs +++ b/Projects/UOContent/Items/Resources/Tailor/BoltOfCloth.cs @@ -22,7 +22,10 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { - if (Deleted) return false; + if (Deleted) + { + return false; + } Hue = sender.DyedHue; @@ -31,7 +34,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } ScissorHelper(from, new Cloth(), 50); diff --git a/Projects/UOContent/Items/Resources/Tailor/Cloth.cs b/Projects/UOContent/Items/Resources/Tailor/Cloth.cs index bd1d5f3d3..b18f2b427 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Cloth.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Cloth.cs @@ -23,7 +23,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -32,7 +34,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } ScissorHelper(from, new Bandage(), 1); diff --git a/Projects/UOContent/Items/Resources/Tailor/Cotton.cs b/Projects/UOContent/Items/Resources/Tailor/Cotton.cs index ba3fc8c4c..67f56ec98 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Cotton.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Cotton.cs @@ -19,7 +19,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -71,12 +73,16 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Cotton.Deleted) + { return; + } var wheel = targeted as ISpinningWheel; if (wheel == null && targeted is AddonComponent component) + { wheel = component.Addon as ISpinningWheel; + } if (wheel is Item) { diff --git a/Projects/UOContent/Items/Resources/Tailor/Flax.cs b/Projects/UOContent/Items/Resources/Tailor/Flax.cs index 55278b0e2..f6828cb94 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Flax.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Flax.cs @@ -61,12 +61,16 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Flax.Deleted) + { return; + } var wheel = targeted as ISpinningWheel; if (wheel == null && targeted is AddonComponent component) + { wheel = component.Addon as ISpinningWheel; + } if (wheel is Item) { diff --git a/Projects/UOContent/Items/Resources/Tailor/Hides.cs b/Projects/UOContent/Items/Resources/Tailor/Hides.cs index 877eb1d9f..f77a15b6d 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Hides.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Hides.cs @@ -34,7 +34,9 @@ namespace Server.Items get { if (m_Resource >= CraftResource.SpinedLeather && m_Resource <= CraftResource.BarbedLeather) + { return 1049687 + (m_Resource - CraftResource.SpinedLeather); + } return 1047023; } @@ -78,9 +80,13 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (Amount > 1) + { list.Add(1050039, "{0}\t#{1}", Amount, 1024216); // ~1_NUMBER~ ~2_ITEMNAME~ + } else + { list.Add(1024216); // pile of hides + } } public override void GetProperties(ObjectPropertyList list) @@ -92,9 +98,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } } @@ -113,7 +123,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } if (Core.AOS && !IsChildOf(from.Backpack)) { @@ -155,7 +168,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } if (Core.AOS && !IsChildOf(from.Backpack)) { @@ -197,7 +213,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } if (Core.AOS && !IsChildOf(from.Backpack)) { @@ -239,7 +258,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } if (Core.AOS && !IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Items/Resources/Tailor/Leathers.cs b/Projects/UOContent/Items/Resources/Tailor/Leathers.cs index 8200bb2f5..aeee3b360 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Leathers.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Leathers.cs @@ -34,7 +34,9 @@ namespace Server.Items get { if (m_Resource >= CraftResource.SpinedLeather && m_Resource <= CraftResource.BarbedLeather) + { return 1049684 + (m_Resource - CraftResource.SpinedLeather); + } return 1047022; } @@ -78,9 +80,13 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (Amount > 1) + { list.Add(1050039, "{0}\t#{1}", Amount, 1024199); // ~1_NUMBER~ ~2_ITEMNAME~ + } else + { list.Add(1024199); // cut leather + } } public override void GetProperties(ObjectPropertyList list) @@ -92,9 +98,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } } diff --git a/Projects/UOContent/Items/Resources/Tailor/UncutCloth.cs b/Projects/UOContent/Items/Resources/Tailor/UncutCloth.cs index 60f0e8b3f..51aaffc55 100644 --- a/Projects/UOContent/Items/Resources/Tailor/UncutCloth.cs +++ b/Projects/UOContent/Items/Resources/Tailor/UncutCloth.cs @@ -23,7 +23,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -32,7 +34,10 @@ namespace Server.Items public bool Scissor(Mobile from, Scissors scissors) { - if (Deleted || !from.CanSee(this)) return false; + if (Deleted || !from.CanSee(this)) + { + return false; + } ScissorHelper(from, new Bandage(), 1); diff --git a/Projects/UOContent/Items/Resources/Tailor/Wool.cs b/Projects/UOContent/Items/Resources/Tailor/Wool.cs index e6e50e178..99c00e6ba 100644 --- a/Projects/UOContent/Items/Resources/Tailor/Wool.cs +++ b/Projects/UOContent/Items/Resources/Tailor/Wool.cs @@ -19,7 +19,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -71,12 +73,16 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Wool.Deleted) + { return; + } var wheel = targeted as ISpinningWheel; if (wheel == null && targeted is AddonComponent component) + { wheel = component.Addon as ISpinningWheel; + } if (wheel is Item) { diff --git a/Projects/UOContent/Items/Resources/Tailor/YarnsAndThreads.cs b/Projects/UOContent/Items/Resources/Tailor/YarnsAndThreads.cs index 3f9b1cfcc..c1f4ad12a 100644 --- a/Projects/UOContent/Items/Resources/Tailor/YarnsAndThreads.cs +++ b/Projects/UOContent/Items/Resources/Tailor/YarnsAndThreads.cs @@ -18,7 +18,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -61,12 +63,16 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Material.Deleted) + { return; + } var loom = targeted as ILoom; if (loom == null && targeted is AddonComponent component) + { loom = component.Addon as ILoom; + } if (loom != null) { @@ -79,7 +85,9 @@ namespace Server.Items m_Material.Consume(); if (targeted is Item item) - item.SendLocalizedMessageTo(from, 1010001 + loom.Phase++); + { + item.SendLocalizedMessageTo(@from, 1010001 + loom.Phase++); + } } else { diff --git a/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs b/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs index 0625c3c7a..9696cb3b4 100644 --- a/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs +++ b/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs @@ -38,7 +38,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1) + { PhysicalBonus = 0; + } } } } diff --git a/Projects/UOContent/Items/Shields/Artifacts/ArcaneShield.cs b/Projects/UOContent/Items/Shields/Artifacts/ArcaneShield.cs index 17ce858cc..491f1d44b 100644 --- a/Projects/UOContent/Items/Shields/Artifacts/ArcaneShield.cs +++ b/Projects/UOContent/Items/Shields/Artifacts/ArcaneShield.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Attributes.NightSight == 0) + { Attributes.NightSight = 1; + } } } } diff --git a/Projects/UOContent/Items/Shields/BaseShield.cs b/Projects/UOContent/Items/Shields/BaseShield.cs index da3afdbce..c51223e2e 100644 --- a/Projects/UOContent/Items/Shields/BaseShield.cs +++ b/Projects/UOContent/Items/Shields/BaseShield.cs @@ -22,7 +22,10 @@ namespace Server.Items var ar = base.ArmorRating; if (m != null) + { return m.Skills.Parry.Value * ar / 200.0 + 1.0; + } + return ar; } } @@ -43,7 +46,9 @@ namespace Server.Items if (version < 1) { if (this is Aegis) + { return; + } // The 15 bonus points to resistances are not applied to shields on OSI. PhysicalBonus = 0; @@ -68,14 +73,20 @@ namespace Server.Items var absorbed = (int)(halfArmor + halfArmor * Utility.RandomDouble()); if (absorbed < 2) + { absorbed = 2; + } int wear; if (weapon.Type == WeaponType.Bashing) + { wear = absorbed / 2; + } else + { wear = Utility.Random(2); + } if (wear > 0 && MaxHitPoints > 0) { @@ -97,11 +108,13 @@ namespace Server.Items MaxHitPoints -= wear; if (Parent is Mobile mobile) + { mobile.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged. + } } else { @@ -115,13 +128,18 @@ namespace Server.Items } if (!(Parent is Mobile owner)) + { return damage; + } var ar = ArmorRating; var chance = (owner.Skills.Parry.Value - ar * 2.0) / 100.0; if (chance < 0.01) + { chance = 0.01; + } + /* FORMULA: Displayed AR = ((Parrying Skill * Base AR of Shield) � 200) + 1 @@ -132,12 +150,18 @@ namespace Server.Items if (owner.CheckSkill(SkillName.Parry, chance)) { if (weapon.Skill == SkillName.Archery) + { damage -= (int)ar; + } else + { damage -= (int)(ar / 2.0); + } if (damage < 0) + { damage = 0; + } owner.FixedEffect(0x37B9, 10, 16); diff --git a/Projects/UOContent/Items/Shields/ChaosShield.cs b/Projects/UOContent/Items/Shields/ChaosShield.cs index 9de7f7a68..e8f2dd247 100644 --- a/Projects/UOContent/Items/Shields/ChaosShield.cs +++ b/Projects/UOContent/Items/Shields/ChaosShield.cs @@ -8,7 +8,9 @@ namespace Server.Items public ChaosShield() : base(0x1BC3) { if (!Core.AOS) + { LootType = LootType.Newbied; + } Weight = 5.0; } @@ -49,13 +51,17 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (Validate(Parent as Mobile)) - base.OnSingleClick(from); + { + base.OnSingleClick(@from); + } } public virtual bool Validate(Mobile m) { if (m?.Player != true || m.AccessLevel != AccessLevel.Player || Core.AOS) + { return true; + } if (!(m.Guild is Guild g) || g.Type != GuildType.Chaos) { diff --git a/Projects/UOContent/Items/Shields/MetalKiteShield.cs b/Projects/UOContent/Items/Shields/MetalKiteShield.cs index cd44bfb97..0653d14b8 100644 --- a/Projects/UOContent/Items/Shields/MetalKiteShield.cs +++ b/Projects/UOContent/Items/Shields/MetalKiteShield.cs @@ -25,7 +25,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -39,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 5.0) + { Weight = 7.0; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Shields/OrderShield.cs b/Projects/UOContent/Items/Shields/OrderShield.cs index 2eb290196..8d0675872 100644 --- a/Projects/UOContent/Items/Shields/OrderShield.cs +++ b/Projects/UOContent/Items/Shields/OrderShield.cs @@ -8,7 +8,9 @@ namespace Server.Items public OrderShield() : base(0x1BC4) { if (!Core.AOS) + { LootType = LootType.Newbied; + } Weight = 7.0; } @@ -37,7 +39,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 6.0) + { Weight = 7.0; + } } public override void Serialize(IGenericWriter writer) @@ -52,13 +56,17 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (Validate(Parent as Mobile)) - base.OnSingleClick(from); + { + base.OnSingleClick(@from); + } } public virtual bool Validate(Mobile m) { if (Core.AOS || m?.Player != true || m.AccessLevel != AccessLevel.Player) + { return true; + } if (!(m.Guild is Guild g) || g.Type != GuildType.Order) { diff --git a/Projects/UOContent/Items/Shields/WoodenKiteShield.cs b/Projects/UOContent/Items/Shields/WoodenKiteShield.cs index 7c9cc1a5c..16309a8ac 100644 --- a/Projects/UOContent/Items/Shields/WoodenKiteShield.cs +++ b/Projects/UOContent/Items/Shields/WoodenKiteShield.cs @@ -29,7 +29,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 7.0) + { Weight = 5.0; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Blacksmith Items/Misc/LargeForge.cs b/Projects/UOContent/Items/Skill Items/Blacksmith Items/Misc/LargeForge.cs index 8a7bc92b8..5bb6ea9fb 100644 --- a/Projects/UOContent/Items/Skill Items/Blacksmith Items/Misc/LargeForge.cs +++ b/Projects/UOContent/Items/Skill Items/Blacksmith Items/Misc/LargeForge.cs @@ -24,17 +24,27 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y + 1, Z); + } + if (m_Item2 != null) + { m_Item2.Location = new Point3D(X, Y + 2, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } + if (m_Item2 != null) + { m_Item2.Map = Map; + } } public override void OnAfterDelete() @@ -84,13 +94,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 1, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -138,13 +152,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X, Y - 2, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -196,17 +214,27 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X + 1, Y, Z); + } + if (m_Item2 != null) + { m_Item2.Location = new Point3D(X + 2, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } + if (m_Item2 != null) + { m_Item2.Map = Map; + } } public override void OnAfterDelete() @@ -256,13 +284,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 1, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() @@ -310,13 +342,17 @@ namespace Server.Items public override void OnLocationChange(Point3D oldLocation) { if (m_Item != null) + { m_Item.Location = new Point3D(X - 2, Y, Z); + } } public override void OnMapChange() { if (m_Item != null) + { m_Item.Map = Map; + } } public override void OnAfterDelete() diff --git a/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs b/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs index 15bdd89ad..f60437ba0 100644 --- a/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs +++ b/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs @@ -18,7 +18,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Parent != null || !VerifyMove(from)) + { return; + } if (!from.InRange(this, 2)) { @@ -31,9 +33,13 @@ namespace Server.Items var dir = PlayerMobile.GetDirection4(from.Location, Location); if (dir == Direction.North || dir == Direction.South) + { ItemID = 0xA55; + } else + { ItemID = 0xA56; + } } else // unrolled { @@ -44,7 +50,9 @@ namespace Server.Items var entry = Campfire.GetEntry(from); if (entry?.Safe == true) - from.SendGump(new LogoutGump(entry, this)); + { + @from.SendGump(new LogoutGump(entry, this)); + } } } } @@ -103,7 +111,9 @@ namespace Server.Items m_CloseTimer.Stop(); if (Campfire.GetEntry(pm) != m_Entry) + { return; + } if (info.ButtonID == 1 && m_Entry.Safe && m_Bedroll.Parent == null && m_Bedroll.IsAccessibleTo(pm) && m_Bedroll.VerifyMove(pm) && m_Bedroll.Map == pm.Map && pm.InRange(m_Bedroll, 2)) diff --git a/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs b/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs index d39684feb..447660288 100644 --- a/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs +++ b/Projects/UOContent/Items/Skill Items/Camping/Campfire.cs @@ -55,7 +55,9 @@ namespace Server.Items set { if (Status == value) + { return; + } switch (value) { @@ -96,16 +98,25 @@ namespace Server.Items var age = now - Created; if (age >= TimeSpan.FromSeconds(100.0)) + { Delete(); + } else if (age >= TimeSpan.FromSeconds(90.0)) + { Status = CampfireStatus.Off; + } else if (age >= TimeSpan.FromSeconds(60.0)) + { Status = CampfireStatus.Extinguishing; + } if (Status == CampfireStatus.Off || Deleted) + { return; + } foreach (var entry in m_Entries.ToList()) + { if (!entry.Valid || entry.Player.NetState == null) { RemoveEntry(entry); @@ -115,10 +126,12 @@ namespace Server.Items entry.Safe = true; entry.Player.SendLocalizedMessage(500621); // The camp is now secure. } + } var eable = GetClientsInRange(SecureRange); foreach (var state in eable) + { if (state.Mobile is PlayerMobile pm && GetEntry(pm) == null) { var entry = new CampfireEntry(pm, this); @@ -128,6 +141,7 @@ namespace Server.Items pm.SendLocalizedMessage(500620); // You feel it would take a few moments to secure your camp. } + } eable.Free(); } @@ -135,10 +149,14 @@ namespace Server.Items private void ClearEntries() { if (m_Entries == null) + { return; + } foreach (var entry in m_Entries.ToList()) + { RemoveEntry(entry); + } } public override void OnAfterDelete() diff --git a/Projects/UOContent/Items/Skill Items/Camping/Kindling.cs b/Projects/UOContent/Items/Skill Items/Camping/Kindling.cs index a3d6454b4..5aebc39d4 100644 --- a/Projects/UOContent/Items/Skill Items/Camping/Kindling.cs +++ b/Projects/UOContent/Items/Skill Items/Camping/Kindling.cs @@ -35,7 +35,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!VerifyMove(from)) + { return; + } if (!from.InRange(GetWorldLocation(), 2)) { @@ -58,7 +60,9 @@ namespace Server.Items Consume(); if (!Deleted && Parent == null) - from.PlaceInBackpack(this); + { + @from.PlaceInBackpack(this); + } new Campfire().MoveToWorld(fireLocation, from.Map); } @@ -67,10 +71,14 @@ namespace Server.Items private Point3D GetFireLocation(Mobile from) { if (from.Region.IsPartOf()) + { return Point3D.Zero; + } if (Parent == null) + { return Location; + } var list = new List(4); @@ -80,7 +88,9 @@ namespace Server.Items AddOffsetLocation(from, 1, 0, list); if (list.Count == 0) + { return Point3D.Zero; + } return list.RandomElement(); } @@ -103,7 +113,9 @@ namespace Server.Items loc = new Point3D(x, y, map.GetAverageZ(x, y)); if (map.CanFit(loc, 1) && from.InLOS(loc)) + { list.Add(loc); + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Carpenter Items/Board.cs b/Projects/UOContent/Items/Skill Items/Carpenter Items/Board.cs index 3dede79ee..2eac48b20 100644 --- a/Projects/UOContent/Items/Skill Items/Carpenter Items/Board.cs +++ b/Projects/UOContent/Items/Skill Items/Carpenter Items/Board.cs @@ -43,7 +43,9 @@ namespace Server.Items get { if (m_Resource >= CraftResource.OakWood && m_Resource <= CraftResource.YewWood) + { return 1075052 + ((int)m_Resource - (int)CraftResource.OakWood); + } return m_Resource switch { @@ -66,9 +68,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } @@ -98,10 +104,14 @@ namespace Server.Items } if (version == 0 && Weight == 0.1 || version <= 2 && Weight == 2) + { Weight = -1; + } if (version <= 1) + { m_Resource = CraftResource.RegularWood; + } } } diff --git a/Projects/UOContent/Items/Skill Items/Carpenter Items/TaxidermyKit.cs b/Projects/UOContent/Items/Skill Items/Carpenter Items/TaxidermyKit.cs index b010c1bc0..6fecf07f7 100644 --- a/Projects/UOContent/Items/Skill Items/Carpenter Items/TaxidermyKit.cs +++ b/Projects/UOContent/Items/Skill Items/Carpenter Items/TaxidermyKit.cs @@ -87,7 +87,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Kit.Deleted) + { return; + } var corpse = targeted as Corpse; @@ -114,7 +116,9 @@ namespace Server.Items foreach (var t in m_Table) { if (t.CreatureType != obj.GetType()) + { continue; + } var pack = from.Backpack; @@ -139,7 +143,9 @@ namespace Server.Items from.AddToBackpack(new TrophyDeed(t, hunter, weight)); if (corpse != null) + { corpse.VisitedByTaxidermist = true; + } m_Kit.Delete(); return; @@ -233,10 +239,15 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (!map.CanFit(p.X, p.Y, p.Z, ItemData.Height)) + { return false; + } if (ItemID == NorthID) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // North wall + } + return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // West wall } @@ -249,7 +260,9 @@ namespace Server.Items if (m_AnimalWeight >= 20) { if (m_Hunter != null) + { list.Add(1070857, m_Hunter.Name); // Caught by ~1_fisherman~ + } list.Add(1070858, m_AnimalWeight.ToString()); // ~1_weight~ stones } @@ -300,7 +313,9 @@ namespace Server.Items private void FixMovingCrate() { if (Deleted) + { return; + } if (Movable || IsLockedDown) { @@ -420,7 +435,9 @@ namespace Server.Items if (m_AnimalWeight >= 20) { if (m_Hunter != null) + { list.Add(1070857, m_Hunter.Name); // Caught by ~1_fisherman~ + } list.Add(1070858, m_AnimalWeight.ToString()); // ~1_weight~ stones } @@ -478,7 +495,8 @@ namespace Server.Items var westWall = BaseAddon.IsWall(from.X - 1, from.Y, from.Z, from.Map); if (northWall && westWall) - switch (from.Direction & Direction.Mask) + { + switch (@from.Direction & Direction.Mask) { case Direction.North: case Direction.South: @@ -491,18 +509,25 @@ namespace Server.Items break; default: - from.SendMessage("Turn to face the wall on which to hang this trophy."); + @from.SendMessage("Turn to face the wall on which to hang this trophy."); return; } + } var itemID = 0; if (northWall) + { itemID = NorthID; + } else if (westWall) + { itemID = WestID; + } else - from.SendLocalizedMessage(1042626); // The trophy must be placed next to a wall. + { + @from.SendLocalizedMessage(1042626); // The trophy must be placed next to a wall. + } if (itemID > 0) { diff --git a/Projects/UOContent/Items/Skill Items/Fishing/FishingPole.cs b/Projects/UOContent/Items/Skill Items/Fishing/FishingPole.cs index 391dee5e2..a12ce0b42 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/FishingPole.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/FishingPole.cs @@ -23,9 +23,13 @@ namespace Server.Items var loc = GetWorldLocation(); if (!from.InLOS(loc) || !from.InRange(loc, 2)) - from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1019045); // I can't reach that + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1019045); // I can't reach that + } else - Fishing.System.BeginHarvesting(from, this); + { + Fishing.System.BeginHarvesting(@from, this); + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -38,7 +42,9 @@ namespace Server.Items public override bool CheckConflictingLayer(Mobile m, Item item, Layer layer) { if (base.CheckConflictingLayer(m, item, layer)) + { return true; + } if (layer == Layer.OneHanded) { @@ -63,7 +69,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1 && Layer == Layer.OneHanded) + { Layer = Layer.TwoHanded; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/MessageInABottle.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/MessageInABottle.cs index 228cbb160..9e4d5f050 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/MessageInABottle.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/MessageInABottle.cs @@ -39,7 +39,9 @@ namespace Server.Items public static int GetRandomLevel() { if (Core.AOS && Utility.Random(25) < 1) + { return 4; // ancient + } return Utility.RandomMinMax(1, 3); } @@ -82,10 +84,14 @@ namespace Server.Items } if (version < 2) + { m_Level = GetRandomLevel(); + } if (version < 3 && TargetMap == Map.Tokuno) + { TargetMap = Map.Trammel; + } } public override void OnDoubleClick(Mobile from) diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs index b744654c3..4c835c10d 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs @@ -48,7 +48,9 @@ namespace Server.Items get { if (IsAncient) + { return 1063450; // an ancient SOS + } return 1041081; // a waterstained SOS } @@ -81,9 +83,13 @@ namespace Server.Items public void UpdateHue() { if (IsAncient) + { Hue = 0x481; + } else + { Hue = 0; + } } public override void Serialize(IGenericWriter writer) @@ -127,7 +133,9 @@ namespace Server.Items TargetMap = Map; if (TargetMap == null || TargetMap == Map.Internal) + { TargetMap = Map.Trammel; + } TargetLocation = FindLocation(TargetMap); MessageIndex = Utility.Random(MessageEntry.Entries.Length); @@ -137,13 +145,19 @@ namespace Server.Items } if (version < 2) + { m_Level = MessageInABottle.GetRandomLevel(); + } if (version < 3) + { UpdateHue(); + } if (version < 4 && TargetMap == Map.Tokuno) + { TargetMap = Map.Trammel; + } } public override void OnDoubleClick(Mobile from) @@ -153,9 +167,13 @@ namespace Server.Items MessageEntry entry; if (MessageIndex >= 0 && MessageIndex < MessageEntry.Entries.Length) + { entry = MessageEntry.Entries[MessageIndex]; + } else + { entry = MessageEntry.Entries[MessageIndex = Utility.Random(MessageEntry.Entries.Length)]; + } // from.CloseGump( typeof( MessageGump ) ); from.SendGump(new MessageGump(entry, TargetMap, TargetLocation)); @@ -169,21 +187,33 @@ namespace Server.Items public static Point3D FindLocation(Map map) { if (map == null || map == Map.Internal) + { return Point3D.Zero; + } Rectangle2D[] regions; if (map == Map.Felucca || map == Map.Trammel) + { regions = m_BritRegions; + } else if (map == Map.Ilshenar) + { regions = m_IlshRegions; + } else if (map == Map.Malas) + { regions = m_MalasRegions; + } else + { regions = new[] { new Rectangle2D(0, 0, map.Width, map.Height) }; + } if (regions.Length == 0) + { return Point3D.Zero; + } for (var i = 0; i < 50; ++i) { @@ -192,22 +222,36 @@ namespace Server.Items var y = Utility.Random(reg.Y, reg.Height); if (!ValidateDeepWater(map, x, y)) + { continue; + } var valid = true; for (int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5) + { if (!ValidateDeepWater(map, x + offset, y + offset)) + { valid = false; + } else if (!ValidateDeepWater(map, x + offset, y - offset)) + { valid = false; + } else if (!ValidateDeepWater(map, x - offset, y + offset)) + { valid = false; + } else if (!ValidateDeepWater(map, x - offset, y - offset)) + { valid = false; + } + } if (valid) + { return new Point3D(x, y, 0); + } } return Point3D.Zero; @@ -219,7 +263,9 @@ namespace Server.Items var water = false; for (var i = 0; !water && i < m_WaterTiles.Length; i += 2) + { water = tileID >= m_WaterTiles[i] && tileID <= m_WaterTiles[i + 1]; + } return water; } @@ -234,9 +280,13 @@ namespace Server.Items string fmt; if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth)) + { fmt = $"{yLat}°{yMins}'{(ySouth ? "S" : "N")},{xLong}°{xMins}'{(xEast ? "E" : "W")}"; + } else + { fmt = "?????"; + } AddPage(0); diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs index 6bf027831..4302ea80c 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs @@ -83,32 +83,48 @@ namespace Server.Items public static Point3D ReverseLookup(Map map, int xLong, int yLat, int xMins, int yMins, bool xEast, bool ySouth) { if (map == null || map == Map.Internal) + { return Point3D.Zero; + } if (!ComputeMapDetails(map, 0, 0, out var xCenter, out var yCenter, out var xWidth, out var yHeight)) + { return Point3D.Zero; + } var absLong = xLong + (double)xMins / 60; var absLat = yLat + (double)yMins / 60; if (!xEast) + { absLong = 360.0 - absLong; + } if (!ySouth) + { absLat = 360.0 - absLat; + } var x = xCenter + (int)(absLong * xWidth / 360); var y = yCenter + (int)(absLat * yHeight / 360); if (x < 0) + { x += xWidth; + } else if (x >= xWidth) + { x -= xWidth; + } if (y < 0) + { y += yHeight; + } else if (y >= yHeight) + { y -= yHeight; + } var z = map.GetAverageZ(x, y); @@ -121,29 +137,41 @@ namespace Server.Items ) { if (map == null || map == Map.Internal) + { return false; + } int x = p.X, y = p.Y; if (!ComputeMapDetails(map, x, y, out var xCenter, out var yCenter, out var xWidth, out var yHeight)) + { return false; + } var absLong = (double)((x - xCenter) * 360) / xWidth; var absLat = (double)((y - yCenter) * 360) / yHeight; if (absLong > 180.0) + { absLong = -180.0 + absLong % 180.0; + } if (absLat > 180.0) + { absLat = -180.0 + absLat % 180.0; + } bool east = absLong >= 0, south = absLat >= 0; if (absLong < 0.0) + { absLong = -absLong; + } if (absLat < 0.0) + { absLat = -absLat; + } xLong = (int)absLong; yLat = (int)absLat; diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs index ab255f22d..b848e9070 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs @@ -12,7 +12,9 @@ namespace Server.Items var weight = ItemData.Weight; if (weight >= 255) + { weight = 1; + } Weight = weight; } @@ -24,7 +26,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } if (ItemID >= 0x13A4 && ItemID <= 0x13AE) { diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs index d5555df45..f00a8f21e 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs @@ -43,9 +43,13 @@ namespace Server.Items Weight = 1.0; if (Utility.RandomDouble() < 0.01) + { Hue = m_Hues.RandomElement(); + } else + { Hue = 0x8A0; + } } public SpecialFishingNet(Serial serial) : base(serial) @@ -94,7 +98,9 @@ namespace Server.Items InUse = reader.ReadBool(); if (InUse) + { Delete(); + } break; } @@ -123,15 +129,21 @@ namespace Server.Items public void OnTarget(Mobile from, object obj) { if (Deleted || InUse) + { return; + } if (!(obj is IPoint3D p3D)) + { return; + } var map = from.Map; if (map == null || map == Map.Internal) + { return; + } int x = p3D.X, y = p3D.Y, z = map.GetAverageZ(x, y); // OSI just takes the targeted Z @@ -150,8 +162,12 @@ namespace Server.Items var p = new Point3D(x, y, z); if (GetType() == typeof(SpecialFishingNet)) + { for (var i = 1; i < Amount; ++i) // these were stackable before, doh - from.AddToBackpack(new SpecialFishingNet()); + { + @from.AddToBackpack(new SpecialFishingNet()); + } + } InUse = true; Movable = false; @@ -191,7 +207,9 @@ namespace Server.Items private void DoEffect(Mobile from, Point3D p, int index) { if (Deleted) + { return; + } if (index == 1) { @@ -201,6 +219,7 @@ namespace Server.Items else if (index <= 7 || index == 14) { if (RequireDeepWater) + { for (var i = 0; i < 3; ++i) { int x, y; @@ -244,16 +263,25 @@ namespace Server.Items Effects.SendLocationEffect(new Point3D(p.X + x, p.Y + y, p.Z), Map, 0x352D, 16, 4); } + } else + { Effects.SendLocationEffect(p, Map, 0x352D, 16, 4); + } if (Utility.RandomBool()) + { Effects.PlaySound(p, Map, 0x364); + } if (index == 14) - FinishEffect(p, Map, from); + { + FinishEffect(p, Map, @from); + } else + { Z -= 1; + } } } @@ -262,7 +290,9 @@ namespace Server.Items var count = Utility.RandomMinMax(1, 3); if (Hue != 0x8A0) + { count += Utility.RandomMinMax(1, 2); + } return count; } @@ -296,7 +326,9 @@ namespace Server.Items spawn.MoveToWorld(new Point3D(x, y, p.Z), map); if (spawn is Kraken && Utility.RandomDouble() < 0.2) + { spawn.PackItem(new MessageInABottle(map == Map.Felucca ? Map.Felucca : Map.Trammel)); + } } protected virtual void FinishEffect(Point3D p, Map map, Mobile from) @@ -329,14 +361,24 @@ namespace Server.Items var valid = ValidateDeepWater(map, x, y); for (int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5) + { if (!ValidateDeepWater(map, x + offset, y + offset)) + { valid = false; + } else if (!ValidateDeepWater(map, x + offset, y - offset)) + { valid = false; + } else if (!ValidateDeepWater(map, x - offset, y + offset)) + { valid = false; + } else if (!ValidateDeepWater(map, x - offset, y - offset)) + { valid = false; + } + } return valid; } @@ -347,7 +389,9 @@ namespace Server.Items var water = false; for (var i = 0; !water && i < m_WaterTiles.Length; i += 2) + { water = tileID >= m_WaterTiles[i] && tileID <= m_WaterTiles[i + 1]; + } return water; } @@ -355,21 +399,27 @@ namespace Server.Items private static bool ValidateUndeepWater(Map map, object obj, ref int z) { if (!(obj is StaticTarget)) + { return false; + } var target = (StaticTarget)obj; if (BaseHouse.FindHouseAt(target.Location, map, 0) != null) + { return false; + } var itemID = target.ItemID; for (var i = 0; i < m_UndeepWaterTiles.Length; i += 2) + { if (itemID >= m_UndeepWaterTiles[i] && itemID <= m_UndeepWaterTiles[i + 1]) { z = target.Z; return true; } + } return false; } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs index 18fbcf58c..f8bff4064 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs @@ -64,7 +64,9 @@ namespace Server.Items Quality = (ToolQuality)quality; if (makersMark) - Crafter = from; + { + Crafter = @from; + } return quality; } @@ -100,7 +102,9 @@ namespace Server.Items public int GetUsesScalar() { if (m_Quality == ToolQuality.Exceptional) + { return 200; + } return 100; } @@ -114,7 +118,9 @@ namespace Server.Items // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ if (m_Quality == ToolQuality.Exceptional) + { list.Add(1060636); // exceptional + } list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ } @@ -134,9 +140,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack) || Parent == from) - HarvestSystem.BeginHarvesting(from, this); + { + HarvestSystem.BeginHarvesting(@from, this); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -149,13 +159,19 @@ namespace Server.Items public static void AddContextMenuEntries(Mobile from, Item item, List list, HarvestSystem system) { if (system != Mining.System) + { return; + } if (!item.IsChildOf(from.Backpack) && item.Parent != from) + { return; + } if (!(from is PlayerMobile pm)) + { return; + } var miningEntry = new ContextMenuEntry(pm.ToggleMiningStone ? 6179 : 6178); miningEntry.Color = 0x421F; @@ -212,7 +228,9 @@ namespace Server.Items var stoneMining = mobile.StoneMining && mobile.Skills.Mining.Base >= 100.0; if (mobile.ToggleMiningStone == value || value && !stoneMining) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs index fe405c4db..bf4efee97 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/GargoylesPickaxe.cs @@ -57,7 +57,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 0x973) + { Hue = 0x0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs index 8406445c7..d059f52b3 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/ProspectorsTool.cs @@ -54,9 +54,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack) || Parent == from) - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } public void Prospect(Mobile from, object toProspect) diff --git a/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs b/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs index 423aedb23..6400d84d5 100644 --- a/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs +++ b/Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs @@ -46,7 +46,9 @@ namespace Server.Items public virtual bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 0, new Board())) + { return false; + } return true; } @@ -66,9 +68,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(m_Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(m_Resource)); + } } } @@ -97,13 +103,18 @@ namespace Server.Items } if (version == 0) + { m_Resource = CraftResource.RegularWood; + } } public virtual bool TryCreateBoards(Mobile from, double skill, Item item) { if (Deleted || !from.CanSee(this)) + { return false; + } + if (from.Skills.Carpentry.Value < skill && from.Skills.Lumberjacking.Value < skill) { @@ -146,7 +157,9 @@ namespace Server.Items public override bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 100, new HeartwoodBoard())) + { return false; + } return true; } @@ -182,7 +195,9 @@ namespace Server.Items public override bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 100, new BloodwoodBoard())) + { return false; + } return true; } @@ -218,7 +233,9 @@ namespace Server.Items public override bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 100, new FrostwoodBoard())) + { return false; + } return true; } @@ -254,7 +271,9 @@ namespace Server.Items public override bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 65, new OakBoard())) + { return false; + } return true; } @@ -290,7 +309,9 @@ namespace Server.Items public override bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 80, new AshBoard())) + { return false; + } return true; } @@ -326,7 +347,9 @@ namespace Server.Items public override bool Axe(Mobile from, BaseAxe axe) { if (!TryCreateBoards(from, 95, new YewBoard())) + { return false; + } return true; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/BookOfBushido.cs b/Projects/UOContent/Items/Skill Items/Magical/BookOfBushido.cs index 6256ab228..83348f2ea 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/BookOfBushido.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/BookOfBushido.cs @@ -28,7 +28,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Core.ML) + { Layer = Layer.OneHanded; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/BookOfChivalry.cs b/Projects/UOContent/Items/Skill Items/Magical/BookOfChivalry.cs index 652d61caa..984ded43e 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/BookOfChivalry.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/BookOfChivalry.cs @@ -28,7 +28,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Core.ML) + { Layer = Layer.OneHanded; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/BookOfNinjitsu.cs b/Projects/UOContent/Items/Skill Items/Magical/BookOfNinjitsu.cs index 7cac60f36..aaae744f7 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/BookOfNinjitsu.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/BookOfNinjitsu.cs @@ -28,7 +28,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Core.ML) + { Layer = Layer.OneHanded; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs index 68942521b..f373def87 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/Moongate.cs @@ -45,18 +45,26 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.Player) + { return; + } if (from.InRange(GetWorldLocation(), 1)) - CheckGate(from, 1); + { + CheckGate(@from, 1); + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } public override bool OnMoveOver(Mobile m) { if (m.Player) + { CheckGate(m, 0); + } return true; } @@ -64,7 +72,9 @@ namespace Server.Items public virtual void CheckGate(Mobile m, int range) { if (m.Hidden && m.AccessLevel == AccessLevel.Player && Core.ML) + { m.RevealingAction(); + } new DelayTimer(m, this, range).Start(); } @@ -103,7 +113,9 @@ namespace Server.Items m.MoveToWorld(Target, TargetMap); if (m.AccessLevel == AccessLevel.Player || !m.Hidden) + { m.PlaySound(0x1FE); + } OnGateUsed(m); } @@ -136,18 +148,24 @@ namespace Server.Items TargetMap = reader.ReadMap(); if (version >= 1) + { Dispellable = reader.ReadBool(); + } } public virtual bool ValidateUse(Mobile from, bool message) { if (from.Deleted || Deleted) + { return false; + } if (from.Map != Map || !from.InRange(this, 1)) { if (message) - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } return false; } @@ -161,7 +179,10 @@ namespace Server.Items from.Map != Map.Felucca && TargetMap == Map.Felucca && ShowFeluccaWarning) { if (from.AccessLevel == AccessLevel.Player || !from.Hidden) - from.Send(new PlaySound(0x20E, from.Location)); + { + @from.Send(new PlaySound(0x20E, @from.Location)); + } + from.CloseGump(); from.SendGump(new MoongateConfirmGump(from, this)); } @@ -174,7 +195,9 @@ namespace Server.Items public virtual void EndConfirmation(Mobile from) { if (!ValidateUse(from, true)) + { return; + } UseGate(from); } @@ -182,12 +205,18 @@ namespace Server.Items public virtual void DelayCallback(Mobile from, int range) { if (!ValidateUse(from, false) || !from.InRange(this, range)) + { return; + } if (TargetMap != null) - BeginConfirmation(from); + { + BeginConfirmation(@from); + } else - from.SendMessage("This moongate does not seem to go anywhere."); + { + @from.SendMessage("This moongate does not seem to go anywhere."); + } } public static bool IsInTown(Point3D p, Map map) => @@ -253,7 +282,9 @@ namespace Server.Items public virtual void Warning_Callback(Mobile from, bool okay) { if (okay) - EndConfirmation(from); + { + EndConfirmation(@from); + } } public override void BeginConfirmation(Mobile from) @@ -351,6 +382,7 @@ namespace Server.Items AddAlphaRegion(10, 40, 400, 200); if (from.Map != Map.Felucca && gate.TargetMap == Map.Felucca && gate.ShowFeluccaWarning) + { AddHtmlLocalized( 10, 40, @@ -361,7 +393,9 @@ namespace Server.Items false, true ); // This Gate goes to Felucca... Continue to enter the gate, Cancel to stay here + } else + { AddHtmlLocalized( 10, 40, @@ -372,6 +406,7 @@ namespace Server.Items false, true ); // Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here + } AddImageTiled(10, 250, 400, 20, 2624); AddAlphaRegion(10, 250, 400, 20); @@ -408,7 +443,9 @@ namespace Server.Items public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1) + { m_Gate.EndConfirmation(m_From); + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs index 5a728530f..eb18ef030 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs @@ -49,7 +49,9 @@ namespace Server.Items get { if (m_Held > 0 && (int)m_Type >= (int)PotionEffect.Conflagration) + { return 1072658 + (int)m_Type - (int)PotionEffect.Conflagration; + } return m_Held > 0 ? 1041620 + (int)m_Type : 1041641; } @@ -91,7 +93,9 @@ namespace Server.Items } if (version < 1) + { Timer.DelayCall(UpdateWeight); + } } public override void GetProperties(ObjectPropertyList list) @@ -101,29 +105,53 @@ namespace Server.Items int number; if (m_Held <= 0) + { number = 502246; // The keg is empty. + } else if (m_Held < 5) + { number = 502248; // The keg is nearly empty. + } else if (m_Held < 20) + { number = 502249; // The keg is not very full. + } else if (m_Held < 30) + { number = 502250; // The keg is about one quarter full. + } else if (m_Held < 40) + { number = 502251; // The keg is about one third full. + } else if (m_Held < 47) + { number = 502252; // The keg is almost half full. + } else if (m_Held < 54) + { number = 502254; // The keg is approximately half full. + } else if (m_Held < 70) + { number = 502253; // The keg is more than half full. + } else if (m_Held < 80) + { number = 502255; // The keg is about three quarters full. + } else if (m_Held < 96) + { number = 502256; // The keg is very full. + } else if (m_Held < 100) + { number = 502257; // The liquid is almost to the top of the keg. + } else + { number = 502258; // The keg is completely full. + } list.Add(number); } @@ -135,29 +163,53 @@ namespace Server.Items int number; if (m_Held <= 0) + { number = 502246; // The keg is empty. + } else if (m_Held < 5) + { number = 502248; // The keg is nearly empty. + } else if (m_Held < 20) + { number = 502249; // The keg is not very full. + } else if (m_Held < 30) + { number = 502250; // The keg is about one quarter full. + } else if (m_Held < 40) + { number = 502251; // The keg is about one third full. + } else if (m_Held < 47) + { number = 502252; // The keg is almost half full. + } else if (m_Held < 54) + { number = 502254; // The keg is approximately half full. + } else if (m_Held < 70) + { number = 502253; // The keg is more than half full. + } else if (m_Held < 80) + { number = 502255; // The keg is about three quarters full. + } else if (m_Held < 96) + { number = 502256; // The keg is very full. + } else if (m_Held < 100) + { number = 502257; // The liquid is almost to the top of the keg. + } else + { number = 502258; // The keg is completely full. + } LabelTo(from, number); } @@ -182,7 +234,9 @@ namespace Server.Items from.PlaySound(0x240); if (--Held == 0) - from.SendLocalizedMessage(502245); // The keg is now empty. + { + @from.SendLocalizedMessage(502245); // The keg is now empty. + } } else { @@ -238,7 +292,9 @@ namespace Server.Items pot.Consume(toHold); if (!pot.Deleted) - pot.Bounce(from); + { + pot.Bounce(@from); + } return true; } @@ -266,7 +322,9 @@ namespace Server.Items pot.Consume(toHold); if (!pot.Deleted) - pot.Bounce(from); + { + pot.Bounce(@from); + } return true; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs index ba4bc469a..4a76a96b2 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/RecallRune.cs @@ -30,7 +30,9 @@ namespace Server.Items get { if (m_House?.Deleted == true) + { House = null; + } return m_House; } @@ -137,17 +139,29 @@ namespace Server.Items private void CalculateHue() { if (!m_Marked) + { Hue = 0; + } else if (m_TargetMap == Map.Trammel) + { Hue = House != null ? 0x47F : 50; + } else if (m_TargetMap == Map.Felucca) + { Hue = House != null ? 0x66D : 0; + } else if (m_TargetMap == Map.Ilshenar) + { Hue = House != null ? 0x55F : 1102; + } else if (m_TargetMap == Map.Malas) + { Hue = House != null ? 0x55F : 1102; + } else if (m_TargetMap == Map.Tokuno) + { Hue = House != null ? 0x47F : 1154; + } } public void Mark(Mobile m) @@ -179,7 +193,9 @@ namespace Server.Items var map = m_House.Map; if (map?.CanFit(x, y, z, 16, false, false) == false) + { z = map.GetAverageZ(x, y); + } Target = new Point3D(x, y, z); m_TargetMap = map; @@ -193,7 +209,9 @@ namespace Server.Items } if (!setDesc) + { m_Description = BaseRegion.GetRuneNameFor(Region.Find(Target, m_TargetMap)); + } CalculateHue(); InvalidateProperties(); @@ -208,18 +226,30 @@ namespace Server.Items string desc; if ((desc = m_Description) == null || (desc = desc.Trim()).Length == 0) + { desc = "an unknown location"; + } if (m_TargetMap == Map.Tokuno) + { list.Add(House != null ? 1063260 : 1063259, RuneFormat, desc); // ~1_val~ (Tokuno Islands)[(House)] + } else if (m_TargetMap == Map.Malas) + { list.Add(House != null ? 1062454 : 1060804, RuneFormat, desc); // ~1_val~ (Malas)[(House)] + } else if (m_TargetMap == Map.Felucca) + { list.Add(House != null ? 1062452 : 1060805, RuneFormat, desc); // ~1_val~ (Felucca)[(House)] + } else if (m_TargetMap == Map.Trammel) + { list.Add(House != null ? 1062453 : 1060806, RuneFormat, desc); // ~1_val~ (Trammel)[(House)] + } else + { list.Add(House != null ? "{0} ({1})(House)" : "{0} ({1})", string.Format(RuneFormat, desc), m_TargetMap); + } } } @@ -230,36 +260,46 @@ namespace Server.Items var desc = m_Description?.Trim().IsNullOrDefault("an unknown location"); if (m_TargetMap == Map.Tokuno) + { LabelTo( - from, + @from, House != null ? 1063260 : 1063259, string.Format(RuneFormat, desc) ); // ~1_val~ (Tokuno Islands)[(House)] + } else if (m_TargetMap == Map.Malas) + { LabelTo( - from, + @from, House != null ? 1062454 : 1060804, string.Format(RuneFormat, desc) ); // ~1_val~ (Malas)[(House)] + } else if (m_TargetMap == Map.Felucca) + { LabelTo( - from, + @from, House != null ? 1062452 : 1060805, string.Format(RuneFormat, desc) ); // ~1_val~ (Felucca)[(House)] + } else if (m_TargetMap == Map.Trammel) + { LabelTo( - from, + @from, House != null ? 1062453 : 1060806, string.Format(RuneFormat, desc) ); // ~1_val~ (Trammel)[(House)] + } else + { LabelTo( - from, + @from, House != null ? "{0} ({1})(House)" : "{0} ({1})", string.Format(RuneFormat, desc), m_TargetMap ); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Magical/NecromancerSpellbook.cs b/Projects/UOContent/Items/Skill Items/Magical/NecromancerSpellbook.cs index 0db4ebc43..d7ce5604e 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/NecromancerSpellbook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/NecromancerSpellbook.cs @@ -28,7 +28,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Core.ML) + { Layer = Layer.OneHanded; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs index 4b31fe2d5..d60fb1d83 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs @@ -52,7 +52,9 @@ namespace Server.Items PlayDrinkEffect(from); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs index 09f6439f5..bf3a5bc6c 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs @@ -83,7 +83,9 @@ namespace Server.Items if (pack != null) { if ((int)PotionEffect >= (int)PotionEffect.Invisibility) + { return 1; + } var kegs = pack.FindItemsByType(); @@ -96,10 +98,14 @@ namespace Server.Items // continue; if (keg.Held <= 0 || keg.Held >= 100) + { continue; + } if (keg.Type != PotionEffect) + { continue; + } ++keg.Held; @@ -120,10 +126,14 @@ namespace Server.Items var handTwo = m.FindItemOnLayer(Layer.TwoHanded); if (handTwo is BaseWeapon) + { handOne = handTwo; + } if (handTwo is BaseRanged ranged && ranged.Balanced) + { return true; + } return handOne == null || handTwo == null; } @@ -131,7 +141,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!Movable) + { return; + } if (from.InRange(GetWorldLocation(), 1)) { @@ -144,9 +156,14 @@ namespace Server.Items Amount--; if (from.Backpack?.Deleted != false) - from.Backpack.DropItem(pot); + { + @from.Backpack.DropItem(pot); + } else - pot.MoveToWorld(from.Location, from.Map); + { + pot.MoveToWorld(@from.Location, @from.Map); + } + pot.Drink(from); } else @@ -191,7 +208,9 @@ namespace Server.Items } if (version == 0) + { Stackable = Core.ML; + } } public abstract void Drink(Mobile from); @@ -203,10 +222,14 @@ namespace Server.Items m.PlaySound(0x2D6); if (!DuelContext.IsFreeConsume(m)) + { m.AddToBackpack(new Bottle()); + } if (m.Body.IsHuman && !m.Mounted) + { m.Animate(34, 5, 1, true, false, 0); + } } public static int EnhancePotions(Mobile m) @@ -215,7 +238,9 @@ namespace Server.Items var skillBonus = m.Skills.Alchemy.Fixed / 330 * 10; if (Core.ML && EP > 50 && m.AccessLevel <= AccessLevel.Player) + { EP = 50; + } return EP + skillBonus; } @@ -223,7 +248,9 @@ namespace Server.Items public static TimeSpan Scale(Mobile m, TimeSpan v) { if (!Core.AOS) + { return v; + } var scalar = 1.0 + 0.01 * EnhancePotions(m); @@ -233,7 +260,9 @@ namespace Server.Items public static double Scale(Mobile m, double v) { if (!Core.AOS) + { return v; + } var scalar = 1.0 + 0.01 * EnhancePotions(m); @@ -243,7 +272,9 @@ namespace Server.Items public static int Scale(Mobile m, int v) { if (!Core.AOS) + { return v; + } return AOS.Scale(v, 100 + EnhancePotions(m)); } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs index b54790352..e09425319 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs @@ -41,12 +41,16 @@ namespace Server.Items } if (from.Target is ThrowTarget targ && targ.Potion == this) + { return; + } from.RevealingAction(); if (!m_Users.Contains(from)) - m_Users.Add(from); + { + m_Users.Add(@from); + } from.Target = new ThrowTarget(this); } @@ -68,26 +72,36 @@ namespace Server.Items public virtual void Explode(Mobile from, Point3D loc, Map map) { if (Deleted || map == null) + { return; + } Consume(); // Check if any other players are using this potion for (var i = 0; i < m_Users.Count; i++) + { if (m_Users[i].Target is ThrowTarget targ && targ.Potion == this) - Target.Cancel(from); + { + Target.Cancel(@from); + } + } // Effects Effects.PlaySound(loc, map, 0x20C); for (var i = -2; i <= 2; i++) + { for (var j = -2; j <= 2; j++) { var p = new Point3D(loc.X + i, loc.Y + j, loc.Z); - if (map.CanFit(p, 12, true, false) && from.InLOS(p)) - new InternalItem(from, p, map, MinDamage, MaxDamage); + if (map.CanFit(p, 12, true, false) && @from.InLOS(p)) + { + new InternalItem(@from, p, map, MinDamage, MaxDamage); + } } + } } public static void AddDelay(Mobile m) @@ -100,7 +114,9 @@ namespace Server.Items public static int GetDelay(Mobile m) { if (m_Delay.TryGetValue(m, out var timer) && timer.Next > DateTime.UtcNow) + { return (int)(timer.Next - DateTime.UtcNow).TotalSeconds; + } return 0; } @@ -122,10 +138,14 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (Potion.Deleted || Potion.Map == Map.Internal) + { return; + } if (!(targeted is IPoint3D p) || from.Map == null) + { return; + } // Add delay AddDelay(from); @@ -137,9 +157,13 @@ namespace Server.Items IEntity to; if (p is Mobile mobile) + { to = mobile; + } else - to = new Entity(Serial.Zero, new Point3D(p), from.Map); + { + to = new Entity(Serial.Zero, new Point3D(p), @from.Map); + } Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue); Timer.DelayCall(TimeSpan.FromSeconds(1.5), Potion.Explode, from, new Point3D(p), from.Map); @@ -196,7 +220,9 @@ namespace Server.Items m_MaxDamage = max; if (From == null) + { return; + } var alchemySkill = From.Skills.Alchemy.Fixed; var alchemyBonus = alchemySkill / 125 + alchemySkill / 250; @@ -262,7 +288,9 @@ namespace Server.Items protected override void OnTick() { if (m_Item.Deleted) + { return; + } if (DateTime.UtcNow > m_End) { @@ -274,17 +302,21 @@ namespace Server.Items var from = m_Item.From; if (m_Item.Map == null || from == null) + { return; + } foreach (var m in m_Item.GetMobilesInRange(0)) - if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != from) && - SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false)) + { + if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != @from) && + SpellHelper.ValidIndirectTarget(@from, m) && @from.CanBeHarmful(m, false)) { - from.DoHarmful(m); + @from.DoHarmful(m); - AOS.Damage(m, from, m_Item.GetDamage(), 0, 100, 0, 0, 0); + AOS.Damage(m, @from, m_Item.GetDamage(), 0, 100, 0, 0, 0); m.PlaySound(0x208); } + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs index 01a2a99fd..226c8b0b2 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs @@ -42,12 +42,16 @@ namespace Server.Items } if (from.Target is ThrowTarget targ && targ.Potion == this) + { return; + } from.RevealingAction(); if (!m_Users.Contains(from)) - m_Users.Add(from); + { + m_Users.Add(@from); + } from.Target = new ThrowTarget(this); } @@ -69,14 +73,20 @@ namespace Server.Items public virtual void Explode(Mobile from, Point3D loc, Map map) { if (Deleted || map == null) + { return; + } Consume(); // Check if any other players are using this potion for (var i = 0; i < m_Users.Count; i++) + { if (m_Users[i].Target is ThrowTarget targ && targ.Potion == this) - Target.Cancel(from); + { + Target.Cancel(@from); + } + } // Effects Effects.PlaySound(loc, map, 0x207); @@ -86,19 +96,25 @@ namespace Server.Items Timer.DelayCall(TimeSpan.FromSeconds(0.3), CircleEffect2, loc, map); foreach (var mobile in map.GetMobilesInRange(loc, Radius)) + { if (mobile is BaseCreature mon) { if (mon.Controlled || mon.Summoned) + { continue; + } - mon.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(5.0)); // TODO check + mon.Pacify(@from, DateTime.UtcNow + TimeSpan.FromSeconds(5.0)); // TODO check } + } } public virtual void BlastEffect(Point3D p, Map map) { if (map.CanFit(p, 12, true, false)) + { Effects.SendLocationEffect(p, map, 0x376A, 4, 9); + } } public void CircleEffect2(Point3D p, Map m) @@ -116,7 +132,9 @@ namespace Server.Items public static int GetDelay(Mobile m) { if (m_Delay.TryGetValue(m, out var timer) && timer.Next > DateTime.UtcNow) + { return (int)(timer.Next - DateTime.UtcNow).TotalSeconds; + } return 0; } @@ -138,10 +156,14 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (Potion.Deleted || Potion.Map == Map.Internal) + { return; + } if (!(targeted is IPoint3D p) || from.Map == null) + { return; + } // Add delay AddDelay(from); @@ -153,9 +175,13 @@ namespace Server.Items IEntity to; if (p is Mobile mobile) + { to = mobile; + } else - to = new Entity(Serial.Zero, new Point3D(p), from.Map); + { + to = new Entity(Serial.Zero, new Point3D(p), @from.Map); + } Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue); Timer.DelayCall(TimeSpan.FromSeconds(1.0), Potion.Explode, from, new Point3D(p), from.Map); diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs index 7b8b7c7f2..6f98a1b6c 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs @@ -89,7 +89,9 @@ namespace Server.Items from.PlaySound(0x1E0); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs index 7fba6e4b7..564e5b5f4 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs @@ -49,13 +49,19 @@ namespace Server.Items public virtual IEntity FindParent(Mobile from) { if (HeldBy?.Holding == this) + { return HeldBy; + } if (RootParent != null) + { return RootParent; + } if (Map == Map.Internal) - return from; + { + return @from; + } return this; } @@ -72,14 +78,18 @@ namespace Server.Items Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode. if (targ?.Potion == this) + { return; + } from.RevealingAction(); Users ??= new List(); if (!Users.Contains(from)) - Users.Add(from); + { + Users.Add(@from); + } from.Target = new ThrowTarget(this); @@ -90,26 +100,32 @@ namespace Server.Items var timer = 3; if (Core.ML) + { m_Timer = Timer.DelayCall( TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 5, - () => Detonate_OnTick(from, timer--) + () => Detonate_OnTick(@from, timer--) ); // 3.6 seconds explosion delay + } else + { m_Timer = Timer.DelayCall( TimeSpan.FromSeconds(0.75), TimeSpan.FromSeconds(1.0), 4, - () => Detonate_OnTick(from, timer--) + () => Detonate_OnTick(@from, timer--) ); // 2.6 seconds explosion delay + } } } private void Detonate_OnTick(Mobile from, int timer) { if (Deleted) + { return; + } var parent = FindParent(from); @@ -139,27 +155,39 @@ namespace Server.Items else { if (parent is Item item) + { item.PublicOverheadMessage(MessageType.Regular, 0x22, false, timer.ToString()); + } else if (parent is Mobile mobile) + { mobile.PublicOverheadMessage(MessageType.Regular, 0x22, false, timer.ToString()); + } } } private void Reposition_OnTick(Mobile from, Point3D loc, Map map) { if (Deleted) + { return; + } if (InstantExplosion) - Explode(from, true, loc, map); + { + Explode(@from, true, loc, map); + } else + { MoveToWorld(loc, map); + } } public void Explode(Mobile from, bool direct, Point3D loc, Map map) { if (Deleted) + { return; + } Consume(); @@ -168,11 +196,15 @@ namespace Server.Items var m = Users[i]; if (m.Target is ThrowTarget targ && targ.Potion == this) + { Target.Cancel(m); + } } if (map == null) + { return; + } Effects.PlaySound(loc, map, 0x307); @@ -180,7 +212,9 @@ namespace Server.Items var alchemyBonus = 0; if (direct) - alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); + { + alchemyBonus = (int)(@from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); + } var eable = map.GetObjectsInRange(loc, ExplosionRange, LeveledExplosion); var toDamage = 0; @@ -190,7 +224,9 @@ namespace Server.Items { if (!(o is Mobile mobile) || from != null && (!SpellHelper.ValidIndirectTarget(from, mobile) || !from.CanBeHarmful(mobile, false))) + { return o is BaseExplosionPotion && o != this; + } ++toDamage; return true; @@ -216,9 +252,13 @@ namespace Server.Items damage += alchemyBonus; if (!Core.AOS && damage > 40) + { damage = 40; + } else if (Core.AOS && toDamage > 2) + { damage /= toDamage - 1; + } AOS.Damage(m, from, damage, 0, 100, 0, 0, 0); } @@ -238,15 +278,21 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (Potion.Deleted || Potion.Map == Map.Internal) + { return; + } if (!(targeted is IPoint3D p)) + { return; + } var map = from.Map; if (map == null) + { return; + } SpellHelper.GetSurfaceTop(ref p); @@ -257,14 +303,21 @@ namespace Server.Items if (p is Mobile m) { if (!RelativeLocation) // explosion location = current mob location. + { p = m.Location; + } else + { to = m; + } } Effects.SendMovingEffect(from, to, Potion.ItemID, 7, 0, false, false, Potion.Hue); - if (Potion.Amount > 1) Mobile.LiftItemDupe(Potion, 1); + if (Potion.Amount > 1) + { + Mobile.LiftItemDupe(Potion, 1); + } Potion.Internalize(); Timer.DelayCall(TimeSpan.FromSeconds(1.0), Potion.Reposition_OnTick, from, new Point3D(p), map); diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs index adf8b670a..61f311d8d 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs @@ -61,7 +61,9 @@ namespace Server.Items PlayDrinkEffect(from); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } Timer.DelayCall(TimeSpan.FromSeconds(Delay), from.EndAction); } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs index 9ef046df1..2170db7c7 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs @@ -40,7 +40,9 @@ namespace Server.Items PlayDrinkEffect(from); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs index 6fd8f1882..d2cafee0f 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs @@ -43,7 +43,9 @@ namespace Server.Items PlayDrinkEffect(from); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs index 8e4a03d01..0ccddaf94 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs @@ -37,7 +37,9 @@ namespace Server.Items PlayDrinkEffect(from); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs index f4cbf128b..08cc28f82 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs @@ -52,7 +52,9 @@ namespace Server.Items PlayDrinkEffect(from); if (!DuelContext.IsFreeConsume(from)) + { Consume(); + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs index 26256b3f0..dcea428ac 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs @@ -99,16 +99,22 @@ namespace Server.Items get { if (m_DefaultIndex >= 0 && m_DefaultIndex < Entries.Count) + { return Entries[m_DefaultIndex]; + } return null; } set { if (value == null) + { m_DefaultIndex = -1; + } else + { m_DefaultIndex = Entries.IndexOf(value); + } } } @@ -122,12 +128,16 @@ namespace Server.Items var charges = 5 + quality + (int)(from.Skills.Inscribe.Value / 30); if (charges > 10) + { charges = 10; + } MaxCharges = Core.SE ? charges * 2 : charges; if (makersMark) - Crafter = from; + { + Crafter = @from; + } m_Quality = (BookQuality)(quality - 1); @@ -160,7 +170,9 @@ namespace Server.Items writer.Write(Entries.Count); for (var i = 0; i < Entries.Count; ++i) + { Entries[i].Serialize(writer); + } writer.Write(m_Description); writer.Write(CurCharges); @@ -175,7 +187,9 @@ namespace Server.Items LootType = LootType.Blessed; if (Core.SE && Weight == 3.0) + { Weight = 1.0; + } var version = reader.ReadInt(); @@ -203,7 +217,9 @@ namespace Server.Items Entries = new List(count); for (var i = 0; i < count; ++i) + { Entries.Add(new RunebookEntry(reader)); + } m_Description = reader.ReadString(); CurCharges = reader.ReadInt(); @@ -218,9 +234,13 @@ namespace Server.Items public void DropRune(Mobile from, RunebookEntry e, int index) { if (m_DefaultIndex > index) + { m_DefaultIndex -= 1; + } else if (m_DefaultIndex == index) + { m_DefaultIndex = -1; + } Entries.RemoveAt(index); @@ -242,11 +262,17 @@ namespace Server.Items var ns = toCheck.NetState; if (ns == null) + { return false; + } foreach (var gump in ns.Gumps) + { if (gump is RunebookGump bookGump && bookGump.Book == this) + { return true; + } + } return false; } @@ -256,13 +282,19 @@ namespace Server.Items base.GetProperties(list); if (m_Quality == BookQuality.Exceptional) + { list.Add(1063341); // exceptional + } if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } if (!string.IsNullOrEmpty(m_Description)) + { list.Add(m_Description); + } } public override bool OnDragLift(Mobile from) @@ -274,8 +306,12 @@ namespace Server.Items } foreach (var m in Openers) + { if (IsOpen(m)) + { m.CloseGump(); + } + } Openers.Clear(); @@ -285,12 +321,16 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (m_Description?.Length > 0) - LabelTo(from, m_Description); + { + LabelTo(@from, m_Description); + } base.OnSingleClick(from); if (m_Crafter != null) - LabelTo(from, 1050043, m_Crafter.Name); + { + LabelTo(@from, 1050043, m_Crafter.Name); + } } public override void OnDoubleClick(Mobile from) @@ -319,13 +359,17 @@ namespace Server.Items public virtual void OnTravel() { if (!Core.SA) + { NextUse = DateTime.UtcNow + UseDelay; + } } public override void OnAfterDuped(Item newItem) { if (!(newItem is Runebook book)) + { return; + } book.Entries = new List(); @@ -340,7 +384,9 @@ namespace Server.Items public bool CheckAccess(Mobile m) { if (!IsLockedDown || m.AccessLevel >= AccessLevel.GameMaster) + { return true; + } var house = BaseHouse.FindHouseAt(this); diff --git a/Projects/UOContent/Items/Skill Items/Magical/Scrolls/SpellScroll.cs b/Projects/UOContent/Items/Skill Items/Magical/Scrolls/SpellScroll.cs index 16c5e8d2c..9beb0c112 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Scrolls/SpellScroll.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Scrolls/SpellScroll.cs @@ -57,13 +57,17 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (from.Alive && Movable) + { list.Add(new AddToSpellbookEntry()); + } } public override void OnDoubleClick(Mobile from) { if (!DesignContext.Check(from)) + { return; // They are customizing + } if (!IsChildOf(from.Backpack)) { @@ -74,9 +78,13 @@ namespace Server.Items var spell = SpellRegistry.NewSpell(SpellID, from, this); if (spell != null) + { spell.Cast(); + } else - from.SendLocalizedMessage(502345); // This spell has been temporarily disabled. + { + @from.SendLocalizedMessage(502345); // This spell has been temporarily disabled. + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs index ad4999ff7..d2df1a104 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs @@ -184,11 +184,17 @@ namespace Server.Items if (magery >= 1000) { if (magery >= 1200) + { propertyCounts = m_LegendPropertyCounts; + } else if (magery >= 1100) + { propertyCounts = m_ElderPropertyCounts; + } else + { propertyCounts = m_GrandPropertyCounts; + } minIntensity = 55; maxIntensity = 75; @@ -212,7 +218,9 @@ namespace Server.Items } if (makersMark) - Crafter = from; + { + Crafter = @from; + } m_Quality = (BookQuality)(quality - 1); @@ -264,9 +272,13 @@ namespace Server.Items if (obj is Spellbook book) { if (book.BookCount == 64) + { book.Content = ulong.MaxValue; + } else + { book.Content = (1ul << book.BookCount) - 1; + } from.SendMessage("The spellbook has been filled."); @@ -288,7 +300,9 @@ namespace Server.Items private static void EventSink_OpenSpellbookRequest(Mobile from, int typeID) { if (!DesignContext.Check(from)) + { return; // They are customizing + } var type = typeID switch { @@ -309,7 +323,10 @@ namespace Server.Items private static void EventSink_TargetedSpell(Mobile from, IEntity target, int spellId) { - if (!DesignContext.Check(from)) return; // They are customizing + if (!DesignContext.Check(from)) + { + return; // They are customizing + } var book = Find(from, spellId); @@ -322,20 +339,28 @@ namespace Server.Items var move = SpellRegistry.GetSpecialMove(spellId); if (move != null) - SpecialMove.SetCurrentMove(from, move); + { + SpecialMove.SetCurrentMove(@from, move); + } else - SpellRegistry.NewSpell(spellId, from, null)?.Cast(); + { + SpellRegistry.NewSpell(spellId, @from, null)?.Cast(); + } } private static void EventSink_CastSpellRequest(Mobile from, int spellID, Item item) { if (!DesignContext.Check(from)) + { return; // They are customizing + } var book = item as Spellbook; if (book?.HasSpell(spellID) != true) - book = Find(from, spellID); + { + book = Find(@from, spellID); + } if (book?.HasSpell(spellID) == true) { @@ -350,9 +375,13 @@ namespace Server.Items var spell = SpellRegistry.NewSpell(spellID, from, null); if (spell != null) + { spell.Cast(); + } else - from.SendLocalizedMessage(502345); // This spell has been temporarily disabled. + { + @from.SendLocalizedMessage(502345); // This spell has been temporarily disabled. + } } } else @@ -364,19 +393,39 @@ namespace Server.Items public static SpellbookType GetTypeForSpell(int spellID) { if (spellID >= 0 && spellID < 64) + { return SpellbookType.Regular; + } + if (spellID >= 100 && spellID < 117) + { return SpellbookType.Necromancer; + } + if (spellID >= 200 && spellID < 210) + { return SpellbookType.Paladin; + } + if (spellID >= 400 && spellID < 406) + { return SpellbookType.Samurai; + } + if (spellID >= 500 && spellID < 508) + { return SpellbookType.Ninja; + } + if (spellID >= 600 && spellID < 617) + { return SpellbookType.Arcanist; + } + if (spellID >= 677 && spellID < 693) + { return SpellbookType.Mystic; + } return SpellbookType.Invalid; } @@ -400,7 +449,9 @@ namespace Server.Items public static Spellbook Find(Mobile from, int spellID, SpellbookType type) { if (from == null) + { return null; + } if (from.Deleted) { @@ -411,9 +462,13 @@ namespace Server.Items var searchAgain = false; if (!m_Table.TryGetValue(from, out var list)) - m_Table[from] = list = FindAllSpellbooks(from); + { + m_Table[@from] = list = FindAllSpellbooks(@from); + } else + { searchAgain = true; + } var book = FindSpellbookInList(list, from, spellID, type); @@ -434,13 +489,17 @@ namespace Server.Items for (var i = list.Count - 1; i >= 0; --i) { if (i >= list.Count) + { continue; + } var book = list[i]; if (!book.Deleted && (book.Parent == from || pack != null && book.Parent == pack) && ValidateSpellbook(book, spellID, type)) + { return book; + } list.RemoveAt(i); } @@ -455,13 +514,19 @@ namespace Server.Items var spellbook = FindEquippedSpellbook(from); if (spellbook != null) + { list.Add(spellbook); + } var pack = from.Backpack; for (var i = 0; i < pack?.Items.Count; ++i) + { if (pack.Items[i] is Spellbook sp) + { list.Add(sp); + } + } return list; } @@ -474,16 +539,24 @@ namespace Server.Items public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { if (!Ethic.CheckTrade(from, to, newOwner, this)) + { return false; + } return base.AllowSecureTrade(from, to, newOwner, accepted); } public override bool CanEquip(Mobile from) { - if (!Ethic.CheckEquip(from, this)) return false; + if (!Ethic.CheckEquip(from, this)) + { + return false; + } - if (!from.CanBeginAction()) return false; + if (!from.CanBeginAction()) + { + return false; + } return base.CanEquip(from); } @@ -496,7 +569,10 @@ namespace Server.Items { var type = GetTypeForSpell(scroll.SpellID); - if (type != SpellbookType) return false; + if (type != SpellbookType) + { + return false; + } if (HasSpell(scroll.SpellID)) { @@ -526,7 +602,9 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { if (!(newItem is Spellbook book)) + { return; + } book.Attributes = new AosAttributes(newItem, Attributes); book.SkillBonuses = new AosSkillBonuses(newItem, SkillBonuses); @@ -547,13 +625,19 @@ namespace Server.Items var modName = Serial.ToString(); if (strBonus != 0) - from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) - from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) - from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + { + @from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } from.CheckStatTimers(); @@ -590,7 +674,9 @@ namespace Server.Items var ns = to.NetState; if (ns == null) + { return; + } if (Parent == null) { @@ -600,9 +686,13 @@ namespace Server.Items { // What will happen if the client doesn't know about our parent? if (ns.ContainerGridLines) + { to.Send(new ContainerContentUpdate6017(this)); + } else + { to.Send(new ContainerContentUpdate(this)); + } } else if (Parent is Mobile) { @@ -611,9 +701,13 @@ namespace Server.Items } if (ns.HighSeas) + { to.Send(new DisplaySpellbookHS(Serial)); + } else + { to.Send(new DisplaySpellbook(Serial)); + } if (ObjectPropertyList.Enabled) { @@ -624,17 +718,25 @@ namespace Server.Items else { if (ns.ContainerGridLines) + { to.Send(new SpellbookContent6017(Serial, BookOffset + 1, m_Content)); + } else + { to.Send(new SpellbookContent(Serial, BookOffset + 1, m_Content)); + } } } else { if (ns.ContainerGridLines) + { to.Send(new SpellbookContent6017(Serial, BookOffset + 1, m_Content)); + } else + { to.Send(new SpellbookContent(Serial, BookOffset + 1, m_Content)); + } } } @@ -643,13 +745,19 @@ namespace Server.Items base.GetProperties(list); if (m_Quality == BookQuality.Exceptional) + { list.Add(1063341); // exceptional + } if (m_EngravedText != null) + { list.Add(1072305, m_EngravedText); // Engraved: ~1_INSCRIPTION~ + } if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } SkillBonuses.GetProperties(list); @@ -657,89 +765,141 @@ namespace Server.Items { var entry = SlayerGroup.GetEntryByName(m_Slayer); if (entry != null) + { list.Add(entry.Title); + } } if (m_Slayer2 != SlayerName.None) { var entry = SlayerGroup.GetEntryByName(m_Slayer2); if (entry != null) + { list.Add(entry.Title); + } } int prop; if ((prop = Attributes.WeaponDamage) != 0) + { list.Add(1060401, prop.ToString()); // damage increase ~1_val~% + } if ((prop = Attributes.DefendChance) != 0) + { list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% + } if ((prop = Attributes.BonusDex) != 0) + { list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ + } if ((prop = Attributes.EnhancePotions) != 0) + { list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% + } if ((prop = Attributes.CastRecovery) != 0) + { list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ + } if ((prop = Attributes.CastSpeed) != 0) + { list.Add(1060413, prop.ToString()); // faster casting ~1_val~ + } if ((prop = Attributes.AttackChance) != 0) + { list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% + } if ((prop = Attributes.BonusHits) != 0) + { list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ + } if ((prop = Attributes.BonusInt) != 0) + { list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ + } if ((prop = Attributes.LowerManaCost) != 0) + { list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% + } if ((prop = Attributes.LowerRegCost) != 0) + { list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% + } if ((prop = Attributes.Luck) != 0) + { list.Add(1060436, prop.ToString()); // luck ~1_val~ + } if ((prop = Attributes.BonusMana) != 0) + { list.Add(1060439, prop.ToString()); // mana increase ~1_val~ + } if ((prop = Attributes.RegenMana) != 0) + { list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ + } if (Attributes.NightSight != 0) + { list.Add(1060441); // night sight + } if ((prop = Attributes.ReflectPhysical) != 0) + { list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% + } if ((prop = Attributes.RegenStam) != 0) + { list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ + } if ((prop = Attributes.RegenHits) != 0) + { list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ + } if (Attributes.SpellChanneling != 0) + { list.Add(1060482); // spell channeling + } if ((prop = Attributes.SpellDamage) != 0) + { list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% + } if ((prop = Attributes.BonusStam) != 0) + { list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ + } if ((prop = Attributes.BonusStr) != 0) + { list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ + } if ((prop = Attributes.WeaponSpeed) != 0) + { list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% + } if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) + { list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% + } list.Add(1042886, SpellCount.ToString()); // ~1_NUMBERS_OF_SPELLS~ Spells } @@ -749,7 +909,9 @@ namespace Server.Items base.OnSingleClick(from); if (m_Crafter != null) - LabelTo(from, 1050043, m_Crafter.Name); // crafted by ~1_NAME~ + { + LabelTo(@from, 1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } LabelTo(from, 1042886, SpellCount.ToString()); } @@ -759,11 +921,15 @@ namespace Server.Items var pack = from.Backpack; if (Parent == from || pack != null && Parent == pack) - DisplayTo(from); + { + DisplayTo(@from); + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 500207 ); // The spellbook must be in your backpack (and not in a container within) to open. + } } public override void Serialize(IGenericWriter writer) @@ -839,7 +1005,9 @@ namespace Server.Items SkillBonuses ??= new AosSkillBonuses(this); if (Core.AOS && Parent is Mobile mobile) + { SkillBonuses.AddTo(mobile); + } var strBonus = Attributes.BonusStr; var dexBonus = Attributes.BonusDex; @@ -852,13 +1020,19 @@ namespace Server.Items var modName = Serial.ToString(); if (strBonus != 0) + { m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + } if (dexBonus != 0) + { m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + } if (intBonus != 0) + { m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } } m.CheckStatTimers(); diff --git a/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs b/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs index 743af79eb..dd5985915 100644 --- a/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs +++ b/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs @@ -28,7 +28,9 @@ namespace Server.Items public virtual bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -73,7 +75,9 @@ namespace Server.Items private static void EventSink_BandageTargetRequest(Mobile from, Item item, Mobile target) { if (!(item is Bandage b) || b.Deleted) + { return; + } if (!from.InRange(b.GetWorldLocation(), Range)) { @@ -103,14 +107,18 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Bandage.Deleted) + { return; + } if (targeted is Mobile mobile) { if (from.InRange(m_Bandage.GetWorldLocation(), Bandage.Range)) { if (!(BandageContext.BeginHeal(from, mobile) == null || DuelContext.IsFreeConsume(from))) + { m_Bandage.Consume(); + } } else { @@ -120,7 +128,9 @@ namespace Server.Items else if (targeted is PlagueBeastInnard innard) { if (innard.OnBandage(from)) + { m_Bandage.Consume(); + } } else { @@ -133,7 +143,9 @@ namespace Server.Items if (targeted is PlagueBeastInnard innard) { if (innard.OnBandage(from)) + { m_Bandage.Consume(); + } } else { @@ -186,14 +198,20 @@ namespace Server.Items public static SkillName GetPrimarySkill(Mobile m) { if (!m.Player && (m.Body.IsMonster || m.Body.IsAnimal)) + { return SkillName.Veterinary; + } + return SkillName.Healing; } public static SkillName GetSecondarySkill(Mobile m) { if (!m.Player && (m.Body.IsMonster || m.Body.IsAnimal)) + { return SkillName.AnimalLore; + } + return SkillName.Anatomy; } @@ -259,7 +277,10 @@ namespace Server.Items { petPatient.ResurrectPet(); - for (var i = 0; i < petPatient.Skills.Length; ++i) petPatient.Skills[i].Base -= 0.1; + for (var i = 0; i < petPatient.Skills.Length; ++i) + { + petPatient.Skills[i].Base -= 0.1; + } } else if (master?.InRange(petPatient, 3) == true) { @@ -291,7 +312,9 @@ namespace Server.Items } if (!found) + { healerNumber = 1049670; // The pet's owner must be nearby to attempt resurrection. + } } } else @@ -304,9 +327,13 @@ namespace Server.Items else { if (petPatient?.IsDeadPet == true) + { healerNumber = 503256; // You fail to resurrect the creature. + } else + { healerNumber = 500966; // You are unable to resurrect your patient. + } patientNumber = -1; } @@ -385,12 +412,18 @@ namespace Server.Items var toHeal = min + Utility.RandomDouble() * (max - min); if (Patient.Body.IsMonster || Patient.Body.IsAnimal) + { toHeal += Patient.HitsMax / 100.0; + } if (Core.AOS) + { toHeal -= toHeal * Slips * 0.35; // TODO: Verify algorithm + } else + { toHeal -= Slips * 4; + } if (toHeal < 1) { @@ -408,13 +441,19 @@ namespace Server.Items } if (healerNumber != -1) + { Healer.SendLocalizedMessage(healerNumber); + } if (patientNumber != -1) + { Patient.SendLocalizedMessage(patientNumber); + } if (playSound) + { Patient.PlaySound(0x57); + } if (checkSkills) { @@ -457,9 +496,13 @@ namespace Server.Items if (onSelf) { if (Core.AOS) + { seconds = 5.0 + 0.5 * ((double)(120 - dex) / 10); // TODO: Verify algorithm + } else + { seconds = 9.4 + 0.6 * ((double)(120 - dex) / 10); + } } else { @@ -470,18 +513,28 @@ namespace Server.Items else if (Core.AOS) { if (dex < 204) + { seconds = 3.2 - Math.Sin((double)dex / 130) * 2.5 + resDelay; + } else + { seconds = 0.7 + resDelay; + } } else { if (dex >= 100) + { seconds = 3.0 + resDelay; + } else if (dex >= 40) + { seconds = 4.0 + resDelay; + } else + { seconds = 5.0 + resDelay; + } } } @@ -495,7 +548,9 @@ namespace Server.Items m_Table[healer] = context; if (!onSelf) + { patient.SendLocalizedMessage(1008078, false, healer.Name); // : Attempting to heal you. + } healer.SendLocalizedMessage(500956); // You begin applying the bandages. return context; diff --git a/Projects/UOContent/Items/Skill Items/Misc/FireHorn.cs b/Projects/UOContent/Items/Skill Items/Misc/FireHorn.cs index 7239c446b..cf438082f 100644 --- a/Projects/UOContent/Items/Skill Items/Misc/FireHorn.cs +++ b/Projects/UOContent/Items/Skill Items/Misc/FireHorn.cs @@ -24,7 +24,9 @@ namespace Server.Items private bool CheckUse(Mobile from) { if (!IsAccessibleTo(from)) + { return false; + } if (from.Map != Map || !from.InRange(GetWorldLocation(), 2)) { @@ -39,7 +41,9 @@ namespace Server.Items } if (from.Backpack?.GetAmount(typeof(SulfurousAsh)) >= (Core.AOS ? 4 : 15)) + { return true; + } from.SendLocalizedMessage(1049617); // You do not have enough sulfurous ash. return false; @@ -57,7 +61,9 @@ namespace Server.Items public void Use(Mobile from, IPoint3D loc) { if (!CheckUse(from)) + { return; + } from.BeginAction(); Timer.DelayCall(Core.AOS ? TimeSpan.FromSeconds(6.0) : TimeSpan.FromSeconds(12.0), EndAction, from); @@ -105,10 +111,14 @@ namespace Server.Items { if (from == m || !SpellHelper.ValidIndirectTarget(from, m) || !from.CanBeHarmful(m, false) || Core.AOS && !from.InLOS(m)) + { return false; + } if (m.Player) + { playerVsPlayer = true; + } return true; } @@ -136,9 +146,13 @@ namespace Server.Items int avgDamage; if (playerVsPlayer) + { avgDamage = weightAvg / 3; + } else + { avgDamage = weightAvg / 2; + } minDamage = avgDamage * 9 / 10; maxDamage = avgDamage * 10 / 9; @@ -148,7 +162,9 @@ namespace Server.Items var total = prov + disc / 5 + peace / 5; if (playerVsPlayer) + { total /= 3; + } maxDamage = total * 2 / 30; minDamage = maxDamage * 7 / 10; @@ -157,9 +173,13 @@ namespace Server.Items double damage = Utility.RandomMinMax(minDamage, maxDamage); if (Core.AOS && targets.Count > 1) + { damage = damage * 2 / targets.Count; + } else if (!Core.AOS) + { damage /= targets.Count; + } for (var i = 0; i < targets.Count; ++i) { @@ -217,13 +237,19 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Horn.Deleted) + { return; + } IPoint3D loc; if (targeted is Item item) + { loc = item.GetWorldLocation(); + } else + { loc = targeted as IPoint3D; + } m_Horn.Use(from, loc); } diff --git a/Projects/UOContent/Items/Skill Items/Misc/RecipeScroll.cs b/Projects/UOContent/Items/Skill Items/Misc/RecipeScroll.cs index f4ee8d554..31eeddc8c 100644 --- a/Projects/UOContent/Items/Skill Items/Misc/RecipeScroll.cs +++ b/Projects/UOContent/Items/Skill Items/Misc/RecipeScroll.cs @@ -49,7 +49,9 @@ namespace Server.Items var r = Recipe; if (r != null) + { list.Add(1049644, r.TextDefinition.ToString()); // [~1_stuff~] + } } public override void OnDoubleClick(Mobile from) diff --git a/Projects/UOContent/Items/Skill Items/Misc/RepairDeed.cs b/Projects/UOContent/Items/Skill Items/Misc/RepairDeed.cs index 912498f25..827388295 100644 --- a/Projects/UOContent/Items/Skill Items/Misc/RepairDeed.cs +++ b/Projects/UOContent/Items/Skill Items/Misc/RepairDeed.cs @@ -39,9 +39,13 @@ namespace Server.Items ) : base(0x14F0) { if (normalizeLevel) + { SkillLevel = (int)(level / 10) * 10; + } else + { SkillLevel = level; + } m_Skill = skill; m_Crafter = crafter; @@ -101,7 +105,9 @@ namespace Server.Items base.GetProperties(list); if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } // On OSI it says it's exceptional. Intentional difference. } @@ -109,7 +115,9 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (Deleted || !from.CanSee(this)) + { return; + } LabelTo( from, @@ -118,7 +126,9 @@ namespace Server.Items ); // A repair service contract from ~1_SKILL_TITLE~ ~2_SKILL_NAME~. if (m_Crafter != null) - LabelTo(from, 1050043, m_Crafter.Name); // crafted by ~1_NAME~ + { + LabelTo(@from, 1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } } private static TextDefinition GetSkillTitle(double skillLevel) @@ -126,9 +136,14 @@ namespace Server.Items var skill = (int)(skillLevel / 10); if (skill >= 11) + { return 1062008 + skill - 11; + } + if (skill >= 5) + { return 1061123 + skill - 5; + } return skill switch { @@ -141,8 +156,12 @@ namespace Server.Items public static RepairSkillType GetTypeFor(CraftSystem s) { for (var i = 0; i < RepairSkillInfo.Table.Length; i++) + { if (RepairSkillInfo.Table[i].System == s) + { return (RepairSkillType)i; + } + } return RepairSkillType.Smithing; } @@ -150,17 +169,25 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Check(from)) - Repair.Do(from, RepairSkillInfo.GetInfo(m_Skill).System, this); + { + Repair.Do(@from, RepairSkillInfo.GetInfo(m_Skill).System, this); + } } public bool Check(Mobile from) { if (!IsChildOf(from.Backpack)) - from.SendLocalizedMessage(1047012); // The contract must be in your backpack to use it. + { + @from.SendLocalizedMessage(1047012); // The contract must be in your backpack to use it. + } else if (!VerifyRegion(from)) - TextDefinition.SendMessageTo(from, RepairSkillInfo.GetInfo(m_Skill).NotNearbyMessage); + { + TextDefinition.SendMessageTo(@from, RepairSkillInfo.GetInfo(m_Skill).NotNearbyMessage); + } else + { return true; + } return false; } @@ -238,7 +265,9 @@ namespace Server.Items var v = (int)type; if (v < 0 || v >= Table.Length) + { v = 0; + } return Table[v]; } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/BambooFlute.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/BambooFlute.cs index 6a4b7cc07..017893ec6 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/BambooFlute.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/BambooFlute.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs index 248e1ea03..c4e1e8c39 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -107,7 +107,9 @@ namespace Server.Items set { if (value != m_ReplenishesCharges && value) + { m_LastReplenished = DateTime.UtcNow; + } m_ReplenishesCharges = value; } @@ -121,7 +123,9 @@ namespace Server.Items Quality = (InstrumentQuality)quality; if (makersMark) - Crafter = from; + { + Crafter = @from; + } return quality; } @@ -151,7 +155,9 @@ namespace Server.Items public void CheckReplenishUses(bool invalidate = true) { if (!m_ReplenishesCharges || m_UsesRemaining >= InitMaxUses) + { return; + } if (m_LastReplenished + ChargeReplenishRate < DateTime.UtcNow) { @@ -164,7 +170,9 @@ namespace Server.Items m_LastReplenished = DateTime.UtcNow; if (invalidate) + { InvalidateProperties(); + } } } @@ -200,7 +208,9 @@ namespace Server.Items public static BaseInstrument GetInstrument(Mobile from) { if (m_Instruments.TryGetValue(from, out var instrument) && instrument.IsChildOf(from.Backpack)) + { return instrument; + } m_Instruments.Remove(from); return null; @@ -255,31 +265,45 @@ namespace Server.Items val += targ.SkillsTotal / 10.0; if (val > 700) + { val = 700 + (int)((val - 700) * (3.0 / 11)); + } var bc = targ as BaseCreature; if (IsMageryCreature(bc)) + { val += 100; + } if (IsFireBreathingCreature(bc)) + { val += 100; + } if (IsPoisonImmune(bc)) + { val += 100; + } if (targ is VampireBat || targ is VampireBatFamiliar) + { val += 100; + } val += GetPoisonLevel(bc) * 20; val /= 10; if (bc?.IsParagon == true) + { val += 40.0; + } if (Core.SE && val > 160.0) + { val = 160.0; + } return val; } @@ -289,7 +313,9 @@ namespace Server.Items var val = GetBaseDifficulty(targ); if (m_Quality == InstrumentQuality.Exceptional) + { val -= 5.0; // 10% + } if (m_Slayer != SlayerName.None) { @@ -298,9 +324,13 @@ namespace Server.Items if (entry != null) { if (entry.Slays(targ)) + { val -= 10.0; // 20% + } else if (entry.Group.OppositionSuperSlays(targ)) + { val += 10.0; // -20% + } } } @@ -311,9 +341,13 @@ namespace Server.Items if (entry != null) { if (entry.Slays(targ)) + { val -= 10.0; // 20% + } else if (entry.Group.OppositionSuperSlays(targ)) + { val += 10.0; // -20% + } } } @@ -333,32 +367,44 @@ namespace Server.Items base.GetProperties(list); if (m_Crafter != null) + { list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ + } if (m_Quality == InstrumentQuality.Exceptional) + { list.Add(1060636); // exceptional + } list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ if (m_ReplenishesCharges) + { list.Add(1070928); // Replenish Charges + } if (m_Slayer != SlayerName.None) { var entry = SlayerGroup.GetEntryByName(m_Slayer); if (entry != null) + { list.Add(entry.Title); + } } if (m_Slayer2 != SlayerName.None) { var entry = SlayerGroup.GetEntryByName(m_Slayer2); if (entry != null) + { list.Add(entry.Title); + } } if (m_UsesRemaining != oldUses) + { Timer.DelayCall(InvalidateProperties); + } } public override void OnSingleClick(Mobile from) @@ -368,30 +414,42 @@ namespace Server.Items if (DisplayLootType) { if (LootType == LootType.Blessed) + { attrs.Add(new EquipInfoAttribute(1038021)); // blessed + } else if (LootType == LootType.Cursed) + { attrs.Add(new EquipInfoAttribute(1049643)); // cursed + } } if (m_Quality == InstrumentQuality.Exceptional) + { attrs.Add(new EquipInfoAttribute(1018305 - (int)m_Quality)); + } if (m_ReplenishesCharges) + { attrs.Add(new EquipInfoAttribute(1070928)); // Replenish Charges + } // TODO: Must this support item identification? if (m_Slayer != SlayerName.None) { var entry = SlayerGroup.GetEntryByName(m_Slayer); if (entry != null) + { attrs.Add(new EquipInfoAttribute(entry.Title)); + } } if (m_Slayer2 != SlayerName.None) { var entry = SlayerGroup.GetEntryByName(m_Slayer2); if (entry != null) + { attrs.Add(new EquipInfoAttribute(entry.Title)); + } } int number; @@ -407,7 +465,9 @@ namespace Server.Items } if (attrs.Count == 0 && Crafter == null && Name != null) + { return; + } var eqInfo = new EquipmentInfo( number, @@ -427,7 +487,9 @@ namespace Server.Items writer.Write(m_ReplenishesCharges); if (m_ReplenishesCharges) + { writer.Write(m_LastReplenished); + } writer.Write(m_Crafter); @@ -454,7 +516,9 @@ namespace Server.Items m_ReplenishesCharges = reader.ReadBool(); if (m_ReplenishesCharges) + { m_LastReplenished = reader.ReadDateTime(); + } goto case 2; } @@ -514,9 +578,13 @@ namespace Server.Items new InternalTimer(from).Start(); if (CheckMusicianship(from)) - PlayInstrumentWell(from); + { + PlayInstrumentWell(@from); + } else - PlayInstrumentBadly(from); + { + PlayInstrumentBadly(@from); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/Drums.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/Drums.cs index 8f2c76c92..da9567aa2 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/Drums.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/Drums.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 4.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/Harp.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/Harp.cs index 35feb2e5a..e317788bc 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/Harp.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/Harp.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 35.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/LapHarp.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/LapHarp.cs index 532a66f83..e6eef310f 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/LapHarp.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/LapHarp.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 10.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/Lute.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/Lute.cs index db56ecf93..90c82d01a 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/Lute.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/Lute.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 3.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/Tambourine.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/Tambourine.cs index 45137fa85..97870d002 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/Tambourine.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/Tambourine.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/TambourineTassel.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/TambourineTassel.cs index 7f36f0745..54aeb33f0 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/TambourineTassel.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/TambourineTassel.cs @@ -23,7 +23,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Ninjitsu/EggBomb.cs b/Projects/UOContent/Items/Skill Items/Ninjitsu/EggBomb.cs index bb835721f..92340098c 100644 --- a/Projects/UOContent/Items/Skill Items/Ninjitsu/EggBomb.cs +++ b/Projects/UOContent/Items/Skill Items/Ninjitsu/EggBomb.cs @@ -72,7 +72,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ItemID == 0x2809) // Temporary solution for clients 7.0.0.0 and up + { ItemID = 0x2808; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Ninjitsu/Fukiya.cs b/Projects/UOContent/Items/Skill Items/Ninjitsu/Fukiya.cs index 10cd2eb85..8bbcfff63 100644 --- a/Projects/UOContent/Items/Skill Items/Ninjitsu/Fukiya.cs +++ b/Projects/UOContent/Items/Skill Items/Ninjitsu/Fukiya.cs @@ -78,7 +78,10 @@ namespace Server.Items public void AttackAnimation(Mobile from, Mobile to) { - if (from.Body.IsHuman && !from.Mounted) from.Animate(33, 2, 1, true, true, 0); + if (from.Body.IsHuman && !from.Mounted) + { + @from.Animate(33, 2, 1, true, true, 0); + } from.PlaySound(0x223); from.MovingEffect(to, 0x2804, 5, 0, false, false); @@ -91,7 +94,9 @@ namespace Server.Items list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ if (m_Poison != null && m_PoisonCharges > 0) + { list.Add(1062412 + m_Poison.Level, m_PoisonCharges.ToString()); + } } public override void OnDoubleClick(Mobile from) diff --git a/Projects/UOContent/Items/Skill Items/Ninjitsu/FukiyaDarts.cs b/Projects/UOContent/Items/Skill Items/Ninjitsu/FukiyaDarts.cs index 6423a25ea..77624e823 100644 --- a/Projects/UOContent/Items/Skill Items/Ninjitsu/FukiyaDarts.cs +++ b/Projects/UOContent/Items/Skill Items/Ninjitsu/FukiyaDarts.cs @@ -27,7 +27,9 @@ namespace Server.Items ) { if (quality == 2) + { UsesRemaining *= 2; + } return quality; } @@ -78,7 +80,9 @@ namespace Server.Items list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ if (m_Poison != null && m_PoisonCharges > 0) + { list.Add(1062412 + m_Poison.Level, m_PoisonCharges.ToString()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs b/Projects/UOContent/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs index d0b8e3756..a7ff91cef 100644 --- a/Projects/UOContent/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs +++ b/Projects/UOContent/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs @@ -80,7 +80,10 @@ namespace Server.Items public void AttackAnimation(Mobile from, Mobile to) { - if (from.Body.IsHuman) from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0); + if (from.Body.IsHuman) + { + @from.Animate(@from.Mounted ? 26 : 9, 7, 1, true, false, 0); + } from.PlaySound(0x23A); from.MovingEffect(to, 0x27AC, 1, 0, false, false); @@ -93,7 +96,9 @@ namespace Server.Items list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ if (m_Poison != null && m_PoisonCharges > 0) + { list.Add(1062412 + m_Poison.Level, m_PoisonCharges.ToString()); + } } public override bool OnEquip(Mobile from) diff --git a/Projects/UOContent/Items/Skill Items/Ninjitsu/NinjaWeapons.cs b/Projects/UOContent/Items/Skill Items/Ninjitsu/NinjaWeapons.cs index 8b9682d67..3cee4cc3b 100644 --- a/Projects/UOContent/Items/Skill Items/Ninjitsu/NinjaWeapons.cs +++ b/Projects/UOContent/Items/Skill Items/Ninjitsu/NinjaWeapons.cs @@ -46,7 +46,9 @@ namespace Server.Items public static void AttemptShoot(PlayerMobile from, INinjaWeapon weapon) { if (CanUseWeapon(from, weapon)) - from.BeginTarget(weapon.WeaponMaxRange, false, TargetFlags.Harmful, OnTarget, weapon); + { + @from.BeginTarget(weapon.WeaponMaxRange, false, TargetFlags.Harmful, OnTarget, weapon); + } } private static void Shoot(PlayerMobile from, Mobile target, INinjaWeapon weapon) @@ -66,7 +68,9 @@ namespace Server.Items ConsumeUse(weapon); if (CombatCheck(from, target)) - Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnHit, from, target, weapon); + { + Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnHit, @from, target, weapon); + } Timer.DelayCall(TimeSpan.FromSeconds(2.5), ResetUsing, from); } @@ -117,26 +121,36 @@ namespace Server.Items else { if (weapon.UsesRemaining > 0) + { if (weapon.Poison == null && ammo.Poison != null || weapon.Poison != null && ammo.Poison != null && weapon.Poison.Level != ammo.Poison.Level) { - Unload(from, weapon); + Unload(@from, weapon); need = Math.Min(MaxUses, ammo.UsesRemaining); } + } var poisonneeded = Math.Min(MaxUses - weapon.PoisonCharges, ammo.PoisonCharges); weapon.UsesRemaining += need; weapon.PoisonCharges += poisonneeded; - if (weapon.PoisonCharges > 0) weapon.Poison = ammo.Poison; + if (weapon.PoisonCharges > 0) + { + weapon.Poison = ammo.Poison; + } ammo.PoisonCharges -= poisonneeded; ammo.UsesRemaining -= need; if (ammo.UsesRemaining < 1) + { ((Item)ammo).Delete(); - else if (ammo.PoisonCharges < 1) ammo.Poison = null; + } + else if (ammo.PoisonCharges < 1) + { + ammo.Poison = null; + } } } // "else" here would mean they targeted "ammo" with 0 uses. undefined behavior. } @@ -168,7 +182,10 @@ namespace Server.Items { if (!from.NinjaWepCooldown) { - if (BasePotion.HasFreeHand(from)) return true; + if (BasePotion.HasFreeHand(from)) + { + return true; + } from.SendLocalizedMessage(weapon.NoFreeHandMessage); } @@ -196,40 +213,73 @@ namespace Server.Items var atSkillValue = attacker.Skills.Ninjitsu.Value; var defSkillValue = defWeapon?.GetDefendSkillValue(attacker, defender) ?? 0.0; - 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)) || - AnimalForm.UnderTransformation(attacker, typeof(BakeKitsune))) attackValue += 20; + AnimalForm.UnderTransformation(attacker, typeof(BakeKitsune))) + { + attackValue += 20; + } - if (HitLower.IsUnderAttackEffect(attacker)) attackValue -= 25; + if (HitLower.IsUnderAttackEffect(attacker)) + { + attackValue -= 25; + } - if (attackValue > 45) attackValue = 45; + if (attackValue > 45) + { + attackValue = 45; + } attackValue = (atSkillValue + 20.0) * (100 + attackValue); double defenseValue = AosAttributes.GetValue(defender, AosAttribute.DefendChance); - if (DivineFurySpell.UnderEffect(defender)) defenseValue -= 20; + if (DivineFurySpell.UnderEffect(defender)) + { + defenseValue -= 20; + } - if (HitLower.IsUnderDefenseEffect(defender)) defenseValue -= 25; + if (HitLower.IsUnderDefenseEffect(defender)) + { + defenseValue -= 25; + } var refBonus = 0; - if (Block.GetBonus(defender, ref refBonus)) defenseValue += refBonus; + if (Block.GetBonus(defender, ref refBonus)) + { + defenseValue += refBonus; + } - if (Discordance.GetEffect(attacker, ref refBonus)) defenseValue -= refBonus; + if (Discordance.GetEffect(attacker, ref refBonus)) + { + defenseValue -= refBonus; + } - if (defenseValue > 45) defenseValue = 45; + if (defenseValue > 45) + { + defenseValue = 45; + } defenseValue = (defSkillValue + 20.0) * (100 + defenseValue); var chance = attackValue / (defenseValue * 2.0); - if (chance < 0.02) chance = 0.02; + if (chance < 0.02) + { + chance = 0.02; + } return attacker.CheckSkill(atkSkill.SkillName, chance); } @@ -237,7 +287,10 @@ namespace Server.Items private static void OnHit(Mobile from, Mobile target, INinjaWeapon weapon) { if (!from.CanBeHarmful(target)) + { return; + } + from.DoHarmful(target); AOS.Damage(target, from, weapon.WeaponDamage, 100, 0, 0, 0, 0); @@ -245,13 +298,20 @@ namespace Server.Items if (weapon.Poison != null && weapon.PoisonCharges > 0) { if (EvilOmenSpell.TryEndEffect(target)) - target.ApplyPoison(from, Poison.GetPoison(weapon.Poison.Level + 1)); + { + target.ApplyPoison(@from, Poison.GetPoison(weapon.Poison.Level + 1)); + } else - target.ApplyPoison(from, weapon.Poison); + { + target.ApplyPoison(@from, weapon.Poison); + } weapon.PoisonCharges--; - if (weapon.PoisonCharges < 1) weapon.Poison = null; + if (weapon.PoisonCharges < 1) + { + weapon.Poison = null; + } } } @@ -260,11 +320,17 @@ namespace Server.Items if (from is PlayerMobile player && WeaponIsValid(weapon, from)) { if (targeted is Mobile mobile) + { Shoot(player, mobile, weapon); + } else if (targeted.GetType() == weapon.AmmoType) + { Reload(player, weapon, (INinjaAmmo)targeted); + } else + { player.SendLocalizedMessage(weapon.WrongAmmoMessage); + } } } @@ -282,7 +348,9 @@ namespace Server.Items public override void OnClick() { if (WeaponIsValid(weapon, Owner.From)) + { Owner.From.BeginTarget(10, false, TargetFlags.Harmful, OnTarget, weapon); + } } } @@ -300,7 +368,10 @@ namespace Server.Items public override void OnClick() { - if (WeaponIsValid(weapon, Owner.From)) Unload(Owner.From, weapon); + if (WeaponIsValid(weapon, Owner.From)) + { + Unload(Owner.From, weapon); + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Ninjitsu/Shuriken.cs b/Projects/UOContent/Items/Skill Items/Ninjitsu/Shuriken.cs index c83e06d36..d87751222 100644 --- a/Projects/UOContent/Items/Skill Items/Ninjitsu/Shuriken.cs +++ b/Projects/UOContent/Items/Skill Items/Ninjitsu/Shuriken.cs @@ -28,7 +28,9 @@ namespace Server.Items ) { if (quality == 2) + { UsesRemaining *= 2; + } return quality; } @@ -79,7 +81,9 @@ namespace Server.Items list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ if (m_Poison != null && m_PoisonCharges > 0) + { list.Add(1062412 + m_Poison.Level, m_PoisonCharges.ToString()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Specialized/Sand.cs b/Projects/UOContent/Items/Skill Items/Specialized/Sand.cs index 7c5e3eefa..db0d5b29e 100644 --- a/Projects/UOContent/Items/Skill Items/Specialized/Sand.cs +++ b/Projects/UOContent/Items/Skill Items/Specialized/Sand.cs @@ -32,7 +32,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Name == "sand") + { Name = null; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs index 5ff8509cd..abf3818e9 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs @@ -142,9 +142,13 @@ namespace Server.Items AddBackground(10, 10, 430, 430, 3000); if (m_Definition.TitleString != null) + { AddHtml(20, 30, 400, 25, m_Definition.TitleString); + } else if (m_Definition.Title > 0) + { AddHtmlLocalized(20, 30, 400, 25, m_Definition.Title); + } AddButton(20, 400, 4005, 4007, 1); AddHtmlLocalized(55, 400, 200, 25, 1011036); // OKAY @@ -165,9 +169,13 @@ namespace Server.Items AddButton(30, 85 + i * 25, 5224, 5224, 0, GumpButtonType.Page, 1 + i); if (groups[i].NameString != null) + { AddHtml(55, 85 + i * 25, 200, 25, groups[i].NameString); + } else + { AddHtmlLocalized(55, 85 + i * 25, 200, 25, groups[i].Name); + } } for (var i = 0; i < groups.Length; ++i) @@ -204,7 +212,9 @@ namespace Server.Items var hues = m_Definition.Groups[group].Hues; if (index >= 0 && index < hues.Length) + { m_Callback(m_From, m_State, hues[index]); + } } } @@ -213,7 +223,9 @@ namespace Server.Items case 2: // Default { if (m_Definition.DefaultSupported) + { m_Callback(m_From, m_State, 0); + } break; } diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs index 18db1f49a..404fc2836 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs @@ -142,11 +142,17 @@ namespace Server.Items else if (item is IDyable dyable && m_Tub.AllowDyables) { if (!from.InRange(m_Tub.GetWorldLocation(), 1) || !from.InRange(item.GetWorldLocation(), 1)) - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } else if (item.Parent is Mobile) - from.SendLocalizedMessage(500861); // Can't Dye clothing that is being worn. + { + @from.SendLocalizedMessage(500861); // Can't Dye clothing that is being worn. + } else if (dyable.Dye(from, m_Tub)) - from.PlaySound(0x23E); + { + @from.PlaySound(0x23E); + } } else if ((FurnitureAttribute.Check(item) || item is PotionKeg) && m_Tub.AllowFurniture) { @@ -165,11 +171,17 @@ namespace Server.Items var house = BaseHouse.FindHouseAt(item); if (house == null || !house.HasLockedDownItem(item) && !house.HasSecureItem(item)) - from.SendLocalizedMessage(501022); // Furniture must be locked down to paint it. + { + @from.SendLocalizedMessage(501022); // Furniture must be locked down to paint it. + } else if (!house.IsCoOwner(from)) - from.SendLocalizedMessage(501023); // You must be the owner to use this item. + { + @from.SendLocalizedMessage(501023); // You must be the owner to use this item. + } else + { okay = true; + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs index 7b6188790..a3c95005b 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs @@ -23,7 +23,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -33,7 +35,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076217); // 1st Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -61,7 +65,9 @@ namespace Server.Items } if (LootType == LootType.Regular) + { LootType = LootType.Blessed; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs index 3d7f7b724..4d0031ff6 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs @@ -24,7 +24,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -34,7 +36,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076218); // 2nd Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs index ac24e675e..6695064d5 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs @@ -62,7 +62,11 @@ namespace Server.Items { case 1: // Okay { - if (info.Switches.Length > 0) m_Callback(m_From, m_State, info.Switches[0]); + if (info.Switches.Length > 0) + { + m_Callback(m_From, m_State, info.Switches[0]); + } + break; } case 2: // Default diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicLeatherDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicLeatherDyeTub.cs index 20e60a0dd..72695282c 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicLeatherDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/MetallicLeatherDyeTub.cs @@ -21,7 +21,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076221); // 5th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs index 92daa61d1..fa5281102 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs @@ -24,7 +24,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -34,7 +36,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076217); // 1st Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs index 590d39904..99d26933c 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs @@ -24,7 +24,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -34,7 +36,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076220); // 4th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs index cb4187105..b9fe86bf6 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs @@ -20,7 +20,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -30,7 +32,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076217); // 1st Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs index 8b7b6ff15..c04f763d0 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs @@ -24,7 +24,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -34,7 +36,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(1076221); // 5th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Dyes.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Dyes.cs index f5054ffb6..2654644b6 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Dyes.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Dyes.cs @@ -37,7 +37,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 0.0) + { Weight = 3.0; + } /* m_UsesRemaining = ( version == 0 ) ? 25 : reader.ReadInt(); */ } @@ -66,11 +68,17 @@ namespace Server.Items if (tub.Redyable) { if (tub.MetallicHues) /* OSI has three metallic tubs now */ - from.SendGump(new MetallicHuePicker(from, SetTubHue, tub)); + { + @from.SendGump(new MetallicHuePicker(@from, SetTubHue, tub)); + } else if (tub.CustomHuePicker != null) - from.SendGump(new CustomHuePickerGump(from, tub.CustomHuePicker, SetTubHue, tub)); + { + @from.SendGump(new CustomHuePickerGump(@from, tub.CustomHuePicker, SetTubHue, tub)); + } else - from.SendHuePicker(new InternalPicker(tub)); + { + @from.SendHuePicker(new InternalPicker(tub)); + } } else if (tub is BlackDyeTub) { diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs index 540d6e226..6eea8855d 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs @@ -60,7 +60,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Item.Deleted) + { return; + } /*if (targeted is Item && !((Item)targeted).IsStandardLoot()) { @@ -84,13 +86,19 @@ namespace Server.Items else if (targeted is Item item && !item.Movable) { if (item is IScissorable obj && (obj is PlagueBeastInnard || obj is PlagueBeastMutationCore)) - if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) - from.PlaySound(0x248); + { + if (CanScissor(@from, obj) && obj.Scissor(@from, m_Item)) + { + @from.PlaySound(0x248); + } + } } else if (targeted is IScissorable obj) { if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) - from.PlaySound(0x248); + { + @from.PlaySound(0x248); + } } else { @@ -103,7 +111,9 @@ namespace Server.Items if (targeted is IScissorable obj && (obj is PlagueBeastInnard || obj is PlagueBeastMutationCore)) { if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) - from.PlaySound(0x248); + { + @from.PlaySound(0x248); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs b/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs index a11578f84..74a7567c2 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/DisguiseKit.cs @@ -41,23 +41,41 @@ namespace Server.Items var pm = from as PlayerMobile; if (!IsChildOf(from.Backpack)) - from.SendLocalizedMessage(1042001); + { + @from.SendLocalizedMessage(1042001); + } else if (pm == null || pm.NpcGuild != NpcGuild.ThievesGuild) - from.SendLocalizedMessage(501702); + { + @from.SendLocalizedMessage(501702); + } else if (Stealing.SuspendOnMurder && pm.Kills > 0) - from.SendLocalizedMessage(501703); + { + @from.SendLocalizedMessage(501703); + } else if (!from.CanBeginAction()) - from.SendLocalizedMessage(501704); + { + @from.SendLocalizedMessage(501704); + } else if (Sigil.ExistsOn(from)) - from.SendLocalizedMessage(1010465); // You cannot disguise yourself while holding a sigil + { + @from.SendLocalizedMessage(1010465); // You cannot disguise yourself while holding a sigil + } else if (TransformationSpellHelper.UnderTransformation(from)) - from.SendLocalizedMessage(1061634); + { + @from.SendLocalizedMessage(1061634); + } else if (from.BodyMod == 183 || from.BodyMod == 184) - from.SendLocalizedMessage(1040002); + { + @from.SendLocalizedMessage(1040002); + } else if (!from.CanBeginAction() || from.IsBodyMod) - from.SendLocalizedMessage(501705); + { + @from.SendLocalizedMessage(501705); + } else + { return true; + } return false; } @@ -65,7 +83,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (ValidateUse(from)) - from.SendGump(new DisguiseGump(from, this, true, false)); + { + @from.SendGump(new DisguiseGump(@from, this, true, false)); + } } } @@ -153,7 +173,9 @@ namespace Server.Items var entry = entries[i]; if (entry == null) + { continue; + } var x = i % 2 * 205; var y = i / 2 * 55; @@ -174,9 +196,13 @@ namespace Server.Items if (info.ButtonID == 0) { if (m_Used) + { m_From.SendLocalizedMessage(501706); // Disguises wear off after 2 hours. + } else + { m_From.SendLocalizedMessage(501707); // You're looking good. + } return; } @@ -184,7 +210,9 @@ namespace Server.Items var switches = info.Switches; if (switches.Length == 0) + { return; + } var switched = switches[0]; var type = switched % 2; @@ -199,22 +227,32 @@ namespace Server.Items var entry = entries[index]; if (entry == null) + { return; + } if (!m_Kit.ValidateUse(m_From)) + { return; + } if (!hair && (m_From.Female || m_From.Body.IsFemale)) + { return; + } m_From.NameMod = NameList.RandomName(m_From.Female ? "female" : "male"); if (m_From is PlayerMobile pm) { if (hair) + { pm.SetHairMods(entry.m_ItemID, -2); + } else + { pm.SetHairMods(-2, entry.m_ItemID); + } } m_From.SendGump(new DisguiseGump(m_From, m_Kit, hair, true)); @@ -257,7 +295,9 @@ namespace Server.Items public static void CreateTimer(Mobile m, TimeSpan delay) { if (m != null && !IsDisguised(m)) + { Timers[m] = new InternalTimer(m, delay); + } } public static void StartTimer(Mobile m) @@ -271,11 +311,15 @@ namespace Server.Items public static void StopTimer(Mobile m) { if (!Timers.TryGetValue(m, out var t)) + { return; + } var ts = t.Next - DateTime.UtcNow; if (ts < TimeSpan.Zero) + { ts = TimeSpan.Zero; + } t.Delay = ts; t.Stop(); @@ -307,7 +351,9 @@ namespace Server.Items m_Player.NameMod = null; if (m_Player is PlayerMobile mobile) + { mobile.SetHairMods(-1, -1); + } RemoveTimer(m_Player); } diff --git a/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs b/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs index 6cb2d6b94..f555a1fd4 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/DisguisePersistance.cs @@ -9,9 +9,13 @@ namespace Server.Items Movable = false; if (Instance?.Deleted != false) + { Instance = this; + } else + { base.Delete(); + } } public DisguisePersistance(Serial serial) : base(serial) => Instance = this; diff --git a/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs b/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs index 48dcf8170..67b10b075 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs @@ -42,7 +42,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version == 0 && Weight == 0.1) + { Weight = -1; + } } public override void OnDoubleClick(Mobile from) @@ -60,7 +62,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Item.Deleted) + { return; + } if (targeted is ILockpickable lockpickable) { @@ -119,7 +123,9 @@ namespace Server.Items var item = (Item)m_Item; if (!m_From.InRange(item.GetWorldLocation(), 1)) + { return; + } if (m_Item.LockLevel == 0 || m_Item.LockLevel == -255) { diff --git a/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs b/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs index e2bdb2744..9e7f58998 100644 --- a/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs +++ b/Projects/UOContent/Items/Skill Items/Tinkering/Clocks.cs @@ -41,7 +41,9 @@ namespace Server.Items GetTime(map, x, y, out _, out _, out var totalMinutes); if (map != null) + { totalMinutes /= 10 + map.MapIndex * 20; + } return (MoonPhase)(totalMinutes % 8); } @@ -58,7 +60,9 @@ namespace Server.Items totalMinutes = (int)(timeSpan.TotalSeconds / SecondsPerUOMinute); if (map != null) + { totalMinutes += map.MapIndex * 320; + } // Really on OSI this must be by subserver totalMinutes += x / 16; @@ -91,26 +95,44 @@ namespace Server.Items // 08:00 PM - 11:59 AM : Late at night if (hours >= 20) + { generalNumber = 1042957; // It's late at night + } else if (hours >= 16) + { generalNumber = 1042956; // It's early in the evening + } else if (hours >= 13) + { generalNumber = 1042955; // It's the afternoon + } else if (hours >= 12) + { generalNumber = 1042954; // It's around noon + } else if (hours >= 08) + { generalNumber = 1042953; // It's late in the morning + } else if (hours >= 04) + { generalNumber = 1042952; // It's early in the morning + } else if (hours >= 01) + { generalNumber = 1042951; // It's the middle of the night + } else + { generalNumber = 1042950; // 'Tis the witching hour. 12 Midnight. + } hours %= 12; if (hours == 0) + { hours = 12; + } exactTime = $"{hours}:{minutes:D2}"; } diff --git a/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs b/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs index 4781225c0..b313ee557 100644 --- a/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs +++ b/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs @@ -56,7 +56,9 @@ namespace Server.Items var qs = player.Quest; if (!(qs is WitchApprenticeQuest)) + { return; + } var obj = qs.FindObjective(); diff --git a/Projects/UOContent/Items/Skill Items/Tools/BaseRunicTool.cs b/Projects/UOContent/Items/Skill Items/Tools/BaseRunicTool.cs index 6c44dde66..cffcd3085 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/BaseRunicTool.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/BaseRunicTool.cs @@ -116,12 +116,18 @@ namespace Server.Items v = 100 - v; if (LootPack.CheckLuck(m_LuckChance)) + { v += 10; + } if (v < min) + { v = min; + } else if (v > max) + { v = max; + } percent = v; } @@ -129,7 +135,9 @@ namespace Server.Items var scaledBy = Math.Abs(high - low) + 1; if (scaledBy != 0) + { scaledBy = 10000 / scaledBy; + } percent *= 10000 + scaledBy; @@ -142,12 +150,18 @@ namespace Server.Items ) { if (attr == AosAttribute.CastSpeed) + { attrs[attr] += Scale(min, max, low / scale, high / scale) * scale; + } else + { attrs[attr] = Scale(min, max, low / scale, high / scale) * scale; + } if (attr == AosAttribute.SpellChanneling) + { attrs[AosAttribute.CastSpeed] -= 1; + } } private static void ApplyAttribute( @@ -214,7 +228,9 @@ namespace Server.Items possibleSkills.Remove(sk); for (var i = 0; !found && i < 5; ++i) + { found = attrs.GetValues(i, out var check, out _) && check == sk; + } } while (found && count > 0); attrs.SetValues(index, sk, Scale(min, max, low, high)); @@ -247,11 +263,17 @@ namespace Server.Items var avail = 0; for (var i = 0; i < count; ++i) + { if (!m_Props[i]) + { m_Possible[avail++] = i; + } + } if (avail == 0) + { return -1; + } var v = m_Possible[Utility.Random(avail)]; @@ -267,7 +289,9 @@ namespace Server.Items var attrs = resInfo?.AttributeInfo; if (attrs == null) + { return; + } var attributeCount = Utility.RandomMinMax(attrs.RunicMinAttributes, attrs.RunicMaxAttributes); var min = attrs.RunicMinIntensity; @@ -295,14 +319,18 @@ namespace Server.Items m_Props.SetAll(false); if (weapon is BaseRanged) + { m_Props.Set(2, true); // ranged weapons cannot be ubws or mageweapon + } for (var i = 0; i < attributeCount; ++i) { var random = GetUniqueRandom(25); if (random == -1) + { break; + } switch (random) { @@ -453,6 +481,7 @@ namespace Server.Items }; if (randomizeOrder) + { for (var i = 0; i < attrs.Length; i++) { var temp = attrs[i]; @@ -461,6 +490,7 @@ namespace Server.Items attrs[i] = attrs[rand]; attrs[rand] = temp; } + } /* totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Cold, totalDamage ); @@ -472,7 +502,9 @@ namespace Server.Items * */ for (var i = 0; i < attrs.Length; i++) + { totalDamage = AssignElementalDamage(weapon, attrs[i], totalDamage); + } // Order is Cold, Energy, Fire, Poison -> Physical left // Cannot be looped, AoselementAttribute is 'out of order' @@ -483,7 +515,9 @@ namespace Server.Items private static int AssignElementalDamage(BaseWeapon weapon, AosElementAttribute attr, int totalDamage) { if (totalDamage <= 0) + { return 0; + } var random = Utility.Random(totalDamage / 10 + 1) * 10; weapon.AosElementDamages[attr] = random; @@ -498,7 +532,9 @@ namespace Server.Items var groups = SlayerGroup.Groups; if (groups.Length == 0) + { return SlayerName.None; + } var group = groups[ @@ -517,7 +553,9 @@ namespace Server.Items var entries = group.Entries; if (entries.Length == 0) + { return SlayerName.None; + } entry = entries.RandomElement(); } @@ -532,7 +570,9 @@ namespace Server.Items var attrs = resInfo?.AttributeInfo; if (attrs == null) + { return; + } var attributeCount = Utility.RandomMinMax(attrs.RunicMinAttributes, attrs.RunicMaxAttributes); var min = attrs.RunicMinIntensity; @@ -564,7 +604,10 @@ namespace Server.Items var baseOffset = isShield ? 0 : 4; if (!isShield && armor.MeditationAllowance == ArmorMeditationAllowance.All) + { m_Props.Set(3, true); // remove mage armor from possible properties + } + if (armor.Resource >= CraftResource.RegularLeather && armor.Resource <= CraftResource.BarbedLeather) { m_Props.Set(0, true); // remove lower requirements from possible properties for leather armor @@ -572,17 +615,21 @@ namespace Server.Items } if (armor.RequiredRace == Race.Elf) + { m_Props.Set( 7, true ); // elves inherently have night sight and elf only armor doesn't get night sight as a mod + } for (var i = 0; i < attributeCount; ++i) { var random = GetUniqueRandom(baseCount); if (random == -1) + { break; + } random += baseOffset; @@ -597,9 +644,14 @@ namespace Server.Items break; case 2: if (Core.ML) + { ApplyAttribute(primary, min, max, AosAttribute.ReflectPhysical, 1, 15); + } else + { ApplyAttribute(primary, min, max, AosAttribute.AttackChance, 1, 15); + } + break; case 3: ApplyAttribute(primary, min, max, AosAttribute.CastSpeed, 1, 1); @@ -695,7 +747,9 @@ namespace Server.Items var random = GetUniqueRandom(19); if (random == -1) + { break; + } switch (random) { @@ -784,7 +838,9 @@ namespace Server.Items var random = GetUniqueRandom(24); if (random == -1) + { break; + } switch (random) { @@ -887,7 +943,9 @@ namespace Server.Items var random = GetUniqueRandom(16); if (random == -1) + { break; + } switch (random) { @@ -899,7 +957,9 @@ namespace Server.Items ApplyAttribute(primary, min, max, AosAttribute.BonusInt, 1, 8); for (var j = 0; j < 4; ++j) + { m_Props.Set(j, true); + } break; } diff --git a/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs b/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs index df136fa8c..4840a0ab1 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs @@ -69,7 +69,9 @@ namespace Server.Items Quality = (ToolQuality)quality; if (makersMark) - Crafter = from; + { + Crafter = @from; + } return quality; } @@ -105,7 +107,9 @@ namespace Server.Items public int GetUsesScalar() { if (m_Quality == ToolQuality.Exceptional) + { return 200; + } return 100; } @@ -119,7 +123,9 @@ namespace Server.Items // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ if (m_Quality == ToolQuality.Exceptional) + { list.Add(1060636); // exceptional + } list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ } @@ -136,7 +142,9 @@ namespace Server.Items var check = m.FindItemOnLayer(Layer.OneHanded); if (check is BaseTool && check != tool && !(check is AncientSmithyHammer)) + { return false; + } check = m.FindItemOnLayer(Layer.TwoHanded); @@ -160,9 +168,13 @@ namespace Server.Items // Blacksmithing shows the gump regardless of proximity of an anvil and forge after SE if (num > 0 && (num != 1044267 || !Core.SE)) - from.SendLocalizedMessage(num); + { + @from.SendLocalizedMessage(num); + } else - from.SendGump(new CraftGump(from, system, this, null)); + { + @from.SendGump(new CraftGump(@from, system, this, null)); + } } else { diff --git a/Projects/UOContent/Items/Skill Items/Tools/Blowpipe.cs b/Projects/UOContent/Items/Skill Items/Tools/Blowpipe.cs index a12635218..a0cbbb4c2 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/Blowpipe.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/Blowpipe.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 4.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/DovetailSaw.cs b/Projects/UOContent/Items/Skill Items/Tools/DovetailSaw.cs index ace0e56da..8210096aa 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/DovetailSaw.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/DovetailSaw.cs @@ -31,7 +31,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/FletcherTools.cs b/Projects/UOContent/Items/Skill Items/Tools/FletcherTools.cs index 5fb1f0470..0cffc8e37 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/FletcherTools.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/FletcherTools.cs @@ -31,7 +31,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/JointingPlane.cs b/Projects/UOContent/Items/Skill Items/Tools/JointingPlane.cs index eb738294a..393450803 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/JointingPlane.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/JointingPlane.cs @@ -31,7 +31,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/MapmakersPen.cs b/Projects/UOContent/Items/Skill Items/Tools/MapmakersPen.cs index b5457b37a..f760be821 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/MapmakersPen.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/MapmakersPen.cs @@ -33,7 +33,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/RunicDovetailSaw.cs b/Projects/UOContent/Items/Skill Items/Tools/RunicDovetailSaw.cs index a55a30e79..7bc951ed0 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/RunicDovetailSaw.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/RunicDovetailSaw.cs @@ -31,7 +31,9 @@ namespace Server.Items var index = CraftResources.GetIndex(Resource); if (index >= 1 && index <= 6) + { return 1072633 + index; + } return 1024137; // dovetail saw } diff --git a/Projects/UOContent/Items/Skill Items/Tools/RunicFletcherTool.cs b/Projects/UOContent/Items/Skill Items/Tools/RunicFletcherTool.cs index 6c0da7872..489090620 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/RunicFletcherTool.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/RunicFletcherTool.cs @@ -31,7 +31,9 @@ namespace Server.Items var index = CraftResources.GetIndex(Resource); if (index >= 1 && index <= 6) + { return 1072627 + index; + } return 1044559; // Fletcher's Tools } diff --git a/Projects/UOContent/Items/Skill Items/Tools/RunicHammer.cs b/Projects/UOContent/Items/Skill Items/Tools/RunicHammer.cs index 9316816de..f3051982f 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/RunicHammer.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/RunicHammer.cs @@ -34,7 +34,9 @@ namespace Server.Items var index = CraftResources.GetIndex(Resource); if (index >= 1 && index <= 8) + { return 1049019 + index; + } return 1045128; // runic smithy hammer } @@ -47,16 +49,22 @@ namespace Server.Items var index = CraftResources.GetIndex(Resource); if (index >= 1 && index <= 8) + { return; + } if (!CraftResources.IsStandard(Resource)) { var num = CraftResources.GetLocalizationNumber(Resource); if (num > 0) + { list.Add(num); + } else + { list.Add(CraftResources.GetName(Resource)); + } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs b/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs index fad8d69f8..ae5d9449b 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs @@ -33,9 +33,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(Resource); if (num > 0) + { v = $"#{num}"; + } else + { v = CraftResources.GetName(Resource); + } } list.Add(1061119, v); // ~1_LEATHER_TYPE~ runic sewing kit @@ -50,9 +54,13 @@ namespace Server.Items var num = CraftResources.GetLocalizationNumber(Resource); if (num > 0) + { v = $"#{num}"; + } else + { v = CraftResources.GetName(Resource); + } } LabelTo(from, 1061119, v); // ~1_LEATHER_TYPE~ runic sewing kit @@ -72,7 +80,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ItemID == 0x13E4 || ItemID == 0x13E3) + { ItemID = 0xF9D; + } } } } diff --git a/Projects/UOContent/Items/Skill Items/Tools/ScribesPen.cs b/Projects/UOContent/Items/Skill Items/Tools/ScribesPen.cs index ebc392657..6f3071d6f 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/ScribesPen.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/ScribesPen.cs @@ -33,7 +33,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs index 03b96762e..8120aa8e9 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs @@ -66,7 +66,9 @@ namespace Server.Items var name = RandomTrack(DawnsMusicRarity.Common); if (!Tracks.Contains(name)) + { Tracks.Add(name); + } } } @@ -84,7 +86,9 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { if (!(newItem is DawnsMusicBox box)) + { return; + } box.Tracks = new List(); box.Tracks.AddRange(Tracks); @@ -117,11 +121,19 @@ namespace Server.Items } if (commonSongs > 0) + { list.Add(1075234, commonSongs.ToString()); // ~1_NUMBER~ Common Tracks + } + if (uncommonSongs > 0) + { list.Add(1075235, uncommonSongs.ToString()); // ~1_NUMBER~ Uncommon Tracks + } + if (rareSongs > 0) + { list.Add(1075236, rareSongs.ToString()); // ~1_NUMBER~ Rare Tracks + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -156,9 +168,13 @@ namespace Server.Items public void PlayMusic(Mobile m, MusicName music) { if (m_Timer?.Running == true) + { EndMusic(m); + } else + { m_ItemID = ItemID; + } m.Send(new PlayMusic(music)); m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), 4, Animate); @@ -167,12 +183,16 @@ namespace Server.Items public void EndMusic(Mobile m) { if (m_Timer?.Running == true) + { m_Timer.Stop(); + } m.Send(StopMusic.Instance); if (m_Count > 0) + { ItemID = m_ItemID; + } m_Count = 0; } @@ -201,7 +221,9 @@ namespace Server.Items writer.Write(Tracks.Count); for (var i = 0; i < Tracks.Count; i++) + { writer.Write((int)Tracks[i]); + } writer.Write((int)Level); writer.Write(m_ItemID); @@ -217,7 +239,9 @@ namespace Server.Items Tracks = new List(); for (var i = 0; i < count; i++) + { Tracks.Add((MusicName)reader.ReadInt()); + } Level = (SecureLevel)reader.ReadInt(); m_ItemID = reader.ReadInt(); @@ -288,7 +312,9 @@ namespace Server.Items public static DawnsMusicInfo GetInfo(MusicName name) { if (m_Info == null) // sanity + { return null; + } m_Info.TryGetValue(name, out var info); return info; diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs index d71faf015..2cb17d374 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs @@ -39,11 +39,17 @@ namespace Server.Items if (info != null) { if (info.Rarity == DawnsMusicRarity.Common) + { list.Add(1075204); // Gear for Dawn's Music Box (Common) + } else if (info.Rarity == DawnsMusicRarity.Uncommon) + { list.Add(1075205); // Gear for Dawn's Music Box (Uncommon) + } else if (info.Rarity == DawnsMusicRarity.Rare) + { list.Add(1075206); // Gear for Dawn's Music Box (Rare) + } list.Add(info.Name); } @@ -88,11 +94,17 @@ namespace Server.Items var rand = Utility.RandomDouble(); if (rand < 0.025) + { rarity = DawnsMusicRarity.Rare; + } else if (rand < 0.225) + { rarity = DawnsMusicRarity.Uncommon; + } else + { rarity = DawnsMusicRarity.Common; + } Music = DawnsMusicBox.RandomTrack(rarity); } @@ -107,7 +119,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Gear?.Deleted != false) + { return; + } if (targeted is DawnsMusicBox box) { diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs index 89d9fb161..e17343dac 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/FountainOfLife.cs @@ -92,7 +92,9 @@ namespace Server.Items var allow = base.OnDragDrop(from, dropped); if (allow) - Enhance(from); + { + Enhance(@from); + } return allow; } @@ -108,7 +110,9 @@ namespace Server.Items var allow = base.OnDragDropInto(from, item, p); if (allow) - Enhance(from); + { + Enhance(@from); + } return allow; } @@ -154,9 +158,13 @@ namespace Server.Items var now = DateTime.UtcNow; if (next < now) + { m_Timer = Timer.DelayCall(RechargeTime, Recharge); + } else + { m_Timer = Timer.DelayCall(next - now, RechargeTime, Recharge); + } } public void Recharge() @@ -171,7 +179,9 @@ namespace Server.Items for (var i = Items.Count - 1; i >= 0 && m_Charges > 0; --i) { if (Items[i] is EnhancedBandage) + { continue; + } if (Items[i] is Bandage bandage) { @@ -191,7 +201,9 @@ namespace Server.Items } if (from == null || !TryDropItem(from, enhanced, false)) // try stacking first + { DropItem(enhanced); + } } } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/OssianGrimoire.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/OssianGrimoire.cs index 2e27e1de0..47c0c2bbb 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/OssianGrimoire.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/OssianGrimoire.cs @@ -33,7 +33,9 @@ var version = reader.ReadEncodedInt(); if (version == 0) + { Attributes.IncreasedKarmaLoss = 5; + } } } } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/QuiverOfInfinity.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/QuiverOfInfinity.cs index 5dcec732c..be400f435 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/QuiverOfInfinity.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/QuiverOfInfinity.cs @@ -34,10 +34,14 @@ var version = reader.ReadEncodedInt(); if (version < 1 && DamageIncrease == 0) + { DamageIncrease = 10; + } if (version < 2 && Attributes.WeaponDamage == 10) + { Attributes.WeaponDamage = 0; + } } } } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/Talismans.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/Talismans.cs index 2fbd9b39e..dcc3dcf34 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/Talismans.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/Talismans.cs @@ -50,19 +50,33 @@ namespace Server.Items { base.OnRemoved(parent); - if (parent is Mobile m) AnimalForm.RemoveContext(m, true); + if (parent is Mobile m) + { + AnimalForm.RemoveContext(m, true); + } } public static bool EntryEnabled(Mobile m, Type type) { if (type == typeof(Squirrel)) + { return m.Talisman is SquirrelFormTalisman; + } + if (type == typeof(Ferret)) + { return m.Talisman is FerretFormTalisman; + } + if (type == typeof(CuSidhe)) + { return m.Talisman is CuSidheFormTalisman; + } + if (type == typeof(Reptalon)) + { return m.Talisman is ReptalonFormTalisman; + } return true; } diff --git a/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenBed.cs b/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenBed.cs index d3217db5b..47998ec07 100644 --- a/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenBed.cs +++ b/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenBed.cs @@ -121,7 +121,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenFallenChair.cs b/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenFallenChair.cs index 35fa64e9c..297aa29a3 100644 --- a/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenFallenChair.cs +++ b/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenFallenChair.cs @@ -27,7 +27,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version < 1 && ItemID == 0xC17) + { ItemID = 0xC19; + } } } diff --git a/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenVanity.cs b/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenVanity.cs index c85ae547d..4ab1b0de3 100644 --- a/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenVanity.cs +++ b/Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenVanity.cs @@ -117,7 +117,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs b/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs index 5b322324c..0a053bc94 100644 --- a/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs +++ b/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs @@ -78,7 +78,9 @@ namespace Server.Items base.GetProperties(list); if (m_Bonus != 0) + { list.Add(1060451, "#1042354\t{0}", m_Bonus.ToString()); // ~1_skillname~ +~2_val~ + } } public override void Serialize(IGenericWriter writer) @@ -114,7 +116,9 @@ namespace Server.Items } if (Hue == 0) + { Hue = 0x482; + } } } } diff --git a/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs b/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs index 237d52d15..e34c1f0ce 100644 --- a/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs +++ b/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs @@ -201,7 +201,9 @@ namespace Server.Items base.GetProperties(list); if (m_Bonus != 0) + { list.Add(1062005, m_Bonus.ToString()); // mining bonus +~1_val~ + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs b/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs index 91ebb8bb6..4d8d64b45 100644 --- a/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs +++ b/Projects/UOContent/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs @@ -84,9 +84,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } private class InternalTarget : Target @@ -128,15 +132,24 @@ namespace Server.Items var bonus = initMaxHP - wearable.MaxHitPoints; if (bonus > 10) + { bonus = 10; + } wearable.MaxHitPoints += bonus; wearable.HitPoints += bonus; wearable.ScaleDurability(); - if (wearable.MaxHitPoints > 255) wearable.MaxHitPoints = 255; - if (wearable.HitPoints > 255) wearable.HitPoints = 255; + if (wearable.MaxHitPoints > 255) + { + wearable.MaxHitPoints = 255; + } + + if (wearable.HitPoints > 255) + { + wearable.HitPoints = 255; + } if (wearable.MaxHitPoints > origMaxHP) { diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs index 1fc687dca..0e10092af 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs @@ -28,7 +28,9 @@ namespace Server.Items Clock.GetTime(Map, X, Y, out var hours, out int _); if (hours < 4 || hours > 20) + { Effects.PlaySound(Location, Map, 0x569); + } UpdateImage(); } @@ -43,7 +45,9 @@ namespace Server.Items base.OnAfterDelete(); if (m_Timer?.Running == true) + { m_Timer.Stop(); + } } public override void Serialize(IGenericWriter writer) @@ -70,36 +74,64 @@ namespace Server.Items if (FacingSouth) { if (hours < 4) + { ItemID = 0x2A60; + } else if (hours < 6) + { ItemID = 0x2A5F; + } else if (hours < 8) + { ItemID = 0x2A5E; + } else if (hours < 16) + { ItemID = 0x2A5D; + } else if (hours < 18) + { ItemID = 0x2A5E; + } else if (hours < 20) + { ItemID = 0x2A5F; + } else + { ItemID = 0x2A60; + } } else { if (hours < 4) + { ItemID = 0x2A64; + } else if (hours < 6) + { ItemID = 0x2A63; + } else if (hours < 8) + { ItemID = 0x2A62; + } else if (hours < 16) + { ItemID = 0x2A61; + } else if (hours < 18) + { ItemID = 0x2A62; + } else if (hours < 20) + { ItemID = 0x2A63; + } else + { ItemID = 0x2A64; + } } } @@ -120,7 +152,9 @@ namespace Server.Items protected override void OnTick() { if (m_Component?.Deleted == false) + { m_Component.UpdateImage(); + } } } } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/BedOfNails.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/BedOfNails.cs index 3fcda6d44..98eac9c43 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/BedOfNails.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/BedOfNails.cs @@ -21,7 +21,9 @@ namespace Server.Items var allow = base.OnMoveOver(m); if (allow && Addon is BedOfNailsAddon addon) + { addon.OnMoveOver(m); + } return allow; } @@ -69,13 +71,19 @@ namespace Server.Items if (m.Player) { if (m.Female) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x53B, 0x53D)); + } else + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x53E, 0x540)); + } } if (m_Timer?.Running != true) + { (m_Timer = new InternalTimer(m)).Start(); + } } return true; @@ -143,7 +151,9 @@ namespace Server.Items z = m_Mobile.Map.GetAverageZ(x, y); if (!m_Mobile.Map.CanFit(x, y, z, 1, false, false)) + { continue; + } } var blood = new Blood(Utility.RandomMinMax(0x122C, 0x122F)); diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneCouch.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneCouch.cs index 7623cfb9a..0474cc718 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneCouch.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneCouch.cs @@ -17,7 +17,9 @@ namespace Server.Items var allow = base.OnMoveOver(m); if (allow && m.Alive && m.Player && (m.AccessLevel == AccessLevel.Player || !m.Hidden)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x547, 0x54A)); + } return allow; } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneThrone.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneThrone.cs index b26a3d2cb..7f9041181 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneThrone.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/BoneThrone.cs @@ -18,7 +18,9 @@ namespace Server.Items var allow = base.OnMoveOver(m); if (allow && m.Alive && m.Player && (m.AccessLevel == AccessLevel.Player || !m.Hidden)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x54B, 0x54D)); + } return allow; } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs index c9e7a15da..48c995a3f 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs @@ -20,9 +20,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x565, 0x566)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void OnMovement(Mobile m, Point3D old) @@ -72,7 +76,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (version == 0 && ItemID != 0x2A69 && ItemID != 0x2A6D) + { ItemID = 0x2A69; + } } } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs index 41a6f5f3c..1c02ab645 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs @@ -23,9 +23,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x567, 0x568)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void OnAfterDelete() @@ -33,7 +37,9 @@ namespace Server.Items base.OnAfterDelete(); if (m_Timer?.Running == true) + { m_Timer.Stop(); + } } public override void Serialize(IGenericWriter writer) @@ -55,9 +61,13 @@ namespace Server.Items private void Change() { if (ItemID < 0x2A61) + { ItemID = Utility.RandomMinMax(0x2A5D, 0x2A60); + } else + { ItemID = Utility.RandomMinMax(0x2A61, 0x2A64); + } } } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs index 0f8e16679..f43857563 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs @@ -31,7 +31,9 @@ namespace Server.Items else if (Utility.InRange(old, Location, 2) && !Utility.InRange(m.Location, Location, 2)) { if (ItemID == 0x2A7C || ItemID == 0x2A7E) + { ItemID -= 1; + } } } } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieBlue.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieBlue.cs index eaad33507..e9a25dfdf 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieBlue.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieBlue.cs @@ -18,9 +18,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x55C, 0x55E)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieGreen.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieGreen.cs index 03fa6f1e8..58e79c9ea 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieGreen.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieGreen.cs @@ -18,9 +18,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x554, 0x557)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieLime.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieLime.cs index ebdb0ac1f..b84eb381c 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieLime.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieLime.cs @@ -18,9 +18,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x55F, 0x561)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieOrange.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieOrange.cs index 073d36d70..41a54aa6a 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieOrange.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieOrange.cs @@ -18,9 +18,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x558, 0x55B)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieWhite.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieWhite.cs index 65541a645..5308a1cc6 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieWhite.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/MountedPixieWhite.cs @@ -18,9 +18,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x562, 0x564)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/SacrificialAltar.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/SacrificialAltar.cs index cdde23388..a4e1ecdd2 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/SacrificialAltar.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/SacrificialAltar.cs @@ -28,7 +28,9 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item dropped) { if (!base.OnDragDrop(from, dropped)) + { return false; + } if (TotalItems >= 50) { @@ -50,7 +52,9 @@ namespace Server.Items public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { if (!base.OnDragDropInto(from, item, p)) + { return false; + } if (TotalItems >= 50) { @@ -83,7 +87,9 @@ namespace Server.Items var version = reader.ReadEncodedInt(); if (Items.Count > 0) + { m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(3), Empty); + } } public virtual void Flip(Mobile from, Direction direction) @@ -112,13 +118,17 @@ namespace Server.Items Effects.PlaySound(location, Map, 0x32E); if (Items.Count > 0) + { for (var i = Items.Count - 1; i >= 0; --i) { if (i >= Items.Count) + { continue; + } Items[i].Delete(); } + } } m_Timer?.Stop(); diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/UnsettlingPortrait.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/UnsettlingPortrait.cs index 2aab1ab62..ed5945bae 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/UnsettlingPortrait.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/UnsettlingPortrait.cs @@ -23,9 +23,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Utility.InRange(Location, from.Location, 2)) + { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x567, 0x568)); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void OnAfterDelete() @@ -54,13 +58,21 @@ namespace Server.Items private void ChangeDirection() { if (ItemID == 0x2A65) + { ItemID += 1; + } else if (ItemID == 0x2A66) + { ItemID -= 1; + } else if (ItemID == 0x2A67) + { ItemID += 1; + } else if (ItemID == 0x2A68) + { ItemID -= 1; + } } } diff --git a/Projects/UOContent/Items/Special/Gifts/HearthOfHomeFire.cs b/Projects/UOContent/Items/Special/Gifts/HearthOfHomeFire.cs index c72bef809..09f621627 100644 --- a/Projects/UOContent/Items/Special/Gifts/HearthOfHomeFire.cs +++ b/Projects/UOContent/Items/Special/Gifts/HearthOfHomeFire.cs @@ -117,7 +117,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs b/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs index 62969ba7d..b312c9c61 100644 --- a/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs +++ b/Projects/UOContent/Items/Special/Gifts/RoseOfTrinsic.cs @@ -47,9 +47,13 @@ namespace Server.Items else { if (value <= 0) + { m_Petals = 0; + } else + { m_Petals = value; + } StartSpawnTimer(m_SpawnTime); } @@ -129,7 +133,9 @@ namespace Server.Items Level = (SecureLevel)reader.ReadEncodedInt(); if (m_Petals < 10) + { StartSpawnTimer(m_NextSpawnTime - DateTime.UtcNow); + } } private class SpawnTimer : Timer @@ -146,7 +152,9 @@ namespace Server.Items protected override void OnTick() { if (m_Rose.Deleted) + { return; + } m_Rose.m_SpawnTimer = null; m_Rose.Petals++; diff --git a/Projects/UOContent/Items/Special/Heritage Items/Curtains.cs b/Projects/UOContent/Items/Special/Heritage Items/Curtains.cs index eb34691eb..d7365011a 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/Curtains.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/Curtains.cs @@ -20,7 +20,9 @@ namespace Server.Items public virtual bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; return true; @@ -31,8 +33,11 @@ namespace Server.Items base.OnDoubleClick(from); if (Addon != null) - if (from.InRange(Location, 1)) + { + if (@from.InRange(Location, 1)) + { foreach (var c in Addon.Components) + { if (c is CurtainsComponent curtain) { var temp = curtain.ItemID; @@ -41,8 +46,11 @@ namespace Server.Items } else { - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } + } + } + } } public override void Serialize(IGenericWriter writer) @@ -183,7 +191,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/FruitTrees.cs b/Projects/UOContent/Items/Special/Heritage Items/FruitTrees.cs index 9e32c8f95..46759ca65 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/FruitTrees.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/FruitTrees.cs @@ -35,7 +35,9 @@ namespace Server.Items var fruit = Fruit; if (fruit == null) + { return; + } if (!from.PlaceInBackpack(fruit)) { @@ -45,7 +47,9 @@ namespace Server.Items else { if (--m_Fruits == 0) + { Timer.DelayCall(TimeSpan.FromMinutes(30), Respawn); + } from.SendLocalizedMessage(501016); // You pick some fruit and put it in your backpack. } @@ -84,7 +88,9 @@ namespace Server.Items m_Fruits = reader.ReadInt(); if (m_Fruits == 0) + { Respawn(); + } } } diff --git a/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs b/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs index 4eb9cdff4..b66670f23 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs @@ -88,9 +88,13 @@ namespace Server.Items public virtual void Activate(AddonComponent c, Mobile from) { if (c.ItemID == 0x125E || c.ItemID == 0x1269 || c.ItemID == 0x1260) + { c.ItemID = 0x1269; + } else + { c.ItemID = 0x1247; + } // blood var amount = Utility.RandomMinMax(3, 7); @@ -106,7 +110,9 @@ namespace Server.Items z = c.Map.GetAverageZ(x, y); if (!c.Map.CanFit(x, y, z, 1, false, false)) + { continue; + } } var blood = new Blood(Utility.RandomMinMax(0x122C, 0x122F)); @@ -114,9 +120,13 @@ namespace Server.Items } if (from.Female) - from.PlaySound(Utility.RandomMinMax(0x150, 0x153)); + { + @from.PlaySound(Utility.RandomMinMax(0x150, 0x153)); + } else - from.PlaySound(Utility.RandomMinMax(0x15A, 0x15D)); + { + @from.PlaySound(Utility.RandomMinMax(0x15A, 0x15D)); + } from.LocalOverheadMessage( MessageType.Regular, @@ -131,13 +141,21 @@ namespace Server.Items private void Deactivate(AddonComponent c) { if (c.ItemID == 0x1269) + { c.ItemID = 0x1260; + } else if (c.ItemID == 0x1260) + { c.ItemID = 0x125E; + } else if (c.ItemID == 0x1247) + { c.ItemID = 0x1246; + } else if (c.ItemID == 0x1246) + { c.ItemID = 0x1230; + } } } diff --git a/Projects/UOContent/Items/Special/Heritage Items/HangingAxes.cs b/Projects/UOContent/Items/Special/Heritage Items/HangingAxes.cs index 64e81aa22..13011be2f 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/HangingAxes.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/HangingAxes.cs @@ -117,7 +117,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/HangingSwords.cs b/Projects/UOContent/Items/Special/Heritage Items/HangingSwords.cs index 145c982e7..0b92850eb 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/HangingSwords.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/HangingSwords.cs @@ -117,7 +117,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs b/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs index 5d7684033..bb610e8d8 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs @@ -161,7 +161,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0 || info.ButtonID < 1 || info.ButtonID > 8) + { return; + } m_Deed.m_Type = info.ButtonID - 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/IronMaiden.cs b/Projects/UOContent/Items/Special/Heritage Items/IronMaiden.cs index 13b09def8..ff57499dd 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/IronMaiden.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/IronMaiden.cs @@ -62,7 +62,9 @@ namespace Server.Items c.ItemID += 1; if (c.ItemID < 0x124D) + { return; + } // blood var amount = Utility.RandomMinMax(3, 7); @@ -78,7 +80,9 @@ namespace Server.Items z = c.Map.GetAverageZ(x, y); if (!c.Map.CanFit(x, y, z, 1, false, false)) + { continue; + } } var blood = new Blood(Utility.RandomMinMax(0x122C, 0x122F)); diff --git a/Projects/UOContent/Items/Special/Heritage Items/Statue.cs b/Projects/UOContent/Items/Special/Heritage Items/Statue.cs index 5569fd7a6..dc090e7be 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/Statue.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/Statue.cs @@ -119,7 +119,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/UnmadeBed.cs b/Projects/UOContent/Items/Special/Heritage Items/UnmadeBed.cs index 96848bba9..365b00b60 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/UnmadeBed.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/UnmadeBed.cs @@ -121,7 +121,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/Vanity.cs b/Projects/UOContent/Items/Special/Heritage Items/Vanity.cs index f0c52da9b..513f4314d 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/Vanity.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/Vanity.cs @@ -9,9 +9,13 @@ namespace Server.Items public VanityAddon(bool east) : base(east ? 0xA44 : 0xA3C) { if (east) // east + { AddComponent(new AddonContainerComponent(0xA45), 0, -1, 0); + } else // south + { AddComponent(new AddonContainerComponent(0xA3D), -1, 0, 0); + } } public VanityAddon(Serial serial) : base(serial) @@ -114,7 +118,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Heritage Items/WoodenCoffin.cs b/Projects/UOContent/Items/Special/Heritage Items/WoodenCoffin.cs index d92d80b7f..284befb56 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/WoodenCoffin.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/WoodenCoffin.cs @@ -146,7 +146,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == 0) + { return; + } m_Deed.m_East = info.ButtonID != 1; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Holiday/Christmas/HolidayTree.cs b/Projects/UOContent/Items/Special/Holiday/Christmas/HolidayTree.cs index 682d8124d..2a134f617 100644 --- a/Projects/UOContent/Items/Special/Holiday/Christmas/HolidayTree.cs +++ b/Projects/UOContent/Items/Special/Holiday/Christmas/HolidayTree.cs @@ -108,7 +108,9 @@ namespace Server.Items public override void OnAfterDelete() { for (var i = 0; i < m_Components.Count; ++i) + { m_Components[i].Delete(); + } } private void AddOrnament(int x, int y, int z, int itemID) @@ -134,7 +136,9 @@ namespace Server.Items writer.Write(m_Components.Count); for (var i = 0; i < m_Components.Count; ++i) + { writer.Write(m_Components[i]); + } } public override void Deserialize(IGenericReader reader) @@ -162,7 +166,9 @@ namespace Server.Items var item = reader.ReadItem(); if (item != null) + { m_Components.Add(item); + } } break; @@ -195,7 +201,9 @@ namespace Server.Items var house = BaseHouse.FindHouseAt(this); if (house?.Addons.Contains(this) == true) + { house.Addons.Remove(this); + } from.SendLocalizedMessage(503393); // A deed for the tree has been placed in your backpack. } @@ -256,7 +264,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_Tree?.Deleted == false) - m_Tree.OnDoubleClick(from); + { + m_Tree.OnDoubleClick(@from); + } } public override void Serialize(IGenericWriter writer) @@ -281,7 +291,9 @@ namespace Server.Items m_Tree = reader.ReadItem() as HolidayTree; if (m_Tree == null) + { Delete(); + } break; } diff --git a/Projects/UOContent/Items/Special/Holiday/HolidayBell.cs b/Projects/UOContent/Items/Special/Holiday/HolidayBell.cs index 17aa63433..41dfaf98b 100644 --- a/Projects/UOContent/Items/Special/Holiday/HolidayBell.cs +++ b/Projects/UOContent/Items/Special/Holiday/HolidayBell.cs @@ -81,8 +81,13 @@ public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) - from.SendLocalizedMessage(500446); // That is too far away. - else from.PlaySound(m_SoundID); + { + @from.SendLocalizedMessage(500446); // That is too far away. + } + else + { + @from.PlaySound(m_SoundID); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs b/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs index b256d62d4..7714fc15d 100644 --- a/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs +++ b/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs @@ -27,7 +27,9 @@ namespace Server.Items private static CandyCaneTimer EnsureTimer(Mobile from) { if (!m_ToothAches.TryGetValue(from, out var timer)) - m_ToothAches[from] = timer = new CandyCaneTimer(from); + { + m_ToothAches[@from] = timer = new CandyCaneTimer(@from); + } return timer; } @@ -96,7 +98,9 @@ namespace Server.Items */ if (Utility.RandomBool() && Eater.Body.IsHuman && !Eater.Mounted) + { Eater.Animate(32, 5, 1, true, false, 0); + } } else if (Eaten == 60) { diff --git a/Projects/UOContent/Items/Special/Holiday/HolidayPottedPlant.cs b/Projects/UOContent/Items/Special/Holiday/HolidayPottedPlant.cs index 252bf670d..a9aeeb68a 100644 --- a/Projects/UOContent/Items/Special/Holiday/HolidayPottedPlant.cs +++ b/Projects/UOContent/Items/Special/Holiday/HolidayPottedPlant.cs @@ -119,7 +119,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false) + { return; + } var from = sender.Mobile; diff --git a/Projects/UOContent/Items/Special/Holiday/IcyPatch.cs b/Projects/UOContent/Items/Special/Holiday/IcyPatch.cs index 6debe2a2c..62039334c 100644 --- a/Projects/UOContent/Items/Special/Holiday/IcyPatch.cs +++ b/Projects/UOContent/Items/Special/Holiday/IcyPatch.cs @@ -29,6 +29,7 @@ namespace Server.Items public override bool OnMoveOver(Mobile m) { if (m is PlayerMobile && m.Alive && m.AccessLevel == AccessLevel.Player) + { switch (Utility.Random(3)) { case 0: @@ -41,6 +42,7 @@ namespace Server.Items RunSequence(m, 1095162, true); break; // You lose your footing and ungracefully splatter on the ground. } + } return base.OnMoveOver(m); } @@ -61,12 +63,16 @@ namespace Server.Items if (message == 1095162) { if (m.Mounted) + { m.Mount.Rider = null; + } var p = new Point3D(Location); if (SpellHelper.FindValidSpawnLocation(Map, ref p, true)) + { Timer.DelayCall(TimeSpan.FromSeconds(0), m.MoveToWorld, p, m.Map); + } action = 21 + Utility.Random(2); sound = m.Female ? 0x317 : 0x426; @@ -78,13 +84,17 @@ namespace Server.Items } if (action > 0) + { Timer.DelayCall(TimeSpan.FromSeconds(0.4), BeginFall_Callback, m, action, sound); + } } private static void BeginFall_Callback(Mobile m, int action, int sound) { if (!m.Mounted) + { m.Animate(action, 1, 1, false, true, 0); + } m.PlaySound(sound); } diff --git a/Projects/UOContent/Items/Special/Holiday/SnowGlobes.cs b/Projects/UOContent/Items/Special/Holiday/SnowGlobes.cs index f2135702e..58086ff70 100644 --- a/Projects/UOContent/Items/Special/Holiday/SnowGlobes.cs +++ b/Projects/UOContent/Items/Special/Holiday/SnowGlobes.cs @@ -193,7 +193,9 @@ namespace Server.Items var idx = (int)m_Type; if (idx < 0 || idx >= m_PlaceNames.Length) + { return "a snowy scene"; + } return $"a snowy scene of {m_PlaceNames[idx]}"; } @@ -278,7 +280,9 @@ namespace Server.Items get { if (m_Type >= SnowGlobeTypeThree.Covetous) + { return 1075440 + ((int)m_Type - 4); + } return 1075294 + (int)m_Type; } diff --git a/Projects/UOContent/Items/Special/Holiday/SnowStatue.cs b/Projects/UOContent/Items/Special/Holiday/SnowStatue.cs index d84883f75..f41d1f073 100644 --- a/Projects/UOContent/Items/Special/Holiday/SnowStatue.cs +++ b/Projects/UOContent/Items/Special/Holiday/SnowStatue.cs @@ -204,7 +204,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false) + { return; + } var from = sender.Mobile; diff --git a/Projects/UOContent/Items/Special/Holiday/Snowman.cs b/Projects/UOContent/Items/Special/Holiday/Snowman.cs index c5dc35dd1..f94f8d02b 100644 --- a/Projects/UOContent/Items/Special/Holiday/Snowman.cs +++ b/Projects/UOContent/Items/Special/Holiday/Snowman.cs @@ -106,7 +106,9 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -120,7 +122,9 @@ namespace Server.Items base.GetProperties(list); if (m_Title != null) + { list.Add(1062841, m_Title); // ~1_NAME~ the Snowman + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Holiday/Wreath.cs b/Projects/UOContent/Items/Special/Holiday/Wreath.cs index f04bc87d9..4dde978cd 100644 --- a/Projects/UOContent/Items/Special/Holiday/Wreath.cs +++ b/Projects/UOContent/Items/Special/Holiday/Wreath.cs @@ -26,10 +26,15 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (!map.CanFit(p.X, p.Y, p.Z, ItemData.Height)) + { return false; + } if (ItemID == 0x232C) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // North wall + } + return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // West wall } @@ -38,7 +43,9 @@ namespace Server.Items public virtual bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } var house = BaseHouse.FindHouseAt(this); @@ -76,7 +83,9 @@ namespace Server.Items private void FixMovingCrate() { if (Deleted) + { return; + } if (Movable || IsLockedDown) { @@ -138,7 +147,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Addon.Deleted) + { return; + } if (info.ButtonID == 1) { @@ -217,7 +228,9 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted) { if (!(targeted is IPoint3D p)) + { return; + } var loc = new Point3D(p); @@ -229,9 +242,13 @@ namespace Server.Items var westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map); if (northWall && westWall) - from.SendGump(new WreathDeedGump(from, loc, this)); + { + @from.SendGump(new WreathDeedGump(@from, loc, this)); + } else - PlaceAddon(from, loc, northWall, westWall); + { + PlaceAddon(@from, loc, northWall, westWall); + } } else { @@ -242,7 +259,9 @@ namespace Server.Items private void PlaceAddon(Mobile from, Point3D loc, bool northWall, bool westWall) { if (Deleted) + { return; + } var house = BaseHouse.FindHouseAt(loc, from.Map, 16); @@ -255,11 +274,17 @@ namespace Server.Items var itemID = 0; if (northWall) + { itemID = 0x232C; + } else if (westWall) + { itemID = 0x232D; + } else - from.SendLocalizedMessage(1062840); // The decoration must be placed next to a wall. + { + @from.SendLocalizedMessage(1062840); // The decoration must be placed next to a wall. + } if (itemID > 0) { @@ -298,7 +323,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs index 80c7bf888..c69b1f665 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleDeed.cs @@ -101,7 +101,9 @@ namespace Server.Items } if (IsExpired) + { list.Add(1150487); // [Expired] + } // list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~ } @@ -109,7 +111,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!ValidLocation()) + { return; + } if (IsChildOf(from.Backpack)) { @@ -188,11 +192,15 @@ namespace Server.Items private static string FormatDescription(HouseRaffleDeed deed) { if (deed == null) + { return string.Empty; + } if (deed.IsExpired) + { return $"This deed once entitled the bearer to build a house on the plot of land located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.

The deed has expired, and now the indicated plot of land is subject to normal house construction rules.

This deed functions as a recall rune marked for the location of the plot it represents.
"; + } var daysLeft = (int)Math.Ceiling( (deed.Stone.Started + deed.Stone.Duration + diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs index 5e30a5dc9..8fe03caab 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs @@ -88,14 +88,22 @@ namespace Server.Gumps AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor)); if (page > 0) + { AddButton(567, 104, 0x15E3, 0x15E7, 1); + } else + { AddImage(567, 104, 0x25EA); + } if ((page + 1) * 10 < m_List.Count) + { AddButton(584, 104, 0x15E1, 0x15E5, 2); + } else + { AddImage(584, 104, 0x25E6); + } AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor)); AddHtml(47, 120, 250, 20, Color("Name", LabelColor)); @@ -111,7 +119,9 @@ namespace Server.Gumps var entry = m_List[i]; if (entry == null) + { continue; + } AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i); @@ -123,18 +133,26 @@ namespace Server.Gumps if (entry.From != null) { if (entry.From.Account is Account acc) + { name = $"{entry.From.Name} ({acc})"; + } else + { name = entry.From.Name; + } } if (name != null) + { AddHtml(x + 2, 140 + idx * 20, 250, 20, Color(name, color)); + } x += 250; if (entry.Address != null) + { AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(entry.Address.ToString()), color)); + } x += 100; @@ -162,7 +180,9 @@ namespace Server.Gumps case 1: // Previous { if (m_Page > 0) + { m_Page--; + } from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); @@ -171,7 +191,9 @@ namespace Server.Gumps case 2: // Next { if ((m_Page + 1) * 10 < m_Stone.Entries.Count) + { m_Page++; + } from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); @@ -204,7 +226,9 @@ namespace Server.Gumps m_Stone.Entries.Remove(m_List[buttonId]); if (m_Page > 0 && m_Page * 10 >= m_List.Count - 1) + { m_Page--; + } from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); } @@ -224,11 +248,19 @@ namespace Server.Gumps var yIsNull = y?.From == null; if (xIsNull && yIsNull) + { return 0; + } + if (xIsNull) + { return -1; + } + if (yIsNull) + { return 1; + } var result = Insensitive.Compare(x.From.Name, y.From.Name); @@ -246,21 +278,37 @@ namespace Server.Gumps var yIsNull = y?.From == null; if (xIsNull && yIsNull) + { return 0; + } + if (xIsNull) + { return -1; + } + if (yIsNull) + { return 1; + } var a = x.From.Account as Account; var b = y.From.Account as Account; if (a == null && b == null) + { return 0; + } + if (a == null) + { return -1; + } + if (b == null) + { return 1; + } var result = Insensitive.Compare(a.Username, b.Username); @@ -278,11 +326,19 @@ namespace Server.Gumps var yIsNull = y?.Address == null; if (xIsNull && yIsNull) + { return 0; + } + if (xIsNull) + { return -1; + } + if (yIsNull) + { return 1; + } var a = x.Address.GetAddressBytes(); var b = y.Address.GetAddressBytes(); @@ -292,7 +348,9 @@ namespace Server.Gumps var compare = a[i].CompareTo(b[i]); if (compare != 0) + { return compare; + } } return x.Date.CompareTo(y.Date); diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleRegion.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleRegion.cs index 5cde8b8c9..bd92cc616 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleRegion.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleRegion.cs @@ -16,18 +16,26 @@ namespace Server.Regions public override bool AllowHousing(Mobile from, Point3D p) { if (m_Stone == null) + { return false; + } if (m_Stone.IsExpired) + { return true; + } if (m_Stone.Deed == null) + { return false; + } var pack = from.Backpack; if (pack != null && ContainsDeed(pack)) + { return true; + } var bank = from.FindBankNoCreate(); diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs index 973df50c9..308675648 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs @@ -209,7 +209,9 @@ namespace Server.Items get { if (m_State != HouseRaffleState.Completed) + { return false; + } return m_Started + m_Duration + ExpirationTime <= DateTime.UtcNow; } @@ -238,7 +240,9 @@ namespace Server.Items public static void CheckEnd_OnTick() { for (var i = 0; i < m_AllStones.Count; i++) + { m_AllStones[i].CheckEnd(); + } } public static void Initialize() @@ -248,6 +252,7 @@ namespace Server.Items var stone = m_AllStones[i]; if (stone.IsExpired) + { switch (stone.ExpireAction) { case HouseRaffleExpireAction.HideStone: @@ -266,6 +271,7 @@ namespace Server.Items break; } } + } } Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), CheckEnd_OnTick); @@ -293,16 +299,22 @@ namespace Server.Items private bool HasEntered(Mobile from) { if (!(from.Account is Account acc)) + { return false; + } foreach (var entry in Entries) + { if (entry.From != null) { var entryAcc = entry.From.Account as Account; if (entryAcc == acc) + { return true; + } } + } return false; } @@ -310,15 +322,23 @@ namespace Server.Items private bool IsAtIPLimit(Mobile from) { if (from.NetState == null) + { return false; + } var address = from.NetState.Address; var tickets = 0; foreach (var entry in Entries) + { if (Utility.IPMatchClassC(entry.Address, address)) + { if (++tickets >= EntryLimitPerIP) + { return true; + } + } + } return false; } @@ -332,6 +352,7 @@ namespace Server.Items bool xEast = false, ySouth = false; if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth)) + { result.AppendFormat( "{0}°{1}'{2},{3}°{4}'{5}", yLat, @@ -341,11 +362,16 @@ namespace Server.Items xMins, xEast ? "E" : "W" ); + } else + { result.AppendFormat("{0},{1}", loc.X, loc.Y); + } if (displayMap) + { result.AppendFormat(" ({0})", map); + } return result.ToString(); } @@ -362,7 +388,9 @@ namespace Server.Items public string FormatLocation() { if (!ValidLocation()) + { return "no location set"; + } return FormatLocation(GetPlotCenter(), m_Facet, true); } @@ -374,7 +402,9 @@ namespace Server.Items base.GetProperties(list); if (ValidLocation()) + { list.Add(FormatLocation()); + } switch (m_State) { @@ -424,16 +454,22 @@ namespace Server.Items list.Add(new EditEntry(from, this)); if (m_State == HouseRaffleState.Inactive) - list.Add(new ActivateEntry(from, this)); + { + list.Add(new ActivateEntry(@from, this)); + } else - list.Add(new ManagementEntry(from, this)); + { + list.Add(new ManagementEntry(@from, this)); + } } } public override void OnDoubleClick(Mobile from) { if (m_State != HouseRaffleState.Active || !from.CheckAlive()) + { return; + } if (!from.InRange(GetWorldLocation(), 2)) { @@ -442,11 +478,16 @@ namespace Server.Items } if (HasEntered(from)) - from.SendMessage(MessageHue, "You have already entered this plot's raffle."); + { + @from.SendMessage(MessageHue, "You have already entered this plot's raffle."); + } else if (IsAtIPLimit(from)) - from.SendMessage(MessageHue, "You may not enter this plot's raffle."); + { + @from.SendMessage(MessageHue, "You may not enter this plot's raffle."); + } else - from.SendGump( + { + @from.SendGump( new WarningGump( 1150470, 0x7F00, @@ -454,18 +495,23 @@ namespace Server.Items 0xFFFFFF, 420, 280, - okay => Purchase_Callback(from, okay) + okay => Purchase_Callback(@from, okay) ) ); // CONFIRM TICKET PURCHASE + } } public void Purchase_Callback(Mobile from, bool okay) { if (Deleted || m_State != HouseRaffleState.Active || !from.CheckAlive() || HasEntered(from) || IsAtIPLimit(from)) + { return; + } if (!(from.Account is Account)) + { return; + } if (okay) { @@ -492,7 +538,9 @@ namespace Server.Items public void CheckEnd() { if (m_State != HouseRaffleState.Active || m_Started + m_Duration > DateTime.UtcNow) + { return; + } m_State = HouseRaffleState.Completed; @@ -565,7 +613,9 @@ namespace Server.Items writer.Write(Entries.Count); foreach (var entry in Entries) + { entry.Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -615,7 +665,9 @@ namespace Server.Items var entry = new RaffleEntry(reader, version); if (entry.From == null) + { continue; // Character was deleted + } Entries.Add(entry); } @@ -627,11 +679,17 @@ namespace Server.Items if (version < 3) { if (oldActive) + { m_State = HouseRaffleState.Active; + } else if (m_Winner != null) + { m_State = HouseRaffleState.Completed; + } else + { m_State = HouseRaffleState.Inactive; + } } break; @@ -662,7 +720,9 @@ namespace Server.Items public override void OnClick() { if (m_Stone.Deleted || m_From.AccessLevel < AccessLevel.Seer) + { return; + } m_From.SendGump(new PropertiesGump(m_From, m_Stone)); } @@ -674,13 +734,17 @@ namespace Server.Items : base(from, stone, 5113) // Start { if (!stone.ValidLocation()) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_Stone.Deleted || m_From.AccessLevel < AccessLevel.Seer || !m_Stone.ValidLocation()) + { return; + } m_Stone.CurrentState = HouseRaffleState.Active; } @@ -696,7 +760,9 @@ namespace Server.Items public override void OnClick() { if (m_Stone.Deleted || m_From.AccessLevel < AccessLevel.Seer) + { return; + } m_From.SendGump(new HouseRaffleManagementGump(m_Stone)); } diff --git a/Projects/UOContent/Items/Special/ML/BaseImprisonedMobile.cs b/Projects/UOContent/Items/Special/ML/BaseImprisonedMobile.cs index 1b8476dbb..050209954 100644 --- a/Projects/UOContent/Items/Special/ML/BaseImprisonedMobile.cs +++ b/Projects/UOContent/Items/Special/ML/BaseImprisonedMobile.cs @@ -19,9 +19,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) - from.SendGump(new ConfirmBreakCrystalGump(this)); + { + @from.SendGump(new ConfirmBreakCrystalGump(this)); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/ML/GrizzledMareStatuette.cs b/Projects/UOContent/Items/Special/ML/GrizzledMareStatuette.cs index 441435c05..d6f5c8cb0 100644 --- a/Projects/UOContent/Items/Special/ML/GrizzledMareStatuette.cs +++ b/Projects/UOContent/Items/Special/ML/GrizzledMareStatuette.cs @@ -69,7 +69,10 @@ namespace Server.Mobiles var version = reader.ReadInt(); - if (version < 1) Timer.DelayCall(TimeSpan.FromSeconds(0), OnAfterDeserialize_Callback); + if (version < 1) + { + Timer.DelayCall(TimeSpan.FromSeconds(0), OnAfterDeserialize_Callback); + } } } } diff --git a/Projects/UOContent/Items/Special/MiniHouses.cs b/Projects/UOContent/Items/Special/MiniHouses.cs index 72e8e933b..51f0fb858 100644 --- a/Projects/UOContent/Items/Special/MiniHouses.cs +++ b/Projects/UOContent/Items/Special/MiniHouses.cs @@ -47,9 +47,15 @@ namespace Server.Items var num = 0; for (var y = 0; y < size; ++y) + { for (var x = 0; x < size; ++x) + { if (info.Graphics[num] != 0x1) // Veteran Rewards Mod + { AddComponent(new AddonComponent(info.Graphics[num++]), size - x - 1, size - y - 1, 0); + } + } + } } public override void Serialize(IGenericWriter writer) @@ -141,7 +147,9 @@ namespace Server.Items } if (Weight == 0.0) + { Weight = 1.0; + } } } @@ -223,7 +231,9 @@ namespace Server.Items Graphics = new int[count]; for (var i = 0; i < count; ++i) + { Graphics[i] = start + i; + } LabelNumber = labelNumber; } @@ -243,7 +253,9 @@ namespace Server.Items var v = (int)type; if (v < 0 || v >= m_Info.Length) + { v = 0; + } return m_Info[v]; } diff --git a/Projects/UOContent/Items/Special/MonsterStatuette.cs b/Projects/UOContent/Items/Special/MonsterStatuette.cs index 39a697c70..0bbe228bd 100644 --- a/Projects/UOContent/Items/Special/MonsterStatuette.cs +++ b/Projects/UOContent/Items/Special/MonsterStatuette.cs @@ -120,7 +120,9 @@ namespace Server.Items var v = (int)type; if (v < 0 || v >= m_Table.Length) + { v = 0; + } return m_Table[v]; } @@ -141,11 +143,17 @@ namespace Server.Items m_Type = type; if (m_Type == MonsterStatuetteType.Slime) + { Hue = Utility.RandomSlimeHue(); + } else if (m_Type == MonsterStatuetteType.RedDeath) + { Hue = 0x21; + } else if (m_Type == MonsterStatuetteType.HalloweenGhoul) + { Hue = 0xF4; + } } public MonsterStatuette(Serial serial) : base(serial) @@ -173,13 +181,21 @@ namespace Server.Items ItemID = MonsterStatuetteInfo.GetInfo(m_Type).ItemID; if (m_Type == MonsterStatuetteType.Slime) + { Hue = Utility.RandomSlimeHue(); + } else if (m_Type == MonsterStatuetteType.RedDeath) + { Hue = 0x21; + } else if (m_Type == MonsterStatuetteType.HalloweenGhoul) + { Hue = 0xF4; + } else + { Hue = 0; + } InvalidateProperties(); } @@ -202,7 +218,9 @@ namespace Server.Items var sounds = MonsterStatuetteInfo.GetInfo(m_Type).Sounds; if (sounds.Length > 0) + { Effects.PlaySound(Location, Map, sounds.RandomElement()); + } } base.OnMovement(m, oldLocation); @@ -213,12 +231,18 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && IsRewardItem) + { list.Add(RewardSystem.GetRewardYearLabel(this, new object[] { m_Type })); // X Year Veteran Reward + } if (m_TurnedOn) + { list.Add(502695); // turned on + } else + { list.Add(502696); // turned off + } } public bool IsOwner(Mobile mob) => BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true; @@ -294,7 +318,9 @@ namespace Server.Items m_Statuette.TurnedOn = newValue; if (newValue && !m_Statuette.IsLockedDown) - from.SendLocalizedMessage(502693); // Remember, this only works when locked down. + { + @from.SendLocalizedMessage(502693); // Remember, this only works when locked down. + } } else { diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs index f9e6a6368..e0115d399 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs @@ -79,7 +79,9 @@ namespace Server.Items var random = Utility.Random(3); if (i == 5) + { random = 0; + } organ = random switch { @@ -112,7 +114,9 @@ namespace Server.Items public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) { if (dropped is PlagueBeastInnard || dropped is PlagueBeastGland) - return base.TryDropItem(from, dropped, sendFullMessage); + { + return base.TryDropItem(@from, dropped, sendFullMessage); + } return false; } @@ -127,6 +131,7 @@ namespace Server.Items var cy = p.Y + ir.Y + ir.Height / 2; for (var i = Items.Count - 1; i >= 0; i--) + { if (Items[i] is PlagueBeastComponent innard) { var r = ItemBounds.Table[innard.ItemID]; @@ -136,10 +141,11 @@ namespace Server.Items if (cx >= x && cx <= x + r.Width && cy >= y && cy <= y + r.Height) { - innard.OnDragDrop(from, item); + innard.OnDragDrop(@from, item); break; } } + } return base.OnDragDropInto(from, item, p); } diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBlood.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBlood.cs index 89f667533..686784c54 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBlood.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBlood.cs @@ -25,7 +25,9 @@ namespace Server.Items public override void OnAfterDelete() { if (m_Timer?.Running == true) + { m_Timer.Stop(); + } } public override bool OnBandage(Mobile from) @@ -33,7 +35,9 @@ namespace Server.Items if (IsAccessibleTo(from) && !Patched) { if (m_Timer?.Running == true) + { m_Timer.Stop(); + } if (Starting) { @@ -41,9 +45,13 @@ namespace Server.Items Y -= 9; if (Organ is PlagueBeastRubbleOrgan) + { Y -= 5; + } else if (Organ is PlagueBeastBackupOrgan) + { X += 7; + } } else { @@ -56,9 +64,15 @@ namespace Server.Items var pack = Owner?.Backpack; if (pack != null) + { for (var i = 0; i < pack.Items.Count; i++) + { if (pack.Items[i] is PlagueBeastMainOrgan main && main.Complete) - main.FinishOpening(from); + { + main.FinishOpening(@from); + } + } + } PublicOverheadMessage(MessageType.Regular, 0x3B2, 1071916); // * You patch up the wound with a bandage * @@ -71,7 +85,9 @@ namespace Server.Items private void Hemorrhage() { if (Patched) + { return; + } Owner?.PlaySound(0x25); diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastHeart.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastHeart.cs index af32640e0..6d6c0ebf6 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastHeart.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastHeart.cs @@ -19,7 +19,9 @@ namespace Server.Items public override void OnAfterDelete() { if (m_Timer?.Running == true) + { m_Timer.Stop(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastInnard.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastInnard.cs index ae32a24b1..0e0e339e8 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastInnard.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastInnard.cs @@ -30,24 +30,34 @@ namespace Server.Items public override bool IsAccessibleTo(Mobile check) { if ((int)check.AccessLevel >= (int)AccessLevel.GameMaster) + { return true; + } var owner = Owner; if (owner == null) + { return false; + } if (!owner.InRange(check, 2)) + { owner.PrivateOverheadMessage(MessageType.Label, 0x3B2, 500446, check.NetState); // That is too far away. + } else if (owner.OpenedBy != null && owner.OpenedBy != check) // TODO check + { owner.PrivateOverheadMessage( MessageType.Label, 0x3B2, 500365, check.NetState ); // That is being used by someone else + } else if (owner.Frozen) + { return true; + } return false; } @@ -68,7 +78,9 @@ namespace Server.Items var owner = Owner; if (owner?.Alive != true) + { Delete(); + } } } @@ -100,7 +112,9 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item dropped) { if (Organ?.OnDropped(from, dropped, this) == true && dropped is PlagueBeastComponent component) + { Organ.Components.Add(component); + } return true; } @@ -117,7 +131,9 @@ namespace Server.Items ); // * You rip the organ out of the plague beast's flesh * if (Organ.Components.Contains(this)) + { Organ.Components.Remove(this); + } Organ = null; from.PlaySound(0x1CA); diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastMutationCore.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastMutationCore.cs index f1a0c8a2a..623575f59 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastMutationCore.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastMutationCore.cs @@ -40,7 +40,9 @@ namespace Server.Items ); // * You remove the plague mutation core from the plague beast, causing it to dissolve into a pile of goo * if (owner != null) + { Timer.DelayCall(TimeSpan.FromSeconds(1), KillParent, owner); + } return true; } diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs index a77104e26..b5d4cbd77 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastOrgans.cs @@ -37,7 +37,9 @@ namespace Server.Items public void AddComponent(PlagueBeastComponent c, int x, int y) { if (Parent is Container pack) + { pack.DropItem(c); + } c.Organ = this; c.Location = new Point3D(X + x, Y + y, Z); @@ -66,7 +68,9 @@ namespace Server.Items public override void OnAfterDelete() { if (m_Timer?.Running == true) + { m_Timer.Stop(); + } } public virtual bool OnLifted(Mobile from, PlagueBeastComponent c) => c.IsGland || c.IsBrain; @@ -116,7 +120,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!Opened) - FinishOpening(from); + { + FinishOpening(@from); + } } public override void FinishOpening(Mobile from) @@ -130,7 +136,9 @@ namespace Server.Items AddComponent(new PlagueBeastComponent(0x1DA3, 0x21), 26, 46); if (BrainHue > 0) + { AddComponent(new PlagueBeastComponent(0x1CF0, BrainHue, true), 22, 29); + } Opened = true; } @@ -165,11 +173,13 @@ namespace Server.Items public override void Carve(Mobile from, Item with) { if (IsAccessibleTo(from)) + { with.PublicOverheadMessage( MessageType.Regular, 0x3B2, 1071896 ); // This is too crude an implement for such a procedure. + } } public override bool OnLifted(Mobile from, PlagueBeastComponent c) @@ -193,9 +203,13 @@ namespace Server.Items AddComponent(new PlagueBeastComponent(0x1777, 0x1), 10, 14); if (BrainHue > 0) + { AddComponent(new PlagueBeastComponent(0x1CF0, BrainHue, true), 1, 24); // 22, 29 + } else + { AddComponent(new PlagueBeastBlood(), -7, 24); + } } public override void Serialize(IGenericWriter writer) @@ -260,9 +274,13 @@ namespace Server.Items AddComponent(new PlagueBeastComponent(0x1777, 0x1), 5, 14); if (BrainHue > 0) + { AddComponent(new PlagueBeastComponent(0x1CF0, BrainHue, true), -5, 22); + } else + { AddComponent(new PlagueBeastBlood(), -13, 25); + } Opened = true; } @@ -274,7 +292,9 @@ namespace Server.Items var hue = m_Hues.RandomElement(); if (hue != exclude) + { return hue; + } } return 0xD; @@ -285,7 +305,9 @@ namespace Server.Items if (vein.Hue != Hue) { if (!Opened && m_Veins > 0 && --m_Veins == 0) - FinishOpening(from); + { + FinishOpening(@from); + } } else { @@ -354,11 +376,13 @@ namespace Server.Items public override void Carve(Mobile from, Item with) { if (IsAccessibleTo(from)) + { with.PublicOverheadMessage( MessageType.Regular, 0x3B2, 1071896 ); // This is too crude an implement for such a procedure. + } } public override bool OnLifted(Mobile from, PlagueBeastComponent c) @@ -409,7 +433,9 @@ namespace Server.Items public void FinishHealing() { for (var i = 0; i < 7 && i < Components.Count; i++) + { Components[i].Hue = 0x6; + } m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2), OpenOrgan); } @@ -420,7 +446,9 @@ namespace Server.Items AddComponent(new PlagueBeastComponent(0x1366, 0x1), 57, 66); if (BrainHue > 0) + { AddComponent(new PlagueBeastComponent(0x1CF0, BrainHue, true), 55, 69); + } } public override void Serialize(IGenericWriter writer) @@ -482,7 +510,9 @@ namespace Server.Items public override bool OnLifted(Mobile from, PlagueBeastComponent c) { if (c.IsBrain) + { m_Brains--; + } return true; } @@ -515,7 +545,9 @@ namespace Server.Items } if (m_Brains == 4) - FinishOpening(from); + { + FinishOpening(@from); + } return true; } diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastVein.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastVein.cs index 2a4d3dd53..a110f3f8a 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastVein.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastVein.cs @@ -39,7 +39,9 @@ namespace Server.Items public override void OnAfterDelete() { if (m_Timer?.Running == true) + { m_Timer.Stop(); + } } private void CuttingDone(Mobile from) @@ -47,14 +49,20 @@ namespace Server.Items Cut = true; if (ItemID == 0x1B1C) + { ItemID = 0x1B1B; + } else + { ItemID = 0x1B1C; + } Owner?.PlaySound(0x199); if (Organ is PlagueBeastRubbleOrgan organ) - organ.OnVeinCut(from, this); + { + organ.OnVeinCut(@from, this); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Rares/Containers/BaseWaterContainer.cs b/Projects/UOContent/Items/Special/Rares/Containers/BaseWaterContainer.cs index b6ba77dfe..debc3e849 100644 --- a/Projects/UOContent/Items/Special/Rares/Containers/BaseWaterContainer.cs +++ b/Projects/UOContent/Items/Special/Rares/Containers/BaseWaterContainer.cs @@ -45,7 +45,9 @@ var rootParent = RootParent; if (rootParent?.Map != null && rootParent.Map != Map.Internal) + { MoveToWorld(rootParent.Location, rootParent.Map); + } } InvalidateProperties(); @@ -55,7 +57,10 @@ public override void OnDoubleClick(Mobile from) { - if (IsEmpty) base.OnDoubleClick(from); + if (IsEmpty) + { + base.OnDoubleClick(@from); + } } public override void OnSingleClick(Mobile from) @@ -67,9 +72,13 @@ else { if (Name == null) - LabelTo(from, LabelNumber); + { + LabelTo(@from, LabelNumber); + } else - LabelTo(from, Name); + { + LabelTo(@from, Name); + } } } @@ -82,20 +91,30 @@ else { if (Name == null) - LabelTo(from, LabelNumber); + { + LabelTo(@from, LabelNumber); + } else - LabelTo(from, Name); + { + LabelTo(@from, Name); + } } } public override void GetProperties(ObjectPropertyList list) { - if (IsEmpty) base.GetProperties(list); + if (IsEmpty) + { + base.GetProperties(list); + } } public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { - if (!IsEmpty) return false; + if (!IsEmpty) + { + return false; + } return base.OnDragDropInto(from, item, p); } diff --git a/Projects/UOContent/Items/Special/RewardCake.cs b/Projects/UOContent/Items/Special/RewardCake.cs index bcfbcf6bc..718c764f9 100644 --- a/Projects/UOContent/Items/Special/RewardCake.cs +++ b/Projects/UOContent/Items/Special/RewardCake.cs @@ -41,7 +41,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 1)) - from.LocalOverheadMessage(MessageType.Regular, 906, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 906, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs b/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs index 51f2a96d7..c1e2c2436 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs @@ -121,24 +121,34 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (from.Alive) - list.Add(new UseBagEntry(this, Charges > 0 && IsChildOf(from.Backpack))); + { + list.Add(new UseBagEntry(this, Charges > 0 && IsChildOf(@from.Backpack))); + } } public override void OnDoubleClick(Mobile from) { if (from.Region.IsPartOf()) - from.SendMessage("You may not do that in jail."); + { + @from.SendMessage("You may not do that in jail."); + } else if (!IsChildOf(from.Backpack)) + { MessageHelper.SendLocalizedMessageTo( this, - from, + @from, 1062334, 0x59 ); // The bag of sending must be in your backpack. + } else if (Charges == 0) - MessageHelper.SendLocalizedMessageTo(this, from, 1042544, 0x59); // This item is out of charges. + { + MessageHelper.SendLocalizedMessageTo(this, @from, 1042544, 0x59); // This item is out of charges. + } else - from.Target = new SendTarget(this); + { + @from.Target = new SendTarget(this); + } } public override void Serialize(IGenericWriter writer) @@ -184,18 +194,24 @@ namespace Server.Items m_Bag = bag; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() { if (m_Bag.Deleted) + { return; + } var from = Owner.From; if (from.CheckAlive()) - m_Bag.OnDoubleClick(from); + { + m_Bag.OnDoubleClick(@from); + } } } @@ -208,7 +224,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Bag.Deleted) + { return; + } if (from.Region.IsPartOf()) { diff --git a/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs b/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs index da3b36b5d..b9262625a 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BallOfSummoning.cs @@ -147,9 +147,13 @@ namespace Server.Items } if (Pet == null) - LinkPet(from); + { + LinkPet(@from); + } else - CastSummonPet(from); + { + CastSummonPet(@from); + } } public void LinkPet(Mobile from) @@ -157,7 +161,9 @@ namespace Server.Items var pet = Pet; if (Deleted || pet != null || RootParent != from) + { return; + } from.SendLocalizedMessage( 1054114 @@ -170,7 +176,9 @@ namespace Server.Items var pet = Pet; if (Deleted || pet == null || RootParent != from) + { return; + } if (Charges == 0) { @@ -242,9 +250,13 @@ namespace Server.Items else { if (Core.ML) - new PetSummoningSpell(this, from).Cast(); + { + new PetSummoningSpell(this, @from).Cast(); + } else - SummonPet(from); + { + SummonPet(@from); + } } } @@ -253,7 +265,9 @@ namespace Server.Items var pet = Pet; if (pet == null) + { return; + } Charges--; @@ -262,7 +276,9 @@ namespace Server.Items pet.SetControlMaster(from); if (pet.Summoned) - pet.SummonMaster = from; + { + pet.SummonMaster = @from; + } pet.ControlTarget = from; pet.ControlOrder = OrderType.Follow; @@ -272,7 +288,9 @@ namespace Server.Items from.Stabled.Remove(pet); if (from is PlayerMobile mobile) + { mobile.AutoStabled.Remove(pet); + } } pet.MoveToWorld(from.Location, from.Map); @@ -284,7 +302,10 @@ namespace Server.Items 0x43 ); // The Crystal Ball fills with a green mist. Your pet has been summoned. - if (from is PlayerMobile playerMobile) playerMobile.LastPetBallTime = DateTime.UtcNow; + if (from is PlayerMobile playerMobile) + { + playerMobile.LastPetBallTime = DateTime.UtcNow; + } } public void UnlinkPet(Mobile from) @@ -357,7 +378,9 @@ namespace Server.Items var from = Owner.From; if (from.CheckAlive()) - m_Callback(from); + { + m_Callback(@from); + } } } @@ -370,7 +393,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Ball.Deleted || m_Ball.Pet != null) + { return; + } if (m_Ball.RootParent != from) { @@ -476,19 +501,25 @@ namespace Server.Items public override void DoHurtFizzle() { if (!m_Stop) + { base.DoHurtFizzle(); + } } public override void DoFizzle() { if (!m_Stop) + { base.DoFizzle(); + } } public override void OnDisturb(DisturbType type, bool message) { if (message && !m_Stop) + { Caster.SendLocalizedMessage(1080074); // You have been disrupted while attempting to summon your pet! + } } public override void OnCast() diff --git a/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs b/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs index 81c26f234..b3b920f9e 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs @@ -50,7 +50,9 @@ namespace Server.Items get { if (m_Bound?.Deleted == true) + { m_Bound = null; + } return m_Bound; } @@ -124,9 +126,13 @@ namespace Server.Items var bound = Bound; if (Bound == null) - Bind(from); + { + Bind(@from); + } else - Activate(from); + { + Activate(@from); + } } public void Activate(Mobile from) @@ -134,7 +140,9 @@ namespace Server.Items var bound = Bound; if (Deleted || bound == null) + { return; + } if (!IsChildOf(from)) { @@ -168,12 +176,18 @@ namespace Server.Items var bound = Bound; if (Deleted || bound == null) + { return; + } if (!IsChildOf(from)) - from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it. + { + @from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it. + } else - CheckUse(from, true); + { + CheckUse(@from, true); + } } private bool CheckUse(Mobile from, bool successMessage) @@ -181,7 +195,9 @@ namespace Server.Items var bound = Bound; if (bound == null) + { return false; + } var boundRoot = bound.RootParent as Mobile; @@ -219,8 +235,16 @@ namespace Server.Items return false; } - if (!SpellHelper.CheckTravel(from, TravelCheckType.RecallFrom)) return false; - if (!SpellHelper.CheckTravel(from, boundRoot.Map, boundRoot.Location, TravelCheckType.RecallTo)) return false; + if (!SpellHelper.CheckTravel(from, TravelCheckType.RecallFrom)) + { + return false; + } + + if (!SpellHelper.CheckTravel(from, boundRoot.Map, boundRoot.Location, TravelCheckType.RecallTo)) + { + return false; + } + if (boundRoot.Map == Map.Felucca && from is PlayerMobile mobile && mobile.Young) { mobile.SendLocalizedMessage(1049543); // You decide against traveling to Felucca while you are still young. @@ -264,7 +288,9 @@ namespace Server.Items } if (successMessage) - from.SendLocalizedMessage(1054015); // The bracelet's twin is available for transport. + { + @from.SendLocalizedMessage(1054015); // The bracelet's twin is available for transport. + } return true; } @@ -272,7 +298,9 @@ namespace Server.Items public void Bind(Mobile from) { if (Deleted) + { return; + } if (!IsChildOf(from)) { @@ -288,7 +316,9 @@ namespace Server.Items public void Inscribe(Mobile from) { if (Deleted) + { return; + } if (!IsChildOf(from)) { @@ -348,7 +378,9 @@ namespace Server.Items m_Callback = callback; if (!enabled) + { Flags |= CMEFlags.Disabled; + } } public override void OnClick() @@ -356,7 +388,9 @@ namespace Server.Items var from = Owner.From; if (from.CheckAlive()) - m_Callback(from); + { + m_Callback(@from); + } } } @@ -379,7 +413,9 @@ namespace Server.Items if (m_Bracelet.Deleted || m_From.Deleted || !m_Bracelet.CheckUse(m_From, false) || !(m_Bracelet.Bound.RootParent is Mobile boundRoot)) + { return; + } m_Bracelet.Charges--; @@ -400,7 +436,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Bracelet.Deleted) + { return; + } if (!m_Bracelet.IsChildOf(from)) { @@ -442,7 +480,9 @@ namespace Server.Items public override void OnResponse(Mobile from, string text) { if (m_Bracelet.Deleted) + { return; + } if (!m_Bracelet.IsChildOf(from)) { diff --git a/Projects/UOContent/Items/Special/Solen Items/PowderOfTranslocation.cs b/Projects/UOContent/Items/Special/Solen Items/PowderOfTranslocation.cs index da8d399af..20abedc94 100644 --- a/Projects/UOContent/Items/Special/Solen Items/PowderOfTranslocation.cs +++ b/Projects/UOContent/Items/Special/Solen Items/PowderOfTranslocation.cs @@ -29,9 +29,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 2)) - from.Target = new InternalTarget(this); + { + @from.Target = new InternalTarget(this); + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } } public override void Serialize(IGenericWriter writer) @@ -57,7 +61,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Powder.Deleted) + { return; + } if (!from.InRange(m_Powder.GetWorldLocation(), 2)) { @@ -101,7 +107,9 @@ namespace Server.Items } if (transItem is Item item) - MessageHelper.SendLocalizedMessageTo(item, from, 1054139, transItem.TranslocationItemName, 0x43); + { + MessageHelper.SendLocalizedMessageTo(item, @from, 1054139, transItem.TranslocationItemName, 0x43); + } } } else diff --git a/Projects/UOContent/Items/Special/SoulStone.cs b/Projects/UOContent/Items/Special/SoulStone.cs index de14a1c60..efb42d02f 100644 --- a/Projects/UOContent/Items/Special/SoulStone.cs +++ b/Projects/UOContent/Items/Special/SoulStone.cs @@ -49,7 +49,9 @@ namespace Server.Items m_ActiveItemID = value; if (!IsEmpty) + { ItemID = m_ActiveItemID; + } } } @@ -62,7 +64,9 @@ namespace Server.Items m_InactiveItemID = value; if (IsEmpty) + { ItemID = m_InactiveItemID; + } } } @@ -100,9 +104,13 @@ namespace Server.Items m_SkillValue = value; if (!IsEmpty) + { ItemID = m_ActiveItemID; + } else + { ItemID = m_InactiveItemID; + } InvalidateProperties(); } @@ -119,12 +127,14 @@ namespace Server.Items base.GetProperties(list); if (!IsEmpty) + { list.Add( 1070721, "#{0}\t{1:0.0}", AosSkillBonuses.GetLabel(Skill), SkillValue ); // Skill stored: ~1_skillname~ ~2_skillamount~ + } list.Add(1041602, "{0}", LastUserName ?? $"#{1074235}"); // Owner: ~1_val~ } @@ -136,7 +146,9 @@ namespace Server.Items var info = m.Aggressed[i]; if (DateTime.UtcNow - info.LastCombatTime < time) + { return true; + } } return false; @@ -148,7 +160,10 @@ namespace Server.Items var pm = from as PlayerMobile; - if (Deleted || !IsAccessibleTo(from)) return false; + if (Deleted || !IsAccessibleTo(from)) + { + return false; + } if (from.Map != Map || !from.InRange(GetWorldLocation(), 2)) { @@ -234,7 +249,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!CheckUse(from)) + { return; + } from.CloseGump(); from.CloseGump(); @@ -243,9 +260,13 @@ namespace Server.Items from.CloseGump(); if (IsEmpty) - from.SendGump(new SelectSkillGump(this, from)); + { + @from.SendGump(new SelectSkillGump(this, @from)); + } else - from.SendGump(new ConfirmTransferGump(this, from)); + { + @from.SendGump(new ConfirmTransferGump(this, @from)); + } } public override void Serialize(IGenericWriter writer) @@ -377,20 +398,28 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0 || !m_Stone.IsEmpty) + { return; + } var from = sender.Mobile; var iSkill = info.ButtonID - 1; if (iSkill < 0 || iSkill >= from.Skills.Length) + { return; + } var skill = from.Skills[iSkill]; if (skill.Base <= 0.0) + { return; + } if (!m_Stone.CheckUse(from)) + { return; + } from.SendGump(new ConfirmSkillGump(m_Stone, skill)); } @@ -465,12 +494,16 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0 || !m_Stone.IsEmpty) + { return; + } var from = sender.Mobile; if (!m_Stone.CheckUse(from)) + { return; + } if (info.ButtonID == 1) // Is asking for another selection { @@ -479,7 +512,9 @@ namespace Server.Items } if (m_Skill.Base <= 0.0) + { return; + } if (m_Skill.Lock != SkillLock.Down) { @@ -616,12 +651,16 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0 || m_Stone.IsEmpty) + { return; + } var from = sender.Mobile; if (!m_Stone.CheckUse(from)) + { return; + } if (info.ButtonID == 1) // Remove skill points { @@ -652,13 +691,17 @@ namespace Server.Items for (var i = 0; i < from.Skills.Length; ++i) { if (from.Skills[i].Lock != SkillLock.Down) + { continue; + } available += from.Skills[i].BaseFixedPoint; } if (requiredAmount > available) + { cannotAbsorb = true; + } } if (cannotAbsorb) @@ -719,22 +762,26 @@ namespace Server.Items } if (requiredAmount > 0) - for (var i = 0; i < from.Skills.Length; ++i) + { + for (var i = 0; i < @from.Skills.Length; ++i) { - if (from.Skills[i].Lock != SkillLock.Down) - continue; - - if (requiredAmount >= from.Skills[i].BaseFixedPoint) + if (@from.Skills[i].Lock != SkillLock.Down) { - requiredAmount -= from.Skills[i].BaseFixedPoint; - from.Skills[i].Base = 0.0; + continue; + } + + if (requiredAmount >= @from.Skills[i].BaseFixedPoint) + { + requiredAmount -= @from.Skills[i].BaseFixedPoint; + @from.Skills[i].Base = 0.0; } else { - from.Skills[i].BaseFixedPoint -= requiredAmount; + @from.Skills[i].BaseFixedPoint -= requiredAmount; break; } } + } fromSkill.Base = skillValue; m_Stone.SkillValue = 0.0; @@ -775,8 +822,12 @@ namespace Server.Items Effects.SendTargetParticles(from, 0x375A, 35, 90, 0x00, 0x00, 9502, (EffectLayer)255, 0x100); if (m_Stone is SoulstoneFragment frag) + { if (--frag.UsesRemaining <= 0) - from.SendLocalizedMessage(1070974); // You have used up your soulstone fragment. + { + @from.SendLocalizedMessage(1070974); // You have used up your soulstone fragment. + } + } } } @@ -817,12 +868,16 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0 || m_Stone.IsEmpty) + { return; + } var from = sender.Mobile; if (!m_Stone.CheckUse(from)) + { return; + } m_Stone.SkillValue = 0.0; from.SendLocalizedMessage(1070726); // You have successfully deleted the Soulstone's skill points. @@ -859,17 +914,25 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 0) + { return; + } var from = sender.Mobile; if (!m_Stone.CheckUse(from)) + { return; + } if (m_Stone.IsEmpty) - from.SendGump(new SelectSkillGump(m_Stone, from)); + { + @from.SendGump(new SelectSkillGump(m_Stone, @from)); + } else - from.SendGump(new ConfirmTransferGump(m_Stone, from)); + { + @from.SendGump(new ConfirmTransferGump(m_Stone, @from)); + } } } } @@ -937,15 +1000,21 @@ namespace Server.Items if (version <= 1) { if (ItemID == 0x2A93 || ItemID == 0x2A94) + { ActiveItemID = Utility.Random(0x2AA1, 9); + } else + { ActiveItemID = ItemID; + } InactiveItemID = ActiveItemID; } if (version == 0 && Weight == 1) + { Weight = -1; + } } protected override bool CheckUse(Mobile from) @@ -953,11 +1022,13 @@ namespace Server.Items var canUse = base.CheckUse(from); if (canUse) + { if (m_UsesRemaining <= 0) { - from.SendLocalizedMessage(1070975); // That soulstone fragment has no more uses. + @from.SendLocalizedMessage(1070975); // That soulstone fragment has no more uses. return false; } + } return canUse; } @@ -1035,7 +1106,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076217); // 1st Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs b/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs index 19003863d..9def6904d 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs @@ -73,7 +73,9 @@ namespace Server.Items Hue = 0x481; if (Value == 105.0 || skill == SkillName.Blacksmith || skill == SkillName.Tailoring) + { LootType = LootType.Regular; + } } public PowerScroll(Serial serial) : base(serial) @@ -100,7 +102,9 @@ namespace Server.Items * Legendary Scroll (120 Skill): */ if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0) + { return 1049635 + (int)level; + } return 0; } @@ -121,7 +125,10 @@ namespace Server.Items if (Core.SE) { _Skills.AddRange(m_SESkills); - if (Core.ML) _Skills.AddRange(m_MLSkills); + if (Core.ML) + { + _Skills.AddRange(m_MLSkills); + } } } } @@ -163,9 +170,13 @@ namespace Server.Items * a mythical scroll of ~1_type~ (115 Skill) OR * a legendary scroll of ~1_type~ (120 Skill) */ + { list.Add(1049639 + (int)level, GetNameLocalized()); + } else + { list.Add("a power scroll of {0} ({1} Skill)", GetName(), Value); + } } public override void OnSingleClick(Mobile from) @@ -173,20 +184,28 @@ namespace Server.Items var level = (Value - 105.0) / 5.0; if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0) - LabelTo(from, 1049639 + (int)level, GetNameLocalized()); + { + LabelTo(@from, 1049639 + (int)level, GetNameLocalized()); + } else - LabelTo(from, "a power scroll of {0} ({1} Skill)", GetName(), Value); + { + LabelTo(@from, "a power scroll of {0} ({1} Skill)", GetName(), Value); + } } public override bool CanUse(Mobile from) { if (!base.CanUse(from)) + { return false; + } var skill = from.Skills[Skill]; if (skill == null) + { return false; + } if (skill.Cap >= Value) { @@ -203,7 +222,9 @@ namespace Server.Items public override void Use(Mobile from) { if (!CanUse(from)) + { return; + } from.SendLocalizedMessage( 1049513, diff --git a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs index 72dacc06c..2dc10140e 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofAlacrity.cs @@ -39,19 +39,27 @@ namespace Server.Items public override bool CanUse(Mobile from) { if (!(base.CanUse(from) && from is PlayerMobile pm)) + { return false; + } var context = MLQuestSystem.GetContext(pm); if (context != null) + { foreach (var instance in context.QuestInstances) + { foreach (var objective in instance.Objectives) + { if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && objectiveInstance.Handles(Skill)) { - from.SendMessage("You are already under the effect of an enhanced skillgain quest."); + @from.SendMessage("You are already under the effect of an enhanced skillgain quest."); return false; } + } + } + } if (pm.AcceleratedStart > DateTime.UtcNow) { @@ -65,7 +73,9 @@ namespace Server.Items public override void Use(Mobile from) { if (!(CanUse(from) && from is PlayerMobile pm)) + { return; + } var tskill = from.Skills[Skill].Base; var tcap = from.Skills[Skill].Cap; diff --git a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs index 0f91628cb..ce2236287 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/ScrollofTranscendence.cs @@ -38,27 +38,39 @@ namespace Server.Items base.GetProperties(list); if (Value == 1) + { list.Add(1076759, "{0}\t{1}.0 Skill Points", GetName(), Value); + } else + { list.Add(1076759, "{0}\t{1} Skill Points", GetName(), Value); + } } public override bool CanUse(Mobile from) { if (!(base.CanUse(from) && from is PlayerMobile pm)) + { return false; + } var context = MLQuestSystem.GetContext(pm); if (context != null) + { foreach (var instance in context.QuestInstances) + { foreach (var objective in instance.Objectives) + { if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && objectiveInstance.Handles(Skill)) { - from.SendMessage("You are already under the effect of an enhanced skillgain quest."); + @from.SendMessage("You are already under the effect of an enhanced skillgain quest."); return false; } + } + } + } if (pm.AcceleratedStart > DateTime.UtcNow) { @@ -72,7 +84,9 @@ namespace Server.Items public override void Use(Mobile from) { if (!CanUse(from)) + { return; + } var tskill = from.Skills[Skill].Base; // value of skill without item bonuses etc var tcap = from.Skills[Skill].Cap; // maximum value permitted @@ -81,7 +95,9 @@ namespace Server.Items var newValue = Value; if (tskill + newValue > tcap) + { newValue = tcap - tskill; + } if (tskill < tcap && from.Skills[Skill].Lock == SkillLock.Up) { @@ -91,12 +107,14 @@ namespace Server.Items for (var i = 0; i < ns; i++) // skill must point down and its value must be enough - if (from.Skills[i].Lock == SkillLock.Down && from.Skills[i].Base >= newValue) + { + if (@from.Skills[i].Lock == SkillLock.Down && @from.Skills[i].Base >= newValue) { - from.Skills[i].Base -= newValue; + @from.Skills[i].Base -= newValue; canGain = true; break; } + } } else { @@ -146,7 +164,9 @@ namespace Server.Items Insured = false; if (Hue == 0x7E) + { Hue = 0x490; + } } } } diff --git a/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs b/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs index de388a49c..52416304c 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs @@ -40,14 +40,19 @@ namespace Server.Items var table = SkillInfo.Table; if (index >= 0 && index < table.Length) + { return table[index].Name.ToLower(); + } + return "???"; } public virtual bool CanUse(Mobile from) { if (Deleted) + { return false; + } if (!IsChildOf(from.Backpack)) { @@ -65,7 +70,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (!CanUse(from)) + { return; + } from.CloseGump(); from.SendGump(new InternalGump(from, this)); @@ -100,16 +107,26 @@ namespace Server.Items InheritsItem = true; if (!(this is StatCapScroll)) + { Skill = (SkillName)reader.ReadInt(); + } else + { Skill = SkillName.Alchemy; + } if (this is ScrollofAlacrity) + { Value = 0.0; + } else if (this is StatCapScroll) + { Value = reader.ReadInt(); + } else + { Value = reader.ReadDouble(); + } break; } @@ -144,20 +161,30 @@ namespace Server.Items AddHtmlLocalized(310, 172, 120, 20, 1046363, 0xFFFFFF); // No if (m_Scroll.Title != 0) + { AddHtmlLocalized(40, 20, 260, 20, m_Scroll.Title, 0xFFFFFF); + } else + { AddHtml(40, 20, 260, 20, m_Scroll.DefaultTitle); + } if (m_Scroll is StatCapScroll) + { AddHtmlLocalized(310, 20, 120, 20, 1038019, 0xFFFFFF); // Power + } else + { AddHtmlLocalized(310, 20, 120, 20, AosSkillBonuses.GetLabel(m_Scroll.Skill), 0xFFFFFF); + } } public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 1) + { m_Scroll.Use(m_Mobile); + } } } } diff --git a/Projects/UOContent/Items/Special/Special Scrolls/StatScroll.cs b/Projects/UOContent/Items/Special/Special Scrolls/StatScroll.cs index 6d547d4ff..0fa9fa8e6 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/StatScroll.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/StatScroll.cs @@ -32,7 +32,9 @@ namespace Server.Items * Ultimate Scroll (+25 Maximum Stats): */ if (level >= 0 && level <= 4 && Value % 5 == 0) + { return 1049458 + level; + } return 0; } @@ -52,9 +54,13 @@ namespace Server.Items * a legendary scroll of ~1_type~ (+20 Maximum Stats) OR * an ultimate scroll of ~1_type~ (+25 Maximum Stats) */ + { list.Add(1049463 + level, "#1049476"); + } else + { list.Add("a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225); + } } public override void OnSingleClick(Mobile from) @@ -62,20 +68,28 @@ namespace Server.Items var level = ((int)Value - 230) / 5; if (level >= 0 && level <= 4 && (int)Value % 5 == 0) - LabelTo(from, 1049463 + level, "#1049476"); + { + LabelTo(@from, 1049463 + level, "#1049476"); + } else - LabelTo(from, "a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225); + { + LabelTo(@from, "a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225); + } } public override bool CanUse(Mobile from) { if (!base.CanUse(from)) + { return false; + } var newValue = (int)Value; if (from is PlayerMobile mobile && mobile.HasStatReward) + { newValue += 5; + } if (from.StatCap >= newValue) { @@ -89,14 +103,20 @@ namespace Server.Items public override void Use(Mobile from) { if (!CanUse(from)) + { return; + } from.SendLocalizedMessage(1049512); // You feel a surge of magic as the scroll enhances your powers! if (from is PlayerMobile mobile && mobile.HasStatReward) + { mobile.StatCap = (int)Value + 5; + } else - from.StatCap = (int)Value; + { + @from.StatCap = (int)Value; + } Effects.SendLocationParticles( EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs b/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs index 035fbdaa8..8bf3a9528 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs @@ -26,7 +26,9 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (from is PlayerMobile mobile) + { list.Add(new LockKarmaEntry(mobile, Addon as AnkhOfSacrificeAddon)); + } list.Add(new ResurrectEntry(from, Addon as AnkhOfSacrificeAddon)); } @@ -63,17 +65,21 @@ namespace Server.Items var delay = m.AnkhNextUse - DateTime.UtcNow; if (delay.TotalMinutes > 0) + { m.SendLocalizedMessage( 1079265, Math.Round(delay.TotalMinutes) .ToString() ); // You must wait ~1_minutes~ minutes before you can use this item. + } else + { m.SendLocalizedMessage( 1079263, Math.Round(delay.TotalSeconds) .ToString() ); // You must wait ~1_seconds~ seconds before you can use this item. + } } else { @@ -96,7 +102,9 @@ namespace Server.Items public override void OnClick() { if (m_Ankh?.Deleted != false) + { return; + } Resurrect(m_Mobile as PlayerMobile, m_Ankh); } @@ -124,13 +132,17 @@ namespace Server.Items m_Mobile.KarmaLocked = !m_Mobile.KarmaLocked; if (m_Mobile.KarmaLocked) + { m_Mobile.SendLocalizedMessage( 1060192 ); // Your karma has been locked. Your karma can no longer be raised. + } else + { m_Mobile.SendLocalizedMessage( 1060191 ); // Your karma has been unlocked. Your karma can be raised again. + } } } } @@ -153,7 +165,10 @@ namespace Server.Items return; } - if (from is PlayerMobile mobile) mobile.AnkhNextUse = DateTime.UtcNow + TimeSpan.FromHours(1); + if (from is PlayerMobile mobile) + { + mobile.AnkhNextUse = DateTime.UtcNow + TimeSpan.FromHours(1); + } base.OnResponse(state, info); } @@ -219,7 +234,9 @@ namespace Server.Items public override void OnMovement(Mobile m, Point3D oldLocation) { if (!m.Alive && Utility.InRange(Location, m.Location, 1) && !Utility.InRange(Location, oldLocation, 1)) + { AnkhOfSacrificeComponent.Resurrect(m as PlayerMobile, this); + } } public override void Serialize(IGenericWriter writer) @@ -298,13 +315,17 @@ namespace Server.Items }; if (!Deleted) - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -322,7 +343,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1080457); // 10th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs b/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs index e02b37d8f..e20d52477 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs @@ -39,17 +39,24 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true) + { return false; + } if (FacingSouth) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // north wall + } + return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // west wall } public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } Hue = sender.DyedHue; @@ -72,7 +79,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && m_IsRewardItem) + { list.Add(1076218); // 2nd Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) @@ -151,13 +160,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076218); // 2nd Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -231,21 +244,30 @@ namespace Server.Items } if (i > 1) + { AddButton(75, 198, 0x8AF, 0x8AF, 0, GumpButtonType.Page, i - 1); + } if (i < 4) + { AddButton(475, 198, 0x8B0, 0x8B0, 0, GumpButtonType.Page, i + 1); + } } } public override void OnResponse(NetState sender, RelayInfo info) { if (m_Banner?.Deleted != false) + { return; + } var m = sender.Mobile; - if (info.ButtonID < Start || info.ButtonID > End || (info.ButtonID & 0x1) != 0) return; + if (info.ButtonID < Start || info.ButtonID > End || (info.ButtonID & 0x1) != 0) + { + return; + } m.SendLocalizedMessage(1042037); // Where would you like to place this banner? m.Target = new InternalTarget(m_Banner, info.ButtonID); @@ -266,7 +288,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Banner?.Deleted != false) + { return; + } if (m_Banner.IsChildOf(from.Backpack)) { @@ -278,7 +302,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null) + { return; + } var p3d = new Point3D(p); var id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; @@ -367,14 +393,20 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Banner?.Deleted != false || m_House == null) + { return; + } Banner banner = null; if (info.ButtonID == (int)Buttons.East) + { banner = new Banner(m_ItemID + 1); + } else if (info.ButtonID == (int)Buttons.South) + { banner = new Banner(m_ItemID); + } if (banner != null) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/BloodyPentagram.cs b/Projects/UOContent/Items/Special/Veteran Rewards/BloodyPentagram.cs index 8cf6436dd..be9f47b1d 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/BloodyPentagram.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/BloodyPentagram.cs @@ -161,7 +161,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } base.OnDoubleClick(from); } @@ -171,7 +173,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076221); // 5th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/Brazier.cs b/Projects/UOContent/Items/Special/Veteran Rewards/Brazier.cs index fa21830e1..ebfe6b9c8 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/Brazier.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/Brazier.cs @@ -83,9 +83,13 @@ namespace Server.Items if (house?.IsCoOwner(from) == true) { if (m_Fire != null) + { TurnOff(); + } else + { TurnOn(); + } } else { @@ -108,7 +112,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076222); // 6th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -163,7 +169,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -181,7 +189,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076222); // 6th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -231,12 +241,16 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Brazier?.Deleted != false) + { return; + } var m = sender.Mobile; if (info.ButtonID != 0x19AA && info.ButtonID != 0x19BB) + { return; + } var brazier = new RewardBrazier(info.ButtonID) { IsRewardItem = m_Brazier.IsRewardItem }; diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs b/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs index 62332260c..6f2868b64 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs @@ -24,7 +24,9 @@ namespace Server.Items if (Addon is CannonAddon addon) { if (addon.IsRewardItem) + { list.Add(1076223); // 7th Year Veteran Reward + } list.Add(1076207, addon.Charges.ToString()); // Remaining Charges: ~1_val~ } @@ -125,7 +127,9 @@ namespace Server.Items m_Charges = value; foreach (var c in Components) + { c.InvalidateProperties(); + } } } @@ -138,7 +142,9 @@ namespace Server.Items m_IsRewardItem = value; foreach (var c in Components) + { c.InvalidateProperties(); + } } } @@ -157,11 +163,15 @@ namespace Server.Items var keg = from.Backpack.FindItemByType(); if (Validate(keg) > 0) - from.SendGump(new InternalGump(this, keg)); + { + @from.SendGump(new InternalGump(this, keg)); + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1076198 ); // You do not have a full keg of explosion potions needed to recharge the cannon. + } } } } @@ -174,7 +184,9 @@ namespace Server.Items public int Validate(PotionKeg keg) { if (keg?.Deleted != false || keg.Held != 100) + { return 0; + } return keg.Type switch { @@ -207,7 +219,9 @@ namespace Server.Items var map = Map; if (target == null || map == null) + { return; + } Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D)); Effects.SendLocationEffect(target, map, m_Effects.RandomElement(), 16, 1); @@ -256,10 +270,14 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Cannon?.Deleted != false) + { return; + } if (!(targeted is IPoint3D p)) + { return; + } if (from.InLOS(new Point3D(p))) { @@ -274,30 +292,42 @@ namespace Server.Items { case CannonDirection.North: if (y < 0 && Math.Abs(x) <= -y / 3) + { allow = true; + } break; case CannonDirection.East: if (x > 0 && Math.Abs(y) <= x / 3) + { allow = true; + } break; case CannonDirection.South: if (y > 0 && Math.Abs(x) <= y / 3) + { allow = true; + } break; case CannonDirection.West: if (x < 0 && Math.Abs(y) <= -x / 3) + { allow = true; + } break; } if (allow && Utility.InRange(new Point3D(p), m_Cannon.Location, 14)) + { m_Cannon.DoFireEffect(p); + } else - from.SendLocalizedMessage(1076203); // Target out of range. + { + @from.SendLocalizedMessage(1076203); // Target out of range. + } } else { @@ -356,7 +386,9 @@ namespace Server.Items public override void OnResponse(NetState state, RelayInfo info) { if (m_Cannon?.Deleted == false && info.ButtonID == (int)Buttons.Recharge) + { m_Cannon.Fill(state.Mobile, m_Keg); + } } private enum Buttons @@ -424,7 +456,9 @@ namespace Server.Items m_Direction = (CannonDirection)option; if (!Deleted) - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void GetProperties(ObjectPropertyList list) @@ -432,7 +466,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076223); // 7th Year Veteran Reward + } list.Add(1076207, m_Charges.ToString()); // Remaining Charges: ~1_val~ } @@ -440,7 +476,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs b/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs index 2d58f99d9..9c8224e06 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs @@ -37,7 +37,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076217); // 1st Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -63,7 +65,9 @@ namespace Server.Items var parent = deed; while (parent != null && !(parent is CommodityDeedBox)) + { parent = parent.Parent as Item; + } return parent as CommodityDeedBox; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/ContestMiniHouse.cs b/Projects/UOContent/Items/Special/Veteran Rewards/ContestMiniHouse.cs index 335e8a7d6..753ae19ec 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/ContestMiniHouse.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/ContestMiniHouse.cs @@ -104,7 +104,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, new object[] { Type })) + { return; + } base.OnDoubleClick(from); } @@ -114,7 +116,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && m_IsRewardItem) + { list.Add(1076217); // 1st Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs b/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs index 6c9baab91..08670eb85 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs @@ -24,7 +24,9 @@ namespace Server.Items get { if (ItemID < 0x1582) + { return (ItemID & 0x1) == 0; + } return ItemID <= 0x1585; } @@ -62,7 +64,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && m_IsRewardItem) + { list.Add(1076220); // 4th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) @@ -141,13 +145,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076220); // 4th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -224,9 +232,13 @@ namespace Server.Items AddButton(60 + j * 60, 50, 0x845, 0x846, itemID); if (itemID < 0x1582) + { itemID += 2; + } else + { itemID += 1; + } } switch (i) @@ -246,7 +258,9 @@ namespace Server.Items if (m_Shield?.Deleted != false || info.ButtonID < Start || info.ButtonID > End || ((info.ButtonID & 0x1) != 0 || info.ButtonID >= 0x1582) && (info.ButtonID < 0x1582 || info.ButtonID > 0x1585)) + { return; + } sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration? sender.Mobile.Target = new InternalTarget(m_Shield, info.ButtonID); @@ -267,7 +281,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Shield?.Deleted != false) + { return; + } if (!m_Shield.IsChildOf(from.Backpack)) { @@ -287,7 +303,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null) + { return; + } var p3d = new Point3D(p); var id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; @@ -363,14 +381,21 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Shield?.Deleted != false || m_House == null) + { return; + } DecorativeShield shield = null; if (info.ButtonID == (int)Buttons.East) + { shield = new DecorativeShield(GetWestItemID(m_ItemID)); + } + if (info.ButtonID == (int)Buttons.South) + { shield = new DecorativeShield(m_ItemID); + } if (shield != null) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/FlamingHead.cs b/Projects/UOContent/Items/Special/Veteran Rewards/FlamingHead.cs index 13108e55f..5e1752e6a 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/FlamingHead.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/FlamingHead.cs @@ -39,15 +39,25 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true) + { return false; + } if (Type == StoneFaceTrapType.NorthWestWall) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map) && BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // north and west wall + } + if (Type == StoneFaceTrapType.NorthWall) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // north wall + } + if (Type == StoneFaceTrapType.WestWall) + { return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // west wall + } return false; } @@ -68,7 +78,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && m_IsRewardItem) + { list.Add(1076218); // 2nd Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) @@ -147,13 +159,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076218); // 2nd Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -202,7 +218,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Head?.Deleted != false) + { return; + } if (!m_Head.IsChildOf(from.Backpack)) { @@ -222,7 +240,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null) + { return; + } var p3d = new Point3D(p); var id = TileData.ItemTable[0x10F5]; @@ -247,11 +267,17 @@ namespace Server.Items FlamingHead head = null; if (north && west) + { head = new FlamingHead(StoneFaceTrapType.NorthWestWall); + } else if (north) + { head = new FlamingHead(); + } else if (west) + { head = new FlamingHead(StoneFaceTrapType.WestWall); + } if (north || west) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs index b3e48da98..4ac2c0228 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs @@ -29,7 +29,9 @@ namespace Server.Items { if (ItemID == 0x1A03 || ItemID == 0x1A05 || ItemID == 0x1A09 || ItemID == 0x1B1E || ItemID == 0x1B7F) + { return true; + } return false; } @@ -49,10 +51,15 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true) + { return false; + } if (FacingSouth) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // north wall + } + return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // west wall } @@ -72,7 +79,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && m_IsRewardItem) + { list.Add(1076220); // 4th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) @@ -151,13 +160,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076220); // 4th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -246,7 +259,9 @@ namespace Server.Items { if (m_Skeleton?.Deleted != false || info.ButtonID != 0x1A03 && info.ButtonID != 0x1A05 && info.ButtonID != 0x1A09 && info.ButtonID != 0x1B1E && info.ButtonID != 0x1B7F) + { return; + } sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration? sender.Mobile.Target = new InternalTarget(m_Skeleton, info.ButtonID); @@ -267,7 +282,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Skeleton?.Deleted != false) + { return; + } if (!m_Skeleton.IsChildOf(from.Backpack)) { @@ -287,7 +304,9 @@ namespace Server.Items var map = from.Map; if (p == null || map == null) + { return; + } var p3d = new Point3D(p); var id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; @@ -364,14 +383,21 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Skeleton?.Deleted != false || m_House == null) + { return; + } HangingSkeleton banner = null; if (info.ButtonID == (int)Buttons.East) + { banner = new HangingSkeleton(GetWestItemID(m_ItemID)); + } + if (info.ButtonID == (int)Buttons.South) + { banner = new HangingSkeleton(m_ItemID); + } if (banner != null) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs b/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs index ffcf0a83d..b004148c6 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/MiningCart.cs @@ -138,8 +138,11 @@ namespace Server.Items */ if (!from.InRange(GetWorldLocation(), 2) || !from.InLOS(this) || !(from.Z - Z > -3 && from.Z - Z < 3)) - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + } else if (house?.HasSecureAccess(from, SecureLevel.Friends) == true) + { switch (CartType) { case MiningCartType.OreSouth: @@ -164,10 +167,10 @@ namespace Server.Items // ReSharper disable once PossibleNullReferenceException ingots.Amount = amount; - if (!from.PlaceInBackpack(ingots)) + if (!@from.PlaceInBackpack(ingots)) { ingots.Delete(); - from.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. + @from.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. } else { @@ -177,7 +180,7 @@ namespace Server.Items } else { - from.SendLocalizedMessage(1094725); // There are no more resources available at this time. + @from.SendLocalizedMessage(1094725); // There are no more resources available at this time. } break; @@ -203,16 +206,16 @@ namespace Server.Items 11 => new Turquoise(), 12 => new EcruCitrine(), 13 => new FireRuby(), - _ => new BlueDiamond() // 14 + _ => new BlueDiamond() // 14 }; var amount = Math.Min(5, Gems); gems.Amount = amount; - if (!from.PlaceInBackpack(gems)) + if (!@from.PlaceInBackpack(gems)) { gems.Delete(); - from.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. + @from.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. } else { @@ -222,13 +225,16 @@ namespace Server.Items } else { - from.SendLocalizedMessage(1094725); // There are no more resources available at this time. + @from.SendLocalizedMessage(1094725); // There are no more resources available at this time. } break; } + } else - from.SendLocalizedMessage(1061637); // You are not allowed to access this. + { + @from.SendLocalizedMessage(1061637); // You are not allowed to access this. + } } public override void Serialize(IGenericWriter writer) @@ -244,9 +250,13 @@ namespace Server.Items writer.Write(Ore); if (m_Timer != null) + { writer.Write(m_Timer.Next); + } else + { writer.Write(DateTime.UtcNow + TimeSpan.FromDays(1)); + } } public override void Deserialize(IGenericReader reader) @@ -268,7 +278,9 @@ namespace Server.Items var next = reader.ReadDateTime(); if (next < DateTime.UtcNow) + { next = DateTime.UtcNow; + } m_Timer = Timer.DelayCall(next - DateTime.UtcNow, TimeSpan.FromDays(1), GiveResources); break; @@ -334,7 +346,9 @@ namespace Server.Items m_CartType = (MiningCartType)choice; if (!Deleted) - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void GetProperties(ObjectPropertyList list) @@ -342,13 +356,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1080457); // 10th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/MinotaurStatue.cs b/Projects/UOContent/Items/Special/Veteran Rewards/MinotaurStatue.cs index 8de4e14d9..f0c93a786 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/MinotaurStatue.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/MinotaurStatue.cs @@ -137,13 +137,17 @@ namespace Server.Items m_StatueType = (MinotaurStatueType)option; if (!Deleted) - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -161,7 +165,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076218); // 2nd Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs b/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs index 444b648ef..c933063b5 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs @@ -87,7 +87,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -105,7 +107,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076219); // 3rd Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -167,7 +171,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Cactus?.Deleted != false || info.ButtonID < 0x1E0F || info.ButtonID > 0x1E14) + { return; + } var cactus = new RewardPottedCactus(info.ButtonID) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/StoneAnkh.cs b/Projects/UOContent/Items/Special/Veteran Rewards/StoneAnkh.cs index cfae21f8b..33aa414b7 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/StoneAnkh.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/StoneAnkh.cs @@ -20,7 +20,9 @@ namespace Server.Items base.GetProperties(list); if (Addon is StoneAnkh ankh && ankh.IsRewardItem) + { list.Add(1076221); // 5th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -93,7 +95,9 @@ namespace Server.Items base.GetProperties(list); if (Core.ML && m_IsRewardItem) + { list.Add(1076221); // 5th Year Veteran Reward + } } public override void OnComponentUsed(AddonComponent c, Mobile from) @@ -178,7 +182,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -201,7 +207,9 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076221); // 5th Year Veteran Reward + } } public override void Serialize(IGenericWriter writer) @@ -251,7 +259,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed?.Deleted != false || info.ButtonID == (int)Buttons.Cancel) + { return; + } m_Deed.m_East = info.ButtonID == (int)Buttons.East; m_Deed.SendTarget(sender.Mobile); diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs b/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs index 816c013d3..c7db7e91b 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/TreeStump.cs @@ -144,9 +144,13 @@ namespace Server.Items writer.Write(m_Logs); if (m_Timer != null) + { writer.Write(m_Timer.Next); + } else + { writer.Write(DateTime.UtcNow + TimeSpan.FromDays(1)); + } } public override void Deserialize(IGenericReader reader) @@ -161,7 +165,9 @@ namespace Server.Items var next = reader.ReadDateTime(); if (next < DateTime.UtcNow) + { next = DateTime.UtcNow; + } m_Timer = Timer.DelayCall(next - DateTime.UtcNow, TimeSpan.FromDays(1), GiveLogs); } @@ -238,7 +244,9 @@ namespace Server.Items }; if (!Deleted) - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void GetProperties(ObjectPropertyList list) @@ -246,13 +254,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076223); // 7th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs b/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs index 273f6fd14..17503ade3 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs @@ -22,10 +22,14 @@ namespace Server.Items public bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } if (Addon != null) + { Addon.Hue = sender.DyedHue; + } return true; } @@ -303,13 +307,17 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076225); // 9th Year Veteran Reward + } } public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (IsChildOf(from.Backpack)) { @@ -496,7 +504,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_WallBanner?.Deleted != false || info.ButtonID <= 0 || info.ButtonID >= 31) + { return; + } m_WallBanner.Use(sender.Mobile, info.ButtonID); } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/WeaponEngravingTool.cs b/Projects/UOContent/Items/Special/Veteran Rewards/WeaponEngravingTool.cs index 09219efaa..b8d1d93dd 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/WeaponEngravingTool.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/WeaponEngravingTool.cs @@ -58,7 +58,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) + { return; + } if (m_UsesRemaining > 0) { @@ -82,11 +84,15 @@ namespace Server.Items else { if (from.Backpack.FindItemByType() != null) - from.SendGump(new ConfirmGump(this, null)); + { + @from.SendGump(new ConfirmGump(this, null)); + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1076166 ); // You do not have a blue diamond needed to recharge the engraving tool. + } } from.SendLocalizedMessage(1076163); // There are no charges left on this engraving tool. @@ -98,10 +104,14 @@ namespace Server.Items base.GetProperties(list); if (m_IsRewardItem) + { list.Add(1076224); // 8th Year Veteran Reward + } if (ShowUsesRemaining) + { list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ + } } public override void Serialize(IGenericWriter writer) @@ -127,7 +137,9 @@ namespace Server.Items public virtual void Recharge(Mobile from, Mobile guildmaster) { if (from.Backpack == null) + { return; + } var diamond = from.Backpack.FindItemByType(); @@ -205,7 +217,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { if (m_Tool?.Deleted != false) + { return; + } if (targeted is BaseWeapon item) { @@ -263,7 +277,9 @@ namespace Server.Items public override void OnResponse(NetState state, RelayInfo info) { if (m_Tool?.Deleted != false || m_Target?.Deleted != false) + { return; + } if (info.ButtonID != (int)Buttons.Okay) { @@ -274,7 +290,9 @@ namespace Server.Items var relay = info.GetTextEntry((int)Buttons.Text); if (relay == null) + { return; + } if (string.IsNullOrEmpty(relay.Text)) { @@ -353,7 +371,9 @@ namespace Server.Items public override void OnResponse(NetState state, RelayInfo info) { if (m_Engraver?.Deleted != false || info.ButtonID != (int)Buttons.Confirm) + { return; + } m_Engraver.Recharge(state.Mobile, m_Guildmaster); } diff --git a/Projects/UOContent/Items/Suits/BaseSuit.cs b/Projects/UOContent/Items/Suits/BaseSuit.cs index 1cf5b2d11..2b206d1aa 100644 --- a/Projects/UOContent/Items/Suits/BaseSuit.cs +++ b/Projects/UOContent/Items/Suits/BaseSuit.cs @@ -48,7 +48,9 @@ namespace Server.Items public bool Validate() { if (!(RootParent is Mobile mobile) || mobile.AccessLevel >= AccessLevel) + { return true; + } Delete(); return false; @@ -57,13 +59,17 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { if (Validate()) - base.OnSingleClick(from); + { + base.OnSingleClick(@from); + } } public override void OnDoubleClick(Mobile from) { if (Validate()) - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override bool VerifyMove(Mobile from) => from.AccessLevel >= AccessLevel; @@ -71,7 +77,9 @@ namespace Server.Items public override bool OnEquip(Mobile from) { if (from.AccessLevel < AccessLevel) - from.SendMessage("You may not wear this."); + { + @from.SendMessage("You may not wear this."); + } return from.AccessLevel >= AccessLevel; } diff --git a/Projects/UOContent/Items/Talismans/BaseTalisman.cs b/Projects/UOContent/Items/Talismans/BaseTalisman.cs index 3927bff06..ba1fccac3 100644 --- a/Projects/UOContent/Items/Talismans/BaseTalisman.cs +++ b/Projects/UOContent/Items/Talismans/BaseTalisman.cs @@ -192,7 +192,9 @@ namespace Server.Items m_Charges = value; if (m_ChargeTime > 0) + { StartTimer(); + } InvalidateProperties(); } @@ -337,13 +339,17 @@ namespace Server.Items var count = e.GetInt32(0); for (var i = 0; i < count; i++) + { m.AddToBackpack(Loot.RandomTalisman()); + } } public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseTalisman talisman)) + { return; + } talisman.m_Summoner = new TalismanAttribute(m_Summoner); talisman.m_Protection = new TalismanAttribute(m_Protection); @@ -439,7 +445,9 @@ namespace Server.Items var type = GetSummoner(); if (m_Summoner?.IsEmpty == false) + { type = m_Summoner.Type; + } if (type != null) { @@ -461,9 +469,13 @@ namespace Server.Items if (m_Summoner?.Amount > 1) { if (item.Stackable) + { item.Amount = m_Summoner.Amount; + } else + { count = m_Summoner.Amount; + } } if (from.Backpack == null || count * item.Weight > from.Backpack.MaxWeight || @@ -479,17 +491,27 @@ namespace Server.Items from.PlaceInBackpack(item); if (i + 1 < count) + { item = ActivatorUtil.CreateInstance(type) as Item; + } } if (item is Board) - from.SendLocalizedMessage(1075000); // You have been given some wooden boards. + { + @from.SendLocalizedMessage(1075000); // You have been given some wooden boards. + } else if (item is IronIngot) - from.SendLocalizedMessage(1075001); // You have been given some ingots. + { + @from.SendLocalizedMessage(1075001); // You have been given some ingots. + } else if (item is Bandage) - from.SendLocalizedMessage(1075002); // You have been given some clean bandages. + { + @from.SendLocalizedMessage(1075002); // You have been given some clean bandages. + } else if (m_Summoner?.Name != null) - from.SendLocalizedMessage(1074853, m_Summoner.Name.ToString()); // You have been given ~1_name~ + { + @from.SendLocalizedMessage(1074853, m_Summoner.Name.ToString()); // You have been given ~1_name~ + } } else if (obj is BaseCreature mob) { @@ -519,22 +541,32 @@ namespace Server.Items } if (m_Removal != TalismanRemoval.None) - from.Target = new TalismanTarget(this); + { + @from.Target = new TalismanTarget(this); + } } public override void AddNameProperty(ObjectPropertyList list) { if (ForceShowName) + { base.AddNameProperty(list); + } else if (m_Summoner?.IsEmpty == false) + { list.Add( 1072400, m_Summoner?.Name ?? "Unknown" ); // Talisman of ~1_name~ Summoning + } else if (m_Removal != TalismanRemoval.None) + { list.Add(1072389, $"#{1072000 + (int)m_Removal}"); // Talisman of ~1_name~ + } else + { base.AddNameProperty(list); + } } public override void GetProperties(ObjectPropertyList list) @@ -544,143 +576,213 @@ namespace Server.Items if (Blessed) { if (BlessedFor != null) + { list.Add( 1072304, !string.IsNullOrEmpty(BlessedFor.Name) ? BlessedFor.Name : "Unnamed Warrior" ); // Owned by ~1_name~ + } else + { list.Add(1072304, "Nobody"); // Owned by ~1_name~ + } } if (Parent is Mobile && m_MaxChargeTime > 0) { if (m_ChargeTime > 0) + { list.Add(1074884, m_ChargeTime.ToString()); // Charge time left: ~1_val~ + } else + { list.Add(1074883); // Fully Charged + } } list.Add(1075085); // Requirement: Mondain's Legacy if (m_Killer?.IsEmpty == false && m_Killer.Amount > 0) + { list.Add( 1072388, "{0}\t{1}", m_Killer.Name?.ToString() ?? "Unknown", m_Killer.Amount ); // ~1_NAME~ Killer: +~2_val~% + } if (m_Protection?.IsEmpty == false && m_Protection.Amount > 0) + { list.Add( 1072387, "{0}\t{1}", m_Protection.Name?.ToString() ?? "Unknown", m_Protection.Amount ); // ~1_NAME~ Protection: +~2_val~% + } if (m_ExceptionalBonus != 0) + { list.Add( 1072395, "#{0}\t{1}", AosSkillBonuses.GetLabel(m_Skill), m_ExceptionalBonus ); // ~1_NAME~ Exceptional Bonus: ~2_val~% + } if (m_SuccessBonus != 0) + { list.Add( 1072394, "#{0}\t{1}", AosSkillBonuses.GetLabel(m_Skill), m_SuccessBonus ); // ~1_NAME~ Bonus: ~2_val~% + } SkillBonuses.GetProperties(list); int prop; if ((prop = Attributes.WeaponDamage) != 0) + { list.Add(1060401, prop.ToString()); // damage increase ~1_val~% + } if ((prop = Attributes.DefendChance) != 0) + { list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% + } if ((prop = Attributes.BonusDex) != 0) + { list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ + } if ((prop = Attributes.EnhancePotions) != 0) + { list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% + } if ((prop = Attributes.CastRecovery) != 0) + { list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ + } if ((prop = Attributes.CastSpeed) != 0) + { list.Add(1060413, prop.ToString()); // faster casting ~1_val~ + } if ((prop = Attributes.AttackChance) != 0) + { list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% + } if ((prop = Attributes.BonusHits) != 0) + { list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ + } if ((prop = Attributes.BonusInt) != 0) + { list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ + } if ((prop = Attributes.LowerManaCost) != 0) + { list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% + } if ((prop = Attributes.LowerRegCost) != 0) + { list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% + } if ((prop = Attributes.Luck) != 0) + { list.Add(1060436, prop.ToString()); // luck ~1_val~ + } if ((prop = Attributes.BonusMana) != 0) + { list.Add(1060439, prop.ToString()); // mana increase ~1_val~ + } if ((prop = Attributes.RegenMana) != 0) + { list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ + } if (Attributes.NightSight != 0) + { list.Add(1060441); // night sight + } if ((prop = Attributes.ReflectPhysical) != 0) + { list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% + } if ((prop = Attributes.RegenStam) != 0) + { list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ + } if ((prop = Attributes.RegenHits) != 0) + { list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ + } if (Attributes.SpellChanneling != 0) + { list.Add(1060482); // spell channeling + } if ((prop = Attributes.SpellDamage) != 0) + { list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% + } if ((prop = Attributes.BonusStam) != 0) + { list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ + } if ((prop = Attributes.BonusStr) != 0) + { list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ + } if ((prop = Attributes.WeaponSpeed) != 0) + { list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% + } if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) + { list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% + } if (m_MaxCharges > 0) + { list.Add(1060741, m_Charges.ToString()); // charges: ~1_val~ + } if (m_Slayer != TalismanSlayerName.None) + { list.Add(1072503 + (int)m_Slayer); + } } private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) + { flags |= toSet; + } } private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; @@ -712,46 +814,74 @@ namespace Server.Items writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) + { Attributes.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + { SkillBonuses.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.Protection)) + { Protection.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.Killer)) + { Killer.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.Summoner)) + { Summoner.Serialize(writer); + } if (GetSaveFlag(flags, SaveFlag.Removal)) + { writer.WriteEncodedInt((int)m_Removal); + } if (GetSaveFlag(flags, SaveFlag.Skill)) + { writer.WriteEncodedInt((int)m_Skill); + } if (GetSaveFlag(flags, SaveFlag.SuccessBonus)) + { writer.WriteEncodedInt(m_SuccessBonus); + } if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus)) + { writer.WriteEncodedInt(m_ExceptionalBonus); + } if (GetSaveFlag(flags, SaveFlag.MaxCharges)) + { writer.WriteEncodedInt(m_MaxCharges); + } if (GetSaveFlag(flags, SaveFlag.Charges)) + { writer.WriteEncodedInt(m_Charges); + } if (GetSaveFlag(flags, SaveFlag.MaxChargeTime)) + { writer.WriteEncodedInt(m_MaxChargeTime); + } if (GetSaveFlag(flags, SaveFlag.ChargeTime)) + { writer.WriteEncodedInt(m_ChargeTime); + } if (GetSaveFlag(flags, SaveFlag.Slayer)) + { writer.WriteEncodedInt((int)m_Slayer); + } } public override void Deserialize(IGenericReader reader) @@ -775,7 +905,9 @@ namespace Server.Items // Backward compatibility if (GetSaveFlag(flags, SaveFlag.Owner)) + { BlessedFor = reader.ReadMobile(); + } m_Protection = GetSaveFlag(flags, SaveFlag.Protection) ? new TalismanAttribute(reader) @@ -788,34 +920,54 @@ namespace Server.Items : new TalismanAttribute(); if (GetSaveFlag(flags, SaveFlag.Removal)) + { m_Removal = (TalismanRemoval)reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.OldKarmaLoss)) + { Attributes.IncreasedKarmaLoss = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.Skill)) + { m_Skill = (SkillName)reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.SuccessBonus)) + { m_SuccessBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus)) + { m_ExceptionalBonus = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.MaxCharges)) + { m_MaxCharges = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.Charges)) + { m_Charges = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.MaxChargeTime)) + { m_MaxChargeTime = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.ChargeTime)) + { m_ChargeTime = reader.ReadEncodedInt(); + } if (GetSaveFlag(flags, SaveFlag.Slayer)) + { m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt(); + } m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed); @@ -829,7 +981,9 @@ namespace Server.Items SkillBonuses.AddTo(m); if (m_ChargeTime > 0) + { StartTimer(); + } } } @@ -838,10 +992,14 @@ namespace Server.Items m_ChargeTime = m_MaxChargeTime; if (m_Charges > 0 && m_MaxCharges > 0) + { m_Charges -= 1; + } if (m_ChargeTime > 0) + { StartTimer(); + } InvalidateProperties(); } @@ -866,7 +1024,9 @@ namespace Server.Items public virtual void StartTimer() { if (m_Timer?.Running != true) + { m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), Slice); + } } public virtual void StopTimer() @@ -898,7 +1058,9 @@ namespace Server.Items public static TalismanAttribute GetRandomSummoner() { if (Utility.RandomDouble() >= 0.025) + { return new TalismanAttribute(); + } var num = Utility.Random(m_Summons.Length); @@ -910,7 +1072,9 @@ namespace Server.Items public static TalismanRemoval GetRandomRemoval() { if (Utility.RandomDouble() < 0.65) + { return (TalismanRemoval)Utility.RandomList(390, 404, 407); + } return TalismanRemoval.None; } @@ -920,7 +1084,9 @@ namespace Server.Items public static TalismanAttribute GetRandomKiller(bool includingNone) { if (includingNone && Utility.RandomBool()) + { return new TalismanAttribute(); + } var num = Utility.Random(m_Killers.Length); @@ -932,7 +1098,9 @@ namespace Server.Items public static TalismanAttribute GetRandomProtection(bool includingNone) { if (includingNone && Utility.RandomBool()) + { return new TalismanAttribute(); + } var num = Utility.Random(m_Killers.Length); @@ -1007,7 +1175,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object o) { if (m_Talisman?.Deleted != false) + { return; + } if (from.Talisman != m_Talisman) { @@ -1070,15 +1240,21 @@ namespace Server.Items mod = target.GetStatMod("[Magic] Str Offset"); if (mod?.Offset < 0) + { target.RemoveStatMod("[Magic] Str Offset"); + } mod = target.GetStatMod("[Magic] Dex Offset"); if (mod?.Offset < 0) + { target.RemoveStatMod("[Magic] Dex Offset"); + } mod = target.GetStatMod("[Magic] Int Offset"); if (mod?.Offset < 0) + { target.RemoveStatMod("[Magic] Int Offset"); + } target.Paralyzed = false; @@ -1095,7 +1271,9 @@ namespace Server.Items target.SendLocalizedMessage(1072408); // Any curses on you have been lifted if (target != from) - from.SendLocalizedMessage(1072409); // Your targets curses have been lifted + { + @from.SendLocalizedMessage(1072409); // Your targets curses have been lifted + } break; case TalismanRemoval.Damage: @@ -1120,7 +1298,9 @@ namespace Server.Items target.SendLocalizedMessage(1072405); // Your lasting damage effects have been removed! if (target != from) - from.SendLocalizedMessage(1072406); // Your Targets lasting damage effects have been removed! + { + @from.SendLocalizedMessage(1072406); // Your Targets lasting damage effects have been removed! + } break; case TalismanRemoval.Ward: @@ -1143,7 +1323,9 @@ namespace Server.Items target.SendLocalizedMessage(1072402); // Your wards have been removed! if (target != from) - from.SendLocalizedMessage(1072403); // Your target's wards have been removed! + { + @from.SendLocalizedMessage(1072403); // Your target's wards have been removed! + } break; case TalismanRemoval.Wildfire: diff --git a/Projects/UOContent/Items/Talismans/Items/RunedSwitch.cs b/Projects/UOContent/Items/Talismans/Items/RunedSwitch.cs index 54069787e..c791f8d7e 100644 --- a/Projects/UOContent/Items/Talismans/Items/RunedSwitch.cs +++ b/Projects/UOContent/Items/Talismans/Items/RunedSwitch.cs @@ -49,7 +49,9 @@ namespace Server.Items protected override void OnTarget(Mobile from, object o) { if (m_Item?.Deleted != false) + { return; + } if (o is BaseTalisman talisman) { diff --git a/Projects/UOContent/Items/Talismans/RandomTalisman.cs b/Projects/UOContent/Items/Talismans/RandomTalisman.cs index e201ac115..2d552f45f 100644 --- a/Projects/UOContent/Items/Talismans/RandomTalisman.cs +++ b/Projects/UOContent/Items/Talismans/RandomTalisman.cs @@ -22,9 +22,13 @@ namespace Server.Items MaxCharges = Utility.RandomMinMax(10, 50); if (Summoner.IsItem) + { MaxChargeTime = 60; + } else + { MaxChargeTime = 1800; + } } Blessed = GetRandomBlessed(); diff --git a/Projects/UOContent/Items/Talismans/TalismanAttribute.cs b/Projects/UOContent/Items/Talismans/TalismanAttribute.cs index aea5cc8e1..8d5c5657a 100644 --- a/Projects/UOContent/Items/Talismans/TalismanAttribute.cs +++ b/Projects/UOContent/Items/Talismans/TalismanAttribute.cs @@ -33,13 +33,19 @@ namespace Server.Items var flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Type)) + { Type = AssemblyHandler.FindFirstTypeForName(reader.ReadString()); + } if (GetSaveFlag(flags, SaveFlag.Name)) + { Name = TextDefinition.Deserialize(reader); + } if (GetSaveFlag(flags, SaveFlag.Amount)) + { Amount = reader.ReadEncodedInt(); + } } [CommandProperty(AccessLevel.GameMaster)] @@ -62,7 +68,9 @@ namespace Server.Items private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) + { flags |= toSet; + } } private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; @@ -80,13 +88,19 @@ namespace Server.Items writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Type)) + { writer.Write(Type.FullName); + } if (GetSaveFlag(flags, SaveFlag.Name)) + { TextDefinition.Serialize(writer, Name); + } if (GetSaveFlag(flags, SaveFlag.Amount)) + { writer.WriteEncodedInt(Amount); + } } public int DamageBonus(Mobile to) => to?.GetType() == Type ? Amount : 0; diff --git a/Projects/UOContent/Items/Talismans/TalismanSlayer.cs b/Projects/UOContent/Items/Talismans/TalismanSlayer.cs index b38b571c3..7456ec9b9 100644 --- a/Projects/UOContent/Items/Talismans/TalismanSlayer.cs +++ b/Projects/UOContent/Items/Talismans/TalismanSlayer.cs @@ -87,13 +87,19 @@ namespace Server.Items public static bool Slays(TalismanSlayerName name, Mobile m) { if (m == null || !m_Table.TryGetValue(name, out var types) || types == null) + { return false; + } var type = m.GetType(); for (var i = 0; i < types.Length; i++) + { if (types[i].IsAssignableFrom(type)) + { return true; + } + } return false; } diff --git a/Projects/UOContent/Items/Talismans/TalismanSummons.cs b/Projects/UOContent/Items/Talismans/TalismanSummons.cs index f2be15c6f..7a73e5421 100644 --- a/Projects/UOContent/Items/Talismans/TalismanSummons.cs +++ b/Projects/UOContent/Items/Talismans/TalismanSummons.cs @@ -24,7 +24,9 @@ namespace Server.Mobiles public override void AddCustomContextEntries(Mobile from, List list) { if (from.Alive && ControlMaster == from) + { list.Add(new TalismanReleaseEntry(this)); + } } public override void Serialize(IGenericWriter writer) @@ -580,7 +582,9 @@ namespace Server.Mobiles public virtual void BeginTunnel() { if (Deleted) + { return; + } new VorpalBunny.BunnyHole().MoveToWorld(Location, Map); diff --git a/Projects/UOContent/Items/Traps/BaseTrap.cs b/Projects/UOContent/Items/Traps/BaseTrap.cs index d53e40649..87a24dda7 100644 --- a/Projects/UOContent/Items/Traps/BaseTrap.cs +++ b/Projects/UOContent/Items/Traps/BaseTrap.cs @@ -28,7 +28,9 @@ namespace Server.Items var hue = Hue & 0x3FFF; if (hue < 2) + { return 0; + } return hue - 1; } @@ -45,7 +47,9 @@ namespace Server.Items base.OnMovement(m, oldLocation); if (m.Location == oldLocation) + { return; + } if (CheckRange(m.Location, oldLocation, 0) && DateTime.UtcNow >= m_NextActiveTrigger) { diff --git a/Projects/UOContent/Items/Traps/FireColumnTrap.cs b/Projects/UOContent/Items/Traps/FireColumnTrap.cs index eec1cff30..e2a5c2179 100644 --- a/Projects/UOContent/Items/Traps/FireColumnTrap.cs +++ b/Projects/UOContent/Items/Traps/FireColumnTrap.cs @@ -53,10 +53,14 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (from.AccessLevel > AccessLevel.Player) + { return; + } if (WarningFlame) + { DoEffect(); + } if (from.Alive && CheckRange(from.Location, 0)) { @@ -73,7 +77,9 @@ namespace Server.Items ); if (!WarningFlame) + { DoEffect(); + } } } diff --git a/Projects/UOContent/Items/Traps/FlameSpurtTrap.cs b/Projects/UOContent/Items/Traps/FlameSpurtTrap.cs index fa59e535a..202ac4bdc 100644 --- a/Projects/UOContent/Items/Traps/FlameSpurtTrap.cs +++ b/Projects/UOContent/Items/Traps/FlameSpurtTrap.cs @@ -33,9 +33,13 @@ namespace Server.Items var map = Map; if (map?.GetSector(GetWorldLocation()).Active == true) + { StartTimer(); + } else + { StopTimer(); + } } public override void OnLocationChange(Point3D oldLocation) @@ -76,7 +80,9 @@ namespace Server.Items public virtual void Refresh() { if (Deleted) + { return; + } var foundPlayer = GetMobilesInRange(3) .Where(mob => mob.Player && mob.Alive && mob.AccessLevel <= AccessLevel.Player) @@ -99,10 +105,14 @@ namespace Server.Items public override bool OnMoveOver(Mobile m) { if (m.AccessLevel > AccessLevel.Player) + { return true; + } if (!(m.Player && m.Alive)) + { return false; + } CheckTimer(); @@ -118,7 +128,9 @@ namespace Server.Items if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player || !CheckRange(m.Location, oldLocation, 1)) + { return; + } CheckTimer(); @@ -126,7 +138,9 @@ namespace Server.Items m.PlaySound(m.Female ? 0x327 : 0x437); if (m.Body.IsHuman) + { m.Animate(20, 1, 1, true, false, 0); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Traps/GasTrap.cs b/Projects/UOContent/Items/Traps/GasTrap.cs index e0a35f741..0d9feb835 100644 --- a/Projects/UOContent/Items/Traps/GasTrap.cs +++ b/Projects/UOContent/Items/Traps/GasTrap.cs @@ -67,7 +67,9 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (Poison == null || !from.Player || !from.Alive || from.AccessLevel > AccessLevel.Player) + { return; + } Effects.SendLocationEffect(Location, Map, GetBaseID(Type) - 2, 16, 3, GetEffectHue(), 0); Effects.PlaySound(Location, Map, 0x231); diff --git a/Projects/UOContent/Items/Traps/GiantSpikeTrap.cs b/Projects/UOContent/Items/Traps/GiantSpikeTrap.cs index 72f085362..b0a49094f 100644 --- a/Projects/UOContent/Items/Traps/GiantSpikeTrap.cs +++ b/Projects/UOContent/Items/Traps/GiantSpikeTrap.cs @@ -22,12 +22,16 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (from.AccessLevel > AccessLevel.Player) + { return; + } Effects.SendLocationEffect(Location, Map, 0x1D99, 48, 2, GetEffectHue(), 0); if (from.Alive && CheckRange(from.Location, 0)) - SpellHelper.Damage(TimeSpan.FromTicks(1), from, from, Utility.Dice(10, 7, 0)); + { + SpellHelper.Damage(TimeSpan.FromTicks(1), @from, @from, Utility.Dice(10, 7, 0)); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/Traps/MushroomTrap.cs b/Projects/UOContent/Items/Traps/MushroomTrap.cs index 228a46c45..9b089da55 100644 --- a/Projects/UOContent/Items/Traps/MushroomTrap.cs +++ b/Projects/UOContent/Items/Traps/MushroomTrap.cs @@ -23,7 +23,9 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (!from.Alive || ItemID != 0x1125 || from.AccessLevel > AccessLevel.Player) + { return; + } ItemID = 0x1126; Effects.PlaySound(Location, Map, 0x306); @@ -36,9 +38,13 @@ namespace Server.Items public virtual void OnMushroomReset() { if (Region.Find(Location, Map).IsPartOf()) + { ItemID = 0x1125; // reset + } else + { Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -55,7 +61,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ItemID == 0x1126) + { OnMushroomReset(); + } } } } diff --git a/Projects/UOContent/Items/Traps/SawTrap.cs b/Projects/UOContent/Items/Traps/SawTrap.cs index 0a4f78c03..98305fe5a 100644 --- a/Projects/UOContent/Items/Traps/SawTrap.cs +++ b/Projects/UOContent/Items/Traps/SawTrap.cs @@ -60,7 +60,9 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (!from.Alive || from.AccessLevel > AccessLevel.Player) + { return; + } Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 6, 3, GetEffectHue(), 0); Effects.PlaySound(Location, Map, 0x21C); diff --git a/Projects/UOContent/Items/Traps/SpikeTrap.cs b/Projects/UOContent/Items/Traps/SpikeTrap.cs index 37ef1add1..66d06ca09 100644 --- a/Projects/UOContent/Items/Traps/SpikeTrap.cs +++ b/Projects/UOContent/Items/Traps/SpikeTrap.cs @@ -59,9 +59,13 @@ namespace Server.Items set { if (value) + { ItemID = GetExtendedID(Type); + } else + { ItemID = GetBaseID(Type); + } } } @@ -99,14 +103,20 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (!from.Alive || from.AccessLevel > AccessLevel.Player) + { return; + } Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 18, 3, GetEffectHue(), 0); Effects.PlaySound(Location, Map, 0x22C); foreach (var mob in GetMobilesInRange(0)) + { if (mob.Alive && !mob.IsDeadBondedPet) + { SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.RandomMinMax(1, 6) * 6); + } + } Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnSpikeExtended); diff --git a/Projects/UOContent/Items/Traps/StoneFaceTrap.cs b/Projects/UOContent/Items/Traps/StoneFaceTrap.cs index acdbd808e..3bbe5e0b3 100644 --- a/Projects/UOContent/Items/Traps/StoneFaceTrap.cs +++ b/Projects/UOContent/Items/Traps/StoneFaceTrap.cs @@ -52,9 +52,13 @@ namespace Server.Items set { if (value) + { ItemID = GetFireID(Type); + } else + { ItemID = GetBaseID(Type); + } } } @@ -88,7 +92,9 @@ namespace Server.Items public override void OnTrigger(Mobile from) { if (!from.Alive || from.AccessLevel > AccessLevel.Player) + { return; + } Effects.PlaySound(Location, Map, 0x359); @@ -106,8 +112,12 @@ namespace Server.Items public virtual void TriggerDamage() { foreach (var mob in GetMobilesInRange(1)) + { if (mob.Alive && !mob.IsDeadBondedPet && mob.AccessLevel == AccessLevel.Player) + { SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.Dice(3, 15, 0)); + } + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs index aad769f5a..405f494ac 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel1.cs @@ -46,19 +46,27 @@ namespace Server.Items // Weapon if (Utility.RandomBool()) + { DropItem(Loot.RandomWeapon()); + } // Armour if (Utility.RandomBool()) + { DropItem(Loot.RandomArmorOrShield()); + } // Clothing if (Utility.RandomBool()) + { DropItem(Loot.RandomClothing()); + } // Jewelry if (Utility.RandomBool()) + { DropItem(Loot.RandomJewelry()); + } } public TreasureChestLevel1(Serial serial) diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs index 9cc656a05..15359e5a8 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel3.cs @@ -73,7 +73,9 @@ namespace Server.Items // Magic Wand for (var i = Utility.Random(1, m_Level); i > 1; i--) + { DropItem(Loot.RandomWand()); + } // Equipment for (var i = Utility.Random(1, m_Level); i > 1; i--) @@ -99,11 +101,15 @@ namespace Server.Items // Clothing for (var i = Utility.Random(1, 2); i > 1; i--) + { DropItem(Loot.RandomClothing()); + } // Jewelry for (var i = Utility.Random(1, 2); i > 1; i--) + { DropItem(Loot.RandomJewelry()); + } } public TreasureChestLevel3(Serial serial) diff --git a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs index fb338a206..36b1c52b1 100644 --- a/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs +++ b/Projects/UOContent/Items/TreasureChests/TreasureChestLevel4.cs @@ -74,7 +74,9 @@ namespace Server.Items // Magic Wand for (var i = Utility.Random(1, m_Level); i > 1; i--) + { DropItem(Loot.RandomWand()); + } // Equipment for (var i = Utility.Random(1, m_Level); i > 1; i--) @@ -100,11 +102,15 @@ namespace Server.Items // Clothing for (var i = Utility.Random(1, 2); i > 1; i--) + { DropItem(Loot.RandomClothing()); + } // Jewelry for (var i = Utility.Random(1, 2); i > 1; i--) + { DropItem(Loot.RandomJewelry()); + } // Crystal ball (not implemented) } diff --git a/Projects/UOContent/Items/Wands/BaseWand.cs b/Projects/UOContent/Items/Wands/BaseWand.cs index fdc6fe77a..c864693f0 100644 --- a/Projects/UOContent/Items/Wands/BaseWand.cs +++ b/Projects/UOContent/Items/Wands/BaseWand.cs @@ -94,7 +94,9 @@ namespace Server.Items --Charges; if (Charges == 0) - from.SendLocalizedMessage(1019073); // This item is out of charges. + { + @from.SendLocalizedMessage(1019073); // This item is out of charges. + } ApplyDelayTo(from); } @@ -121,9 +123,13 @@ namespace Server.Items if (Parent == from) { if (Charges > 0) - OnWandUse(from); + { + OnWandUse(@from); + } else - from.SendLocalizedMessage(1019073); // This item is out of charges. + { + @from.SendLocalizedMessage(1019073); // This item is out of charges. + } } else { @@ -208,9 +214,13 @@ namespace Server.Items if (DisplayLootType) { if (LootType == LootType.Blessed) + { attrs.Add(new EquipInfoAttribute(1038021)); // blessed + } else if (LootType == LootType.Cursed) + { attrs.Add(new EquipInfoAttribute(1049643)); // cursed + } } if (!Identified) @@ -236,7 +246,9 @@ namespace Server.Items }; if (num > 0) + { attrs.Add(new EquipInfoAttribute(num, m_Charges)); + } } int number; @@ -252,7 +264,9 @@ namespace Server.Items } if (attrs.Count == 0 && Crafter == null && Name != null) + { return; + } var eqInfo = new EquipmentInfo( number, @@ -281,10 +295,14 @@ namespace Server.Items public virtual void DoWandTarget(Mobile from, object o) { if (Deleted || Charges <= 0 || Parent != from || o is StaticTarget || o is LandTarget) + { return; + } if (OnWandTarget(from, o)) - ConsumeCharge(from); + { + ConsumeCharge(@from); + } } public virtual bool OnWandTarget(Mobile from, object o) => true; diff --git a/Projects/UOContent/Items/Wands/IDWand.cs b/Projects/UOContent/Items/Wands/IDWand.cs index 8f530569b..3fd6e9a30 100644 --- a/Projects/UOContent/Items/Wands/IDWand.cs +++ b/Projects/UOContent/Items/Wands/IDWand.cs @@ -34,12 +34,18 @@ namespace Server.Items if (o is Item item) { if (item is BaseWeapon weapon) + { weapon.Identified = true; + } else if (item is BaseArmor armor) + { armor.Identified = true; + } if (!Core.AOS) - item.OnSingleClick(from); + { + item.OnSingleClick(@from); + } return true; } diff --git a/Projects/UOContent/Items/Weapons/Abilities/ArmorIgnore.cs b/Projects/UOContent/Items/Weapons/Abilities/ArmorIgnore.cs index b5cc3eec5..540fc2c3c 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/ArmorIgnore.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/ArmorIgnore.cs @@ -15,7 +15,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/ArmorPierce.cs b/Projects/UOContent/Items/Weapons/Abilities/ArmorPierce.cs index 49d7fed6f..8d4203a18 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/ArmorPierce.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/ArmorPierce.cs @@ -28,7 +28,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/ConcussionBlow.cs b/Projects/UOContent/Items/Weapons/Abilities/ConcussionBlow.cs index 0f8844b94..192c6d847 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/ConcussionBlow.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/ConcussionBlow.cs @@ -14,7 +14,9 @@ namespace Server.Items public override bool OnBeforeDamage(Mobile attacker, Mobile defender) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return false; + } ClearCurrentAbility(attacker); @@ -50,7 +52,9 @@ namespace Server.Items double manaPercent = 0; if (defender.ManaMax > 0) + { manaPercent = defender.Mana / (double)defender.ManaMax * 100.0; + } damage += Math.Min((int)(Math.Abs(hitsPercent - manaPercent) / 4), 20); } diff --git a/Projects/UOContent/Items/Weapons/Abilities/CrushingBlow.cs b/Projects/UOContent/Items/Weapons/Abilities/CrushingBlow.cs index 5c5a2f482..a172b82ee 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/CrushingBlow.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/CrushingBlow.cs @@ -11,7 +11,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/DefenseMastery.cs b/Projects/UOContent/Items/Weapons/Abilities/DefenseMastery.cs index c76a246d6..d40892723 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/DefenseMastery.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/DefenseMastery.cs @@ -31,7 +31,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); @@ -45,7 +47,9 @@ namespace Server.Items 50.0) / 70.0)); if (m_Table.TryGetValue(attacker, out var info)) + { EndDefense(info); + } var mod = new ResistanceMod(ResistanceType.Physical, 50 + modifier); attacker.AddResistanceMod(mod); @@ -61,7 +65,9 @@ namespace Server.Items public static bool GetMalus(Mobile targ, ref int damageMalus) { if (!m_Table.TryGetValue(targ, out var info)) + { return false; + } damageMalus = info.m_DamageMalus; return true; @@ -70,7 +76,9 @@ namespace Server.Items private static void EndDefense(DefenseMasteryInfo info) { if (info.m_Mod != null) + { info.m_From.RemoveResistanceMod(info.m_Mod); + } info.m_Timer?.Stop(); diff --git a/Projects/UOContent/Items/Weapons/Abilities/Disarm.cs b/Projects/UOContent/Items/Weapons/Abilities/Disarm.cs index 75992cdd5..d3b348df5 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/Disarm.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/Disarm.cs @@ -34,7 +34,9 @@ namespace Server.Items public override bool RequiresTactics(Mobile from) { if (!(from.Weapon is BaseWeapon weapon)) + { return false; + } return weapon.Skill != SkillName.Wrestling; } @@ -42,14 +44,18 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) + { return; + } ClearCurrentAbility(attacker); var toDisarm = defender.FindItemOnLayer(Layer.OneHanded); if (toDisarm?.Movable == false) + { toDisarm = defender.FindItemOnLayer(Layer.TwoHanded); + } var pack = defender.Backpack; diff --git a/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs b/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs index cf71adf3b..3c828e5a9 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs @@ -19,7 +19,9 @@ namespace Server.Items public override bool Validate(Mobile from) { if (!base.Validate(from)) + { return false; + } if (from.Mounted && !(from.Weapon is Lance)) { @@ -33,14 +35,20 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) + { return; + } if (defender is ChaosDragoon || defender is ChaosDragoonElite) + { return; + } if (attacker.Mounted && (!(attacker.Weapon is Lance) || !(defender.Weapon is Lance)) ) // TODO: Should there be a message here? + { return; + } ClearCurrentAbility(attacker); @@ -53,17 +61,25 @@ namespace Server.Items } if (!CheckMana(attacker, true)) + { return; + } if (Core.ML && attacker is LesserHiryu && Utility.RandomDouble() <= 0.8) + { return; // Lesser Hiryu have an 80% chance of missing this attack + } attacker.SendLocalizedMessage(1060082); // The force of your attack has dislodged them from their mount! if (attacker.Mounted) + { defender.SendLocalizedMessage(1062315); // You fall off your mount! + } else + { defender.SendLocalizedMessage(1060083); // You fall off of your mount and take damage! + } defender.PlaySound(0x140); defender.FixedParticles(0x3728, 10, 15, 9955, EffectLayer.Waist); @@ -71,8 +87,13 @@ namespace Server.Items if (defender is PlayerMobile mobile) { if (AnimalForm.UnderTransformation(mobile)) - mobile.SendLocalizedMessage(1114066, attacker.Name); // ~1_NAME~ knocked you out of animal form! - else if (mobile.Mounted) mobile.SendLocalizedMessage(1040023); // You have been knocked off of your mount! + { + mobile.SendLocalizedMessage(1114066, attacker.Name); // ~1_NAME~ knocked you out of animal form! + } + else if (mobile.Mounted) + { + mobile.SendLocalizedMessage(1040023); // You have been knocked off of your mount! + } mobile.SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds(10), true); } @@ -82,13 +103,21 @@ namespace Server.Items } if (attacker is PlayerMobile playerMobile) + { playerMobile.SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, true); + } else if (Core.ML && attacker is BaseCreature bc) + { if (bc.ControlMaster is PlayerMobile pm) + { pm.SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, false); + } + } if (!attacker.Mounted) + { AOS.Damage(defender, attacker, Utility.RandomMinMax(15, 25), 100, 0, 0, 0, 0); + } } } } diff --git a/Projects/UOContent/Items/Weapons/Abilities/Disrobe.cs b/Projects/UOContent/Items/Weapons/Abilities/Disrobe.cs index fc97c1f99..911bf1f88 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/Disrobe.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/Disrobe.cs @@ -14,13 +14,17 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) + { return; + } ClearCurrentAbility(attacker); var toDisrobe = defender.FindItemOnLayer(Layer.InnerTorso); if (toDisrobe?.Movable == false) + { toDisrobe = defender.FindItemOnLayer(Layer.OuterTorso); + } var pack = defender.Backpack; diff --git a/Projects/UOContent/Items/Weapons/Abilities/DoubleShot.cs b/Projects/UOContent/Items/Weapons/Abilities/DoubleShot.cs index 30b458dcb..3c9c062e4 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/DoubleShot.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/DoubleShot.cs @@ -36,7 +36,10 @@ namespace Server.Items if (base.Validate(from)) { if (from.Mounted) + { return true; + } + from.SendLocalizedMessage(1070770); // You can only execute this attack while mounted! ClearCurrentAbility(from); } @@ -47,7 +50,9 @@ namespace Server.Items public void Use(Mobile attacker, Mobile defender) { if (!Validate(attacker) || !CheckMana(attacker, true) || attacker.Weapon == null) // sanity + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/DoubleStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/DoubleStrike.cs index d3eebd94b..bf963e7f4 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/DoubleStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/DoubleStrike.cs @@ -12,7 +12,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); @@ -35,7 +37,9 @@ namespace Server.Items var weapon = attacker.Weapon; if (!(weapon != null && attacker.InRange(defender, weapon.MaxRange) && attacker.InLOS(defender))) + { return; + } BaseWeapon.InDoubleStrike = true; attacker.RevealingAction(); diff --git a/Projects/UOContent/Items/Weapons/Abilities/DualWield.cs b/Projects/UOContent/Items/Weapons/Abilities/DualWield.cs index 5d22cb0ad..32ee795a8 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/DualWield.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/DualWield.cs @@ -29,7 +29,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } if (Registry.TryGetValue(attacker, out var timer)) { diff --git a/Projects/UOContent/Items/Weapons/Abilities/Feint.cs b/Projects/UOContent/Items/Weapons/Abilities/Feint.cs index 1a6678b33..d2921e375 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/Feint.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/Feint.cs @@ -29,7 +29,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } if (Registry.TryGetValue(defender, out var timer)) { diff --git a/Projects/UOContent/Items/Weapons/Abilities/FrenziedWhirlwind.cs b/Projects/UOContent/Items/Weapons/Abilities/FrenziedWhirlwind.cs index 42b005e61..bcfc04ec5 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/FrenziedWhirlwind.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/FrenziedWhirlwind.cs @@ -32,14 +32,18 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) // Mana check after check that there are targets + { return; + } ClearCurrentAbility(attacker); var map = attacker.Map; if (!(map != null && attacker.Weapon is BaseWeapon weapon)) + { return; + } var targets = attacker.GetMobilesInRange(1) .Where( @@ -52,7 +56,9 @@ namespace Server.Items .ToList(); if (targets.Count == 0 || !CheckMana(attacker, true)) + { return; + } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); @@ -125,7 +131,9 @@ namespace Server.Items m_DamageToDo += DamagePerTick; if (m_DamageRemaining <= 0 && m_DamageToDo < 1) + { m_DamageToDo = 1.0; // Confirm this 'round up' at the end + } var damage = (int)m_DamageToDo; diff --git a/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs index 20104f446..1b64f1d0a 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs @@ -24,12 +24,16 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) + { return; + } ClearCurrentAbility(attacker); if (!(attacker.Weapon is BaseWeapon weapon)) + { return; + } var p = weapon.Poison; @@ -42,13 +46,18 @@ namespace Server.Items } if (!CheckMana(attacker, true)) + { return; + } --weapon.PoisonCharges; // Infectious strike special move now uses poisoning skill to help determine potency var maxLevel = Math.Max(attacker.Skills.Poisoning.Fixed / 200, 0); - if (p.Level > maxLevel) p = Poison.GetPoison(maxLevel); + if (p.Level > maxLevel) + { + p = Poison.GetPoison(maxLevel); + } if (attacker.Skills.Poisoning.Value / 100.0 > Utility.RandomDouble()) { diff --git a/Projects/UOContent/Items/Weapons/Abilities/NerveStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/NerveStrike.cs index 7759c6900..6e9411009 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/NerveStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/NerveStrike.cs @@ -37,7 +37,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/ParalyzingBlow.cs b/Projects/UOContent/Items/Weapons/Abilities/ParalyzingBlow.cs index c007c2c86..a365badd0 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/ParalyzingBlow.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/ParalyzingBlow.cs @@ -53,7 +53,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); @@ -83,7 +85,9 @@ namespace Server.Items public static void BeginImmunity(Mobile m, TimeSpan duration) { if (m_Table.TryGetValue(m, out var timer)) + { timer?.Stop(); + } m_Table[m] = timer = new InternalTimer(m, duration); timer.Start(); diff --git a/Projects/UOContent/Items/Weapons/Abilities/RidingSwipe.cs b/Projects/UOContent/Items/Weapons/Abilities/RidingSwipe.cs index ea7a9c4f5..24b7d682a 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/RidingSwipe.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/RidingSwipe.cs @@ -38,7 +38,9 @@ namespace Server.Items } if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs index 41b1d0713..a43bf94f2 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs @@ -15,12 +15,16 @@ namespace Server.Items public override bool CheckSkills(Mobile from) { if (!base.CheckSkills(from)) + { return false; + } var skill = from.Skills.Stealth; if (skill?.Value >= 80.0) + { return true; + } from.SendLocalizedMessage(1060183); // You lack the required stealth to perform that attack @@ -30,7 +34,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); diff --git a/Projects/UOContent/Items/Weapons/Abilities/TalonStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/TalonStrike.cs index 9f748d1cd..83173fa36 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/TalonStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/TalonStrike.cs @@ -30,7 +30,9 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (m_Table.Contains(defender) || !Validate(attacker) || !CheckMana(attacker, true)) + { return; + } ClearCurrentAbility(attacker); @@ -83,7 +85,9 @@ namespace Server.Items m_DamageToDo += DamagePerTick; if (m_DamageRemaining <= 0 && m_DamageToDo < 1) + { m_DamageToDo = 1.0; // Confirm this 'round up' at the end + } var damage = (int)m_DamageToDo; diff --git a/Projects/UOContent/Items/Weapons/Abilities/WeaponAbility.cs b/Projects/UOContent/Items/Weapons/Abilities/WeaponAbility.cs index 668fe3198..f216cfde3 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/WeaponAbility.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/WeaponAbility.cs @@ -115,9 +115,14 @@ namespace Server.Items if (from.Weapon is BaseWeapon weapon) { if (weapon.PrimaryAbility == this) + { return 70.0; + } + if (weapon.SecondaryAbility == this) + { return 90.0; + } } return 200.0; @@ -138,13 +143,19 @@ namespace Server.Items GetSkill(from, SkillName.Ninjitsu); if (skillTotal >= 300.0) + { mana -= 10; + } else if (skillTotal >= 200.0) + { mana -= 5; + } var scalar = 1.0; if (!MindRotSpell.GetMindRotScalar(from, ref scalar)) + { scalar = 1.0; + } // Lower Mana Cost = 40% var lmc = Math.Min(AosAttributes.GetValue(from, AosAttribute.LowerManaCost), 40); @@ -154,7 +165,9 @@ namespace Server.Items // Using a special move within 3 seconds of the previous special move costs double mana if (GetContext(from) != null) + { mana *= 2; + } return mana; } @@ -162,7 +175,9 @@ namespace Server.Items public virtual bool CheckWeaponSkill(Mobile from) { if (!(from.Weapon is BaseWeapon weapon)) + { return false; + } var skill = from.Skills[weapon.Skill]; var reqSkill = GetRequiredSkill(from); @@ -178,25 +193,33 @@ namespace Server.Items } if (skill?.Base >= reqSkill) + { return true; + } /* */ if (weapon.WeaponAttributes.UseBestSkill > 0 && (from.Skills.Swords.Base >= reqSkill || from.Skills.Macing.Base >= reqSkill || from.Skills.Fencing.Base >= reqSkill)) + { return true; + } /* */ if (reqTactics) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1079308, reqSkill.ToString() ); // You need ~1_SKILL_REQUIREMENT~ weapon and tactics skill to perform that attack + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1060182, reqSkill.ToString() ); // You need ~1_SKILL_REQUIREMENT~ weapon skill to perform that attack + } return false; } @@ -211,7 +234,10 @@ namespace Server.Items if (from.Mana < mana) { - if (from is BaseCreature creature && creature.HasManaOveride) return true; + if (from is BaseCreature creature && creature.HasManaOveride) + { + return true; + } from.SendLocalizedMessage( 1060181, @@ -239,12 +265,16 @@ namespace Server.Items public virtual bool Validate(Mobile from) { if (!from.Player) + { return true; + } var state = from.NetState; if (state == null) + { return false; + } if (RequiresSE && !state.SupportsExpansion(Expansion.SE)) { @@ -267,54 +297,102 @@ namespace Server.Items string option = null; if (this is ArmorIgnore) + { option = "Armor Ignore"; + } else if (this is BleedAttack) + { option = "Bleed Attack"; + } else if (this is ConcussionBlow) + { option = "Concussion Blow"; + } else if (this is CrushingBlow) + { option = "Crushing Blow"; + } else if (this is Disarm) + { option = "Disarm"; + } else if (this is Dismount) + { option = "Dismount"; + } else if (this is DoubleStrike) + { option = "Double Strike"; + } else if (this is InfectiousStrike) + { option = "Infectious Strike"; + } else if (this is MortalStrike) + { option = "Mortal Strike"; + } else if (this is MovingShot) + { option = "Moving Shot"; + } else if (this is ParalyzingBlow) + { option = "Paralyzing Blow"; + } else if (this is ShadowStrike) + { option = "Shadow Strike"; + } else if (this is WhirlwindAttack) + { option = "Whirlwind Attack"; + } else if (this is RidingSwipe) + { option = "Riding Swipe"; + } else if (this is FrenziedWhirlwind) + { option = "Frenzied Whirlwind"; + } else if (this is Block) + { option = "Block"; + } else if (this is DefenseMastery) + { option = "Defense Mastery"; + } else if (this is NerveStrike) + { option = "Nerve Strike"; + } else if (this is TalonStrike) + { option = "Talon Strike"; + } else if (this is Feint) + { option = "Feint"; + } else if (this is DualWield) + { option = "Dual Wield"; + } else if (this is DoubleShot) + { option = "Double Shot"; + } else if (this is ArmorPierce) + { option = "Armor Pierce"; + } if (option != null && !DuelContext.AllowSpecialAbility(from, option, true)) + { return false; + } return CheckSkills(from) && CheckMana(from, false); } @@ -386,7 +464,9 @@ namespace Server.Items Table.Remove(m); if (Core.AOS && m.NetState != null) + { m.Send(ClearWeaponAbility.Instance); + } } public static void Initialize() @@ -397,9 +477,13 @@ namespace Server.Items private static void EventSink_SetAbility(Mobile m, int index) { if (index == 0) + { ClearCurrentAbility(m); + } else if (index >= 1 && index < Abilities.Length) + { SetCurrentAbility(m, Abilities[index]); + } } private static void AddContext(Mobile m, WeaponAbilityContext context) @@ -412,7 +496,9 @@ namespace Server.Items var context = GetContext(m); if (context != null) + { RemoveContext(m, context); + } } private static void RemoveContext(Mobile m, WeaponAbilityContext context) diff --git a/Projects/UOContent/Items/Weapons/Abilities/WhirlwindAttack.cs b/Projects/UOContent/Items/Weapons/Abilities/WhirlwindAttack.cs index 1a6aff235..b17542bf8 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/WhirlwindAttack.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/WhirlwindAttack.cs @@ -15,20 +15,28 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) + { return; + } ClearCurrentAbility(attacker); var map = attacker.Map; if (map == null) + { return; + } if (!(attacker.Weapon is BaseWeapon weapon)) + { return; + } if (!CheckMana(attacker, true)) + { return; + } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); @@ -44,13 +52,17 @@ namespace Server.Items .ToList(); if (targets.Count <= 0) + { return; + } var bushido = attacker.Skills.Bushido.Value; var damageBonus = 1.0 + Math.Pow(targets.Count * bushido / 60, 2) / 100; if (damageBonus > 2.0) + { damageBonus = 2.0; + } attacker.RevealingAction(); diff --git a/Projects/UOContent/Items/Weapons/Artifacts/BladeOfInsanity.cs b/Projects/UOContent/Items/Weapons/Artifacts/BladeOfInsanity.cs index f31fc26fd..889bef0f6 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/BladeOfInsanity.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/BladeOfInsanity.cs @@ -36,7 +36,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 0x44F) + { Hue = 0x76D; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/BladeOfTheRighteous.cs b/Projects/UOContent/Items/Weapons/Artifacts/BladeOfTheRighteous.cs index d8b91b904..fa8331c4d 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/BladeOfTheRighteous.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/BladeOfTheRighteous.cs @@ -38,7 +38,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Slayer == SlayerName.None) + { Slayer = SlayerName.Exorcism; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/BoneCrusher.cs b/Projects/UOContent/Items/Weapons/Artifacts/BoneCrusher.cs index 601fac496..f9e30840a 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/BoneCrusher.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/BoneCrusher.cs @@ -36,10 +36,14 @@ namespace Server.Items var version = reader.ReadInt(); if (Hue == 0x604) + { Hue = 0x60C; + } if (ItemID == 0x1407) + { ItemID = 0x1406; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/LegacyOfTheDreadLord.cs b/Projects/UOContent/Items/Weapons/Artifacts/LegacyOfTheDreadLord.cs index 02ba7ee3d..a10001b8b 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/LegacyOfTheDreadLord.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/LegacyOfTheDreadLord.cs @@ -36,10 +36,14 @@ namespace Server.Items var version = reader.ReadInt(); if (Attributes.CastSpeed == 3) + { Attributes.CastRecovery = 3; + } if (Hue == 0x4B9) + { Hue = 0x676; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/SerpentsFang.cs b/Projects/UOContent/Items/Weapons/Artifacts/SerpentsFang.cs index 8a8cad13d..ba519f73c 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/SerpentsFang.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/SerpentsFang.cs @@ -47,7 +47,9 @@ namespace Server.Items var version = reader.ReadInt(); if (ItemID == 0x1401) + { ItemID = 0x1400; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/StaffOfTheMagi.cs b/Projects/UOContent/Items/Weapons/Artifacts/StaffOfTheMagi.cs index 896964f10..bc645d3a9 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/StaffOfTheMagi.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/StaffOfTheMagi.cs @@ -45,10 +45,14 @@ namespace Server.Items var version = reader.ReadInt(); if (WeaponAttributes.MageWeapon == 0) + { WeaponAttributes.MageWeapon = 30; + } if (ItemID == 0xDF1) + { ItemID = 0xDF0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/TheDragonSlayer.cs b/Projects/UOContent/Items/Weapons/Artifacts/TheDragonSlayer.cs index 417c216f7..83c74c5b2 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/TheDragonSlayer.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/TheDragonSlayer.cs @@ -46,7 +46,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Slayer == SlayerName.None) + { Slayer = SlayerName.DragonSlaying; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/TheDryadBow.cs b/Projects/UOContent/Items/Weapons/Artifacts/TheDryadBow.cs index d0ab56ee8..3419e3cc3 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/TheDryadBow.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/TheDryadBow.cs @@ -48,7 +48,9 @@ namespace Server.Items var version = reader.ReadInt(); if (version < 1) + { SkillBonuses.SetValues(0, m_PossibleBonusSkills.RandomElement(), Utility.Random(4) == 0 ? 10.0 : 5.0); + } } } } diff --git a/Projects/UOContent/Items/Weapons/Artifacts/ZyronicClaw.cs b/Projects/UOContent/Items/Weapons/Artifacts/ZyronicClaw.cs index 90855b710..9489c734e 100644 --- a/Projects/UOContent/Items/Weapons/Artifacts/ZyronicClaw.cs +++ b/Projects/UOContent/Items/Weapons/Artifacts/ZyronicClaw.cs @@ -45,7 +45,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Slayer == SlayerName.None) + { Slayer = SlayerName.ElementalBan; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs b/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs index cd9c69755..c7dae8b37 100644 --- a/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs +++ b/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs @@ -58,7 +58,9 @@ namespace Server.Items public virtual int GetUsesScalar() { if (Quality == WeaponQuality.Exceptional) + { return 200; + } return 100; } @@ -86,7 +88,9 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (HarvestSystem == null || Deleted) + { return; + } var loc = GetWorldLocation(); @@ -103,7 +107,9 @@ namespace Server.Items } if (!(HarvestSystem is Mining)) - from.SendLocalizedMessage(1010018); // What do you want to use this item on? + { + @from.SendLocalizedMessage(1010018); // What do you want to use this item on? + } HarvestSystem.BeginHarvesting(from, this); } @@ -113,7 +119,9 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (HarvestSystem != null) - BaseHarvestTool.AddContextMenuEntries(from, this, list, HarvestSystem); + { + BaseHarvestTool.AddContextMenuEntries(@from, this, list, HarvestSystem); + } } public override void Serialize(IGenericWriter writer) @@ -148,7 +156,9 @@ namespace Server.Items case 0: { if (m_UsesRemaining < 1) + { m_UsesRemaining = 150; + } break; } diff --git a/Projects/UOContent/Items/Weapons/BaseMeleeWeapon.cs b/Projects/UOContent/Items/Weapons/BaseMeleeWeapon.cs index ca12df725..4df9ca877 100644 --- a/Projects/UOContent/Items/Weapons/BaseMeleeWeapon.cs +++ b/Projects/UOContent/Items/Weapons/BaseMeleeWeapon.cs @@ -19,7 +19,9 @@ namespace Server.Items AttuneWeaponSpell.TryAbsorb(defender, ref damage); if (Core.AOS) + { return damage; + } var absorb = defender.MeleeDamageAbsorb; @@ -30,7 +32,9 @@ namespace Server.Items var react = damage / 5; if (react <= 0) + { react = 1; + } defender.MeleeDamageAbsorb -= damage; damage = 0; diff --git a/Projects/UOContent/Items/Weapons/Fists.cs b/Projects/UOContent/Items/Weapons/Fists.cs index 95130342c..c3418cfcb 100644 --- a/Projects/UOContent/Items/Weapons/Fists.cs +++ b/Projects/UOContent/Items/Weapons/Fists.cs @@ -50,14 +50,9 @@ namespace Server.Items var wresValue = defender.Skills.Wrestling.Value; var anatValue = defender.Skills.Anatomy.Value; var evalValue = defender.Skills.EvalInt.Value; - var incrValue = (anatValue + evalValue + 20.0) * 0.5; + var incrValue = Math.Min((anatValue + evalValue + 20.0) * 0.5, 120.0); - if (incrValue > 120.0) - incrValue = 120.0; - - if (wresValue > incrValue) - return wresValue; - return incrValue; + return wresValue > incrValue ? wresValue : incrValue; } private void CheckPreAOSMoves(Mobile attacker, Mobile defender) @@ -116,7 +111,9 @@ namespace Server.Items var toDisarm = defender.FindItemOnLayer(Layer.OneHanded); if (toDisarm?.Movable == false) + { toDisarm = defender.FindItemOnLayer(Layer.TwoHanded); + } var pack = defender.Backpack; @@ -166,7 +163,9 @@ namespace Server.Items public override TimeSpan OnSwing(Mobile attacker, Mobile defender) { if (!Core.AOS) + { CheckPreAOSMoves(attacker, defender); + } return base.OnSwing(attacker, defender); } @@ -219,10 +218,14 @@ namespace Server.Items private static void EventSink_DisarmRequest(Mobile m) { if (Core.AOS) + { return; + } if (!DuelContext.AllowSpecialAbility(m, "Disarm", true)) + { return; + } var armsValue = m.Skills.ArmsLore.Value; var wresValue = m.Skills.Wrestling.Value; @@ -248,10 +251,14 @@ namespace Server.Items private static void EventSink_StunRequest(Mobile m) { if (Core.AOS) + { return; + } if (!DuelContext.AllowSpecialAbility(m, "Stun", true)) + { return; + } var anatValue = m.Skills.Anatomy.Value; var wresValue = m.Skills.Wrestling.Value; diff --git a/Projects/UOContent/Items/Weapons/HitLower.cs b/Projects/UOContent/Items/Weapons/HitLower.cs index c694b7b80..52ee7fbdb 100644 --- a/Projects/UOContent/Items/Weapons/HitLower.cs +++ b/Projects/UOContent/Items/Weapons/HitLower.cs @@ -16,7 +16,9 @@ namespace Server.Items public static bool ApplyAttack(Mobile m) { if (IsUnderAttackEffect(m)) + { return false; + } m_AttackTable.Add(m); var timer = new AttackTimer(m); @@ -36,7 +38,9 @@ namespace Server.Items public static bool ApplyDefense(Mobile m) { if (IsUnderDefenseEffect(m)) + { return false; + } m_DefenseTable.Add(m); var timer = new DefenseTimer(m); diff --git a/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs b/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs index 841c541f7..730fdc312 100644 --- a/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs +++ b/Projects/UOContent/Items/Weapons/Knives/BaseKnife.cs @@ -49,7 +49,9 @@ namespace Server.Items --PoisonCharges; if (Utility.RandomDouble() >= 0.5) // 50% chance to poison + { defender.ApplyPoison(attacker, Poison); + } } } } diff --git a/Projects/UOContent/Items/Weapons/Knives/Cleaver.cs b/Projects/UOContent/Items/Weapons/Knives/Cleaver.cs index 11422cd46..60aa047b6 100644 --- a/Projects/UOContent/Items/Weapons/Knives/Cleaver.cs +++ b/Projects/UOContent/Items/Weapons/Knives/Cleaver.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs b/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs index e667c6a89..2e2d80a02 100644 --- a/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs +++ b/Projects/UOContent/Items/Weapons/Knives/ThrowingDagger.cs @@ -54,24 +54,30 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Dagger.Deleted) return; + if (m_Dagger.Deleted) + { + return; + } if (!from.Items.Contains(m_Dagger)) - from.SendMessage("You must be holding that weapon to use it."); + { + @from.SendMessage("You must be holding that weapon to use it."); + } else if (targeted is Mobile m) - if (m != from && from.HarmfulCheck(m)) + { + if (m != @from && @from.HarmfulCheck(m)) { - var to = from.GetDirectionTo(m); + var to = @from.GetDirectionTo(m); - from.Direction = to; + @from.Direction = to; - from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0); + @from.Animate(@from.Mounted ? 26 : 9, 7, 1, true, false, 0); if (Utility.RandomDouble() >= Math.Sqrt(m.Dex / 100.0) * 0.8) { - from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0); + @from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0); - AOS.Damage(m, from, Utility.Random(5, from.Str / 10), 100, 0, 0, 0, 0); + AOS.Damage(m, @from, Utility.Random(5, @from.Str / 10), 100, 0, 0, 0, 0); m_Dagger.MoveToWorld(m.Location, m.Map); } @@ -119,11 +125,12 @@ namespace Server.Items m_Dagger.MoveToWorld(new Point3D(x, y, m.Z), m.Map); - from.MovingEffect(m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0); + @from.MovingEffect(m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0); - from.SendMessage("You miss."); + @from.SendMessage("You miss."); } } + } } } } diff --git a/Projects/UOContent/Items/Weapons/Maces/FireworksWand.cs b/Projects/UOContent/Items/Weapons/Maces/FireworksWand.cs index fee6501b7..ca1896213 100644 --- a/Projects/UOContent/Items/Weapons/Maces/FireworksWand.cs +++ b/Projects/UOContent/Items/Weapons/Maces/FireworksWand.cs @@ -47,7 +47,9 @@ namespace Server.Items var map = from.Map; if (map == null || map == Map.Internal) + { return; + } if (useCharges) { @@ -91,20 +93,34 @@ namespace Server.Items var hue = Utility.Random(40); if (hue < 8) + { hue = 0x66D; + } else if (hue < 10) + { hue = 0x482; + } else if (hue < 12) + { hue = 0x47E; + } else if (hue < 16) + { hue = 0x480; + } else if (hue < 20) + { hue = 0x47F; + } else + { hue = 0; + } if (Utility.RandomBool()) + { hue = Utility.RandomList(0x47E, 0x47F, 0x480, 0x482, 0x66D); + } var renderMode = Utility.RandomList(0, 2, 3, 4, 5, 7); diff --git a/Projects/UOContent/Items/Weapons/Maces/Maul.cs b/Projects/UOContent/Items/Weapons/Maces/Maul.cs index b8ec91a60..e4db6e8e2 100644 --- a/Projects/UOContent/Items/Weapons/Maces/Maul.cs +++ b/Projects/UOContent/Items/Weapons/Maces/Maul.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 14.0) + { Weight = 10.0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/PoleArms/BasePoleArm.cs b/Projects/UOContent/Items/Weapons/PoleArms/BasePoleArm.cs index 9d8748196..b8858a825 100644 --- a/Projects/UOContent/Items/Weapons/PoleArms/BasePoleArm.cs +++ b/Projects/UOContent/Items/Weapons/PoleArms/BasePoleArm.cs @@ -52,12 +52,18 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (HarvestSystem == null) + { return; + } if (IsChildOf(from.Backpack) || Parent == from) - HarvestSystem.BeginHarvesting(from, this); + { + HarvestSystem.BeginHarvesting(@from, this); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } public override void GetContextMenuEntries(Mobile from, List list) @@ -65,7 +71,9 @@ namespace Server.Items base.GetContextMenuEntries(from, list); if (HarvestSystem != null) - BaseHarvestTool.AddContextMenuEntries(from, this, list, HarvestSystem); + { + BaseHarvestTool.AddContextMenuEntries(@from, this, list, HarvestSystem); + } } public override void Serialize(IGenericWriter writer) @@ -100,7 +108,9 @@ namespace Server.Items case 0: { if (m_UsesRemaining < 1) + { m_UsesRemaining = 150; + } break; } diff --git a/Projects/UOContent/Items/Weapons/PoleArms/Scythe.cs b/Projects/UOContent/Items/Weapons/PoleArms/Scythe.cs index de3a63078..2da05f720 100644 --- a/Projects/UOContent/Items/Weapons/PoleArms/Scythe.cs +++ b/Projects/UOContent/Items/Weapons/PoleArms/Scythe.cs @@ -45,7 +45,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 15.0) + { Weight = 5.0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Ranged/Bow.cs b/Projects/UOContent/Items/Weapons/Ranged/Bow.cs index fcc7dfeee..ed69b13d6 100644 --- a/Projects/UOContent/Items/Weapons/Ranged/Bow.cs +++ b/Projects/UOContent/Items/Weapons/Ranged/Bow.cs @@ -55,7 +55,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 7.0) + { Weight = 6.0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/SE Weapons/Yumi.cs b/Projects/UOContent/Items/Weapons/SE Weapons/Yumi.cs index 1a8d06931..cbaead85f 100644 --- a/Projects/UOContent/Items/Weapons/SE Weapons/Yumi.cs +++ b/Projects/UOContent/Items/Weapons/SE Weapons/Yumi.cs @@ -55,7 +55,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 7.0) + { Weight = 6.0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/SlayerEntry.cs b/Projects/UOContent/Items/Weapons/SlayerEntry.cs index efe675cf6..1acec3c59 100644 --- a/Projects/UOContent/Items/Weapons/SlayerEntry.cs +++ b/Projects/UOContent/Items/Weapons/SlayerEntry.cs @@ -93,8 +93,12 @@ namespace Server.Items var t = m.GetType(); for (var i = 0; i < Types.Length; ++i) + { if (Types[i].IsAssignableFrom(t)) + { return true; + } + } return false; } diff --git a/Projects/UOContent/Items/Weapons/SlayerGroup.cs b/Projects/UOContent/Items/Weapons/SlayerGroup.cs index 19038fec1..7e9d5d7d7 100644 --- a/Projects/UOContent/Items/Weapons/SlayerGroup.cs +++ b/Projects/UOContent/Items/Weapons/SlayerGroup.cs @@ -430,7 +430,9 @@ namespace Server.Items var v = (int)name; if (v >= 0 && v < TotalEntries.Length) + { return TotalEntries[v]; + } return null; } @@ -445,7 +447,9 @@ namespace Server.Items var inGroup = false; for (var j = 0; foundOn != null && !inGroup && j < foundOn.Length; ++j) + { inGroup = foundOn[j] == type; + } if (inGroup) { @@ -483,8 +487,12 @@ namespace Server.Items public bool OppositionSuperSlays(Mobile m) { for (var i = 0; i < Opposition.Length; i++) + { if (Opposition[i].Super.Slays(m)) + { return true; + } + } return false; } diff --git a/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs b/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs index ffc521683..7b51cf741 100644 --- a/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs +++ b/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs @@ -54,7 +54,9 @@ namespace Server.Items --PoisonCharges; if (Utility.RandomDouble() >= 0.5) // 50% chance to poison + { defender.ApplyPoison(attacker, Poison); + } } } } diff --git a/Projects/UOContent/Items/Weapons/SpearsAndForks/Pitchfork.cs b/Projects/UOContent/Items/Weapons/SpearsAndForks/Pitchfork.cs index 4e6086de3..85c04feab 100644 --- a/Projects/UOContent/Items/Weapons/SpearsAndForks/Pitchfork.cs +++ b/Projects/UOContent/Items/Weapons/SpearsAndForks/Pitchfork.cs @@ -41,7 +41,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 10.0) + { Weight = 11.0; + } } } } diff --git a/Projects/UOContent/Items/Weapons/Staves/ShepherdsCrook.cs b/Projects/UOContent/Items/Weapons/Staves/ShepherdsCrook.cs index e171088ef..9c0d3b5f5 100644 --- a/Projects/UOContent/Items/Weapons/Staves/ShepherdsCrook.cs +++ b/Projects/UOContent/Items/Weapons/Staves/ShepherdsCrook.cs @@ -47,7 +47,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 2.0) + { Weight = 4.0; + } } public override void OnDoubleClick(Mobile from) @@ -106,10 +108,14 @@ namespace Server.Items private bool IsHerdable(BaseCreature bc) { if (bc.IsParagon) + { return false; + } if (bc.Tamable) + { return true; + } var map = bc.Map; @@ -122,8 +128,12 @@ namespace Server.Items var t = bc.GetType(); foreach (var type in m_ChampTamables) + { if (type == t) + { return true; + } + } } } @@ -144,17 +154,21 @@ namespace Server.Items var max = m_Creature.MinTameSkill + 30 + Utility.Random(10); if (max <= from.Skills.Herding.Value) + { m_Creature.PrivateOverheadMessage( MessageType.Regular, 0x3B2, 502471, - from.NetState + @from.NetState ); // That wasn't even challenging. + } if (from.CheckTargetSkill(SkillName.Herding, m_Creature, min, max)) { if (p != from) + { p = new Point2D(p.X, p.Y); + } m_Creature.TargetLocation = p; from.SendLocalizedMessage(502479); // The animal walks where it was instructed to. diff --git a/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs b/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs index 7f3354fac..25bd12c6e 100644 --- a/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs +++ b/Projects/UOContent/Items/Weapons/Swords/BaseSword.cs @@ -46,7 +46,9 @@ namespace Server.Items --PoisonCharges; if (Utility.RandomDouble() >= 0.5) // 50% chance to poison + { defender.ApplyPoison(attacker, Poison); + } } } } diff --git a/Projects/UOContent/Items/Weapons/Swords/Kryss.cs b/Projects/UOContent/Items/Weapons/Swords/Kryss.cs index 9a43a5ca3..e57d048d4 100644 --- a/Projects/UOContent/Items/Weapons/Swords/Kryss.cs +++ b/Projects/UOContent/Items/Weapons/Swords/Kryss.cs @@ -48,7 +48,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 1.0) + { Weight = 2.0; + } } } } diff --git a/Projects/UOContent/Json/Converters/TextDefinitionConverter.cs b/Projects/UOContent/Json/Converters/TextDefinitionConverter.cs index b675f24b0..3835365ff 100644 --- a/Projects/UOContent/Json/Converters/TextDefinitionConverter.cs +++ b/Projects/UOContent/Json/Converters/TextDefinitionConverter.cs @@ -32,9 +32,13 @@ namespace Server.Json public override void Write(Utf8JsonWriter writer, TextDefinition value, JsonSerializerOptions options) { if (value.Number > 0) + { writer.WriteNumberValue(value.Number); + } else + { writer.WriteStringValue(value.String); + } } } } diff --git a/Projects/UOContent/Misc/Animations.cs b/Projects/UOContent/Misc/Animations.cs index b5d7d12d2..201b0be52 100644 --- a/Projects/UOContent/Misc/Animations.cs +++ b/Projects/UOContent/Misc/Animations.cs @@ -17,7 +17,9 @@ namespace Server.Misc }; if (action > 0 && from.Alive && !from.Mounted && from.Body.IsHuman) - from.Animate(action, 5, 1, true, false, 0); + { + @from.Animate(action, 5, 1, true, false, 0); + } } } } diff --git a/Projects/UOContent/Misc/AttackMessage.cs b/Projects/UOContent/Misc/AttackMessage.cs index 0f56c8a9c..7c9f349ad 100644 --- a/Projects/UOContent/Misc/AttackMessage.cs +++ b/Projects/UOContent/Misc/AttackMessage.cs @@ -22,7 +22,9 @@ namespace Server.Misc var aggressed = e.Aggressed; if (!aggressor.Player || !aggressed.Player) + { return; + } if (!CheckAggressions(aggressor, aggressed)) { @@ -50,7 +52,9 @@ namespace Server.Misc var info = list[i]; if (info.Attacker == m2 && DateTime.UtcNow < info.LastCombatTime + Delay) + { return true; + } } list = m2.Aggressors; @@ -60,7 +64,9 @@ namespace Server.Misc var info = list[i]; if (info.Attacker == m1 && DateTime.UtcNow < info.LastCombatTime + Delay) + { return true; + } } return false; diff --git a/Projects/UOContent/Misc/AutoSave.cs b/Projects/UOContent/Misc/AutoSave.cs index 79efa5bbb..1f8c3bba7 100644 --- a/Projects/UOContent/Misc/AutoSave.cs +++ b/Projects/UOContent/Misc/AutoSave.cs @@ -44,7 +44,9 @@ namespace Server.Misc protected override void OnTick() { if (!SavesEnabled || AutoRestart.Restarting) + { return; + } if (m_Warning == TimeSpan.Zero) { @@ -57,6 +59,7 @@ namespace Server.Misc s %= 60; if (m > 0 && s > 0) + { World.Broadcast( 0x35, true, @@ -66,10 +69,15 @@ namespace Server.Misc s, s != 1 ? "s" : "" ); + } else if (m > 0) + { World.Broadcast(0x35, true, "The world will save in {0} minute{1}.", m, m != 1 ? "s" : ""); + } else + { World.Broadcast(0x35, true, "The world will save in {0} second{1}.", s, s != 1 ? "s" : ""); + } DelayCall(m_Warning, Save); } @@ -83,7 +91,9 @@ namespace Server.Misc public static void Save(bool permitBackgroundWrite) { if (AutoRestart.Restarting) + { return; + } World.WaitForWriteCompletion(); @@ -102,12 +112,16 @@ namespace Server.Misc private static void Backup() { if (m_Backups.Length == 0) + { return; + } var root = Path.Combine(Core.BaseDirectory, "Backups/Automatic"); if (!Directory.Exists(root)) + { Directory.CreateDirectory(root); + } var existing = Directory.GetDirectories(root); @@ -116,13 +130,16 @@ namespace Server.Misc var dir = Match(existing, m_Backups[i]); if (dir == null) + { continue; + } if (i > 0) { var timeStamp = FindTimeStamp(dir.Name); if (timeStamp != null) + { try { dir.MoveTo(FormatDirectory(root, m_Backups[i - 1], timeStamp)); @@ -131,6 +148,7 @@ namespace Server.Misc { // ignored } + } } else { @@ -148,7 +166,9 @@ namespace Server.Misc var saves = Path.Combine(Core.BaseDirectory, "Saves"); if (Directory.Exists(saves)) + { Directory.Move(saves, FormatDirectory(root, m_Backups[^1], GetTimeStamp())); + } } private static DirectoryInfo Match(string[] paths, string match) @@ -158,7 +178,9 @@ namespace Server.Misc var info = new DirectoryInfo(paths[i]); if (info.Name.StartsWith(match)) + { return info; + } } return null; @@ -176,7 +198,9 @@ namespace Server.Misc var end = input.IndexOf(')', ++start); if (end >= start) + { return input.Substring(start, end - start); + } } return null; diff --git a/Projects/UOContent/Misc/CharacterCreation.cs b/Projects/UOContent/Misc/CharacterCreation.cs index f93eaef43..8fb280fa0 100644 --- a/Projects/UOContent/Misc/CharacterCreation.cs +++ b/Projects/UOContent/Misc/CharacterCreation.cs @@ -41,7 +41,9 @@ namespace Server.Misc private static Item MakeNewbie(Item item) { if (!Core.AOS) + { item.LootType = LootType.Newbied; + } return item; } @@ -70,7 +72,9 @@ namespace Server.Misc // The new AOS bankboxes don't have powerscrolls, they are automatically 'applied': for (var i = 0; i < PowerScroll.Skills.Count; ++i) + { m.Skills[PowerScroll.Skills[i]].Cap = 120.0; + } m.StatCap = 250; @@ -233,7 +237,9 @@ namespace Server.Misc PlaceItemIn(cont, 140, 150, new BagOfAllReagents(500)); for (var i = 0; i < 9; ++i) + { PlaceItemIn(cont, 45 + i * 10, 75, new RecallRune()); + } PlaceItemIn(cont, 141, 74, new FireHorn()); @@ -350,7 +356,9 @@ namespace Server.Misc PlaceItemIn(cont, 93, 66, new PixieSwatter()); for (var i = 0; i < 10; i++) + { PlaceItemIn(cont, 117, 128, new MessageInABottle(Utility.RandomBool() ? Map.Trammel : Map.Felucca, 4)); + } PlaceItemIn(bank, 18, 124, cont); @@ -397,11 +405,13 @@ namespace Server.Misc PlaceItemIn(cont, 49, 45, new Yumi()); for (var i = 0; i < cont.Items.Count; i++) + { if (cont.Items[i] is BaseRanged bow) { bow.Attributes.WeaponSpeed = 35; bow.Attributes.WeaponDamage = 35; } + } PlaceItemIn(bank, 108, 135, cont); } @@ -429,7 +439,9 @@ namespace Server.Misc var bag = new Bag(); for (var i = 0; i < 5; ++i) + { bag.DropItem(new Moonstone(MoonstoneType.Felucca)); + } // Felucca moonstones bank.DropItem(bag); @@ -437,7 +449,9 @@ namespace Server.Misc bag = new Bag(); for (var i = 0; i < 5; ++i) + { bag.DropItem(new Moonstone(MoonstoneType.Trammel)); + } // Trammel moonstones bank.DropItem(bag); @@ -512,7 +526,9 @@ namespace Server.Misc // 5 blank recall runes for (var i = 0; i < 5; ++i) + { bank.DropItem(MakeNewbie(new RecallRune())); + } AddPowerScrolls(bank); } @@ -522,7 +538,9 @@ namespace Server.Misc var bag = new Bag(); for (var i = 0; i < PowerScroll.Skills.Count; ++i) + { bag.DropItem(new PowerScroll(PowerScroll.Skills[i], 120.0)); + } bag.DropItem(new StatCapScroll(250)); @@ -534,8 +552,11 @@ namespace Server.Misc var hue = Utility.ClipDyedHue(shirtHue & 0x3FFF); if (m.Race == Race.Elf) + { EquipItem(new ElvenShirt(hue), true); + } else + { switch (Utility.Random(3)) { case 0: @@ -548,6 +569,7 @@ namespace Server.Misc EquipItem(new Doublet(hue), true); break; } + } } private static void AddPants(Mobile m, int pantsHue) @@ -561,6 +583,7 @@ namespace Server.Misc else { if (m.Female) + { switch (Utility.Random(2)) { case 0: @@ -570,7 +593,9 @@ namespace Server.Misc EquipItem(new Kilt(hue), true); break; } + } else + { switch (Utility.Random(2)) { case 0: @@ -580,25 +605,36 @@ namespace Server.Misc EquipItem(new ShortPants(hue), true); break; } + } } } private static void AddShoes(Mobile m) { if (m.Race == Race.Elf) + { EquipItem(new ElvenBoots(), true); + } else + { EquipItem(new Shoes(Utility.RandomYellowHue()), true); + } } private static Mobile CreateMobile(Account a) { if (a.Count >= a.Limit) + { return null; + } for (var i = 0; i < a.Length; ++i) + { if (a[i] == null) + { return a[i] = new PlayerMobile(); + } + } return null; } @@ -606,12 +642,16 @@ namespace Server.Misc private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args) { if (!VerifyProfession(args.Profession)) + { args.Profession = 0; + } var state = args.State; if (state == null) + { return; + } var newChar = CreateMobile(args.Account as Account); @@ -630,9 +670,13 @@ namespace Server.Misc // newChar.Body = newChar.Female ? 0x191 : 0x190; if (Core.Expansion >= args.Race.RequiredExpansion) + { newChar.Race = args.Race; // Sets body + } else + { newChar.Race = Race.DefaultRace; + } // newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000; newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000; @@ -646,7 +690,9 @@ namespace Server.Misc pm.Profession = args.Profession; if (pm.AccessLevel == AccessLevel.Player && ((Account)pm.Account).Young) + { young = pm.Young = true; + } } SetName(newChar, args.Name); @@ -678,7 +724,9 @@ namespace Server.Misc } if (TestCenter.Enabled) + { FillBankbox(newChar); + } if (young) { @@ -701,20 +749,34 @@ namespace Server.Misc public static bool VerifyProfession(int profession) { if (profession < 0) + { return false; + } + if (profession < 4) + { return true; + } + if (Core.AOS && profession < 6) + { return true; + } + if (Core.SE && profession < 8) + { return true; + } return false; } private static CityInfo GetStartLocation(CharacterCreatedEventArgs args, bool isYoung) { - if (Core.ML) return m_NewHavenInfo; // We don't get the client Version until AFTER Character creation + if (Core.ML) + { + return m_NewHavenInfo; // We don't get the client Version until AFTER Character creation + } var useHaven = isYoung; @@ -726,7 +788,9 @@ namespace Server.Misc case 4: // Necro { if ((flags & ClientFlags.Malas) != 0) + { return new CityInfo("Umbra", "Mardoth's Tower", 2114, 1301, -50, Map.Malas); + } useHaven = true; @@ -749,7 +813,9 @@ namespace Server.Misc case 6: // Samurai { if ((flags & ClientFlags.Tokuno) != 0) + { return new CityInfo("Samurai DE", "Haoti's Grounds", 368, 780, -1, Map.Malas); + } useHaven = true; @@ -768,7 +834,9 @@ namespace Server.Misc case 7: // Ninja { if ((flags & ClientFlags.Tokuno) != 0) + { return new CityInfo("Ninja DE", "Enimo's Residence", 414, 823, -1, Map.Malas); + } useHaven = true; @@ -786,7 +854,9 @@ namespace Server.Misc } if (useHaven) + { return m_NewHavenInfo; + } return args.City; } @@ -800,18 +870,26 @@ namespace Server.Misc var vInt = intel - 10; if (vStr < 0) + { vStr = 0; + } if (vDex < 0) + { vDex = 0; + } if (vInt < 0) + { vInt = 0; + } var total = vStr + vDex + vInt; if (total == 0 || total == vMax) + { return; + } var scalar = vMax / (double)total; @@ -854,7 +932,9 @@ namespace Server.Misc name = name.Trim(); if (!NameVerification.Validate(name, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote)) + { name = "Generic Player"; + } m.Name = name; } @@ -866,13 +946,19 @@ namespace Server.Misc for (var i = 0; i < skills.Length; ++i) { if (skills[i].Value < 0 || skills[i].Value > 50) + { return false; + } total += skills[i].Value; for (var j = i + 1; j < skills.Length; ++j) + { if (skills[j].Value > 0 && skills[j].Name == skills[i].Name) + { return false; + } + } } return total == 100 || total == 120; @@ -968,7 +1054,9 @@ namespace Server.Misc default: { if (!ValidSkills(skills)) + { return; + } break; } @@ -982,9 +1070,14 @@ namespace Server.Misc case 1: // Warrior { if (elf) + { EquipItem(new LeafChest()); + } else + { EquipItem(new LeatherChest()); + } + break; } case 4: // Necromancer @@ -992,8 +1085,12 @@ namespace Server.Misc Container regs = new BagOfNecroReagents(); if (!Core.AOS) + { foreach (var item in regs.Items) + { item.LootType = LootType.Newbied; + } + } PackItem(regs); @@ -1083,9 +1180,13 @@ namespace Server.Misc EquipItem(new Bokuto()); if (elf) + { EquipItem(new RavenHelm()); + } else + { EquipItem(new LeatherJingasa()); + } PackItem(new Scissors()); PackItem(new Bandage(50)); @@ -1109,9 +1210,13 @@ namespace Server.Misc EquipItem(new NinjaTabi(0x2C3)); if (elf) + { EquipItem(new AssassinSpike()); + } else + { EquipItem(new Tekagi()); + } PackItem(new SmokeBomb()); @@ -1136,7 +1241,9 @@ namespace Server.Misc skill.BaseFixedPoint = snv.Value * 10; if (addSkillItems) + { AddSkillItems(snv.Name, m); + } } } } @@ -1145,30 +1252,44 @@ namespace Server.Misc private static void EquipItem(Item item, bool mustEquip = false) { if (!Core.AOS) + { item.LootType = LootType.Newbied; + } if (m_Mobile?.EquipItem(item) == true) + { return; + } var pack = m_Mobile?.Backpack; if (!mustEquip && pack != null) + { pack.DropItem(item); + } else + { item.Delete(); + } } private static void PackItem(Item item) { if (!Core.AOS) + { item.LootType = LootType.Newbied; + } var pack = m_Mobile.Backpack; if (pack != null) + { pack.DropItem(item); + } else + { item.Delete(); + } } private static void PackInstrument() @@ -1298,9 +1419,13 @@ namespace Server.Misc if (elf) { if (m.Female) + { EquipItem(new FemaleElvenRobe(hue)); + } else + { EquipItem(new MaleElvenRobe(hue)); + } } else { @@ -1318,9 +1443,13 @@ namespace Server.Misc if (elf) { if (m.Female) + { EquipItem(new FemaleElvenRobe(hue)); + } else + { EquipItem(new MaleElvenRobe(hue)); + } } else { @@ -1338,9 +1467,13 @@ namespace Server.Misc EquipItem(new WildStaff()); if (m.Female) + { EquipItem(new FemaleElvenRobe(hue)); + } else + { EquipItem(new MaleElvenRobe(hue)); + } } else { @@ -1355,15 +1488,20 @@ namespace Server.Misc PackItem(new Arrow(25)); if (elf) + { EquipItem(new ElvenCompositeLongbow()); + } else + { EquipItem(new Bow()); + } break; } case SkillName.ArmsLore: { if (elf) + { switch (Utility.Random(3)) { case 0: @@ -1376,7 +1514,9 @@ namespace Server.Misc EquipItem(new DiamondMace()); break; } + } else + { switch (Utility.Random(3)) { case 0: @@ -1389,15 +1529,21 @@ namespace Server.Misc EquipItem(new Club()); break; } + } break; } case SkillName.Begging: { if (elf) + { EquipItem(new WildStaff()); + } else + { EquipItem(new GnarledStaff()); + } + break; } case SkillName.Blacksmith: @@ -1458,7 +1604,9 @@ namespace Server.Misc case SkillName.Chivalry: { if (Core.ML) + { PackItem(new BookOfChivalry()); + } break; } @@ -1475,9 +1623,13 @@ namespace Server.Misc case SkillName.Fencing: { if (elf) + { EquipItem(new Leafblade()); + } else + { EquipItem(new Kryss()); + } break; } @@ -1509,9 +1661,13 @@ namespace Server.Misc case SkillName.Herding: { if (elf) + { EquipItem(new WildStaff()); + } else + { EquipItem(new ShepherdsCrook()); + } break; } @@ -1529,9 +1685,14 @@ namespace Server.Misc case SkillName.ItemID: { if (elf) + { EquipItem(new WildStaff()); + } else + { EquipItem(new GnarledStaff()); + } + break; } case SkillName.Lockpicking: @@ -1547,9 +1708,13 @@ namespace Server.Misc case SkillName.Macing: { if (elf) + { EquipItem(new DiamondMace()); + } else + { EquipItem(new Club()); + } break; } @@ -1558,8 +1723,12 @@ namespace Server.Misc var regs = new BagOfReagents(30); if (!Core.AOS) + { foreach (var item in regs.Items) + { item.LootType = LootType.Newbied; + } + } PackItem(regs); @@ -1580,9 +1749,13 @@ namespace Server.Misc EquipItem(new Circlet()); if (m.Female) + { EquipItem(new FemaleElvenRobe(Utility.RandomBlueHue())); + } else + { EquipItem(new MaleElvenRobe(Utility.RandomBlueHue())); + } } else { @@ -1661,18 +1834,26 @@ namespace Server.Misc case SkillName.Swords: { if (elf) + { EquipItem(new RuneBlade()); + } else + { EquipItem(new Katana()); + } break; } case SkillName.Tactics: { if (elf) + { EquipItem(new RuneBlade()); + } else + { EquipItem(new Katana()); + } break; } @@ -1691,9 +1872,13 @@ namespace Server.Misc var hue = Utility.RandomYellowHue(); if (elf) + { EquipItem(new ElvenBoots(hue)); + } else + { EquipItem(new Boots(hue)); + } EquipItem(new SkinningKnife()); break; @@ -1707,9 +1892,13 @@ namespace Server.Misc case SkillName.Wrestling: { if (elf) + { EquipItem(new LeafGloves()); + } else + { EquipItem(new LeatherGloves()); + } break; } diff --git a/Projects/UOContent/Misc/Cleanup.cs b/Projects/UOContent/Misc/Cleanup.cs index 40d23317d..d02c3a1b1 100644 --- a/Projects/UOContent/Misc/Cleanup.cs +++ b/Projects/UOContent/Misc/Cleanup.cs @@ -31,7 +31,9 @@ namespace Server.Misc if (item is CommodityDeed deed) { if (deed.Commodity != null) + { validItems.Add(deed.Commodity); + } continue; } @@ -39,12 +41,20 @@ namespace Server.Misc if (item is BaseHouse house) { foreach (var relEntity in house.RelocatedEntities) + { if (relEntity.Entity is Item item1) + { validItems.Add(item1); + } + } foreach (var inventory in house.VendorInventories) + { foreach (var subItem in inventory.Items) + { validItems.Add(subItem); + } + } } else if (item is BankBox box) { @@ -82,33 +92,47 @@ namespace Server.Misc } if (item.Parent != null || item.Map != Map.Internal || item.HeldBy != null) + { continue; + } if (item.Location != Point3D.Zero) + { continue; + } if (!IsBuggable(item)) + { continue; + } items.Add(item); } for (var i = 0; i < validItems.Count; ++i) + { items.Remove(validItems[i]); + } if (items.Count > 0) { if (boxes > 0) + { Console.WriteLine( "Cleanup: Detected {0} inaccessible items, including {1} bank boxes, removing..", items.Count, boxes ); + } else + { Console.WriteLine("Cleanup: Detected {0} inaccessible items, removing..", items.Count); + } for (var i = 0; i < items.Count; ++i) + { items[i].Delete(); + } } if (hairCleanup.Count > 0) @@ -119,14 +143,18 @@ namespace Server.Misc ); for (var i = 0; i < hairCleanup.Count; i++) + { hairCleanup[i].ConvertHair(); + } } } public static bool IsBuggable(Item item) { if (item is Fists) + { return false; + } if (item is ICommodity || item is BaseBoat || item is Fish || item is BigFish || item is Food || item is CookableFood @@ -153,7 +181,9 @@ namespace Server.Misc || item is WindSpirit || item is DirtPatch || item is Futon) + { return true; + } return false; } diff --git a/Projects/UOContent/Misc/DoorGenerator.cs b/Projects/UOContent/Misc/DoorGenerator.cs index 2882ed7d3..59b1f0cea 100644 --- a/Projects/UOContent/Misc/DoorGenerator.cs +++ b/Projects/UOContent/Misc/DoorGenerator.cs @@ -354,7 +354,9 @@ namespace Server m_Count = 0; for (var i = 0; i < m_BritRegions.Length; ++i) + { Generate(m_BritRegions[i]); + } var trammelCount = m_Count; @@ -362,7 +364,9 @@ namespace Server m_Count = 0; for (var i = 0; i < m_BritRegions.Length; ++i) + { Generate(m_BritRegions[i]); + } var feluccaCount = m_Count; @@ -370,7 +374,9 @@ namespace Server m_Count = 0; for (var i = 0; i < m_IlshRegions.Length; ++i) + { Generate(m_IlshRegions[i]); + } var ilshenarCount = m_Count; @@ -378,7 +384,9 @@ namespace Server m_Count = 0; for (var i = 0; i < m_MalasRegions.Length; ++i) + { Generate(m_MalasRegions[i]); + } var malasCount = m_Count; @@ -398,16 +406,23 @@ namespace Server public static bool IsFrame(int id, int[] list) { if (id > list[^1]) + { return false; + } for (var i = 0; i < list.Length; ++i) { var delta = id - list[i]; if (delta < 0) + { return false; + } + if (delta == 0) + { return true; + } } return false; @@ -430,7 +445,9 @@ namespace Server var tile = tiles[i]; if (tile.Z == z && IsEastFrame(tile.ID)) + { return true; + } } return false; @@ -445,7 +462,9 @@ namespace Server var tile = tiles[i]; if (tile.Z == z && IsSouthFrame(tile.ID)) + { return true; + } } return false; @@ -457,19 +476,29 @@ namespace Server var doorTop = doorZ + 20; if (!m_Map.CanFit(x, y, z, 16, false, false)) + { return null; + } if (y == 1743 && x >= 1343 && x <= 1344) + { return null; + } if (y == 1679 && x >= 1392 && x <= 1393) + { return null; + } if (x == 1320 && y >= 1618 && y <= 1640) + { return null; + } if (x == 1383 && y >= 1642 && y <= 1643) + { return null; + } BaseDoor door = new DarkWoodDoor(facing); door.MoveToWorld(new Point3D(x, y, z), m_Map); @@ -482,6 +511,7 @@ namespace Server public static void Generate(Rectangle2D region) { for (var rx = 0; rx < region.Width; ++rx) + { for (var ry = 0; ry < region.Height; ++ry) { var vx = rx + region.X; @@ -546,6 +576,7 @@ namespace Server } } } + } } } } diff --git a/Projects/UOContent/Misc/Emitter.cs b/Projects/UOContent/Misc/Emitter.cs index f5d3bcf06..61ba4cb7f 100644 --- a/Projects/UOContent/Misc/Emitter.cs +++ b/Projects/UOContent/Misc/Emitter.cs @@ -65,7 +65,9 @@ namespace Server public LocalBuilder AcquireTemp(Type localType) { if (!m_Temps.TryGetValue(localType, out var list)) + { m_Temps[localType] = list = new Queue(); + } return list.Count > 0 ? list.Dequeue() : CreateLocal(localType); } @@ -73,10 +75,14 @@ namespace Server public void ReleaseTemp(LocalBuilder local) { if (local.LocalType == null) + { return; + } if (!m_Temps.TryGetValue(local.LocalType, out var list)) + { m_Temps[local.LocalType] = list = new Queue(); + } list.Enqueue(local); } @@ -115,18 +121,26 @@ namespace Server public void Pop(Type expected) { if (expected == null) + { throw new InvalidOperationException("Expected type cannot be null."); + } var onStack = m_Stack.Pop(); if (expected == typeof(bool)) + { expected = typeof(int); + } if (onStack == typeof(bool)) + { onStack = typeof(int); + } if (!expected.IsAssignableFrom(onStack)) + { throw new InvalidOperationException("Unexpected stack state."); + } } public void Push(Type type) @@ -137,7 +151,9 @@ namespace Server public void Return() { if (m_Stack.Count != (Method.ReturnType == typeof(void) ? 0 : 1)) + { throw new InvalidOperationException("Stack return mismatch."); + } Generator.Emit(OpCodes.Ret); } @@ -159,9 +175,13 @@ namespace Server Push(typeof(string)); if (value != null) + { Generator.Emit(OpCodes.Ldstr, value); + } else + { Generator.Emit(OpCodes.Ldnull); + } } public void Load(Enum value) @@ -207,9 +227,13 @@ namespace Server Push(typeof(bool)); if (value) + { Generator.Emit(OpCodes.Ldc_I4_1); + } else + { Generator.Emit(OpCodes.Ldc_I4_0); + } } public void Load(int value) @@ -260,9 +284,13 @@ namespace Server default: if (value >= sbyte.MinValue && value <= sbyte.MaxValue) + { Generator.Emit(OpCodes.Ldc_I4_S, (sbyte)value); + } else + { Generator.Emit(OpCodes.Ldc_I4, value); + } break; } @@ -303,9 +331,13 @@ namespace Server default: if (index >= byte.MinValue && index <= byte.MinValue) + { Generator.Emit(OpCodes.Ldloc_S, (byte)index); + } else + { Generator.Emit(OpCodes.Ldloc, (short)index); + } break; } @@ -321,9 +353,13 @@ namespace Server public void LoadArgument(int index) { if (index > 0) + { Push(m_ArgumentTypes[index - 1]); + } else + { Push(Type); + } switch (index) { @@ -345,9 +381,13 @@ namespace Server default: if (index >= byte.MinValue && index <= byte.MaxValue) + { Generator.Emit(OpCodes.Ldarg_S, (byte)index); + } else + { Generator.Emit(OpCodes.Ldarg, (short)index); + } break; } @@ -403,7 +443,9 @@ namespace Server public void Chain(Property prop) { for (var i = 0; i < prop.Chain.Length; ++i) + { Call(prop.Chain[i].GetGetMethod()); + } } public void Call(MethodInfo method) @@ -413,7 +455,9 @@ namespace Server var call = m_Calls.Peek(); if (call.parms.Length > 0) + { throw new InvalidOperationException("Method requires parameters."); + } FinishCall(); } @@ -465,12 +509,16 @@ namespace Server ifaces = active.FindInterfaces((type, obj) => type == typeof(IComparable), null); if (ifaces.Length > 0) + { compareTo = ifaces[0].GetMethod("CompareTo", new[] { active }); + } } } if (compareTo == null) + { return false; + } if (!active.IsValueType) { @@ -559,7 +607,9 @@ namespace Server FinishCall(); if (sign == -1) + { Neg(); + } } } @@ -579,7 +629,9 @@ namespace Server FinishCall(); if (sign == -1) + { Neg(); + } } return true; @@ -607,21 +659,33 @@ namespace Server var call = m_Calls.Pop(); if ((call.type.IsValueType || call.type.IsByRef) && call.method.DeclaringType != call.type) + { Generator.Emit(OpCodes.Constrained, call.type); + } if (call.method.DeclaringType?.IsValueType == true || call.method.IsStatic) + { Generator.Emit(OpCodes.Call, call.method); + } else + { Generator.Emit(OpCodes.Callvirt, call.method); + } for (var i = call.parms.Length - 1; i >= 0; --i) + { Pop(call.parms[i].ParameterType); + } if ((call.method.CallingConvention & CallingConventions.HasThis) != 0) + { Pop(call.method.DeclaringType); + } if (call.method.ReturnType != typeof(void)) + { Push(call.method.ReturnType); + } } public void ArgumentPushed() @@ -633,10 +697,14 @@ namespace Server var argumentType = m_Stack.Peek(); if (!parm.ParameterType.IsAssignableFrom(argumentType)) + { throw new InvalidOperationException("Parameter type mismatch."); + } if (argumentType.IsValueType && !parm.ParameterType.IsValueType) + { Generator.Emit(OpCodes.Box, argumentType); + } } private class CallInfo diff --git a/Projects/UOContent/Misc/Fastwalk.cs b/Projects/UOContent/Misc/Fastwalk.cs index 6d2236d1b..38de130b3 100644 --- a/Projects/UOContent/Misc/Fastwalk.cs +++ b/Projects/UOContent/Misc/Fastwalk.cs @@ -21,7 +21,9 @@ namespace Server.Misc Mobile.FwdAccessOverride = AccessOverride; if (Enabled) + { EventSink.FastWalk += OnFastWalk; + } } public static void OnFastWalk(FastWalkEventArgs e) diff --git a/Projects/UOContent/Misc/FoodDecay.cs b/Projects/UOContent/Misc/FoodDecay.cs index 76ece4c53..770666802 100644 --- a/Projects/UOContent/Misc/FoodDecay.cs +++ b/Projects/UOContent/Misc/FoodDecay.cs @@ -30,13 +30,17 @@ namespace Server.Misc public static void HungerDecay(Mobile m) { if (m?.Hunger >= 1) + { m.Hunger -= 1; + } } public static void ThirstDecay(Mobile m) { if (m?.Thirst >= 1) + { m.Thirst -= 1; + } } } } diff --git a/Projects/UOContent/Misc/Geometry.cs b/Projects/UOContent/Misc/Geometry.cs index 9a9fb48e5..a99e52f0a 100644 --- a/Projects/UOContent/Misc/Geometry.cs +++ b/Projects/UOContent/Misc/Geometry.cs @@ -37,13 +37,19 @@ namespace Server.Misc public static void Circle2D(Point3D loc, Map map, int radius, DoEffect_Callback effect, int angleStart, int angleEnd) { if (angleStart < 0 || angleStart > 360) + { angleStart = 0; + } if (angleEnd > 360 || angleEnd < 0) + { angleEnd = 360; + } if (angleStart == angleEnd) + { return; + } var opposite = angleStart > angleEnd; @@ -95,22 +101,36 @@ namespace Server.Misc var quadrant = 2; if (x == 0 && start.Quadrant == 3) + { quadrant = 3; + } if (WithinCircleBounds(quadrant == 3 ? pointB : pointA, quadrant, loc, start, end, opposite)) + { effect(new Point3D(loc.X + x, loc.Y + y, loc.Z), map); + } quadrant = 3; if (y == 0 && start.Quadrant == 0) + { quadrant = 0; + } if (x != 0 && WithinCircleBounds(quadrant == 0 ? pointA : pointB, quadrant, loc, start, end, opposite)) + { effect(new Point3D(loc.X - x, loc.Y + y, loc.Z), map); + } + if (y != 0 && WithinCircleBounds(pointB, 1, loc, start, end, opposite)) + { effect(new Point3D(loc.X + x, loc.Y - y, loc.Z), map); + } + if (x != 0 && y != 0 && WithinCircleBounds(pointA, 0, loc, start, end, opposite)) + { effect(new Point3D(loc.X - x, loc.Y - y, loc.Z), map); + } } public static bool WithinCircleBounds( @@ -119,7 +139,9 @@ namespace Server.Misc ) { if (start.Angle == 0 && end.Angle == 360) + { return true; + } var startX = start.Point.X; var startY = start.Point.Y; @@ -130,21 +152,31 @@ namespace Server.Misc var y = pointLoc.Y; if (pointQuadrant < start.Quadrant || pointQuadrant > end.Quadrant) + { return opposite; + } if (pointQuadrant > start.Quadrant && pointQuadrant < end.Quadrant) + { return !opposite; + } var withinBounds = true; if (start.Quadrant == end.Quadrant) { if (startX == endX && (x > startX || y > startY || y < endY)) + { withinBounds = false; + } else if (startY == endY && (y < startY || x < startX || x > endX)) + { withinBounds = false; + } else if (x < startX || x > endX || y > startY || y < endY) + { withinBounds = false; + } } else if (pointQuadrant == start.Quadrant && (x < startX || y > startY)) { @@ -188,9 +220,13 @@ namespace Server.Misc for (var x = x0; x <= x1; x++) { if (steep) + { effect(new Point3D(y, x, start.Z), map); + } else + { effect(new Point3D(x, y, start.Z), map); + } error -= deltay; diff --git a/Projects/UOContent/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs b/Projects/UOContent/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs index e5e636c8b..8103c7c00 100644 --- a/Projects/UOContent/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs +++ b/Projects/UOContent/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs @@ -87,7 +87,9 @@ namespace Server.Items } if (Dipper != null) + { Dipper = string.Intern(Dipper); + } } } } diff --git a/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs b/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs index e86f7c792..af4b98894 100644 --- a/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs +++ b/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs @@ -26,10 +26,15 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { if (!map.CanFit(p.X, p.Y, p.Z, ItemData.Height)) + { return false; + } if (ItemID == 0x2375) + { return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // North wall + } + return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // West wall } @@ -38,7 +43,9 @@ namespace Server.Items public virtual bool Dye(Mobile from, DyeTub sender) { if (Deleted) + { return false; + } var house = BaseHouse.FindHouseAt(this); @@ -76,7 +83,9 @@ namespace Server.Items private void FixMovingCrate() { if (Deleted) + { return; + } if (Movable || IsLockedDown) { @@ -138,7 +147,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Addon.Deleted || info.ButtonID != 1) + { return; + } if (m_From.InRange(m_Addon.GetWorldLocation(), 3)) { @@ -223,7 +234,9 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted) { if (!(targeted is IPoint3D p)) + { return; + } var loc = new Point3D(p); @@ -235,9 +248,13 @@ namespace Server.Items var westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map); if (northWall && westWall) - from.SendGump(new MistletoeDeedGump(from, loc, this)); + { + @from.SendGump(new MistletoeDeedGump(@from, loc, this)); + } else - PlaceAddon(from, loc, northWall, westWall); + { + PlaceAddon(@from, loc, northWall, westWall); + } } else { @@ -248,7 +265,9 @@ namespace Server.Items private void PlaceAddon(Mobile from, Point3D loc, bool northWall, bool westWall) { if (Deleted) + { return; + } var house = BaseHouse.FindHouseAt(loc, from.Map, 16); @@ -261,11 +280,17 @@ namespace Server.Items var itemID = 0; if (northWall) + { itemID = 0x2374; + } else if (westWall) + { itemID = 0x2375; + } else - from.SendLocalizedMessage(1070883); // The mistletoe must be placed next to a wall. + { + @from.SendLocalizedMessage(1070883); // The mistletoe must be placed next to a wall. + } if (itemID > 0) { @@ -304,7 +329,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (m_Deed.Deleted) + { return; + } switch (info.ButtonID) { diff --git a/Projects/UOContent/Misc/Gifts/Winter2004/Winter2004.cs b/Projects/UOContent/Misc/Gifts/Winter2004/Winter2004.cs index 747b4e328..58886adee 100644 --- a/Projects/UOContent/Misc/Gifts/Winter2004/Winter2004.cs +++ b/Projects/UOContent/Misc/Gifts/Winter2004/Winter2004.cs @@ -24,11 +24,17 @@ namespace Server.Misc var random = Utility.Random(100); if (random < 60) + { box.DropItem(new DecorativeTopiary()); + } else if (random < 84) + { box.DropItem(new FestiveCactus()); + } else + { box.DropItem(new SnowyTree()); + } switch (GiveGift(mob, box)) { diff --git a/Projects/UOContent/Misc/HardwareInfo.cs b/Projects/UOContent/Misc/HardwareInfo.cs index 6438caa9f..abe79630f 100644 --- a/Projects/UOContent/Misc/HardwareInfo.cs +++ b/Projects/UOContent/Misc/HardwareInfo.cs @@ -111,18 +111,24 @@ namespace Server var hwInfo = acct.HardwareInfo; if (hwInfo != null) + { CommandLogging.WriteLine( - from, + @from, "{0} {1} viewing hardware info of {2}", - from.AccessLevel, - CommandLogging.Format(from), + @from.AccessLevel, + CommandLogging.Format(@from), CommandLogging.Format(m) ); + } if (hwInfo != null) - from.SendGump(new PropertiesGump(from, hwInfo)); + { + @from.SendGump(new PropertiesGump(@from, hwInfo)); + } else - from.SendMessage("No hardware information for that account was found."); + { + @from.SendMessage("No hardware information for that account was found."); + } } else { @@ -171,7 +177,9 @@ namespace Server info.TimeReceived = DateTime.UtcNow; if (state.Account is Account acct) + { acct.HardwareInfo = info; + } } } } diff --git a/Projects/UOContent/Misc/HexStringConverter.cs b/Projects/UOContent/Misc/HexStringConverter.cs index fc388ec06..7715ea0f8 100644 --- a/Projects/UOContent/Misc/HexStringConverter.cs +++ b/Projects/UOContent/Misc/HexStringConverter.cs @@ -13,9 +13,13 @@ namespace Server.Misc { var s = i.ToString("X2"); if (BitConverter.IsLittleEndian) + { result[i] = s[0] + ((uint)s[1] << 16); + } else + { result[i] = s[1] + ((uint)s[0] << 16); + } } return result; @@ -28,7 +32,9 @@ namespace Server.Misc { var resultP2 = (uint*)resultP; for (var i = 0; i < bytes.Length; i++) + { resultP2[i] = m_Lookup32Chars[bytes[i]]; + } } return result; @@ -45,9 +51,13 @@ namespace Server.Misc int chr1 = strP[i++]; int chr2 = strP[i++]; if (BitConverter.IsLittleEndian) + { bytes[j++] = (byte)(((chr1 - (chr1 >= 65 ? 55 : 48)) << 4) | (chr2 - (chr2 >= 65 ? 55 : 48))); + } else + { bytes[j++] = (byte)((chr1 - (chr1 >= 65 ? 55 : 48)) | ((chr2 - (chr2 >= 65 ? 55 : 48)) << 4)); + } } } } diff --git a/Projects/UOContent/Misc/Keywords.cs b/Projects/UOContent/Misc/Keywords.cs index 2ed875112..6770fc981 100644 --- a/Projects/UOContent/Misc/Keywords.cs +++ b/Projects/UOContent/Misc/Keywords.cs @@ -18,11 +18,12 @@ namespace Server.Misc var keywords = args.Keywords; for (var i = 0; i < keywords.Length; ++i) + { switch (keywords[i]) { case 0x002A: // *i resign from my guild* { - ((Guild)from.Guild)?.RemoveMember(from); + ((Guild)@from.Guild)?.RemoveMember(@from); break; } @@ -30,16 +31,16 @@ namespace Server.Misc { if (!Core.SE) { - from.SendMessage("Short Term Murders : {0}", from.ShortTermMurders); - from.SendMessage("Long Term Murders : {0}", from.Kills); + @from.SendMessage("Short Term Murders : {0}", @from.ShortTermMurders); + @from.SendMessage("Long Term Murders : {0}", @from.Kills); } else { - from.SendMessage( + @from.SendMessage( 0x3B2, "Short Term Murders: {0} Long Term Murders: {1}", - from.ShortTermMurders, - from.Kills + @from.ShortTermMurders, + @from.Kills ); } @@ -47,12 +48,15 @@ namespace Server.Misc } case 0x0035: // i renounce my young player status* { - if (from is PlayerMobile mobile && mobile.Young && !mobile.HasGump()) + if (@from is PlayerMobile mobile && mobile.Young && !mobile.HasGump()) + { mobile.SendGump(new RenounceYoungGump()); + } break; } } + } } } } diff --git a/Projects/UOContent/Misc/LanguageStatistics.cs b/Projects/UOContent/Misc/LanguageStatistics.cs index 4a9889f59..a1c275a42 100644 --- a/Projects/UOContent/Misc/LanguageStatistics.cs +++ b/Projects/UOContent/Misc/LanguageStatistics.cs @@ -167,11 +167,17 @@ namespace Server.Misc private static string GetFormattedInfo(string code) { if (code == null || code.Length != 3) - return $"Unknown code {code}"; + { + return $"Unknown code {code}"; + } for (var i = 0; i < InternationalCodes.Length; i++) - if (code == InternationalCodes[i].Code) - return $"{InternationalCodes[i].GetName()}"; + { + if (code == InternationalCodes[i].Code) + { + return $"{InternationalCodes[i].GetName()}"; + } + } return $"Unknown code {code}"; } @@ -189,41 +195,61 @@ namespace Server.Misc using var writer = new StreamWriter("languages.txt"); if (CountAccounts) - foreach (Account acc in Accounts.GetAccounts()) - for (var i = 0; i < acc.Length; i++) + { + foreach (Account acc in Accounts.GetAccounts()) { - var mob = acc[i]; + for (var i = 0; i < acc.Length; i++) + { + var mob = acc[i]; - var lang = mob?.Language; + var lang = mob?.Language; - if (lang == null) - continue; + if (lang == null) + { + continue; + } - lang = lang.ToUpper(); + lang = lang.ToUpper(); - if (ht.TryGetValue(lang, out var codes)) - codes.Increase(); - else - ht[lang] = new InternationalCodeCounter(lang); + if (ht.TryGetValue(lang, out var codes)) + { + codes.Increase(); + } + else + { + ht[lang] = new InternationalCodeCounter(lang); + } - break; + break; + } } + } else - foreach (var mob in World.Mobiles.Values) - if (mob.Player) + { + foreach (var mob in World.Mobiles.Values) { - var lang = mob.Language; + if (mob.Player) + { + var lang = mob.Language; - if (lang == null) - continue; + if (lang == null) + { + continue; + } - lang = lang.ToUpper(); + lang = lang.ToUpper(); - if (ht.TryGetValue(lang, out var codes)) - codes.Increase(); - else - ht[lang] = new InternationalCodeCounter(lang); + if (ht.TryGetValue(lang, out var codes)) + { + codes.Increase(); + } + else + { + ht[lang] = new InternationalCodeCounter(lang); + } + } } + } writer.WriteLine( $"Language statistics. Numbers show how many {(CountAccounts ? "accounts" : "playermobile")} use the specified language."); @@ -236,7 +262,9 @@ namespace Server.Misc list.Sort(InternationalCodeComparer.Instance); foreach (var c in list) - writer.WriteLine($"{GetFormattedInfo(c.Code)}‎ : {c.Count}"); + { + writer.WriteLine($"{GetFormattedInfo(c.Code)}‎ : {c.Count}"); + } e.Mobile.SendMessage("Languages list generated."); } @@ -280,8 +308,10 @@ namespace Server.Misc $"{(DefaultLocalNames ? Language_LocalName : Language)}‎ - {(DefaultLocalNames ? Country_LocalName : Country)}"; if (ShowAlternatives) - s += - $"‎ 【{(DefaultLocalNames ? Language : Language_LocalName)}‎ - {(DefaultLocalNames ? Country : Country_LocalName)}‎】"; + { + s += + $"‎ 【{(DefaultLocalNames ? Language : Language_LocalName)}‎ - {(DefaultLocalNames ? Country : Country_LocalName)}‎】"; + } } else { @@ -325,19 +355,29 @@ namespace Server.Misc cb = y.Count; if (ca > cb) - return -1; + { + return -1; + } if (ca < cb) - return 1; + { + return 1; + } if (a == null && b == null) - return 0; + { + return 0; + } if (a == null) - return 1; + { + return 1; + } if (b == null) - return -1; + { + return -1; + } return a.CompareTo(b); } diff --git a/Projects/UOContent/Misc/LightCycle.cs b/Projects/UOContent/Misc/LightCycle.cs index bd5443902..2e796f02f 100644 --- a/Projects/UOContent/Misc/LightCycle.cs +++ b/Projects/UOContent/Misc/LightCycle.cs @@ -62,7 +62,9 @@ namespace Server public static int ComputeLevelFor(Mobile from) { if (m_LevelOverride > int.MinValue) + { return m_LevelOverride; + } Clock.GetTime(from.Map, from.X, from.Y, out var hours, out int minutes); @@ -80,16 +82,24 @@ namespace Server */ if (hours < 4) + { return NightLevel; + } if (hours < 6) + { return NightLevel + ((hours - 4) * 60 + minutes) * (DayLevel - NightLevel) / 120; + } if (hours < 22) + { return DayLevel; + } if (hours < 24) + { return DayLevel + ((hours - 22) * 60 + minutes) * (NightLevel - DayLevel) / 120; + } return NightLevel; // should never be } diff --git a/Projects/UOContent/Misc/Loot.cs b/Projects/UOContent/Misc/Loot.cs index e32f7f325..bc2a6e734 100644 --- a/Projects/UOContent/Misc/Loot.cs +++ b/Projects/UOContent/Misc/Loot.cs @@ -335,9 +335,15 @@ namespace Server public static BaseWand RandomWand() { if (Core.ML) + { return Construct(NewWandTypes) as BaseWand; + } + if (Core.AOS) + { return Construct(WandTypes, NewWandTypes) as BaseWand; + } + return Construct(OldWandTypes, WandTypes, NewWandTypes) as BaseWand; } @@ -346,13 +352,19 @@ namespace Server public static BaseClothing RandomClothing(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLClothingTypes, AosClothingTypes, ClothingTypes) as BaseClothing; + } if (Core.SE && inTokuno) + { return Construct(SEClothingTypes, AosClothingTypes, ClothingTypes) as BaseClothing; + } if (Core.AOS) + { return Construct(AosClothingTypes, ClothingTypes) as BaseClothing; + } return Construct(ClothingTypes) as BaseClothing; } @@ -362,13 +374,19 @@ namespace Server public static BaseWeapon RandomRangedWeapon(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLRangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes) as BaseWeapon; + } if (Core.SE && inTokuno) + { return Construct(SERangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes) as BaseWeapon; + } if (Core.AOS) + { return Construct(AosRangedWeaponTypes, RangedWeaponTypes) as BaseWeapon; + } return Construct(RangedWeaponTypes) as BaseWeapon; } @@ -378,13 +396,19 @@ namespace Server public static BaseWeapon RandomWeapon(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLWeaponTypes, AosWeaponTypes, WeaponTypes) as BaseWeapon; + } if (Core.SE && inTokuno) + { return Construct(SEWeaponTypes, AosWeaponTypes, WeaponTypes) as BaseWeapon; + } if (Core.AOS) + { return Construct(AosWeaponTypes, WeaponTypes) as BaseWeapon; + } return Construct(WeaponTypes) as BaseWeapon; } @@ -394,13 +418,19 @@ namespace Server public static Item RandomWeaponOrJewelry(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLWeaponTypes, AosWeaponTypes, WeaponTypes, JewelryTypes); + } if (Core.SE && inTokuno) + { return Construct(SEWeaponTypes, AosWeaponTypes, WeaponTypes, JewelryTypes); + } if (Core.AOS) + { return Construct(AosWeaponTypes, WeaponTypes, JewelryTypes); + } return Construct(WeaponTypes, JewelryTypes); } @@ -412,10 +442,14 @@ namespace Server public static BaseArmor RandomArmor(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLArmorTypes, ArmorTypes) as BaseArmor; + } if (Core.SE && inTokuno) + { return Construct(SEArmorTypes, ArmorTypes) as BaseArmor; + } return Construct(ArmorTypes) as BaseArmor; } @@ -425,10 +459,14 @@ namespace Server public static BaseHat RandomHat(bool inTokuno) { if (Core.SE && inTokuno) + { return Construct(SEHatTypes, AosHatTypes, HatTypes) as BaseHat; + } if (Core.AOS) + { return Construct(AosHatTypes, HatTypes) as BaseHat; + } return Construct(HatTypes) as BaseHat; } @@ -438,13 +476,19 @@ namespace Server public static Item RandomArmorOrHat(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes); + } if (Core.SE && inTokuno) + { return Construct(SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes); + } if (Core.AOS) + { return Construct(ArmorTypes, AosHatTypes, HatTypes); + } return Construct(ArmorTypes, HatTypes); } @@ -452,7 +496,9 @@ namespace Server public static BaseShield RandomShield() { if (Core.AOS) + { return Construct(AosShieldTypes, ShieldTypes) as BaseShield; + } return Construct(ShieldTypes) as BaseShield; } @@ -462,13 +508,19 @@ namespace Server public static BaseArmor RandomArmorOrShield(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLArmorTypes, ArmorTypes, AosShieldTypes, ShieldTypes) as BaseArmor; + } if (Core.SE && inTokuno) + { return Construct(SEArmorTypes, ArmorTypes, AosShieldTypes, ShieldTypes) as BaseArmor; + } if (Core.AOS) + { return Construct(ArmorTypes, AosShieldTypes, ShieldTypes) as BaseArmor; + } return Construct(ArmorTypes, ShieldTypes) as BaseArmor; } @@ -478,9 +530,12 @@ namespace Server public static Item RandomArmorOrShieldOrJewelry(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct(MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes); + } if (Core.SE && inTokuno) + { return Construct( SEArmorTypes, ArmorTypes, @@ -491,9 +546,12 @@ namespace Server ShieldTypes, JewelryTypes ); + } if (Core.AOS) + { return Construct(ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes); + } return Construct(ArmorTypes, HatTypes, ShieldTypes, JewelryTypes); } @@ -503,6 +561,7 @@ namespace Server public static Item RandomArmorOrShieldOrWeapon(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct( MLWeaponTypes, AosWeaponTypes, @@ -517,8 +576,10 @@ namespace Server AosShieldTypes, ShieldTypes ); + } if (Core.SE && inTokuno) + { return Construct( SEWeaponTypes, AosWeaponTypes, @@ -534,8 +595,10 @@ namespace Server AosShieldTypes, ShieldTypes ); + } if (Core.AOS) + { return Construct( AosWeaponTypes, WeaponTypes, @@ -547,6 +610,7 @@ namespace Server AosShieldTypes, ShieldTypes ); + } return Construct(WeaponTypes, RangedWeaponTypes, ArmorTypes, HatTypes, ShieldTypes); } @@ -556,6 +620,7 @@ namespace Server public static Item RandomArmorOrShieldOrWeaponOrJewelry(bool inTokuno, bool isMondain) { if (Core.ML && isMondain) + { return Construct( MLWeaponTypes, AosWeaponTypes, @@ -571,8 +636,10 @@ namespace Server ShieldTypes, JewelryTypes ); + } if (Core.SE && inTokuno) + { return Construct( SEWeaponTypes, AosWeaponTypes, @@ -589,8 +656,10 @@ namespace Server ShieldTypes, JewelryTypes ); + } if (Core.AOS) + { return Construct( AosWeaponTypes, WeaponTypes, @@ -603,6 +672,7 @@ namespace Server ShieldTypes, JewelryTypes ); + } return Construct(WeaponTypes, RangedWeaponTypes, ArmorTypes, HatTypes, ShieldTypes, JewelryTypes); } @@ -628,7 +698,9 @@ namespace Server public static BaseInstrument RandomInstrument() { if (Core.SE) + { return Construct(InstrumentTypes, SEInstrumentTypes) as BaseInstrument; + } return Construct(InstrumentTypes) as BaseInstrument; } @@ -678,9 +750,13 @@ namespace Server talisman.MaxCharges = Utility.RandomMinMax(10, 50); if (talisman.Summoner.IsItem) + { talisman.MaxChargeTime = 60; + } else + { talisman.MaxChargeTime = 1800; + } } talisman.Blessed = BaseTalisman.GetRandomBlessed(); @@ -697,7 +773,10 @@ namespace Server public static Item Construct(Type type) { - if (type == null) return null; + if (type == null) + { + return null; + } try { @@ -714,7 +793,9 @@ namespace Server public static Item Construct(Type[] types, int index) { if (index >= 0 && index < types.Length) + { return Construct(types[index]); + } return null; } @@ -724,7 +805,9 @@ namespace Server var totalLength = 0; for (var i = 0; i < types.Length; ++i) + { totalLength += types[i].Length; + } if (totalLength > 0) { @@ -733,7 +816,9 @@ namespace Server for (var i = 0; i < types.Length; ++i) { if (index >= 0 && index < types[i].Length) + { return Construct(types[i][index]); + } index -= types[i].Length; } diff --git a/Projects/UOContent/Misc/LootPack.cs b/Projects/UOContent/Misc/LootPack.cs index be72eae9b..bb0f45fa5 100644 --- a/Projects/UOContent/Misc/LootPack.cs +++ b/Projects/UOContent/Misc/LootPack.cs @@ -98,19 +98,27 @@ namespace Server public static int GetLuckChance(Mobile killer, Mobile victim) { if (!Core.AOS) + { return 0; + } var luck = killer.Luck; if (killer is PlayerMobile pmKiller && pmKiller.SentHonorContext != null && pmKiller.SentHonorContext.Target == victim) + { luck += pmKiller.SentHonorContext.PerfectionLuckBonus; + } if (luck < 0) + { return 0; + } if (!Core.SE && luck > 1200) + { luck = 1200; + } return (int)(Math.Pow(luck, 1 / 1.8) * 100); } @@ -126,11 +134,15 @@ namespace Server var ds = list[i]; if (ds.m_HasRight && (highest == null || ds.m_Damage > highest.m_Damage)) + { highest = ds; + } } if (highest == null) + { return 0; + } return GetLuckChance(highest.m_Mobile, dead); } @@ -140,7 +152,9 @@ namespace Server public void Generate(Mobile from, Container cont, bool spawning, int luckChance) { if (cont == null) + { return; + } var checkLuck = Core.AOS; @@ -155,17 +169,25 @@ namespace Server checkLuck = false; if (CheckLuck(luckChance)) + { shouldAdd = entry.Chance > Utility.Random(10000); + } } if (!shouldAdd) + { continue; + } var item = entry.Construct(from, luckChance, spawning); if (item != null) - if (!item.Stackable || !cont.TryDropItem(from, item, false)) + { + if (!item.Stackable || !cont.TryDropItem(@from, item, false)) + { cont.DropItem(item); + } + } } } @@ -639,10 +661,14 @@ namespace Server private static bool IsInTokuno(Mobile m) { if (m.Region.IsPartOf("Fan Dancer's Dojo")) + { return true; + } if (m.Region.IsPartOf("Yomotsu Mines")) + { return true; + } return m.Map == Map.Tokuno; } @@ -652,12 +678,16 @@ namespace Server public Item Construct(Mobile from, int luckChance, bool spawning) { if (m_AtSpawnTime != spawning) + { return null; + } var totalChance = 0; for (var i = 0; i < Items.Length; ++i) + { totalChance += Items[i].Chance; + } var rnd = Utility.Random(totalChance); @@ -666,7 +696,9 @@ namespace Server var item = Items[i]; if (rnd < item.Chance) - return Mutate(from, luckChance, item.Construct(IsInTokuno(from), IsMondain(from))); + { + return Mutate(@from, luckChance, item.Construct(IsInTokuno(@from), IsMondain(@from))); + } rnd -= item.Chance; } @@ -679,19 +711,30 @@ namespace Server var rnd = Utility.RandomMinMax(MinIntensity, MaxIntensity); if (rnd < 50) + { return 1; + } + rnd -= 50; if (rnd < 25) + { return 2; + } + rnd -= 25; if (rnd < 14) + { return 3; + } + rnd -= 14; if (rnd < 8) + { return 4; + } return 5; } @@ -716,21 +759,32 @@ namespace Server var max = MaxIntensity; if (bonusProps < MaxProps && LootPack.CheckLuck(luckChance)) + { ++bonusProps; + } var props = 1 + bonusProps; // Make sure we're not spawning items with 6 properties. if (props > MaxProps) + { props = MaxProps; + } if (item is BaseWeapon weapon) + { BaseRunicTool.ApplyAttributesTo(weapon, false, luckChance, props, MinIntensity, MaxIntensity); + } else if (item is BaseArmor armor) + { BaseRunicTool.ApplyAttributesTo(armor, false, luckChance, props, MinIntensity, MaxIntensity); + } else if (item is BaseJewel jewel) + { BaseRunicTool.ApplyAttributesTo(jewel, false, luckChance, props, MinIntensity, MaxIntensity); + } else + { BaseRunicTool.ApplyAttributesTo( (BaseHat)item, false, @@ -739,34 +793,49 @@ namespace Server MinIntensity, MaxIntensity ); + } } else // not aos { if (item is BaseWeapon weapon) { if (Utility.Random(100) < 80) + { weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus(); + } if (Utility.Random(100) < 60) + { weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus(); + } if (Utility.Random(100) < 40) + { weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus(); + } if (Utility.Random(100) < 5) + { weapon.Slayer = SlayerName.Silver; + } if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && Utility.Random(100) < 5) - weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType()); + { + weapon.Slayer = SlayerGroup.GetLootSlayerType(@from.GetType()); + } } else if (item is BaseArmor armor) { if (Utility.Random(100) < 80) + { armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus(); + } if (Utility.Random(100) < 40) + { armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus(); + } } } } @@ -775,9 +844,13 @@ namespace Server var slayer = SlayerName.None; if (Core.AOS) + { slayer = BaseRunicTool.GetRandomSlayer(); + } else - slayer = SlayerGroup.GetLootSlayerType(from.GetType()); + { + slayer = SlayerGroup.GetLootSlayerType(@from.GetType()); + } if (slayer == SlayerName.None) { @@ -790,7 +863,9 @@ namespace Server } if (item.Stackable) + { item.Amount = Quantity.Roll(); + } } return item; @@ -839,22 +914,30 @@ namespace Server var rnd = Utility.Random(pc); if (rnd < p5) + { return 5; + } rnd -= p5; if (rnd < p4) + { return 4; + } rnd -= p4; if (rnd < p3) + { return 3; + } rnd -= p3; if (rnd < p2) + { return 2; + } return rnd - p2 < p1 ? 1 : 0; } @@ -906,20 +989,31 @@ namespace Server var scrollCount = (maxCircle - minCircle + 1) * 8; if (index == 0) + { scrollCount += m_BlankTypes.Length; + } if (Core.AOS) + { scrollCount += m_NecroTypes[index].Length; + } var rnd = Utility.Random(scrollCount); if (index == 0 && rnd < m_BlankTypes.Length) + { return Loot.Construct(m_BlankTypes); + } + if (index == 0) + { rnd -= m_BlankTypes.Length; + } if (Core.AOS && rnd < m_NecroTypes.Length) + { return Loot.Construct(m_NecroTypes[index]); + } return Loot.RandomScroll(minCircle * 8, maxCircle * 8 + 7, SpellbookType.Regular); } @@ -931,27 +1025,49 @@ namespace Server Item item; if (Type == typeof(BaseRanged)) + { item = Loot.RandomRangedWeapon(inTokuno, isMondain); + } else if (Type == typeof(BaseWeapon)) + { item = Loot.RandomWeapon(inTokuno, isMondain); + } else if (Type == typeof(BaseArmor)) + { item = Loot.RandomArmorOrHat(inTokuno, isMondain); + } else if (Type == typeof(BaseShield)) + { item = Loot.RandomShield(); + } else if (Type == typeof(BaseJewel)) + { item = Core.AOS ? Loot.RandomJewelry() : Loot.RandomArmorOrShieldOrWeapon(); + } else if (Type == typeof(BaseInstrument)) + { item = Loot.RandomInstrument(); + } else if (Type == typeof(Amber)) // gem + { item = Loot.RandomGem(); + } else if (Type == typeof(ClumsyScroll)) // low scroll + { item = RandomScroll(0, 1, 3); + } else if (Type == typeof(ArchCureScroll)) // med scroll + { item = RandomScroll(1, 4, 7); + } else if (Type == typeof(SummonAirElementalScroll)) // high scroll + { item = RandomScroll(2, 8, 8); + } else + { item = ActivatorUtil.CreateInstance(Type) as Item; + } return item; } @@ -972,7 +1088,9 @@ namespace Server var index = str.IndexOf('d', start); if (index < start) + { return; + } Count = Utility.ToInt32(str.Substring(start, index - start)); @@ -982,15 +1100,21 @@ namespace Server var negative = index < start; if (negative) + { index = str.IndexOf('-', start); + } if (index < start) + { index = str.Length; + } Sides = Utility.ToInt32(str.Substring(start, index - start)); if (index == str.Length) + { return; + } start = index + 1; index = str.Length; @@ -998,7 +1122,9 @@ namespace Server Bonus = Utility.ToInt32(str.Substring(start, index - start)); if (negative) + { Bonus *= -1; + } } public LootPackDice(int count, int sides, int bonus) @@ -1019,7 +1145,9 @@ namespace Server var v = Bonus; for (var i = 0; i < Count; ++i) + { v += Utility.Random(1, Sides); + } return v; } diff --git a/Projects/UOContent/Misc/MapUO.cs b/Projects/UOContent/Misc/MapUO.cs index d471135dc..68f6d5bb7 100644 --- a/Projects/UOContent/Misc/MapUO.cs +++ b/Projects/UOContent/Misc/MapUO.cs @@ -10,10 +10,14 @@ namespace Server.Misc public static void Initialize() { if (Settings.PartyTrack) + { ProtocolExtensions.Register(0x00, true, OnPartyTrack); + } if (Settings.GuildTrack) + { ProtocolExtensions.Register(0x01, true, OnGuildTrack); + } } private static void OnPartyTrack(NetState state, PacketReader pvSrc) @@ -26,7 +30,9 @@ namespace Server.Misc var packet = new Packets.PartyTrack(from, party); if (packet.Stream.Length > 8) + { state.Send(packet); + } } } @@ -41,7 +47,9 @@ namespace Server.Misc var packet = new Packets.GuildTrack(from, guild, locations); if (packet.Stream.Length > (locations ? 9 : 5)) + { state.Send(packet); + } } else { @@ -67,12 +75,16 @@ namespace Server.Misc var pmi = party.Members[i]; if (pmi == null || pmi.Mobile == from) + { continue; + } var mob = pmi.Mobile; if (Utility.InUpdateRange(from, mob) && from.CanSee(mob)) + { continue; + } Stream.Write(mob.Serial); Stream.Write((short)mob.X); @@ -104,10 +116,14 @@ namespace Server.Misc var mob = guild.Members[i]; if (mob == null || mob == from || mob.NetState == null) + { continue; + } if (locations && Utility.InUpdateRange(from, mob) && from.CanSee(mob)) + { continue; + } Stream.Write(mob.Serial); @@ -118,9 +134,13 @@ namespace Server.Misc Stream.Write((byte)(mob.Map?.MapID ?? 0)); if (Settings.GuildHitsPercent && mob.Alive) + { Stream.Write((byte)(mob.Hits / Math.Max(mob.HitsMax, 1.0) * 100)); + } else + { Stream.Write((byte)0); + } } } diff --git a/Projects/UOContent/Misc/MondainsLegacy.cs b/Projects/UOContent/Misc/MondainsLegacy.cs index a05b6a1b5..3c097f2f3 100644 --- a/Projects/UOContent/Misc/MondainsLegacy.cs +++ b/Projects/UOContent/Misc/MondainsLegacy.cs @@ -20,7 +20,9 @@ namespace Server public static bool CheckArtifactChance(Mobile m, BaseCreature bc) { if (!Core.ML) + { return false; + } return Paragon.CheckArtifactChance(m, bc); } @@ -28,7 +30,9 @@ namespace Server public static void GiveArtifactTo(Mobile m) { if (!(ActivatorUtil.CreateInstance(Artifacts.RandomElement()) is Item item)) + { return; + } if (m.AddToBackpack(item)) { @@ -54,13 +58,19 @@ namespace Server public static bool CheckML(Mobile from, bool message = true) { if (from?.NetState == null) + { return false; + } if (from.NetState.SupportsExpansion(Expansion.ML)) + { return true; + } if (message) - from.SendLocalizedMessage(1072791); // You must upgrade to Mondain's Legacy in order to use that item. + { + @from.SendLocalizedMessage(1072791); // You must upgrade to Mondain's Legacy in order to use that item. + } return false; } diff --git a/Projects/UOContent/Misc/NameList.cs b/Projects/UOContent/Misc/NameList.cs index c5ac07925..81d3e8217 100644 --- a/Projects/UOContent/Misc/NameList.cs +++ b/Projects/UOContent/Misc/NameList.cs @@ -18,8 +18,12 @@ namespace Server public bool ContainsName(string name) { for (var i = 0; i < List.Length; i++) + { if (name == List[i]) + { return true; + } + } return false; } @@ -50,7 +54,9 @@ namespace Server private void FixNames() { for (var i = 0; i < List.Length; i++) + { List[i] = Utility.Intern(List[i].Trim()); + } } } } diff --git a/Projects/UOContent/Misc/NameVerification.cs b/Projects/UOContent/Misc/NameVerification.cs index ca6d278cc..e942620b8 100644 --- a/Projects/UOContent/Misc/NameVerification.cs +++ b/Projects/UOContent/Misc/NameVerification.cs @@ -110,9 +110,13 @@ namespace Server.Misc public static void ValidateName_OnCommand(CommandEventArgs e) { if (Validate(e.ArgString, 2, 16, true, false, true, 1, SpaceDashPeriodQuote)) + { e.Mobile.SendMessage(0x59, "That name is considered valid."); + } else + { e.Mobile.SendMessage(0x22, "That name is considered invalid."); + } } public static bool Validate( @@ -138,7 +142,9 @@ namespace Server.Misc ) { if (name == null || name.Length < minLength || name.Length > maxLength) + { return false; + } var exceptCount = 0; @@ -146,6 +152,7 @@ namespace Server.Misc if (!allowLetters || !allowDigits || exceptions.Length > 0 && (noExceptionsAtStart || maxExceptions < int.MaxValue)) + { for (var i = 0; i < name.Length; ++i) { var c = name[i]; @@ -153,14 +160,18 @@ namespace Server.Misc if (c >= 'a' && c <= 'z') { if (!allowLetters) + { return false; + } exceptCount = 0; } else if (c >= '0' && c <= '9') { if (!allowDigits) + { return false; + } exceptCount = 0; } @@ -169,44 +180,67 @@ namespace Server.Misc var except = false; for (var j = 0; !except && j < exceptions.Length; ++j) + { if (c == exceptions[j]) + { except = true; + } + } if (!except || i == 0 && noExceptionsAtStart) + { return false; + } if (exceptCount++ == maxExceptions) + { return false; + } } } + } for (var i = 0; i < disallowed.Length; ++i) { var indexOf = name.IndexOf(disallowed[i]); if (indexOf == -1) + { continue; + } var badPrefix = indexOf == 0; for (var j = 0; !badPrefix && j < exceptions.Length; ++j) + { badPrefix = name[indexOf - 1] == exceptions[j]; + } if (!badPrefix) + { continue; + } var badSuffix = indexOf + disallowed[i].Length >= name.Length; for (var j = 0; !badSuffix && j < exceptions.Length; ++j) + { badSuffix = name[indexOf + disallowed[i].Length] == exceptions[j]; + } if (badSuffix) + { return false; + } } for (var i = 0; i < startDisallowed.Length; ++i) + { if (name.StartsWith(startDisallowed[i])) + { return false; + } + } return true; } diff --git a/Projects/UOContent/Misc/Notoriety.cs b/Projects/UOContent/Misc/Notoriety.cs index 4a5760641..2fb1b2447 100644 --- a/Projects/UOContent/Misc/Notoriety.cs +++ b/Projects/UOContent/Misc/Notoriety.cs @@ -33,9 +33,14 @@ namespace Server.Misc private static GuildStatus GetGuildStatus(Mobile m) { if (m.Guild == null) + { return GuildStatus.None; + } + if (((Guild)m.Guild).Enemies.Count == 0 && m.Guild.Type == GuildType.Regular) + { return GuildStatus.Peaceful; + } return GuildStatus.Waring; } @@ -43,7 +48,9 @@ namespace Server.Misc private static bool CheckBeneficialStatus(GuildStatus from, GuildStatus target) { if (from == GuildStatus.Waring || target == GuildStatus.Waring) + { return false; + } return true; } @@ -60,70 +67,104 @@ namespace Server.Misc { if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player) + { return true; + } var pmFrom = from as PlayerMobile; var pmTarg = target as PlayerMobile; if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned) + { pmFrom = bcFrom.SummonMaster as PlayerMobile; + } if (pmTarg == null && target is BaseCreature bcTarg && bcTarg.Summoned) + { pmTarg = bcTarg.SummonMaster as PlayerMobile; + } if (pmFrom != null && pmTarg != null) { if (pmFrom.DuelContext != pmTarg.DuelContext && (pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true)) + { return false; + } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && (pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated)) + { return false; + } if (pmFrom.DuelPlayer?.Eliminated == false && pmFrom.DuelContext?.IsSuddenDeath == true) + { return false; + } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant) + { return false; + } if (pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext) + { return true; + } } if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true) + { return false; + } if (from.Region.IsPartOf() || target.Region.IsPartOf()) + { return false; + } var map = from.Map; var targetFaction = Faction.Find(target, true); if ((!Core.ML || map == Faction.Facet) && targetFaction != null) - if (Faction.Find(from, true) != targetFaction) + { + if (Faction.Find(@from, true) != targetFaction) + { return false; + } + } if ((map?.Rules & MapRules.BeneficialRestrictions) == 0) + { return true; // In felucca, anything goes + } if (!from.Player) + { return true; // NPCs have no restrictions + } if (target is BaseCreature creature && !creature.Controlled) + { return false; // Players cannot heal uncontrolled mobiles + } if (pmFrom?.Young == true || pmTarg?.Young == true) + { return false; // Young players cannot perform beneficial actions towards older players + } if (from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && (targetGuild == fromGuild || fromGuild.IsAlly(targetGuild))) + { return true; // Guild members can be beneficial + } return CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target)); } @@ -132,56 +173,78 @@ namespace Server.Misc { if (from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player) + { return true; + } var pmFrom = from as PlayerMobile; var pmTarg = target as PlayerMobile; var bcTarg = target as BaseCreature; if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned) + { pmFrom = bcFrom.SummonMaster as PlayerMobile; + } if (pmTarg == null && bcTarg?.Summoned == true) + { pmTarg = bcTarg.SummonMaster as PlayerMobile; + } if (pmFrom != null && pmTarg != null) { if (pmFrom.DuelContext != pmTarg.DuelContext && (pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true)) + { return false; + } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && (pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated)) + { return false; + } if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant) + { return false; + } if (pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext) + { return true; + } } if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true) + { return false; + } if (from.Region.IsPartOf() || target.Region.IsPartOf()) + { return false; + } var map = from.Map; if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) + { return true; // In felucca, anything goes + } if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player)) { if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && pmTarg?.CheckYoungProtection(from) == true) + { return false; + } return true; // Uncontrolled NPCs are only restricted by the young system } @@ -191,13 +254,19 @@ namespace Server.Misc if (fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))) + { return true; // Guild allies or enemies can be harmful + } if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from) + { return false; // Cannot harm other controlled mobiles + } if (target.Player) + { return false; // Cannot harm other players + } return bcTarg?.InitialInnocent == true || Notoriety.Compute(from, target) != Notoriety.Innocent; } @@ -212,9 +281,13 @@ namespace Server.Misc if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder == OrderType.Attack || c.ControlOrder == OrderType.Guard)) + { g = (Guild)(c.Guild = c.ControlMaster.Guild); + } else if (c.Map == Map.Internal || c.ControlMaster.Guild == null) + { g = (Guild)(c.Guild = null); + } } return g; @@ -223,7 +296,9 @@ namespace Server.Misc public static int CorpseNotoriety(Mobile source, Corpse target) { if (target.AccessLevel > AccessLevel.Player) + { return Notoriety.CanBeAttacked; + } Body body = target.Amount; @@ -237,57 +312,92 @@ namespace Server.Misc if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) + { return Notoriety.Ally; + } + if (sourceGuild.IsEnemy(targetGuild)) + { return Notoriety.Enemy; + } } if (target.Owner is BaseCreature creature) { if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) + { return Notoriety.Enemy; + } if (CheckHouseFlag(source, creature, target.Location, target.Map)) + { return Notoriety.CanBeAttacked; + } var actual = Notoriety.CanBeAttacked; if (target.Kills >= 5 || body.IsMonster && IsSummoned(creature) || creature.AlwaysMurderer || creature.IsAnimatedDead) + { actual = Notoriety.Murderer; + } if (DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice) + { return actual; + } var sourceParty = Party.Get(source); for (var i = 0; i < list.Count; ++i) + { if (list[i] == source || sourceParty != null && Party.Get(list[i]) == sourceParty) + { return actual; + } + } return Notoriety.Innocent; } if (target.Kills >= 5 || body.IsMonster) + { return Notoriety.Murderer; + } if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0) + { return Notoriety.Criminal; + } if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) + { for (var i = 0; i < list.Count; ++i) + { if (list[i] == source || list[i] is BaseFactionGuard) + { return Notoriety.Enemy; + } + } + } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) + { return Notoriety.CanBeAttacked; + } if (!(target.Owner is PlayerMobile)) + { return Notoriety.CanBeAttacked; + } for (var i = 0; i < list.Count; ++i) + { if (list[i] == source) + { return Notoriety.CanBeAttacked; + } + } return Notoriety.Innocent; } @@ -299,25 +409,35 @@ namespace Server.Misc if (Core.AOS && (target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor || target is TownCrier)) + { return Notoriety.Invulnerable; + } var pmFrom = source as PlayerMobile; var pmTarg = target as PlayerMobile; if (pmFrom != null && pmTarg != null) + { if (pmFrom.DuelContext?.StartedBeginCountdown == true && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext) + { return pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy; + } + } if (target.AccessLevel > AccessLevel.Player) + { return Notoriety.CanBeAttacked; + } if (source.Player && !target.Player && pmFrom != null && bcTarg != null) { var master = bcTarg.GetMaster(); if (master?.AccessLevel > AccessLevel.Player) + { return Notoriety.CanBeAttacked; + } master = bcTarg.ControlMaster; @@ -325,22 +445,30 @@ namespace Server.Misc { if (source == master && CheckAggressor(bcTarg.Aggressors, source) || CheckAggressor(source.Aggressors, bcTarg)) + { return Notoriety.CanBeAttacked; + } return MobileNotoriety(source, master); } if (!bcTarg.Summoned && !bcTarg.Controlled && pmFrom.EnemyOfOneType == bcTarg.GetType()) + { return Notoriety.Enemy; + } } if (target.Kills >= 5 || target.Body.IsMonster && IsSummoned(bcTarg) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true) + { return Notoriety.Murderer; + } if (target.Criminal) + { return Notoriety.Criminal; + } var sourceGuild = GetGuildFor(source.Guild as Guild, source); var targetGuild = GetGuildFor(target.Guild as Guild, target); @@ -348,40 +476,63 @@ namespace Server.Misc if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) + { return Notoriety.Ally; + } + if (sourceGuild.IsEnemy(targetGuild)) + { return Notoriety.Enemy; + } } var srcFaction = Faction.Find(source, true, true); var trgFaction = Faction.Find(target, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) + { return Notoriety.Enemy; + } if (Stealing.ClassicMode && pmTarg?.PermaFlags.Contains(source) == true) + { return Notoriety.CanBeAttacked; + } if (bcTarg?.AlwaysAttackable == true) + { return Notoriety.CanBeAttacked; + } if (CheckHouseFlag(source, target, target.Location, target.Map)) + { return Notoriety.CanBeAttacked; + } if (bcTarg?.InitialInnocent != true) + { if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bcTarg) && pmTarg == null || !Core.ML && !target.CanBeginAction()) + { return Notoriety.CanBeAttacked; + } + } if (CheckAggressor(source.Aggressors, target)) + { return Notoriety.CanBeAttacked; + } if (CheckAggressed(source.Aggressed, target)) + { return Notoriety.CanBeAttacked; + } if (bcTarg?.Controlled == true && bcTarg.ControlOrder == OrderType.Guard && bcTarg.ControlTarget == source) + { return Notoriety.CanBeAttacked; + } if (source is BaseCreature bc) { @@ -389,7 +540,9 @@ namespace Server.Misc if (master != null && (CheckAggressor(master.Aggressors, target) || MobileNotoriety(master, target) == Notoriety.CanBeAttacked || bcTarg != null)) + { return Notoriety.CanBeAttacked; + } } return Notoriety.Innocent; @@ -400,10 +553,14 @@ namespace Server.Misc var house = BaseHouse.FindHouseAt(p, map, 16); if (house?.Public != false || !house.IsFriend(from)) + { return false; + } if (m != null && house.IsFriend(m)) + { return false; + } return !(m is BaseCreature c) || c.Deleted || !c.Controlled || c.ControlMaster == null || !house.IsFriend(c.ControlMaster); @@ -416,8 +573,12 @@ namespace Server.Misc public static bool CheckAggressor(List list, Mobile target) { for (var i = 0; i < list.Count; ++i) + { if (list[i].Attacker == target) + { return true; + } + } return false; } @@ -429,7 +590,9 @@ namespace Server.Misc var info = list[i]; if (!info.CriminalAggression && info.Defender == target) + { return true; + } } return false; diff --git a/Projects/UOContent/Misc/Paperdoll.cs b/Projects/UOContent/Misc/Paperdoll.cs index 81b634332..a30f50f81 100644 --- a/Projects/UOContent/Misc/Paperdoll.cs +++ b/Projects/UOContent/Misc/Paperdoll.cs @@ -25,7 +25,9 @@ namespace Server.Misc var items = beheld.Items; for (var i = 0; i < items.Count; ++i) + { beholder.Send(items[i].OPLPacket); + } // NOTE: OSI sends MobileUpdate when opening your own paperdoll. // It has a very bad rubber-banding affect. What positive affects does it have? diff --git a/Projects/UOContent/Misc/Poison.cs b/Projects/UOContent/Misc/Poison.cs index 1fa2605b4..68d61d977 100644 --- a/Projects/UOContent/Misc/Poison.cs +++ b/Projects/UOContent/Misc/Poison.cs @@ -96,6 +96,7 @@ namespace Server TransformationSpellHelper.UnderTransformation(m_Mobile, typeof(VampiricEmbraceSpell)) || m_Poison.Level < 3 && OrangePetals.UnderEffect(m_Mobile) || AnimalForm.UnderTransformation(m_Mobile, typeof(Unicorn))) + { if (m_Mobile.CurePoison(m_Mobile)) { m_Mobile.LocalOverheadMessage( @@ -115,6 +116,7 @@ namespace Server Stop(); return; } + } if (m_Index++ == m_Poison.m_Count) { @@ -136,9 +138,13 @@ namespace Server damage = 1 + (int)(m_Mobile.Hits * m_Poison.m_Scalar); if (damage < m_Poison.m_Minimum) + { damage = m_Poison.m_Minimum; + } else if (damage > m_Poison.m_Maximum) + { damage = m_Poison.m_Maximum; + } m_LastDamage = damage; } @@ -146,16 +152,22 @@ namespace Server From?.DoHarmful(m_Mobile, true); if (m_Mobile is IHonorTarget honorTarget) + { honorTarget.ReceivedHonorContext?.OnTargetPoisoned(); + } AOS.Damage(m_Mobile, From, damage, 0, 0, 0, 100, 0); if (Utility.RandomDouble() >= 0.60 ) // OSI: randomly revealed between first and third damage tick, guessing 60% chance + { m_Mobile.RevealingAction(); + } if (m_Index % m_Poison.m_MessageInterval == 0) + { m_Mobile.OnPoisoned(From, m_Poison, m_Poison); + } } } } diff --git a/Projects/UOContent/Misc/ProfanityProtection.cs b/Projects/UOContent/Misc/ProfanityProtection.cs index 676d116eb..b065c9d97 100644 --- a/Projects/UOContent/Misc/ProfanityProtection.cs +++ b/Projects/UOContent/Misc/ProfanityProtection.cs @@ -78,7 +78,9 @@ namespace Server.Misc public static void Initialize() { if (Enabled) + { EventSink.Speech += EventSink_Speech; + } } private static bool OnProfanityDetected(Mobile from, string speech) @@ -112,7 +114,9 @@ namespace Server.Misc var from = e.Mobile; if (from.AccessLevel > AccessLevel.Player) + { return; + } if (!NameVerification.Validate( e.Speech, @@ -126,7 +130,9 @@ namespace Server.Misc Disallowed, StartDisallowed )) - e.Blocked = !OnProfanityDetected(from, e.Speech); + { + e.Blocked = !OnProfanityDetected(@from, e.Speech); + } } } } diff --git a/Projects/UOContent/Misc/Profile.cs b/Projects/UOContent/Misc/Profile.cs index 8df6b5e1f..a86a2bb07 100644 --- a/Projects/UOContent/Misc/Profile.cs +++ b/Projects/UOContent/Misc/Profile.cs @@ -15,18 +15,26 @@ namespace Server.Misc public static void EventSink_ChangeProfileRequest(Mobile beholder, Mobile beheld, string text) { if (beholder.ProfileLocked) + { beholder.SendMessage("Your profile is locked. You may not change it."); + } else + { beholder.Profile = text; + } } public static void EventSink_ProfileRequest(Mobile beholder, Mobile beheld) { if (!beheld.Player) + { return; + } if (beholder.Map != beheld.Map || !beholder.InRange(beheld, 12) || !beholder.CanSee(beheld)) + { return; + } var header = Titles.ComputeTitle(beholder, beheld); @@ -35,13 +43,19 @@ namespace Server.Misc if (beheld.ProfileLocked) { if (beholder == beheld) + { footer = "Your profile has been locked."; + } else if (beholder.AccessLevel >= AccessLevel.Counselor) + { footer = "This profile has been locked."; + } } if (footer.Length == 0 && beholder == beheld) + { footer = GetAccountDuration(beheld); + } var body = beheld.Profile ?? ""; var serial = beholder != beheld || !beheld.ProfileLocked ? beheld.Serial : Serial.Zero; @@ -52,21 +66,31 @@ namespace Server.Misc private static string GetAccountDuration(Mobile m) { if (!(m.Account is Account a)) + { return ""; + } var ts = DateTime.UtcNow - a.Created; if (Format(ts.TotalDays, "This account is {0} day{1} old.", out var v)) + { return v; + } if (Format(ts.TotalHours, "This account is {0} hour{1} old.", out v)) + { return v; + } if (Format(ts.TotalMinutes, "This account is {0} minute{1} old.", out v)) + { return v; + } if (Format(ts.TotalSeconds, "This account is {0} second{1} old.", out v)) + { return v; + } return ""; } diff --git a/Projects/UOContent/Misc/ProtocolExtensions.cs b/Projects/UOContent/Misc/ProtocolExtensions.cs index 124ba0b81..d64beee52 100644 --- a/Projects/UOContent/Misc/ProtocolExtensions.cs +++ b/Projects/UOContent/Misc/ProtocolExtensions.cs @@ -20,7 +20,9 @@ namespace Server.Misc public static PacketHandler GetHandler(int packetID) { if (packetID >= 0 && packetID < m_Handlers.Length) + { return m_Handlers[packetID]; + } return null; } diff --git a/Projects/UOContent/Misc/RaceDefinitions.cs b/Projects/UOContent/Misc/RaceDefinitions.cs index 8628d9de1..7ff54198f 100644 --- a/Projects/UOContent/Misc/RaceDefinitions.cs +++ b/Projects/UOContent/Misc/RaceDefinitions.cs @@ -33,16 +33,24 @@ namespace Server.Misc public override bool ValidateHair(bool female, int itemID) { if (itemID == 0) + { return true; + } if (female && itemID == 0x2048 || !female && itemID == 0x2046) + { return false; // Buns & Receding Hair + } if (itemID >= 0x203B && itemID <= 0x203D) + { return true; + } if (itemID >= 0x2044 && itemID <= 0x204A) + { return true; + } return false; } @@ -66,16 +74,24 @@ namespace Server.Misc public override bool ValidateFacialHair(bool female, int itemID) { if (itemID == 0) + { return true; + } if (female) + { return false; + } if (itemID >= 0x203E && itemID <= 0x2041) + { return true; + } if (itemID >= 0x204B && itemID <= 0x204D) + { return true; + } return false; } @@ -83,7 +99,9 @@ namespace Server.Misc public override int RandomFacialHair(bool female) { if (female) + { return 0; + } var rand = Utility.Random(7); @@ -93,9 +111,15 @@ namespace Server.Misc public override int ClipSkinHue(int hue) { if (hue < 1002) + { return 1002; + } + if (hue > 1058) + { return 1058; + } + return hue; } @@ -104,9 +128,15 @@ namespace Server.Misc public override int ClipHairHue(int hue) { if (hue < 1102) + { return 1102; + } + if (hue > 1149) + { return 1149; + } + return hue; } @@ -142,16 +172,24 @@ namespace Server.Misc public override bool ValidateHair(bool female, int itemID) { if (itemID == 0) + { return true; + } if (female && (itemID == 0x2FCD || itemID == 0x2FBF) || !female && (itemID == 0x2FCC || itemID == 0x2FD0)) + { return false; + } if (itemID >= 0x2FBF && itemID <= 0x2FC2) + { return true; + } if (itemID >= 0x2FCC && itemID <= 0x2FD1) + { return true; + } return false; } @@ -178,8 +216,12 @@ namespace Server.Misc public override int ClipSkinHue(int hue) { for (var i = 0; i < m_SkinHues.Length; i++) + { if (m_SkinHues[i] == hue) + { return hue; + } + } return m_SkinHues[0]; } @@ -189,8 +231,12 @@ namespace Server.Misc public override int ClipHairHue(int hue) { for (var i = 0; i < m_HairHues.Length; i++) + { if (m_HairHues[i] == hue) + { return hue; + } + } return m_HairHues[0]; } @@ -225,7 +271,10 @@ namespace Server.Misc public override bool ValidateHair(bool female, int itemID) { - if (female == false) return itemID >= 0x4258 && itemID <= 0x425F; + if (female == false) + { + return itemID >= 0x4258 && itemID <= 0x425F; + } return itemID == 0x4261 || itemID == 0x4262 || itemID >= 0x4273 && itemID <= 0x4275 || itemID == 0x42B0 || itemID == 0x42B1 || itemID == 0x42AA || itemID == 0x42AB; @@ -234,9 +283,15 @@ namespace Server.Misc public override int RandomHair(bool female) { if (Utility.Random(9) == 0) + { return 0; + } + if (!female) + { return 0x4258 + Utility.Random(8); + } + return Utility.Random(9) switch { 0 => 0x4261, @@ -265,8 +320,12 @@ namespace Server.Misc public override int ClipHairHue(int hue) { for (var i = 0; i < m_HornHues.Length; i++) + { if (m_HornHues[i] == hue) + { return hue; + } + } return m_HornHues[0]; } diff --git a/Projects/UOContent/Misc/RegenRates.cs b/Projects/UOContent/Misc/RegenRates.cs index 0a2ebecd9..e9f11b80e 100644 --- a/Projects/UOContent/Misc/RegenRates.cs +++ b/Projects/UOContent/Misc/RegenRates.cs @@ -28,7 +28,9 @@ namespace Server.Misc private static void CheckBonusSkill(Mobile m, int cur, int max, SkillName skill) { if (!m.Alive) + { return; + } var n = (double)cur / max; var v = Math.Sqrt(m.Skills[skill].Value * 0.005); @@ -50,25 +52,39 @@ namespace Server.Misc var bc = from as BaseCreature; if (bc?.IsAnimatedDead == false) + { points += 4; + } if (bc?.IsParagon == true || from is Leviathan) + { points += 40; + } if (Core.ML && from.Race == Race.Human) // Is this affected by the cap? + { points += 2; + } if (points < 0) + { points = 0; + } if (Core.ML && from is PlayerMobile) // does racial bonus go before/after? + { points = Math.Min(points, 18); + } if (CheckTransform(from, typeof(HorrificBeastSpell))) + { points += 20; + } if (CheckAnimal(from, typeof(Dog)) || CheckAnimal(from, typeof(Cat))) - points += from.Skills.Ninjitsu.Fixed / 30; + { + points += @from.Skills.Ninjitsu.Fixed / 30; + } return TimeSpan.FromSeconds(1.0 / (0.1 * (1 + points))); } @@ -76,30 +92,42 @@ namespace Server.Misc private static TimeSpan Mobile_StamRegenRate(Mobile from) { if (from.Skills == null) + { return Mobile.DefaultStamRate; + } CheckBonusSkill(from, from.Stam, from.StamMax, SkillName.Focus); var points = (int)(from.Skills.Focus.Value * 0.1); if (from is BaseCreature creature && creature.IsParagon || from is Leviathan) + { points += 40; + } var cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenStam); if (CheckTransform(from, typeof(VampiricEmbraceSpell))) + { cappedPoints += 15; + } if (CheckAnimal(from, typeof(Kirin))) + { cappedPoints += 20; + } if (Core.ML && from is PlayerMobile) + { cappedPoints = Math.Min(cappedPoints, 24); + } points += cappedPoints; if (points < -1) + { points = -1; + } return TimeSpan.FromSeconds(1.0 / (0.1 * (2 + points))); } @@ -107,10 +135,14 @@ namespace Server.Misc private static TimeSpan Mobile_ManaRegenRate(Mobile from) { if (from.Skills == null) + { return Mobile.DefaultManaRate; + } if (!from.Meditating) - CheckBonusSkill(from, from.Mana, from.ManaMax, SkillName.Meditation); + { + CheckBonusSkill(@from, @from.Mana, @from.ManaMax, SkillName.Meditation); + } double rate; var armorPenalty = GetArmorOffset(from); @@ -126,30 +158,44 @@ namespace Server.Misc var focusPoints = from.Skills.Focus.Value * 0.05; if (armorPenalty > 0) + { medPoints = 0; // In AOS, wearing any meditation-blocking armor completely removes meditation bonus + } var totalPoints = focusPoints + medPoints + (from.Meditating ? medPoints > 13.0 ? 13.0 : medPoints : 0.0); if (from is BaseCreature creature && creature.IsParagon || from is Leviathan) + { totalPoints += 40; + } var cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenMana); if (CheckTransform(from, typeof(VampiricEmbraceSpell))) + { cappedPoints += 3; + } else if (CheckTransform(from, typeof(LichFormSpell))) + { cappedPoints += 13; + } if (Core.ML && from is PlayerMobile) + { cappedPoints = Math.Min(cappedPoints, 18); + } totalPoints += cappedPoints; if (totalPoints < -1) + { totalPoints = -1; + } if (Core.ML) + { totalPoints = Math.Floor(totalPoints); + } rate = 1.0 / (0.1 * (2 + totalPoints)); } @@ -158,18 +204,28 @@ namespace Server.Misc var medPoints = (from.Int + from.Skills.Meditation.Value) * 0.5; if (medPoints <= 0) + { rate = 7.0; + } else if (medPoints <= 100) + { rate = 7.0 - 239 * medPoints / 2400 + 19 * medPoints * medPoints / 48000; + } else if (medPoints < 120) + { rate = 1.0; + } else + { rate = 0.75; + } rate += armorPenalty; if (from.Meditating) + { rate *= 0.5; + } rate = Math.Clamp(rate, 0.5, 7.0); } @@ -182,7 +238,9 @@ namespace Server.Misc var rating = 0.0; if (!Core.AOS) - rating += GetArmorMeditationValue(from.ShieldArmor as BaseArmor); + { + rating += GetArmorMeditationValue(@from.ShieldArmor as BaseArmor); + } rating += GetArmorMeditationValue(from.NeckArmor as BaseArmor); rating += GetArmorMeditationValue(from.HandArmor as BaseArmor); @@ -197,7 +255,9 @@ namespace Server.Misc private static double GetArmorMeditationValue(BaseArmor ar) { if (ar == null || ar.ArmorAttributes.MageArmor != 0 || ar.Attributes.SpellChanneling != 0) + { return 0.0; + } return ar.MeditationAllowance switch { diff --git a/Projects/UOContent/Misc/RenameRequests.cs b/Projects/UOContent/Misc/RenameRequests.cs index 8f613354c..83b0aaca0 100644 --- a/Projects/UOContent/Misc/RenameRequests.cs +++ b/Projects/UOContent/Misc/RenameRequests.cs @@ -31,11 +31,13 @@ namespace Server.Misc var disallowed = ProfanityProtection.Disallowed; for (var i = 0; i < disallowed.Length; i++) + { if (name.IndexOf(disallowed[i]) != -1) { - from.SendLocalizedMessage(1072622); // That name isn't very polite. + @from.SendLocalizedMessage(1072622); // That name isn't very polite. return; } + } from.SendLocalizedMessage( 1072623, diff --git a/Projects/UOContent/Misc/ShardPoller.cs b/Projects/UOContent/Misc/ShardPoller.cs index b2db1804b..a84cfcef4 100644 --- a/Projects/UOContent/Misc/ShardPoller.cs +++ b/Projects/UOContent/Misc/ShardPoller.cs @@ -52,14 +52,18 @@ namespace Server.Misc get { if (StartTime == DateTime.MinValue || !m_Active) + { return TimeSpan.Zero; + } try { var ts = StartTime + Duration - DateTime.UtcNow; if (ts < TimeSpan.Zero) + { return TimeSpan.Zero; + } return ts; } @@ -77,7 +81,9 @@ namespace Server.Misc set { if (m_Active == value) + { return; + } m_Active = value; @@ -98,8 +104,12 @@ namespace Server.Misc public bool HasAlreadyVoted(NetState ns) { for (var i = 0; i < Options.Length; ++i) + { if (Options[i].HasAlreadyVoted(ns)) + { return true; + } + } return false; } @@ -114,16 +124,22 @@ namespace Server.Misc var index = Array.IndexOf(Options, option); if (index < 0) + { return; + } var old = Options; Options = new ShardPollOption[old.Length - 1]; for (var i = 0; i < index; ++i) + { Options[i] = old[i]; + } for (var i = index; i < Options.Length; ++i) + { Options[i] = old[i + 1]; + } } public void AddOption(ShardPollOption option) @@ -132,7 +148,9 @@ namespace Server.Misc Options = new ShardPollOption[old.Length + 1]; for (var i = 0; i < old.Length; ++i) + { Options[i] = old[i]; + } Options[old.Length] = option; } @@ -145,7 +163,9 @@ namespace Server.Misc private static void EventSink_Login(Mobile m) { if (m_ActivePollers.Count == 0) + { return; + } Timer.DelayCall(TimeSpan.FromSeconds(1.0), EventSink_Login_Callback, m); } @@ -155,7 +175,9 @@ namespace Server.Misc var ns = from.NetState; if (ns == null) + { return; + } ShardPollGump spg = null; @@ -164,12 +186,16 @@ namespace Server.Misc var poller = m_ActivePollers[i]; if (poller.Deleted || !poller.Active) + { continue; + } if (poller.TimeRemaining > TimeSpan.Zero) { if (poller.HasAlreadyVoted(ns)) + { continue; + } if (spg == null) { @@ -191,7 +217,9 @@ namespace Server.Misc public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.Administrator) - from.SendGump(new ShardPollGump(from, this, true, null)); + { + @from.SendGump(new ShardPollGump(@from, this, true, null)); + } } public override void Serialize(IGenericWriter writer) @@ -208,7 +236,9 @@ namespace Server.Misc writer.Write(Options.Length); for (var i = 0; i < Options.Length; ++i) + { Options[i].Serialize(writer); + } } public override void Deserialize(IGenericReader reader) @@ -229,10 +259,14 @@ namespace Server.Misc Options = new ShardPollOption[reader.ReadInt()]; for (var i = 0; i < Options.Length; ++i) + { Options[i] = new ShardPollOption(reader); + } if (m_Active) + { m_ActivePollers.Add(this); + } break; } @@ -272,7 +306,9 @@ namespace Server.Misc Voters = new IPAddress[reader.ReadInt()]; for (var i = 0; i < Voters.Length; ++i) + { Voters[i] = Utility.Intern(reader.ReadIPAddress()); + } break; } @@ -297,13 +333,19 @@ namespace Server.Misc public bool HasAlreadyVoted(NetState ns) { if (ns == null) + { return false; + } var ipAddress = ns.Address; for (var i = 0; i < Voters.Length; ++i) + { if (Utility.IPMatchClassC(Voters[i], ipAddress)) + { return true; + } + } return false; } @@ -311,13 +353,17 @@ namespace Server.Misc public void AddVote(NetState ns) { if (ns == null) + { return; + } var old = Voters; Voters = new IPAddress[old.Length + 1]; for (var i = 0; i < old.Length; ++i) + { Voters[i] = old[i]; + } Voters[old.Length] = ns.Address; } @@ -327,7 +373,9 @@ namespace Server.Misc var height = LineBreaks * 18; if (height > 30) + { return height; + } return 30; } @@ -335,7 +383,9 @@ namespace Server.Misc public int GetBreaks(string title) { if (title == null) + { return 1; + } var count = 0; var index = -1; @@ -358,7 +408,9 @@ namespace Server.Misc writer.Write(Voters.Length); for (var i = 0; i < Voters.Length; ++i) + { writer.Write(Voters[i]); + } } } @@ -393,7 +445,9 @@ namespace Server.Misc var isCompleted = totalVotes > 0 && !poller.Active; if (editing && !isViewingResults) + { totalOptionHeight += 35; + } var height = 115 + totalOptionHeight; @@ -405,9 +459,13 @@ namespace Server.Misc string title; if (editing) + { title = isCompleted ? "Poll Completed" : "Poll Editor"; + } else + { title = "Shard Poll"; + } AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32)); @@ -441,9 +499,13 @@ namespace Server.Misc y += optHeight / 2; if (isViewingResults) + { AddImage(24, y - 15, 0x25FE); + } else + { AddRadio(24, y - 15, 0x25F9, 0x25FC, false, 1 + i); + } AddHtml(60, y - 9 * option.LineBreaks, 250, 18 * option.LineBreaks, Color(text, LabelColor32)); @@ -481,6 +543,7 @@ namespace Server.Misc var shardPoller = m_Polls.Dequeue(); if (shardPoller != null) + { Timer.DelayCall( TimeSpan.FromSeconds(1.0), data => @@ -490,6 +553,7 @@ namespace Server.Misc }, (m_From, shardPoller, m_Polls) ); + } } if (info.ButtonID == 1) @@ -497,16 +561,22 @@ namespace Server.Misc var switches = info.Switches; if (switches.Length == 0) + { return; + } var switched = switches[0] - 1; ShardPollOption opt = null; if (switched >= 0 && switched < m_Poller.Options.Length) + { opt = m_Poller.Options[switched]; + } if (opt == null && !Editing) + { return; + } if (Editing) { @@ -527,11 +597,17 @@ namespace Server.Misc else { if (!m_Poller.Active) + { m_From.SendMessage("The poll has been deactivated."); + } else if (m_Poller.HasAlreadyVoted(sender)) + { m_From.SendMessage("You have already voted on this poll."); + } else + { m_Poller.AddVote(sender, opt); + } } } else if (info.ButtonID == 2 && Editing) @@ -566,7 +642,9 @@ namespace Server.Misc if (m.Groups[1].Success) { if (m.Groups[2].Success) + { return $"{m.Groups[2].Value}"; + } } else if (m.Groups[2].Success) { @@ -579,7 +657,9 @@ namespace Server.Misc public static string UrlToHref(string text) { if (text == null) + { return null; + } return m_UrlRegex.Replace(text, UrlRegex_Match); } @@ -593,16 +673,22 @@ namespace Server.Misc else if (text == "DEL") { if (m_Option != null) + { m_Poller.RemoveOption(m_Option); + } } else { text = UrlToHref(text); if (m_Option == null) + { m_Poller.AddOption(new ShardPollOption(text)); + } else + { m_Option.Title = text; + } } from.SendGump(new ShardPollGump(from, m_Poller, true, null)); diff --git a/Projects/UOContent/Misc/ShrinkTable.cs b/Projects/UOContent/Misc/ShrinkTable.cs index 13be4826e..67d4fc1bc 100644 --- a/Projects/UOContent/Misc/ShrinkTable.cs +++ b/Projects/UOContent/Misc/ShrinkTable.cs @@ -18,15 +18,21 @@ namespace Server public static int Lookup(int body, int defaultValue) { if (m_Table == null) + { Load(); + } var val = 0; if (body >= 0 && body < m_Table!.Length) + { val = m_Table[body]; + } if (val == 0) + { val = defaultValue; + } return val; } @@ -51,7 +57,9 @@ namespace Server line = line.Trim(); if (line.Length == 0 || line.StartsWith("#")) + { continue; + } try { @@ -63,7 +71,9 @@ namespace Server var item = Utility.ToInt32(split[1]); if (body >= 0 && body < m_Table.Length) + { m_Table[body] = item; + } } } catch diff --git a/Projects/UOContent/Misc/SkillCheck.cs b/Projects/UOContent/Misc/SkillCheck.cs index c1d9741a6..94a6e7c30 100644 --- a/Projects/UOContent/Misc/SkillCheck.cs +++ b/Projects/UOContent/Misc/SkillCheck.cs @@ -103,14 +103,21 @@ namespace Server.Misc var skill = from.Skills[skillName]; if (skill == null) + { return false; + } var value = skill.Value; if (value < minSkill) + { return false; // Too difficult + } + if (value >= maxSkill) + { return true; // No challenge + } var chance = (value - minSkill) / (maxSkill - minSkill); @@ -123,12 +130,19 @@ namespace Server.Misc var skill = from.Skills[skillName]; if (skill == null) + { return false; + } if (chance < 0.0) + { return false; // Too difficult + } + if (chance >= 1.0) + { return true; // No challenge + } var loc = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize); return CheckSkill(from, skill, loc, chance); @@ -137,7 +151,9 @@ namespace Server.Misc public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance) { if (from.Skills.Cap == 0) + { return false; + } var success = chance >= Utility.RandomDouble(); var gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap; @@ -151,13 +167,19 @@ namespace Server.Misc gc *= skill.Info.GainFactor; if (gc < 0.01) + { gc = 0.01; + } if (from is BaseCreature creature && creature.Controlled) + { gc *= 2; + } if (from.Alive && (gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj) || skill.Base < 10.0)) - Gain(from, skill); + { + Gain(@from, skill); + } return success; } @@ -170,14 +192,21 @@ namespace Server.Misc var skill = from.Skills[skillName]; if (skill == null) + { return false; + } var value = skill.Value; if (value < minSkill) + { return false; // Too difficult + } + if (value >= maxSkill) + { return true; // No challenge + } var chance = (value - minSkill) / (maxSkill - minSkill); @@ -189,12 +218,19 @@ namespace Server.Misc var skill = from.Skills[skillName]; if (skill == null) + { return false; + } if (chance < 0.0) + { return false; // Too difficult + } + if (chance >= 1.0) + { return true; // No challenge + } return CheckSkill(from, skill, target, chance); } @@ -202,10 +238,14 @@ namespace Server.Misc private static bool AllowGain(Mobile from, Skill skill, object obj) { if (Core.AOS && Faction.InSkillLoss(from)) // Changed some time between the introduction of AoS and SE. + { return false; + } if (AntiMacroCode && from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID]) + { return mobile.AntiMacroCheck(skill, obj); + } return true; } @@ -213,24 +253,33 @@ namespace Server.Misc public static void Gain(Mobile from, Skill skill) { if (from.Region.IsPartOf()) + { return; + } if (from is BaseCreature creature && creature.IsDeadPet) + { return; + } if (skill.SkillName == SkillName.Focus && from is BaseCreature) + { return; + } if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up) { var toGain = 1; if (skill.Base <= 10.0) + { toGain = Utility.Random(4) + 1; + } var skills = from.Skills; if (from.Player && skills.Total / skills.Cap >= Utility.RandomDouble()) + { for (var i = 0; i < skills.Length; ++i) { var toLower = skills[i]; @@ -241,12 +290,18 @@ namespace Server.Misc break; } } + } if (from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow) + { toGain *= Utility.RandomMinMax(2, 5); + } - if (!from.Player || skills.Total + toGain <= skills.Cap) skill.BaseFixedPoint += toGain; + if (!from.Player || skills.Total + toGain <= skills.Cap) + { + skill.BaseFixedPoint += toGain; + } } if (skill.Lock == SkillLock.Up) @@ -254,11 +309,17 @@ namespace Server.Misc var info = skill.Info; if (from.StrLock == StatLockType.Up && info.StrGain / 33.3 > Utility.RandomDouble()) - GainStat(from, Stat.Str); + { + GainStat(@from, Stat.Str); + } else if (from.DexLock == StatLockType.Up && info.DexGain / 33.3 > Utility.RandomDouble()) - GainStat(from, Stat.Dex); + { + GainStat(@from, Stat.Dex); + } else if (from.IntLock == StatLockType.Up && info.IntGain / 33.3 > Utility.RandomDouble()) - GainStat(from, Stat.Int); + { + GainStat(@from, Stat.Int); + } } } @@ -276,8 +337,12 @@ namespace Server.Misc public static bool CanRaise(Mobile from, Stat stat) { if (!(from is BaseCreature creature && creature.Controlled)) - if (from.RawStatTotal >= from.StatCap) + { + if (@from.RawStatTotal >= @from.StatCap) + { return false; + } + } return stat switch { @@ -299,13 +364,19 @@ namespace Server.Misc if (atrophy) { if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int))) - --from.RawDex; + { + --@from.RawDex; + } else if (CanLower(from, Stat.Int)) - --from.RawInt; + { + --@from.RawInt; + } } if (CanRaise(from, Stat.Str)) - ++from.RawStr; + { + ++@from.RawStr; + } break; } @@ -314,13 +385,19 @@ namespace Server.Misc if (atrophy) { if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int))) - --from.RawStr; + { + --@from.RawStr; + } else if (CanLower(from, Stat.Int)) - --from.RawInt; + { + --@from.RawInt; + } } if (CanRaise(from, Stat.Dex)) - ++from.RawDex; + { + ++@from.RawDex; + } break; } @@ -329,13 +406,19 @@ namespace Server.Misc if (atrophy) { if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex))) - --from.RawStr; + { + --@from.RawStr; + } else if (CanLower(from, Stat.Dex)) - --from.RawDex; + { + --@from.RawDex; + } } if (CanRaise(from, Stat.Int)) - ++from.RawInt; + { + ++@from.RawInt; + } break; } @@ -351,7 +434,9 @@ namespace Server.Misc if (from is BaseCreature creature && creature.Controlled) { if (creature.LastStrGain + m_PetStatGainDelay >= DateTime.UtcNow) + { return; + } } else if (from.LastStrGain + m_StatGainDelay >= DateTime.UtcNow) { @@ -366,7 +451,9 @@ namespace Server.Misc if (from is BaseCreature creature && creature.Controlled) { if (creature.LastDexGain + m_PetStatGainDelay >= DateTime.UtcNow) + { return; + } } else if (from.LastDexGain + m_StatGainDelay >= DateTime.UtcNow) { @@ -381,7 +468,9 @@ namespace Server.Misc if (from is BaseCreature creature && creature.Controlled) { if (creature.LastIntGain + m_PetStatGainDelay >= DateTime.UtcNow) + { return; + } } else if (from.LastIntGain + m_StatGainDelay >= DateTime.UtcNow) { diff --git a/Projects/UOContent/Misc/TextDefinition.cs b/Projects/UOContent/Misc/TextDefinition.cs index 17518e364..5ad85148d 100644 --- a/Projects/UOContent/Misc/TextDefinition.cs +++ b/Projects/UOContent/Misc/TextDefinition.cs @@ -70,12 +70,18 @@ namespace Server public static void AddTo(ObjectPropertyList list, TextDefinition def) { if (def == null) + { return; + } if (def.Number > 0) + { list.Add(def.Number); + } else if (def.String != null) + { list.Add(def.String); + } } public static implicit operator TextDefinition(int v) => new TextDefinition(v); @@ -92,18 +98,25 @@ namespace Server ) { if (def == null) + { return; + } if (def.Number > 0) { if (numberColor >= 0) // 5 bits per RGB component (15 bit RGB) + { g.AddHtmlLocalized(x, y, width, height, def.Number, numberColor, back, scroll); + } else + { g.AddHtmlLocalized(x, y, width, height, def.Number, back, scroll); + } } else if (def.String != null) { if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB) + { g.AddHtml( x, y, @@ -113,8 +126,11 @@ namespace Server back, scroll ); + } else + { g.AddHtml(x, y, width, height, def.String, back, scroll); + } } } @@ -129,40 +145,60 @@ namespace Server public static void SendMessageTo(Mobile m, TextDefinition def) { if (def == null) + { return; + } if (def.Number > 0) + { m.SendLocalizedMessage(def.Number); + } else if (def.String != null) + { m.SendMessage(def.String); + } } public static void SendMessageTo(Mobile m, TextDefinition def, int hue) { if (def == null) + { return; + } if (def.Number > 0) + { m.SendLocalizedMessage(def.Number, "", hue); + } else if (def.String != null) + { m.SendMessage(hue, def.String); + } } public static void PublicOverheadMessage(Mobile m, MessageType messageType, int hue, TextDefinition def) { if (def == null) + { return; + } if (def.Number > 0) + { m.PublicOverheadMessage(messageType, hue, def.Number); + } else if (def.String != null) + { m.PublicOverheadMessage(messageType, hue, false, def.String); + } } public static TextDefinition Parse(string value) { if (value == null) + { return null; + } int i; bool isInteger; diff --git a/Projects/UOContent/Misc/Titles.cs b/Projects/UOContent/Misc/Titles.cs index cb7357b0b..8c742da49 100644 --- a/Projects/UOContent/Misc/Titles.cs +++ b/Projects/UOContent/Misc/Titles.cs @@ -127,43 +127,67 @@ namespace Server.Misc if (offset > 0) { if (m.Fame >= MaxFame) + { return; + } offset = Math.Max(offset - m.Fame / 100, 0); } else if (offset < 0) { if (m.Fame <= MinFame) + { return; + } offset = Math.Min(offset - m.Fame / 100, 0); } if (m.Fame + offset > MaxFame) + { offset = MaxFame - m.Fame; + } else if (m.Fame + offset < MinFame) + { offset = MinFame - m.Fame; + } m.Fame += offset; if (message) { if (offset > 40) + { m.SendLocalizedMessage(1019054); // You have gained a lot of fame. + } else if (offset > 20) + { m.SendLocalizedMessage(1019053); // You have gained a good amount of fame. + } else if (offset > 10) + { m.SendLocalizedMessage(1019052); // You have gained some fame. + } else if (offset > 0) + { m.SendLocalizedMessage(1019051); // You have gained a little fame. + } else if (offset < -40) + { m.SendLocalizedMessage(1019058); // You have lost a lot of fame. + } else if (offset < -20) + { m.SendLocalizedMessage(1019057); // You have lost a good amount of fame. + } else if (offset < -10) + { m.SendLocalizedMessage(1019056); // You have lost some fame. + } else if (offset < 0) + { m.SendLocalizedMessage(1019055); // You have lost a little fame. + } } } @@ -174,25 +198,35 @@ namespace Server.Misc if (offset > 0) { if (pm?.KarmaLocked == true) + { return; + } if (m.Karma >= MaxKarma) + { return; + } offset = Math.Max(offset - m.Karma / 100, 0); } else if (offset < 0) { if (m.Karma <= MinKarma) + { return; + } offset = Math.Min(offset - m.Karma / 100, 0); } if (m.Karma + offset > MaxKarma) + { offset = MaxKarma - m.Karma; + } else if (m.Karma + offset < MinKarma) + { offset = MinKarma - m.Karma; + } var wasPositiveKarma = m.Karma >= 0; @@ -201,21 +235,37 @@ namespace Server.Misc if (message) { if (offset > 40) + { m.SendLocalizedMessage(1019062); // You have gained a lot of karma. + } else if (offset > 20) + { m.SendLocalizedMessage(1019061); // You have gained a good amount of karma. + } else if (offset > 10) + { m.SendLocalizedMessage(1019060); // You have gained some karma. + } else if (offset > 0) + { m.SendLocalizedMessage(1019059); // You have gained a little karma. + } else if (offset < -40) + { m.SendLocalizedMessage(1019066); // You have lost a lot of karma. + } else if (offset < -20) + { m.SendLocalizedMessage(1019065); // You have lost a good amount of karma. + } else if (offset < -10) + { m.SendLocalizedMessage(1019064); // You have lost some karma. + } else if (offset < 0) + { m.SendLocalizedMessage(1019063); // You have lost a little karma. + } } if (!Core.AOS && wasPositiveKarma && m.Karma < 0 && pm?.KarmaLocked == false) @@ -244,6 +294,7 @@ namespace Server.Misc } else*/ if (beheld.ShowFameTitle || beholder == beheld) + { for (var i = 0; i < m_FameEntries.Length; ++i) { var fe = m_FameEntries[i]; @@ -266,8 +317,11 @@ namespace Server.Misc break; } } + } else + { title.Append(beheld.Name); + } if (beheld is PlayerMobile mobile && mobile.DisplayChampionTitle) { @@ -293,9 +347,13 @@ namespace Server.Misc var offset = 0; if (highestValue > 800) + { offset = 3; + } else if (highestValue > 300) + { offset = highestValue / 300; + } if (offset > 0) { @@ -319,7 +377,10 @@ namespace Server.Misc { var skillTitle = GetSkillTitle(beheld); - if (skillTitle != null) title.Append(", ").Append(skillTitle); + if (skillTitle != null) + { + title.Append(", ").Append(skillTitle); + } } return title.ToString(); @@ -335,7 +396,9 @@ namespace Server.Misc var skillTitle = highest.Info.Title; if (mob.Female && skillTitle.EndsWith("man")) + { skillTitle = $"{skillTitle.Substring(0, skillTitle.Length - 3)}woman"; + } return $"{skillLevel} {skillTitle}"; } @@ -348,7 +411,9 @@ namespace Server.Misc var skills = m.Skills; if (!Core.AOS) + { return skills.Highest; + } Skill highest = null; @@ -357,10 +422,14 @@ namespace Server.Misc var check = m.Skills[i]; if (highest == null || check.BaseFixedPoint > highest.BaseFixedPoint) + { highest = check; + } else if (highest.Lock != SkillLock.Up && check.Lock == SkillLock.Up && check.BaseFixedPoint == highest.BaseFixedPoint) + { highest = check; + } } return highest; diff --git a/Projects/UOContent/Misc/ToggleItem.cs b/Projects/UOContent/Misc/ToggleItem.cs index b52d8dd7a..780d0b738 100644 --- a/Projects/UOContent/Misc/ToggleItem.cs +++ b/Projects/UOContent/Misc/ToggleItem.cs @@ -43,9 +43,13 @@ namespace Server.Items else if (PlayersCanToggle) { if (from.InRange(GetWorldLocation(), 1)) + { Toggle(); + } else - from.SendLocalizedMessage(500446); // That is too far away. + { + @from.SendLocalizedMessage(500446); // That is too far away. + } } } diff --git a/Projects/UOContent/Misc/TreasureMapProtection.cs b/Projects/UOContent/Misc/TreasureMapProtection.cs index b1f8d09bf..a5a1e8d7a 100644 --- a/Projects/UOContent/Misc/TreasureMapProtection.cs +++ b/Projects/UOContent/Misc/TreasureMapProtection.cs @@ -64,13 +64,17 @@ namespace Server public override void OnEnter(Mobile m) { if (m.AccessLevel > AccessLevel.Player) + { m.SendMessage("You have entered a protected treasure map area."); + } } public override void OnExit(Mobile m) { if (m.AccessLevel > AccessLevel.Player) + { m.SendMessage("You have left a protected treasure map area."); + } } } } diff --git a/Projects/UOContent/Misc/ValidationQueue.cs b/Projects/UOContent/Misc/ValidationQueue.cs index 9f8ba1756..10203698f 100644 --- a/Projects/UOContent/Misc/ValidationQueue.cs +++ b/Projects/UOContent/Misc/ValidationQueue.cs @@ -39,8 +39,12 @@ namespace Server var m = type.GetMethod("Validate", BindingFlags.Instance | BindingFlags.Public); if (m != null) + { for (var i = 0; i < m_Queue.Count; ++i) + { m.Invoke(m_Queue[i], null); + } + } m_Queue.Clear(); m_Queue = null; diff --git a/Projects/UOContent/Misc/VendorGenerator.cs b/Projects/UOContent/Misc/VendorGenerator.cs index e73b93f05..b20c4a38c 100644 --- a/Projects/UOContent/Misc/VendorGenerator.cs +++ b/Projects/UOContent/Misc/VendorGenerator.cs @@ -82,7 +82,9 @@ namespace Server var lt = map.Tiles.GetLandTile(x, y); if (IsFloor(lt.ID) && (canFit || CanFit(map, x, y, lt.Z))) + { return true; + } var tiles = map.Tiles.GetStaticTiles(x, y); @@ -92,7 +94,9 @@ namespace Server var id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; if (IsStaticFloor(t.ID) && (canFit || CanFit(map, x, y, t.Z + (id.Surface ? id.CalcHeight : 0)))) + { return true; + } } return false; @@ -122,9 +126,15 @@ namespace Server World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map); for (var i = 0; i < regions.Length; ++i) + { for (var x = 0; x < map.Width; ++x) + { for (var y = 0; y < map.Height; ++y) + { CheckPoint(map, regions[i].X + x, regions[i].Y + y); + } + } + } for (var i = 0; i < m_ShopList.Count; ++i) { @@ -147,11 +157,15 @@ namespace Server eable.Free(); if (hasSpawner) + { break; + } } if (hasSpawner) + { continue; + } var xAvg = xTotal / si.m_Floor.Count; var yAvg = yTotal / si.m_Floor.Count; @@ -160,25 +174,39 @@ namespace Server var flags = si.m_Flags; if ((flags & ShopFlags.Armor) != 0) + { names.Add("armorer"); + } if ((flags & ShopFlags.MetalWeapon) != 0) + { names.Add("weaponsmith"); + } if ((flags & ShopFlags.ArcheryWeapon) != 0) + { names.Add("bowyer"); + } if ((flags & ShopFlags.Scroll) != 0) + { names.Add("mage"); + } if ((flags & ShopFlags.Spellbook) != 0) + { names.Add("mage"); + } if ((flags & ShopFlags.Bread) != 0) + { names.Add("baker"); + } if ((flags & ShopFlags.Jewel) != 0) + { names.Add("jeweler"); + } if ((flags & ShopFlags.Potion) != 0) { @@ -213,7 +241,9 @@ namespace Server var fd = (int)Math.Sqrt(rx * rx + ry * ry); if (fd > 0 && fd < 5) + { fd -= Utility.Random(10); + } if (fd < dist && GetFloorZ(map, fp.X, fp.Y, out _)) { @@ -223,10 +253,14 @@ namespace Server } if (cp == Point2D.Zero) + { continue; + } if (!GetFloorZ(map, cp.X, cp.Y, out var z)) + { continue; + } new Spawner(1, 1, 1, 0, 4, names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map); } @@ -238,7 +272,9 @@ namespace Server private static void CheckPoint(Map map, int x, int y) { if (IsFloor(map, x, y, true)) + { CheckFloor(map, x, y); + } } private static void CheckFloor(Map map, int x, int y) @@ -246,11 +282,13 @@ namespace Server var tiles = map.Tiles.GetStaticTiles(x, y); for (var i = 0; i < tiles.Length; ++i) + { if (IsDisplayCase(tiles[i].ID)) { ProcessDisplayCase(map, tiles, x, y); break; } + } } private static bool IsClothes(int itemID) => @@ -283,33 +321,53 @@ namespace Server if ((flags & TileFlag.Wearable) != 0) { if (IsClothes(itemID)) + { res |= ShopFlags.Clothes; + } else if (IsArmor(itemID)) + { res |= ShopFlags.Armor; + } else if (IsMetalWeapon(itemID)) + { res |= ShopFlags.MetalWeapon; + } else if (IsArcheryWeapon(itemID)) + { res |= ShopFlags.ArcheryWeapon; + } } if (itemID == 0x98C || itemID == 0x103B || itemID == 0x103C) + { res |= ShopFlags.Bread; + } if (itemID >= 0xF0F && itemID <= 0xF30) + { res |= ShopFlags.Jewel; + } if (itemID >= 0xEFB && itemID <= 0xF0D) + { res |= ShopFlags.Potion; + } if (itemID >= 0xF78 && itemID <= 0xF91) + { res |= ShopFlags.Reagent; + } if (itemID >= 0xE35 && itemID <= 0xE3A || itemID >= 0xEF4 && itemID <= 0xEF9 || itemID >= 0x1F2D && itemID <= 0x1F72) + { res |= ShopFlags.Scroll; + } if (itemID == 0xE38 || itemID == 0xEFA) + { res |= ShopFlags.Spellbook; + } return res; } @@ -333,13 +391,17 @@ namespace Server RecurseFindFloor(map, x, y, floor); if (floor.Count == 0) + { return; + } si = new ShopInfo { m_Flags = flags, m_Floor = floor }; m_ShopList.Add(si); for (var i = 0; i < floor.Count; ++i) + { m_ShopTable[floor[i]] = si; + } } } } @@ -355,9 +417,14 @@ namespace Server var landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; if ((landFlags & TileFlag.Impassable) != 0 && topZ > z && z + 16 > lowZ) + { return false; + } + if ((landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored) + { hasSurface = true; + } var staticTiles = map.Tiles.GetStaticTiles(x, y); @@ -366,7 +433,9 @@ namespace Server for (var i = 0; i < staticTiles.Length; ++i) { if (IsDisplayCase(staticTiles[i].ID)) + { continue; + } var id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue]; @@ -374,9 +443,14 @@ namespace Server impassable = id.Impassable; if ((surface || impassable) && staticTiles[i].Z + id.CalcHeight > z && z + 16 > staticTiles[i].Z) + { return false; + } + if (surface && !impassable && z == staticTiles[i].Z + id.CalcHeight) + { hasSurface = true; + } } var sector = map.GetSector(x, y); @@ -393,9 +467,14 @@ namespace Server impassable = id.Impassable; if ((surface || impassable) && item.Z + id.CalcHeight > z && z + 16 > item.Z) + { return false; + } + if (surface && !impassable && z == item.Z + id.CalcHeight) + { hasSurface = true; + } } } @@ -407,14 +486,22 @@ namespace Server var p = new Point2D(x, y); if (floor.Contains(p)) + { return; + } floor.Add(p); for (var xo = -1; xo <= 1; ++xo) + { for (var yo = -1; yo <= 1; ++yo) + { if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false)) + { RecurseFindFloor(map, x + xo, y + yo, floor); + } + } + } } [Flags] diff --git a/Projects/UOContent/Misc/Weather.cs b/Projects/UOContent/Misc/Weather.cs index 1245144a3..363cb7fe1 100644 --- a/Projects/UOContent/Misc/Weather.cs +++ b/Projects/UOContent/Misc/Weather.cs @@ -89,16 +89,22 @@ namespace Server.Misc */ for (var i = 0; i < 15; ++i) + { AddDynamicWeather(+15, 100, 5, 8, 400, 400, new Rectangle2D(0, 0, 5120, 4096)); + } } public static List GetWeatherList(Map facet) { if (facet == null) + { return null; + } if (!m_WeatherByFacet.TryGetValue(facet, out var list)) + { m_WeatherByFacet[facet] = list = new List(); + } return list; } @@ -123,14 +129,20 @@ namespace Server.Misc ); if (!CheckWeatherConflict(m_Facets[i], null, area)) + { isValid = true; + } if (isValid) + { break; + } } if (!isValid) + { continue; + } new Weather( m_Facets[i], @@ -149,6 +161,7 @@ namespace Server.Misc ) { for (var i = 0; i < m_Facets.Length; ++i) + { new Weather( m_Facets[i], area, @@ -157,6 +170,7 @@ namespace Server.Misc chanceOfExtremeTemperature, TimeSpan.FromSeconds(30.0) ); + } } public static bool CheckWeatherConflict(Map facet, Weather exclude, Rectangle2D area) @@ -164,14 +178,18 @@ namespace Server.Misc var list = GetWeatherList(facet); if (list == null) + { return false; + } for (var i = 0; i < list.Count; ++i) { var w = list[i]; if (w != exclude && w.IntersectsWith(area)) + { return true; + } } return false; @@ -189,8 +207,12 @@ namespace Server.Misc public virtual bool IntersectsWith(Rectangle2D area) { for (var i = 0; i < Area.Length; ++i) + { if (CheckIntersection(area, Area[i])) + { return true; + } + } return false; } @@ -198,7 +220,9 @@ namespace Server.Misc public virtual void Reposition() { if (Area.Length == 0) + { return; + } var width = Area[0].Width; var height = Area[0].Height; @@ -216,14 +240,20 @@ namespace Server.Misc ); if (!CheckWeatherConflict(Facet, this, area)) + { isValid = true; + } if (isValid) + { break; + } } if (!isValid) + { return; + } Area[0] = area; } @@ -242,7 +272,9 @@ namespace Server.Misc public virtual void MoveForward() { if (Area.Length == 0) + { return; + } for (var i = 0; i < 5; ++i) // try 5 times to find a valid spot { @@ -279,13 +311,17 @@ namespace Server.Misc if (m_Active) { if (m_Stage > 0 && MoveSpeed > 0) + { MoveForward(); + } int type, density; var temperature = Temperature; if (m_ExtremeTemperature) + { temperature *= -1; + } if (m_Stage < 15) { @@ -296,17 +332,27 @@ namespace Server.Misc density = 150 - m_Stage * 5; if (density < 10) + { density = 10; + } else if (density > 70) + { density = 70; + } } if (density == 0) + { type = 0xFE; + } else if (temperature > 0) + { type = 0; + } else + { type = 2; + } var states = TcpServer.Instances; @@ -318,18 +364,26 @@ namespace Server.Misc var mob = ns.Mobile; if (mob == null || mob.Map != Facet) + { continue; + } var contains = Area.Length == 0; for (var j = 0; !contains && j < Area.Length; ++j) + { contains = Area[j].Contains(mob.Location); + } if (!contains) + { continue; + } if (weatherPacket == null) + { weatherPacket = Packet.Acquire(new Network.Weather(type, density, temperature)); + } ns.Send(weatherPacket); } @@ -361,7 +415,9 @@ namespace Server.Misc var facet = from.Map; if (facet == null) + { return; + } var list = Weather.GetWeatherList(facet); @@ -372,7 +428,9 @@ namespace Server.Misc var w = list[i]; for (var 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); + } } base.OnDoubleClick(from); diff --git a/Projects/UOContent/Misc/WebStatus.cs b/Projects/UOContent/Misc/WebStatus.cs index 96d0089ee..831f9ecdd 100644 --- a/Projects/UOContent/Misc/WebStatus.cs +++ b/Projects/UOContent/Misc/WebStatus.cs @@ -25,7 +25,10 @@ namespace Server.Misc public static void Initialize() { - if (!Enabled) return; + if (!Enabled) + { + return; + } new StatusPage().Start(); @@ -34,7 +37,10 @@ namespace Server.Misc private static void Listen() { - if (!HttpListener.IsSupported) return; + if (!HttpListener.IsSupported) + { + return; + } if (_Listener == null) { @@ -47,7 +53,10 @@ namespace Server.Misc _Listener.Start(); } - if (_Listener.IsListening) _Listener.BeginGetContext(ListenerCallback, null); + if (_Listener.IsListening) + { + _Listener.BeginGetContext(ListenerCallback, null); + } } private static void ListenerCallback(IAsyncResult result) @@ -90,7 +99,10 @@ namespace Server.Misc protected override void OnTick() { - if (!Directory.Exists("web")) Directory.CreateDirectory("web"); + if (!Directory.Exists("web")) + { + Directory.CreateDirectory("web"); + } using (var op = new StreamWriter("web/status.html")) { diff --git a/Projects/UOContent/Misc/WeightOverloading.cs b/Projects/UOContent/Misc/WeightOverloading.cs index 806494215..219bd4724 100644 --- a/Projects/UOContent/Misc/WeightOverloading.cs +++ b/Projects/UOContent/Misc/WeightOverloading.cs @@ -40,7 +40,9 @@ namespace Server.Misc } if (fatigue > 0) + { m.Stam -= (int)fatigue; + } } public static int GetMaxWeight(Mobile m) => m.MaxWeight; @@ -50,7 +52,9 @@ namespace Server.Misc var from = e.Mobile; if (!from.Alive || from.AccessLevel > AccessLevel.Player) + { return; + } if (!from.Player) { @@ -77,7 +81,9 @@ namespace Server.Misc } if (from.Stam * 100 / Math.Max(from.StamMax, 1) < 10) - --from.Stam; + { + --@from.Stam; + } if (from.Stam == 0) { @@ -91,7 +97,9 @@ namespace Server.Misc var amt = pm.Mounted ? 48 : 16; if (++pm.StepsTaken % amt == 0) + { --pm.Stam; + } } DeathStrike.AddStep(from); @@ -102,10 +110,14 @@ namespace Server.Misc var loss = 5 + overWeight / 25; if (from.Mounted) + { loss /= 3; + } if (running) + { loss *= 2; + } return loss; } @@ -113,7 +125,9 @@ namespace Server.Misc public static bool IsOverloaded(Mobile m) { if (!m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player) + { return false; + } return Mobile.BodyWeight + m.TotalWeight > GetMaxWeight(m) + OverloadAllowance; } diff --git a/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs b/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs index 68ca820ee..4af5b68bc 100644 --- a/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs +++ b/Projects/UOContent/Mobiles/AI/AIControlMobileTarget.cs @@ -25,14 +25,20 @@ namespace Server.Targets public void AddAI(BaseAI ai) { if (!m_List.Contains(ai)) + { m_List.Add(ai); + } } protected override void OnTarget(Mobile from, object o) { if (o is Mobile m) + { for (var i = 0; i < m_List.Count; ++i) - m_List[i].EndPickTarget(from, m, Order); + { + m_List[i].EndPickTarget(@from, m, Order); + } + } } } } diff --git a/Projects/UOContent/Mobiles/AI/AnimalAI.cs b/Projects/UOContent/Mobiles/AI/AnimalAI.cs index 36357ef10..9e89e7475 100644 --- a/Projects/UOContent/Mobiles/AI/AnimalAI.cs +++ b/Projects/UOContent/Mobiles/AI/AnimalAI.cs @@ -29,7 +29,9 @@ namespace Server.Mobiles else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have detected {0}, attacking", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; @@ -64,7 +66,9 @@ namespace Server.Mobiles if (m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I cannot find {0}", combatant.Name); + } Action = ActionType.Wander; @@ -72,7 +76,9 @@ namespace Server.Mobiles } if (m_Mobile.Debug) + { m_Mobile.DebugSay("I should be closer to {0}", combatant.Name); + } } if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee) diff --git a/Projects/UOContent/Mobiles/AI/ArcherAI.cs b/Projects/UOContent/Mobiles/AI/ArcherAI.cs index 68c62c311..93a2f8871 100644 --- a/Projects/UOContent/Mobiles/AI/ArcherAI.cs +++ b/Projects/UOContent/Mobiles/AI/ArcherAI.cs @@ -15,7 +15,9 @@ namespace Server.Mobiles if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have detected {0} and I will attack", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; @@ -50,12 +52,16 @@ namespace Server.Mobiles if (m_Mobile.Combatant != null) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I am still not in range of {0}", m_Mobile.Combatant.Name); + } if ((int)m_Mobile.GetDistanceToSqrt(m_Mobile.Combatant) > m_Mobile.RangePerception + 1) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have lost {0}", m_Mobile.Combatant.Name); + } m_Mobile.Combatant = null; Action = ActionType.Guard; @@ -84,15 +90,22 @@ namespace Server.Mobiles var iDiff = m_Mobile.Combatant.Hits - m_Mobile.Hits; if (Utility.Random(0, 100) > 10 + iDiff) // 10% to flee + the diff of hits + { bFlee = true; + } } else if (m_Mobile.Combatant != null && m_Mobile.Hits >= m_Mobile.Combatant.Hits) { if (Utility.Random(0, 100) > 10) // 10% to flee + { bFlee = true; + } } - if (bFlee) Action = ActionType.Flee; + if (bFlee) + { + Action = ActionType.Flee; + } } return true; @@ -103,7 +116,9 @@ namespace Server.Mobiles if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have detected {0}, attacking", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index 91291da1b..90b87b102 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -114,16 +114,26 @@ namespace Server.Mobiles bool activate; if (!m.PlayerRangeSensitive) + { activate = true; + } else if (World.Loading) + { activate = false; + } else if (m.Map == null || m.Map == Map.Internal || !m.Map.GetSector(m).Active) + { activate = false; + } else + { activate = true; + } if (activate) + { m_Timer.Start(); + } Action = ActionType.Wander; } @@ -159,7 +169,9 @@ namespace Server.Mobiles list.Add(new InternalEntry(from, 6108, 14, m_Mobile, this, OrderType.Follow)); // Command: Follow if (m_Mobile.CanDrop) - list.Add(new InternalEntry(from, 6109, 14, m_Mobile, this, OrderType.Drop)); // Command: Drop + { + list.Add(new InternalEntry(@from, 6109, 14, m_Mobile, this, OrderType.Drop)); // Command: Drop + } list.Add(new InternalEntry(from, 6111, 14, m_Mobile, this, OrderType.Attack)); // Command: Kill @@ -187,31 +199,46 @@ namespace Server.Mobiles public virtual void BeginPickTarget(Mobile from, OrderType order) { if (m_Mobile.Deleted || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map) + { return; + } var isOwner = from == m_Mobile.ControlMaster; var isFriend = !isOwner && m_Mobile.IsPetFriend(from); if (!isOwner && !isFriend) + { return; + } + if (isFriend && order != OrderType.Follow && order != OrderType.Stay && order != OrderType.Stop) + { return; + } if (from.Target == null) { if (order == OrderType.Transfer) - from.SendLocalizedMessage(502038); // Click on the person to transfer ownership to. + { + @from.SendLocalizedMessage(502038); // Click on the person to transfer ownership to. + } else if (order == OrderType.Friend) - from.SendLocalizedMessage(502020); // Click on the player whom you wish to make a co-owner. + { + @from.SendLocalizedMessage(502020); // Click on the player whom you wish to make a co-owner. + } else if (order == OrderType.Unfriend) - from.SendLocalizedMessage(1070948); // Click on the player whom you wish to remove as a co-owner. + { + @from.SendLocalizedMessage(1070948); // Click on the player whom you wish to remove as a co-owner. + } from.Target = new AIControlMobileTarget(this, order); } else if (from.Target is AIControlMobileTarget t) { if (t.Order == order) + { t.AddAI(this); + } } } @@ -221,22 +248,31 @@ namespace Server.Mobiles if (currentCombat != null && !aggressor.Hidden && currentCombat != aggressor && m_Mobile.GetDistanceToSqrt(currentCombat) > m_Mobile.GetDistanceToSqrt(aggressor)) + { m_Mobile.Combatant = aggressor; + } } public virtual void EndPickTarget(Mobile from, Mobile target, OrderType order) { if (m_Mobile.Deleted || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map || !from.CheckAlive()) + { return; + } var isOwner = from == m_Mobile.ControlMaster; var isFriend = !isOwner && m_Mobile.IsPetFriend(from); if (!isOwner && !isFriend) + { return; + } + if (isFriend && order != OrderType.Follow && order != OrderType.Stay && order != OrderType.Stop) + { return; + } if (order == OrderType.Attack) { @@ -280,11 +316,15 @@ namespace Server.Mobiles public virtual bool HandlesOnSpeech(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (from.Alive && m_Mobile.Controlled && m_Mobile.Commandable && (from == m_Mobile.ControlMaster || m_Mobile.IsPetFriend(from))) + { return true; + } return from.Alive && from.InRange(m_Mobile.Location, 3) && m_Mobile.IsHumanInTown(); } @@ -346,17 +386,23 @@ namespace Server.Mobiles var toTeach = skill.Base / 3.0; if (toTeach > 42.0) + { toTeach = 42.0; + } if (toTeach > theirSkill.Base) { var number = 1043059 + i; if (number > 1043107) + { continue; + } if (!foundSomething) + { m_Mobile.Say(1043058); // I can train the following: + } m_Mobile.Say(number); @@ -366,7 +412,9 @@ namespace Server.Mobiles } if (!foundSomething) + { m_Mobile.Say(501505); // Alas, I cannot teach thee anything. + } } } else @@ -386,7 +434,9 @@ namespace Server.Mobiles var index = keyword - 0x6D; if (index >= 0 && index < m_KeywordTable.Length) + { toTrain = m_KeywordTable[index]; + } } } @@ -403,9 +453,13 @@ namespace Server.Mobiles var skill = skills[toTrain]; if (skill == null || skill.Base < 60.0 || !m_Mobile.CheckTeach(toTrain, e.Mobile)) + { m_Mobile.Say(501507); // 'Tis not something I can teach thee of. + } else + { m_Mobile.Teach(toTrain, e.Mobile, 0, false); + } } } } @@ -435,7 +489,9 @@ namespace Server.Mobiles case 0x164: // all come { if (!isOwner) + { break; + } if (m_Mobile.CheckControlChance(e.Mobile)) { @@ -454,7 +510,9 @@ namespace Server.Mobiles case 0x16B: // all guard me { if (!isOwner) + { break; + } if (m_Mobile.CheckControlChance(e.Mobile)) { @@ -478,7 +536,9 @@ namespace Server.Mobiles case 0x169: // all attack { if (!isOwner) + { break; + } BeginPickTarget(e.Mobile, OrderType.Attack); return; @@ -516,7 +576,9 @@ namespace Server.Mobiles case 0x155: // *come { if (!isOwner) + { break; + } if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { @@ -529,7 +591,9 @@ namespace Server.Mobiles case 0x156: // *drop { if (!isOwner) + { break; + } if (!m_Mobile.IsDeadPet && !m_Mobile.Summoned && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) @@ -543,27 +607,37 @@ namespace Server.Mobiles case 0x15A: // *follow { if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { BeginPickTarget(e.Mobile, OrderType.Follow); + } return; } case 0x15B: // *friend { if (!isOwner) + { break; + } if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { if (m_Mobile.Summoned || m_Mobile is GrizzledMare) + { e.Mobile.SendLocalizedMessage( 1005481 ); // Summoned creatures are loyal only to their summoners. + } else if (e.Mobile.HasTrade) + { e.Mobile.SendLocalizedMessage( 1070947 ); // You cannot friend a pet with a trade pending + } else + { BeginPickTarget(e.Mobile, OrderType.Friend); + } } return; @@ -571,7 +645,9 @@ namespace Server.Mobiles case 0x15C: // *guard { if (!isOwner) + { break; + } if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { @@ -585,17 +661,23 @@ namespace Server.Mobiles case 0x15E: // *attack { if (!isOwner) + { break; + } if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { BeginPickTarget(e.Mobile, OrderType.Attack); + } return; } case 0x15F: // *patrol { if (!isOwner) + { break; + } if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { @@ -628,7 +710,9 @@ namespace Server.Mobiles case 0x16D: // *release { if (!isOwner) + { break; + } if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { @@ -648,20 +732,28 @@ namespace Server.Mobiles case 0x16E: // *transfer { if (!isOwner) + { break; + } if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { if (m_Mobile.Summoned || m_Mobile is GrizzledMare) + { e.Mobile.SendLocalizedMessage( 1005487 ); // You cannot transfer ownership of a summoned creature. + } else if (e.Mobile.HasTrade) + { e.Mobile.SendLocalizedMessage( 1010507 ); // You cannot transfer a pet with a trade pending + } else + { BeginPickTarget(e.Mobile, OrderType.Transfer); + } } return; @@ -700,7 +792,9 @@ namespace Server.Mobiles m_Mobile.SetControlMaster(e.Mobile); if (m_Mobile.Summoned) + { m_Mobile.SummonMaster = e.Mobile; + } return; } @@ -713,10 +807,14 @@ namespace Server.Mobiles public virtual bool Think() { if (m_Mobile.Deleted) + { return false; + } if (CheckFlee()) + { return true; + } switch (Action) { @@ -815,7 +913,9 @@ namespace Server.Mobiles m_Mobile.DebugSay("I will go to the next waypoint"); m_Mobile.CurrentWayPoint = point.NextPoint; if (point.NextPoint?.Deleted == true) + { m_Mobile.CurrentWayPoint = point.NextPoint = point.NextPoint.NextPoint; + } } } else if (m_Mobile.IsAnimatedDead) @@ -824,18 +924,27 @@ namespace Server.Mobiles var master = m_Mobile.SummonMaster; if (master != null && master.Map == m_Mobile.Map && master.InRange(m_Mobile, m_Mobile.RangePerception)) + { MoveTo(master, false, 1); + } else + { WalkRandomInHome(2, 2, 1); + } } else if (CheckMove()) { if (!m_Mobile.CheckIdle()) + { WalkRandomInHome(2, 2, 1); + } } if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); + !m_Mobile.Combatant.IsDeadBondedPet) + { + m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); + } return true; } @@ -851,9 +960,13 @@ namespace Server.Mobiles var c = m_Mobile.Combatant; if (c?.Deleted != false || c.Map != m_Mobile.Map || !c.Alive || c.IsDeadBondedPet) + { Action = ActionType.Wander; + } else + { m_Mobile.Direction = m_Mobile.GetDirectionTo(c); + } } return true; @@ -909,7 +1022,9 @@ namespace Server.Mobiles public virtual bool Obey() { if (m_Mobile.Deleted) + { return false; + } return m_Mobile.ControlOrder switch { @@ -933,7 +1048,9 @@ namespace Server.Mobiles public virtual void OnCurrentOrderChanged() { if (m_Mobile.Deleted || m_Mobile.ControlMaster?.Deleted != false) + { return; + } switch (m_Mobile.ControlOrder) { @@ -1062,7 +1179,9 @@ namespace Server.Mobiles public virtual bool DoOrderCome() { if (m_Mobile.ControlMaster?.Deleted != false) + { return true; + } var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlMaster); @@ -1100,7 +1219,9 @@ namespace Server.Mobiles public virtual bool DoOrderDrop() { if (m_Mobile.IsDeadPet || !m_Mobile.CanDrop) + { return true; + } m_Mobile.DebugSay("I drop my stuff for my master"); @@ -1111,8 +1232,12 @@ namespace Server.Mobiles var list = pack.Items; for (var i = list.Count - 1; i >= 0; --i) + { if (i < list.Count) + { list[i].MoveToWorld(m_Mobile.Location, m_Mobile.Map); + } + } } m_Mobile.ControlTarget = null; @@ -1126,7 +1251,9 @@ namespace Server.Mobiles var target = m_Mobile.TargetLocation; if (target == null) + { return false; // Creature is not being herded + } var distance = m_Mobile.GetDistanceToSqrt(target); @@ -1137,6 +1264,7 @@ namespace Server.Mobiles } if (distance < 1 && target.X == 1076 && target.Y == 450 && m_Mobile is HordeMinionFamiliar) + { if (m_Mobile.ControlMaster is PlayerMobile pm) { var qs = pm.Quest; @@ -1152,6 +1280,7 @@ namespace Server.Mobiles } } } + } m_Mobile.TargetLocation = null; return false; // At the target or too far away @@ -1201,7 +1330,9 @@ namespace Server.Mobiles { m_Mobile.Warmode = false; if (Core.AOS) + { m_Mobile.CurrentSpeed = 0.1; + } } } } @@ -1324,12 +1455,16 @@ namespace Server.Mobiles public virtual bool DoOrderGuard() { if (m_Mobile.IsDeadPet) + { return true; + } var controlMaster = m_Mobile.ControlMaster; if (controlMaster?.Deleted != false) + { return true; + } var combatant = m_Mobile.Combatant; @@ -1344,13 +1479,19 @@ namespace Server.Mobiles if (attacker?.Deleted == false && attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception) + { if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) < combatant.GetDistanceToSqrt(controlMaster)) + { combatant = attacker; + } + } } if (combatant != null) + { m_Mobile.DebugSay("Crap, my master has been attacked! I will attack one of those bastards!"); + } } if (combatant?.Deleted == false && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && @@ -1375,7 +1516,9 @@ namespace Server.Mobiles m_Mobile.Warmode = false; if (Core.AOS) + { m_Mobile.CurrentSpeed = 0.1; + } WalkMobileRange(controlMaster, 1, false, 0, 1); } @@ -1386,7 +1529,9 @@ namespace Server.Mobiles public virtual bool DoOrderAttack() { if (m_Mobile.IsDeadPet) + { return true; + } if (m_Mobile.ControlTarget?.Deleted != false || m_Mobile.ControlTarget.Map != m_Mobile.Map || !m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet) @@ -1414,10 +1559,14 @@ namespace Server.Mobiles foreach (var aggr in m_Mobile.GetMobilesInRange(m_Mobile.RangePerception)) { if (!m_Mobile.CanSee(aggr) || aggr.Combatant != m_Mobile) + { continue; + } if (aggr.IsDeadBondedPet || !aggr.Alive) + { continue; + } var aggrScore = m_Mobile.GetFightModeRanking(aggr, FightMode.Closest, false); @@ -1475,7 +1624,9 @@ namespace Server.Mobiles } if (m_Mobile.DeleteOnRelease || m_Mobile.IsDeadPet) + { m_Mobile.Delete(); + } m_Mobile.BeginDeleteTimer(); m_Mobile.DropBackpack(); @@ -1486,9 +1637,13 @@ namespace Server.Mobiles public virtual bool DoOrderStay() { if (CheckHerding()) + { m_Mobile.DebugSay("Praise the shepherd!"); + } else + { m_Mobile.DebugSay("My master told me to stay"); + } // m_Mobile.Direction = m_Mobile.GetDirectionTo( m_Mobile.ControlMaster ); @@ -1498,7 +1653,9 @@ namespace Server.Mobiles public virtual bool DoOrderStop() { if (m_Mobile.ControlMaster?.Deleted != false) + { return true; + } m_Mobile.DebugSay("My master told me to stop."); @@ -1508,9 +1665,13 @@ namespace Server.Mobiles m_Mobile.ControlTarget = null; if (Core.ML) + { WalkRandomInHome(3, 2, 1); + } else + { m_Mobile.ControlOrder = OrderType.None; + } return true; } @@ -1518,7 +1679,9 @@ namespace Server.Mobiles public virtual bool DoOrderTransfer() { if (m_Mobile.IsDeadPet) + { return true; + } var from = m_Mobile.ControlMaster; var to = m_Mobile.ControlTarget; @@ -1659,9 +1822,12 @@ namespace Server.Mobiles public virtual void WalkRandom(int iChanceToNotMove, int iChanceToDir, int iSteps) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) + { return; + } for (var i = 0; i < iSteps; i++) + { if (Utility.Random(8 * iChanceToNotMove) <= 8) { var iRndMove = Utility.Random(0, 8 + 9 * iChanceToDir); @@ -1697,6 +1863,7 @@ namespace Server.Mobiles break; } } + } } public double TransformMoveDelay(double delay) @@ -1705,22 +1872,38 @@ namespace Server.Mobiles var isControlled = m_Mobile.Controlled || m_Mobile.Summoned; if (delay == 0.2) + { delay = 0.3; + } else if (delay == 0.25) + { delay = 0.45; + } else if (delay == 0.3) + { delay = 0.6; + } else if (delay == 0.4) + { delay = 0.9; + } else if (delay == 0.5) + { delay = 1.05; + } else if (delay == 0.6) + { delay = 1.2; + } else if (delay == 0.8) + { delay = 1.5; + } if (isPassive) + { delay += 0.2; + } if (!isControlled) { @@ -1729,7 +1912,9 @@ namespace Server.Mobiles else if (m_Mobile.Controlled) { if (m_Mobile.ControlOrder == OrderType.Follow && m_Mobile.ControlTarget == m_Mobile.ControlMaster) + { delay *= 0.5; + } delay -= 0.075; } @@ -1739,9 +1924,13 @@ namespace Server.Mobiles var offset = (double)m_Mobile.Hits / m_Mobile.HitsMax; if (offset < 0.0) + { offset = 0.0; + } else if (offset > 1.0) + { offset = 1.0; + } offset = 1.0 - offset; @@ -1749,7 +1938,9 @@ namespace Server.Mobiles } if (delay < 0.0) + { delay = 0.0; + } if (double.IsNaN(delay)) { @@ -1782,9 +1973,14 @@ namespace Server.Mobiles { if (m_Mobile.Deleted || m_Mobile.Frozen || m_Mobile.Paralyzed || m_Mobile.Spell?.IsCasting == true || m_Mobile.DisallowAllMoves) + { return MoveResult.BadState; + } + if (!CheckMove()) + { return MoveResult.BadState; + } // This makes them always move one step, never any direction changes m_Mobile.Direction = d; @@ -1794,7 +1990,9 @@ namespace Server.Mobiles NextMove += delay; if (Core.TickCount - NextMove > 0) + { NextMove = Core.TickCount; + } m_Mobile.Pushing = false; @@ -1833,35 +2031,49 @@ namespace Server.Mobiles var eable = map.GetItemsInRange(new Point3D(x, y, m_Mobile.Location.Z), 1); foreach (var item in eable) + { if (canOpenDoors && item is BaseDoor door && door.Z + door.ItemData.Height > m_Mobile.Z && m_Mobile.Z + 16 > door.Z) { if (door.X != x || door.Y != y) + { continue; + } if (!door.Locked || !door.UseLocks()) + { m_Obstacles.Enqueue(door); + } if (!canDestroyObstacles) + { break; + } } else if (canDestroyObstacles && item.Movable && item.ItemData.Impassable && item.Z + item.ItemData.Height > m_Mobile.Z && m_Mobile.Z + 16 > item.Z) { if (!m_Mobile.InRange(item.GetWorldLocation(), 1)) + { continue; + } m_Obstacles.Enqueue(item); ++destroyables; } + } eable.Free(); if (destroyables > 0) + { Effects.PlaySound(new Point3D(x, y, m_Mobile.Z), m_Mobile.Map, 0x3B3); + } if (m_Obstacles.Count > 0) + { blocked = false; // retry movement + } while (m_Obstacles.Count > 0) { @@ -1891,7 +2103,9 @@ namespace Server.Mobiles if (check.Movable && check.ItemData.Impassable && cont.Z + check.ItemData.Height > m_Mobile.Z) + { m_Obstacles.Enqueue(check); + } } cont.Destroy(); @@ -1904,7 +2118,9 @@ namespace Server.Mobiles } if (!blocked) + { blocked = !m_Mobile.Move(d); + } } } @@ -1938,7 +2154,9 @@ namespace Server.Mobiles public virtual void WalkRandomInHome(int iChanceToNotMove, int iChanceToDir, int iSteps) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) + { return; + } if (m_Mobile.Home == Point3D.Zero) { @@ -1955,9 +2173,13 @@ namespace Server.Mobiles else { if (region.GoLocation != Point3D.Zero && Utility.Random(10) > 5) + { DoMove(m_Mobile.GetDirectionTo(region.GoLocation)); + } else + { WalkRandom(iChanceToNotMove, iChanceToDir, 1); + } } } else @@ -1968,6 +2190,7 @@ namespace Server.Mobiles else { for (var i = 0; i < iSteps; i++) + { if (m_Mobile.RangeHome != 0) { var iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.Home); @@ -1983,15 +2206,23 @@ namespace Server.Mobiles else { if (Utility.Random(10) > 5) + { DoMove(m_Mobile.GetDirectionTo(m_Mobile.Home)); + } else + { WalkRandom(iChanceToNotMove, iChanceToDir, 1); + } } } else { - if (m_Mobile.Location != m_Mobile.Home) DoMove(m_Mobile.GetDirectionTo(m_Mobile.Home)); + if (m_Mobile.Location != m_Mobile.Home) + { + DoMove(m_Mobile.GetDirectionTo(m_Mobile.Home)); + } } + } } } @@ -2033,7 +2264,9 @@ namespace Server.Mobiles public virtual bool MoveTo(Mobile m, bool run, int range) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m?.Deleted != false) + { return false; + } if (m_Mobile.InRange(m, range)) { @@ -2081,10 +2314,14 @@ namespace Server.Mobiles public virtual bool WalkMobileRange(Mobile m, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) + { return false; + } if (m == null) + { return false; + } for (var i = 0; i < iSteps; i++) { @@ -2099,27 +2336,37 @@ namespace Server.Mobiles if (needCloser && m_Path != null && m_Path.Goal == m) { if (m_Path.Follow(bRun, 1)) + { m_Path = null; + } } else { Direction dirTo; if (iCurrDist > iWantDistMax) + { dirTo = m_Mobile.GetDirectionTo(m); + } else + { dirTo = m.GetDirectionTo(m_Mobile); + } // Add the run flag if (bRun) + { dirTo = dirTo | Direction.Running; + } if (!DoMove(dirTo, true) && needCloser) { m_Path = new PathFollower(m_Mobile, m) { Mover = DoMoveImpl }; if (m_Path.Follow(bRun, 1)) + { m_Path = null; + } } else { @@ -2137,7 +2384,9 @@ namespace Server.Mobiles var iNewDist = (int)m_Mobile.GetDistanceToSqrt(m); if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax) + { return true; + } return false; } @@ -2155,7 +2404,9 @@ namespace Server.Mobiles public virtual bool AcquireFocusMob(int iRange, FightMode acqType, bool bPlayerOnly, bool bFacFriend, bool bFacFoe) { if (m_Mobile.Deleted) + { return false; + } if (m_Mobile.BardProvoked) { @@ -2176,7 +2427,9 @@ namespace Server.Mobiles !m_Mobile.InRange(m_Mobile.ControlTarget, m_Mobile.RangePerception * 2)) { if (m_Mobile.ControlTarget != null && m_Mobile.ControlTarget != m_Mobile.ControlMaster) + { m_Mobile.ControlTarget = null; + } m_Mobile.FocusMob = null; return false; @@ -2228,89 +2481,127 @@ namespace Server.Mobiles foreach (var m in eable) { if (m.Deleted || m.Blessed) + { continue; + } // Let's not target ourselves... if (m == m_Mobile || m is BaseFamiliar) + { continue; + } // Dead targets are invalid. if (!m.Alive || m.IsDeadBondedPet) + { continue; + } // Staff members cannot be targeted. if (m.AccessLevel > AccessLevel.Player) + { continue; + } // Does it have to be a player? if (bPlayerOnly && !m.Player) + { continue; + } // Can't acquire a target we can't see. if (!m_Mobile.CanSee(m)) + { continue; + } var bc = m as BaseCreature; var pm = m as PlayerMobile; if (Core.AOS && bc?.Summoned == true && bc?.Controlled != true) + { continue; + } if (m_Mobile.Summoned && m_Mobile.SummonMaster != null) { // If this is a summon, it can't target its controller. if (m == m_Mobile.SummonMaster) + { continue; + } // It also must abide by harmful spell rules. if (!SpellHelper.ValidIndirectTarget(m_Mobile.SummonMaster, m)) + { continue; + } // Animated creatures cannot attack players directly. if (pm != null && m_Mobile.IsAnimatedDead) + { continue; + } } // If we only want faction friends, make sure it's one. if (bFacFriend && !m_Mobile.IsFriend(m)) + { continue; + } // Ignore anyone under EtherealVoyage if (TransformationSpellHelper.UnderTransformation(m, typeof(EtherealVoyageSpell))) + { continue; + } // Ignore players with activated honor if (pm?.HonorActive == true && m_Mobile.Combatant != m) + { continue; + } if (acqType == FightMode.Aggressor || acqType == FightMode.Evil) { var bValid = IsHostile(m); if (!bValid) + { bValid = m_Mobile.GetFactionAllegiance(m) == BaseCreature.Allegiance.Enemy || m_Mobile.GetEthicAllegiance(m) == BaseCreature.Allegiance.Enemy; + } if (acqType == FightMode.Evil && !bValid) { if (bc?.Controlled == true && bc?.ControlMaster != null) + { bValid = bc.ControlMaster.Karma < 0; + } else + { bValid = m.Karma < 0; + } } if (!bValid) + { continue; + } } else { // Same goes for faction enemies. if (bFacFoe && !m_Mobile.IsEnemy(m)) + { continue; + } // If it's an enemy factioned mobile, make sure we can be harmful to it. if (bFacFoe && !bFacFriend && !m_Mobile.CanBeHarmful(m, false)) + { continue; + } } var theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly); @@ -2334,15 +2625,26 @@ namespace Server.Mobiles { var count = Math.Max(m_Mobile.Aggressors.Count, m_Mobile.Aggressed.Count); - if (m_Mobile.Combatant == from || from.Combatant == m_Mobile) return true; + if (m_Mobile.Combatant == from || from.Combatant == m_Mobile) + { + return true; + } if (count > 0) + { for (var a = 0; a < count; ++a) { - if (a < m_Mobile.Aggressed.Count && m_Mobile.Aggressed[a].Attacker == from) return true; + if (a < m_Mobile.Aggressed.Count && m_Mobile.Aggressed[a].Attacker == @from) + { + return true; + } - if (a < m_Mobile.Aggressors.Count && m_Mobile.Aggressors[a].Defender == from) return true; + if (a < m_Mobile.Aggressors.Count && m_Mobile.Aggressors[a].Defender == @from) + { + return true; + } } + } return false; } @@ -2350,18 +2652,23 @@ namespace Server.Mobiles public virtual void DetectHidden() { if (m_Mobile.Deleted || m_Mobile.Map == null) + { return; + } m_Mobile.DebugSay("Checking for hidden players"); var srcSkill = m_Mobile.Skills.DetectHidden.Value; if (srcSkill <= 0) + { return; + } var eable = m_Mobile.GetMobilesInRange(m_Mobile.RangePerception); foreach (var trg in eable) + { if (trg != m_Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player && m_Mobile.InLOS(trg)) { @@ -2373,7 +2680,9 @@ namespace Server.Mobiles var chance = srcSkill / 1.2 - Math.Min(trgHiding, trgStealth); if (chance < srcSkill / 10) + { chance = srcSkill / 10; + } chance /= 100; @@ -2383,6 +2692,7 @@ namespace Server.Mobiles trg.SendLocalizedMessage(500814); // You have been revealed! } } + } eable.Free(); } @@ -2399,7 +2709,9 @@ namespace Server.Mobiles spawner.HomeLocation == Point3D.Zero && !m_Mobile.Region.AcceptsSpawnsFrom(spawner.Region) || !m_Mobile.InRange(spawner.HomeLocation, spawner.HomeRange) )) + { Timer.DelayCall(ReturnToHome); + } } } @@ -2409,7 +2721,10 @@ namespace Server.Mobiles { var loc = m_Mobile.Spawner.GetSpawnPosition(m_Mobile, m_Mobile.Spawner.Map); - if (loc != Point3D.Zero) m_Mobile.MoveToWorld(loc, m_Mobile.Spawner.Map); + if (loc != Point3D.Zero) + { + m_Mobile.MoveToWorld(loc, m_Mobile.Spawner.Map); + } } } @@ -2450,7 +2765,9 @@ namespace Server.Mobiles if (mobile.IsDeadPet && (order == OrderType.Guard || order == OrderType.Attack || order == OrderType.Transfer || order == OrderType.Drop)) + { Enabled = false; + } } public override void OnClick() @@ -2459,15 +2776,22 @@ namespace Server.Mobiles { if (m_Mobile.IsDeadPet && (m_Order == OrderType.Guard || m_Order == OrderType.Attack || m_Order == OrderType.Transfer || m_Order == OrderType.Drop)) + { return; + } var isOwner = m_From == m_Mobile.ControlMaster; var isFriend = !isOwner && m_Mobile.IsPetFriend(m_From); if (!isOwner && !isFriend) + { return; + } + if (isFriend && m_Order != OrderType.Follow && m_Order != OrderType.Stay && m_Order != OrderType.Stop) + { return; + } switch (m_Order) { @@ -2478,18 +2802,27 @@ namespace Server.Mobiles case OrderType.Unfriend: { if (m_Order == OrderType.Transfer && m_From.HasTrade) + { m_From.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending + } else if (m_Order == OrderType.Friend && m_From.HasTrade) + { m_From.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending + } else + { m_AI.BeginPickTarget(m_From, m_Order); + } break; } case OrderType.Release: { if (m_Mobile.Summoned) + { goto default; + } + m_From.SendGump(new ConfirmReleaseGump(m_From, m_Mobile)); break; @@ -2497,7 +2830,9 @@ namespace Server.Mobiles default: { if (m_Mobile.CheckControlChance(m_From)) + { m_Mobile.ControlOrder = m_Order; + } break; } @@ -2518,10 +2853,14 @@ namespace Server.Mobiles Movable = false; if (!Core.AOS) + { Name = creature.Name; + } else if (ItemID == ShrinkTable.DefaultItemID || creature.GetType().IsDefined(typeof(FriendlyNameAttribute), false) || creature is Reptalon) + { Name = FriendlyNameAttribute.GetFriendlyNameFor(creature.GetType()).ToString(); + } // (As Per OSI)No name. Normally, set by the ItemID of the Shrink Item unless we either explicitly set it with an Attribute, or, no lookup found @@ -2560,20 +2899,28 @@ namespace Server.Mobiles list.Add(1041601, m_Creature.Name); // Pet Name: ~1_val~ if (m_Creature.ControlMaster != null) + { list.Add(1041602, m_Creature.ControlMaster.Name); // Owner: ~1_val~ + } } public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { if (!base.AllowSecureTrade(from, to, newOwner, accepted)) + { return false; + } if (Deleted || m_Creature?.Deleted != false || m_Creature.ControlMaster != from || !from.CheckAlive() || !to.CheckAlive()) + { return false; + } if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14)) + { return false; + } var youngFrom = from is PlayerMobile mobile && mobile.Young; var youngTo = to is PlayerMobile playerMobile && playerMobile.Young; @@ -2634,22 +2981,31 @@ namespace Server.Mobiles public override void OnSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { if (Deleted) + { return; + } Delete(); if (m_Creature?.Deleted != false || m_Creature.ControlMaster != from || !from.CheckAlive() || !to.CheckAlive()) + { return; + } if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14)) + { return; + } if (accepted) + { if (m_Creature.SetControlMaster(to)) { if (m_Creature.Summoned) + { m_Creature.SummonMaster = to; + } m_Creature.ControlTarget = to; m_Creature.ControlOrder = OrderType.Follow; @@ -2660,14 +3016,15 @@ namespace Server.Mobiles m_Creature.PlaySound(m_Creature.GetIdleSound()); - var args = $"{from.Name}\t{m_Creature.Name}\t{to.Name}"; + var args = $"{@from.Name}\t{m_Creature.Name}\t{to.Name}"; - from.SendLocalizedMessage(1043253, args); // You have transferred your pet to ~3_GETTER~. + @from.SendLocalizedMessage(1043253, args); // You have transferred your pet to ~3_GETTER~. to.SendLocalizedMessage( 1043252, args ); // ~1_NAME~ has transferred the allegiance of ~2_PET_NAME~ to you. } + } } } diff --git a/Projects/UOContent/Mobiles/AI/BerserkAI.cs b/Projects/UOContent/Mobiles/AI/BerserkAI.cs index f89a6ad90..7e7a7f4c4 100644 --- a/Projects/UOContent/Mobiles/AI/BerserkAI.cs +++ b/Projects/UOContent/Mobiles/AI/BerserkAI.cs @@ -13,7 +13,9 @@ namespace Server.Mobiles if (AcquireFocusMob(m_Mobile.RangePerception, FightMode.Closest, false, true, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay($"I have detected {m_Mobile.FocusMob.Name} and I will attack"); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; @@ -45,12 +47,16 @@ namespace Server.Mobiles if (m_Mobile.Combatant != null) { if (m_Mobile.Debug) + { m_Mobile.DebugSay($"I am still not in range of {m_Mobile.Combatant.Name}"); + } if ((int)m_Mobile.GetDistanceToSqrt(m_Mobile.Combatant) > m_Mobile.RangePerception + 1) { if (m_Mobile.Debug) + { m_Mobile.DebugSay($"I have lost {m_Mobile.Combatant.Name}"); + } Action = ActionType.Guard; return true; @@ -66,7 +72,9 @@ namespace Server.Mobiles if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, true, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have detected {0}, attacking", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; diff --git a/Projects/UOContent/Mobiles/AI/HealerAI.cs b/Projects/UOContent/Mobiles/AI/HealerAI.cs index 13ee31e36..cf5d19824 100644 --- a/Projects/UOContent/Mobiles/AI/HealerAI.cs +++ b/Projects/UOContent/Mobiles/AI/HealerAI.cs @@ -23,7 +23,9 @@ namespace Server.Mobiles public override bool Think() { if (m_Mobile.Deleted) + { return false; + } var targ = m_Mobile.Target; @@ -32,13 +34,21 @@ namespace Server.Mobiles var spellTarg = targ as ISpellTarget; if (spellTarg?.Spell is CureSpell) + { ProcessTarget(targ, m_ACure); + } else if (spellTarg?.Spell is GreaterHealSpell) + { ProcessTarget(targ, m_AGHeal); + } else if (spellTarg?.Spell is HealSpell) + { ProcessTarget(targ, m_ALHeal); + } else + { targ.Cancel(m_Mobile, TargetCancelType.Canceled); + } } else { @@ -49,23 +59,33 @@ namespace Server.Mobiles if (NeedCure(toHelp)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} needs a cure", toHelp.Name); + } if (!new CureSpell(m_Mobile).Cast()) + { new CureSpell(m_Mobile).Cast(); + } } else if (NeedGHeal(toHelp)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} needs a greater heal", toHelp.Name); + } if (!new GreaterHealSpell(m_Mobile).Cast()) + { new HealSpell(m_Mobile).Cast(); + } } else if (NeedLHeal(toHelp)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} needs a lesser heal", toHelp.Name); + } new HealSpell(m_Mobile).Cast(); } @@ -73,9 +93,13 @@ namespace Server.Mobiles else { if (AcquireFocusMob(m_Mobile.RangePerception, FightMode.Weakest, false, true, false)) + { WalkMobileRange(m_Mobile.FocusMob, 1, false, 4, 7); + } else + { WalkRandomInHome(3, 2, 1); + } } } @@ -89,9 +113,13 @@ namespace Server.Mobiles if (toHelp != null) { if (targ.Range != -1 && !m_Mobile.InRange(toHelp, targ.Range)) + { DoMove(m_Mobile.GetDirectionTo(toHelp) | Direction.Running); + } else + { targ.Invoke(m_Mobile, toHelp); + } } else { @@ -102,7 +130,9 @@ namespace Server.Mobiles private Mobile Find(params NeedDelegate[] funcs) { if (m_Mobile.Deleted) + { return null; + } var map = m_Mobile.Map; @@ -114,9 +144,12 @@ namespace Server.Mobiles foreach (var m in m_Mobile.GetMobilesInRange(m_Mobile.RangePerception)) { if (!m_Mobile.CanSee(m) || !(m is BaseCreature) || ((BaseCreature)m).Team != m_Mobile.Team) + { continue; + } for (var i = 0; i < funcs.Length; ++i) + { if (funcs[i](m)) { var val = -m_Mobile.GetDistanceToSqrt(m); @@ -129,6 +162,7 @@ namespace Server.Mobiles break; } + } } return found; diff --git a/Projects/UOContent/Mobiles/AI/MageAI.cs b/Projects/UOContent/Mobiles/AI/MageAI.cs index 39136b683..93bc51226 100644 --- a/Projects/UOContent/Mobiles/AI/MageAI.cs +++ b/Projects/UOContent/Mobiles/AI/MageAI.cs @@ -68,10 +68,15 @@ namespace Server.Mobiles public override bool Think() { if (m_Mobile.Deleted) + { return false; + } if (ProcessTarget()) + { return true; + } + return base.Think(); } @@ -116,25 +121,37 @@ namespace Server.Mobiles { // If I'm poisoned, always attempt to cure. if (m_Mobile.Poisoned) + { return new CureSpell(m_Mobile); + } // Summoned creatures never heal themselves. if (m_Mobile.Summoned) + { return null; + } if (m_Mobile.Controlled) + { if (Core.TickCount - m_NextHealTime < 0) + { return null; + } + } if (!SmartAI) { if (ScaleBySkill(HealChance, SkillName.Magery) < Utility.RandomDouble()) + { return null; + } } else { if (Utility.Random(0, 4 + (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : m_Mobile.HitsMax / m_Mobile.Hits)) < 3) + { return null; + } } Spell spell = null; @@ -142,9 +159,13 @@ namespace Server.Mobiles if (m_Mobile.Hits < m_Mobile.HitsMax - 50) { if (UseNecromancy()) + { m_Mobile.UseSkill(SkillName.SpiritSpeak); + } else + { spell = new GreaterHealSpell(m_Mobile); + } } else if (m_Mobile.Hits < m_Mobile.HitsMax - 10) { @@ -154,9 +175,13 @@ namespace Server.Mobiles double delay; if (m_Mobile.Int >= 500) + { delay = Utility.RandomMinMax(7, 10); + } else + { delay = Math.Sqrt(600 - m_Mobile.Int); + } m_NextHealTime = Core.TickCount + (int)TimeSpan.FromSeconds(delay).TotalMilliseconds; @@ -168,7 +193,9 @@ namespace Server.Mobiles if (!SmartAI) { if (!MoveTo(m, true, m_Mobile.RangeFight)) + { OnFailedMove(); + } return; } @@ -176,16 +203,22 @@ namespace Server.Mobiles if (m.Paralyzed || m.Frozen) { if (m_Mobile.InRange(m, 1)) + { RunFrom(m); + } else if (!m_Mobile.InRange(m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2) && !MoveTo(m, true, 1)) + { OnFailedMove(); + } } else { if (!m_Mobile.InRange(m, m_Mobile.RangeFight)) { if (!MoveTo(m, true, 1)) + { OnFailedMove(); + } } else if (m_Mobile.InRange(m, m_Mobile.RangeFight - 1)) { @@ -228,22 +261,28 @@ namespace Server.Mobiles { if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen || m_Mobile.DisallowAllMoves) + { return; + } m_Mobile.Direction = d | Direction.Running; if (!DoMove(m_Mobile.Direction, true)) + { OnFailedMove(); + } } public virtual bool UseNecromancy() { if (IsNecromancer) + { return Utility.Random( m_Mobile.Skills.Magery.BaseFixedPoint + m_Mobile.Skills.Necromancy.BaseFixedPoint ) >= m_Mobile.Skills.Magery.BaseFixedPoint; + } return false; } @@ -322,7 +361,9 @@ namespace Server.Mobiles public virtual Spell GetRandomCurseSpellMage() { if (m_Mobile.Skills.Magery.Value >= 40.0 && Utility.Random(4) == 0) + { return new CurseSpell(m_Mobile); + } return Utility.Random(3) switch { @@ -335,7 +376,9 @@ namespace Server.Mobiles public virtual Spell GetRandomManaDrainSpell() { if (m_Mobile.Skills.Magery.Value >= 80.0 && Utility.RandomBool()) + { return new ManaVampireSpell(m_Mobile); + } return new ManaDrainSpell(m_Mobile); } @@ -345,7 +388,9 @@ namespace Server.Mobiles if (!SmartAI) { if (ScaleBySkill(DispelChance, SkillName.Magery) > Utility.RandomDouble()) + { return new DispelSpell(m_Mobile); + } return ChooseSpell(toDispel); } @@ -355,11 +400,17 @@ namespace Server.Mobiles if (spell == null) { if (!m_Mobile.DisallowAllMoves && Utility.Random((int)m_Mobile.GetDistanceToSqrt(toDispel)) == 0) + { spell = new TeleportSpell(m_Mobile); + } else if (Utility.Random(3) == 0 && !m_Mobile.InRange(toDispel, 3) && !toDispel.Paralyzed && !toDispel.Frozen) + { spell = new ParalyzeSpell(m_Mobile); + } else + { spell = new DispelSpell(m_Mobile); + } } return spell; @@ -374,7 +425,9 @@ namespace Server.Mobiles spell = CheckCastHealingSpell(); if (spell != null) + { return spell; + } if (IsNecromancer) { @@ -383,7 +436,9 @@ namespace Server.Mobiles (c.Player ? 18 : 30); if (psDamage > c.Hits) + { return new PainSpikeSpell(m_Mobile); + } } switch (Utility.Random(16)) @@ -392,7 +447,9 @@ namespace Server.Mobiles case 1: // Poison them { if (c.Poisoned) + { goto default; + } m_Mobile.DebugSay("Attempting to poison"); @@ -417,7 +474,9 @@ namespace Server.Mobiles case 5: // Paralyze them { if (c.Paralyzed || m_Mobile.Skills.Magery.Value <= 50.0) + { goto default; + } m_Mobile.DebugSay("Attempting to paralyze"); @@ -434,7 +493,9 @@ namespace Server.Mobiles case 7: // Invis ourselves { if (Utility.RandomBool()) + { goto default; + } m_Mobile.DebugSay("Attempting to invis myself"); @@ -456,14 +517,18 @@ namespace Server.Mobiles spell = CheckCastHealingSpell(); if (spell != null) + { return spell; + } switch (Utility.Random(3)) { case 0: // Poison them { if (c.Poisoned) + { goto case 1; + } spell = new PoisonSpell(m_Mobile); break; @@ -527,9 +592,13 @@ namespace Server.Mobiles else if (m_Combo == 2) { if (!c.Poisoned) + { spell = new PoisonSpell(m_Mobile); + } else if (IsNecromancer) + { spell = new StrangleSpell(m_Mobile); + } ++m_Combo; // Move to next spell } @@ -541,9 +610,13 @@ namespace Server.Mobiles case 0: { if (c.Int < c.Dex) + { spell = new FeeblemindSpell(m_Mobile); + } else + { spell = new ClumsySpell(m_Mobile); + } ++m_Combo; // Move to next spell @@ -580,7 +653,10 @@ namespace Server.Mobiles private TimeSpan GetDelay(Spell spell) { - if (SmartAI || spell is DispelSpell) return TimeSpan.FromSeconds(m_Mobile.ActiveSpeed); + if (SmartAI || spell is DispelSpell) + { + return TimeSpan.FromSeconds(m_Mobile.ActiveSpeed); + } var del = ScaleBySkill(3.0, SkillName.Magery); var min = 6.0 - del * 0.75; @@ -632,7 +708,9 @@ namespace Server.Mobiles if (!Core.AOS && SmartAI && !m_Mobile.StunReady && m_Mobile.Skills.Wrestling.Value >= 80.0 && m_Mobile.Skills.Anatomy.Value >= 80.0) + { EventSink.InvokeStunRequest(m_Mobile); + } if (!m_Mobile.InRange(c, m_Mobile.RangePerception)) { @@ -660,6 +738,7 @@ namespace Server.Mobiles } if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee) + { if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? @@ -687,6 +766,7 @@ namespace Server.Mobiles return true; } } + } if (m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0 && m_Mobile.InRange(c, Core.ML ? 10 : 12)) { @@ -727,9 +807,13 @@ namespace Server.Mobiles if (SmartAI && toDispel != null) { if (m_Mobile.InRange(toDispel, 10)) + { RunFrom(toDispel); + } else if (!m_Mobile.InRange(toDispel, Core.ML ? 10 : 12)) + { RunTo(toDispel); + } } else { @@ -769,7 +853,9 @@ namespace Server.Mobiles Spell spell = new RevealSpell(m_Mobile); if (spell.Cast()) + { m_LastTarget = null; // only do it once + } m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds; } @@ -816,7 +902,9 @@ namespace Server.Mobiles m_Mobile.FocusMob = null; if (m_Mobile.Poisoned && Utility.Random(0, 5) == 0) + { new CureSpell(m_Mobile).Cast(); + } } else { @@ -832,7 +920,9 @@ namespace Server.Mobiles public Mobile FindDispelTarget(bool activeOnly) { if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel) + { return null; + } if (activeOnly) { @@ -851,7 +941,9 @@ namespace Server.Mobiles activePrio = m_Mobile.GetDistanceToSqrt(comb); if (activePrio <= 2) + { return active; + } } for (var i = 0; i < aggressed.Count; ++i) @@ -869,7 +961,9 @@ namespace Server.Mobiles activePrio = prio; if (activePrio <= 2) + { return active; + } } } } @@ -889,7 +983,9 @@ namespace Server.Mobiles activePrio = prio; if (activePrio <= 2) + { return active; + } } } } @@ -913,6 +1009,7 @@ namespace Server.Mobiles } foreach (var m in m_Mobile.GetMobilesInRange(Core.ML ? 10 : 12)) + { if (m != m_Mobile && CanDispel(m)) { var prio = m_Mobile.GetDistanceToSqrt(m); @@ -929,6 +1026,7 @@ namespace Server.Mobiles actPrio = prio; } } + } return active ?? inactive; } @@ -945,7 +1043,9 @@ namespace Server.Mobiles var targ = m_Mobile.Target; if (targ == null) + { return false; + } var spellTarg = targ as ISpellTarget; @@ -967,9 +1067,13 @@ namespace Server.Mobiles toTarget = FindDispelTarget(false); if (!SmartAI && toTarget != null) + { RunTo(toTarget); + } else if (toTarget != null && m_Mobile.InRange(toTarget, 10)) + { RunFrom(toTarget); + } } else if (SmartAI && (isParalyze || isTeleport)) { @@ -980,7 +1084,9 @@ namespace Server.Mobiles toTarget = m_Mobile.Combatant; if (toTarget != null) + { RunTo(toTarget); + } } else if (m_Mobile.InRange(toTarget, 10)) { @@ -997,15 +1103,22 @@ namespace Server.Mobiles toTarget = m_Mobile.Combatant; if (toTarget != null) + { RunTo(toTarget); + } } if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null) { if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget)) + { targ.Invoke(m_Mobile, toTarget); - else if (isDispel) targ.Cancel(m_Mobile, TargetCancelType.Canceled); + } + else if (isDispel) + { + targ.Cancel(m_Mobile, TargetCancelType.Canceled); + } } else if ((targ.Flags & TargetFlags.Beneficial) != 0) { diff --git a/Projects/UOContent/Mobiles/AI/MeleeAI.cs b/Projects/UOContent/Mobiles/AI/MeleeAI.cs index ae05784df..f6871e694 100644 --- a/Projects/UOContent/Mobiles/AI/MeleeAI.cs +++ b/Projects/UOContent/Mobiles/AI/MeleeAI.cs @@ -13,7 +13,9 @@ namespace Server.Mobiles if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have detected {0}, attacking", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; @@ -81,7 +83,9 @@ namespace Server.Mobiles else if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("My move is blocked, so I am going to attack {0}", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; @@ -91,7 +95,9 @@ namespace Server.Mobiles else if (m_Mobile.GetDistanceToSqrt(combatant) > m_Mobile.RangePerception + 1) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I cannot find {0}, so my guard is up", combatant.Name); + } Action = ActionType.Guard; @@ -100,10 +106,13 @@ namespace Server.Mobiles else { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I should be closer to {0}", combatant.Name); + } } if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee) + { if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100) { // We are low on health, should we flee? @@ -126,11 +135,14 @@ namespace Server.Mobiles if (flee) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I am going to flee from {0}", combatant.Name); + } Action = ActionType.Flee; } } + } return true; } @@ -140,7 +152,9 @@ namespace Server.Mobiles if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I have detected {0}, attacking", m_Mobile.FocusMob.Name); + } m_Mobile.Combatant = m_Mobile.FocusMob; Action = ActionType.Combat; diff --git a/Projects/UOContent/Mobiles/AI/OppositionGroup.cs b/Projects/UOContent/Mobiles/AI/OppositionGroup.cs index 607b27d92..ccabc7f39 100644 --- a/Projects/UOContent/Mobiles/AI/OppositionGroup.cs +++ b/Projects/UOContent/Mobiles/AI/OppositionGroup.cs @@ -106,7 +106,9 @@ namespace Server public int IndexOf(object obj) { if (obj == null) + { return -1; + } var type = obj.GetType(); @@ -117,10 +119,14 @@ namespace Server var contains = false; for (var j = 0; !contains && j < group.Length; ++j) - contains = group[j].IsAssignableFrom(type); + { + contains = @group[j].IsAssignableFrom(type); + } if (contains) + { return i; + } } return -1; diff --git a/Projects/UOContent/Mobiles/AI/SpeedInfo.cs b/Projects/UOContent/Mobiles/AI/SpeedInfo.cs index c892da74f..8bfa85fa9 100644 --- a/Projects/UOContent/Mobiles/AI/SpeedInfo.cs +++ b/Projects/UOContent/Mobiles/AI/SpeedInfo.cs @@ -174,10 +174,14 @@ namespace Server public static bool Contains(object obj) { if (!Enabled) + { return false; + } if (m_Table == null) + { LoadTable(); + } return m_Table!.ContainsKey(obj.GetType()); } @@ -185,13 +189,19 @@ namespace Server public static bool GetSpeeds(object obj, ref double activeSpeed, ref double passiveSpeed) { if (!Enabled) + { return false; + } if (m_Table == null) + { LoadTable(); + } if (!m_Table!.TryGetValue(obj.GetType(), out var sp)) + { return false; + } activeSpeed = sp.ActiveSpeed; passiveSpeed = sp.PassiveSpeed; @@ -209,7 +219,9 @@ namespace Server var types = info.Types; for (var j = 0; j < types.Length; ++j) + { m_Table[types[j]] = info; + } } } } diff --git a/Projects/UOContent/Mobiles/AI/ThiefAI.cs b/Projects/UOContent/Mobiles/AI/ThiefAI.cs index 1bf11d7f7..45a09cf3d 100644 --- a/Projects/UOContent/Mobiles/AI/ThiefAI.cs +++ b/Projects/UOContent/Mobiles/AI/ThiefAI.cs @@ -47,11 +47,15 @@ namespace Server.Mobiles m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); if (m_toDisarm?.IsChildOf(m_Mobile.Backpack) != false) + { m_toDisarm = combatant.FindItemOnLayer(Layer.OneHanded) ?? combatant.FindItemOnLayer(Layer.TwoHanded); + } if (!Core.AOS && !m_Mobile.DisarmReady && m_Mobile.Skills.Wrestling.Value >= 80.0 && m_Mobile.Skills.ArmsLore.Value >= 80.0 && m_toDisarm != null) + { EventSink.InvokeDisarmRequest(m_Mobile); + } if (m_toDisarm?.IsChildOf(combatant.Backpack) == true && Core.TickCount - m_Mobile.NextSkillTime >= 0 && m_toDisarm.LootType != LootType.Blessed && @@ -113,7 +117,9 @@ namespace Server.Mobiles } if (m_Mobile.Hits >= m_Mobile.HitsMax * 20 / 100 || !m_Mobile.CanFlee) + { return true; + } // We are low on health, should we flee? bool flee; diff --git a/Projects/UOContent/Mobiles/AI/VendorAI.cs b/Projects/UOContent/Mobiles/AI/VendorAI.cs index 28b3c0dcc..ade3686e5 100644 --- a/Projects/UOContent/Mobiles/AI/VendorAI.cs +++ b/Projects/UOContent/Mobiles/AI/VendorAI.cs @@ -13,7 +13,9 @@ namespace Server.Mobiles if (m_Mobile.Combatant != null) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} is attacking me", m_Mobile.Combatant.Name); + } m_Mobile.Say(Utility.RandomList(1005305, 501603)); @@ -24,7 +26,9 @@ namespace Server.Mobiles if (m_Mobile.FocusMob != null) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} has talked to me", m_Mobile.FocusMob.Name); + } Action = ActionType.Interact; } @@ -46,7 +50,9 @@ namespace Server.Mobiles if (m_Mobile.Combatant != null) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} is attacking me", m_Mobile.Combatant.Name); + } m_Mobile.Say(Utility.RandomList(1005305, 501603)); @@ -67,14 +73,18 @@ namespace Server.Mobiles if (customer.InRange(m_Mobile, m_Mobile.RangeFight)) { if (m_Mobile.Debug) + { m_Mobile.DebugSay("I am with {0}", customer.Name); + } m_Mobile.Direction = m_Mobile.GetDirectionTo(customer); } else { if (m_Mobile.Debug) + { m_Mobile.DebugSay("{0} is gone", customer.Name); + } m_Mobile.FocusMob = null; @@ -94,7 +104,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.InRange(m_Mobile, 4)) + { return true; + } return base.HandlesOnSpeech(from); } diff --git a/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs b/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs index 7328f0f8f..3a495b6b4 100644 --- a/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs +++ b/Projects/UOContent/Mobiles/Animals/Cows/Bull.cs @@ -9,7 +9,9 @@ namespace Server.Mobiles BaseSoundID = 0x64; if (Utility.RandomDouble() <= 0.5) + { Hue = 0x901; + } SetStr(77, 111); SetDex(56, 75); diff --git a/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs b/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs index d71580747..30ebaa1fb 100644 --- a/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs +++ b/Projects/UOContent/Mobiles/Animals/Cows/Cow.cs @@ -39,7 +39,9 @@ namespace Server.Mobiles MinTameSkill = 11.1; if (Core.AOS && Utility.Random(1000) == 0) // 0.1% chance to have mad cows + { FightMode = FightMode.Closest; + } } public Cow(Serial serial) : base(serial) @@ -67,11 +69,17 @@ namespace Server.Mobiles var random = Utility.Random(100); if (random < 5) + { Tip(); + } else if (random < 20) + { PlaySound(120); + } else if (random < 40) + { PlaySound(121); + } } public void Tip() @@ -83,9 +91,15 @@ namespace Server.Mobiles public bool TryMilk(Mobile from) { if (!from.InLOS(this) || !from.InRange(Location, 2)) - from.SendLocalizedMessage(1080400); // You can not milk the cow from this location. + { + @from.SendLocalizedMessage(1080400); // You can not milk the cow from this location. + } + if (Controlled && ControlMaster != from) - from.SendLocalizedMessage(1071182); // The cow nimbly escapes your attempts to milk it. + { + @from.SendLocalizedMessage(1071182); // The cow nimbly escapes your attempts to milk it. + } + if (Milk == 0 && MilkedOn + TimeSpan.FromDays(1) > DateTime.UtcNow) { from.SendLocalizedMessage(1080198); // This cow can not be milked now. Please wait for some time. @@ -93,7 +107,9 @@ namespace Server.Mobiles else { if (Milk == 0) + { Milk = 4; + } MilkedOn = DateTime.UtcNow; Milk--; diff --git a/Projects/UOContent/Mobiles/Animals/Misc/Dolphin.cs b/Projects/UOContent/Mobiles/Animals/Misc/Dolphin.cs index 1e185432e..7aae6d76a 100644 --- a/Projects/UOContent/Mobiles/Animals/Misc/Dolphin.cs +++ b/Projects/UOContent/Mobiles/Animals/Misc/Dolphin.cs @@ -50,21 +50,29 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) + { Jump(); + } } public virtual void Jump() { if (Utility.RandomBool()) + { Animate(3, 16, 1, true, false, 0); + } else + { Animate(4, 20, 1, true, false, 0); + } } public override void OnThink() { if (Utility.RandomDouble() < .005) // slim chance to jump + { Jump(); + } base.OnThink(); } diff --git a/Projects/UOContent/Mobiles/Animals/Misc/PackHorse.cs b/Projects/UOContent/Mobiles/Animals/Misc/PackHorse.cs index 1355dfdef..097424bf2 100644 --- a/Projects/UOContent/Mobiles/Animals/Misc/PackHorse.cs +++ b/Projects/UOContent/Mobiles/Animals/Misc/PackHorse.cs @@ -81,7 +81,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } PackAnimal.CombineBackpacks(this); @@ -93,7 +95,9 @@ namespace Server.Mobiles public override bool IsSnoop(Mobile from) { if (PackAnimal.CheckAccess(this, from)) + { return false; + } return base.IsSnoop(from); } @@ -101,7 +105,9 @@ namespace Server.Mobiles public override bool OnDragDrop(Mobile from, Item item) { if (CheckFeed(from, item)) + { return true; + } if (PackAnimal.CheckAccess(this, from)) { @@ -140,7 +146,9 @@ namespace Server.Mobiles m_From = from; if (animal.IsDeadPet) + { Enabled = false; + } } public override void OnClick() @@ -154,17 +162,23 @@ namespace Server.Mobiles public static void GetContextMenuEntries(BaseCreature animal, Mobile from, List list) { if (CheckAccess(animal, from)) - list.Add(new PackAnimalBackpackEntry(animal, from)); + { + list.Add(new PackAnimalBackpackEntry(animal, @from)); + } } public static bool CheckAccess(BaseCreature animal, Mobile from) { if (from == animal || from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (from.Alive && animal.Controlled && !animal.IsDeadPet && (from == animal.ControlMaster || from == animal.SummonMaster || animal.IsPetFriend(from))) + { return true; + } return false; } @@ -172,10 +186,14 @@ namespace Server.Mobiles public static void CombineBackpacks(BaseCreature animal) { if (Core.AOS) + { return; + } if (animal.IsBonded || animal.IsDeadPet) + { return; + } var pack = animal.Backpack; @@ -186,7 +204,9 @@ namespace Server.Mobiles for (var i = pack.Items.Count - 1; i >= 0; --i) { if (i >= pack.Items.Count) + { continue; + } newPack.DropItem(pack.Items[i]); } @@ -198,12 +218,16 @@ namespace Server.Mobiles public static void TryPackOpen(BaseCreature animal, Mobile from) { if (animal.IsDeadPet) + { return; + } var item = animal.Backpack; if (item != null) - from.Use(item); + { + @from.Use(item); + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Misc/PackLlama.cs b/Projects/UOContent/Mobiles/Animals/Misc/PackLlama.cs index 9f9e4cda3..d916b6dba 100644 --- a/Projects/UOContent/Mobiles/Animals/Misc/PackLlama.cs +++ b/Projects/UOContent/Mobiles/Animals/Misc/PackLlama.cs @@ -80,7 +80,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } PackAnimal.CombineBackpacks(this); @@ -92,7 +94,9 @@ namespace Server.Mobiles public override bool IsSnoop(Mobile from) { if (PackAnimal.CheckAccess(this, from)) + { return false; + } return base.IsSnoop(from); } @@ -100,7 +104,9 @@ namespace Server.Mobiles public override bool OnDragDrop(Mobile from, Item item) { if (CheckFeed(from, item)) + { return true; + } if (PackAnimal.CheckAccess(this, from)) { diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs b/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs index e938877d1..9ba99a47d 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/BaseMount.cs @@ -53,7 +53,9 @@ namespace Server.Mobiles base.Hue = value; if (InternalItem != null) + { InternalItem.Hue = value; + } } } @@ -64,7 +66,9 @@ namespace Server.Mobiles set { if (InternalItem != null) + { InternalItem.ItemID = value; + } } } @@ -95,18 +99,26 @@ namespace Server.Mobiles } else { - if (m_Rider != null) Dismount(m_Rider); + if (m_Rider != null) + { + Dismount(m_Rider); + } Dismount(value); if (InternalItem != null) + { value.AddItem(InternalItem); + } value.Direction = Direction; Internalize(); - if (value.Target is Bola.BolaTarget) Target.Cancel(value); + if (value.Target is Bola.BolaTarget) + { + Target.Cancel(value); + } } m_Rider = value; @@ -117,13 +129,17 @@ namespace Server.Mobiles public virtual void OnRiderDamaged(int amount, Mobile from, bool willKill) { if (m_Rider == null) + { return; + } var attacker = from ?? m_Rider.FindMostRecentDamager(true); if (!(attacker == this || attacker == m_Rider || willKill || DateTime.UtcNow < NextMountAbility) && DoMountAbility(amount, from)) + { NextMountAbility = DateTime.UtcNow + MountAbilityDelay; + } } public override bool OnBeforeDeath() @@ -178,7 +194,9 @@ namespace Server.Mobiles InternalItem = reader.ReadItem(); if (InternalItem == null) + { Delete(); + } break; } @@ -193,20 +211,28 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (IsDeadPet) + { return; + } if (from.IsBodyMod && !from.Body.IsHuman) { if (Core.AOS) // You cannot ride a mount in your current form. - PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1062061, from.NetState); + { + PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1062061, @from.NetState); + } else - from.SendLocalizedMessage(1061628); // You can't do that while polymorphed. + { + @from.SendLocalizedMessage(1061628); // You can't do that while polymorphed. + } return; } if (!CheckMountAllowed(from)) + { return; + } if (from.Mounted) { @@ -221,7 +247,9 @@ namespace Server.Mobiles } if (!DesignContext.Check(from)) + { return; + } if (from.HasTrade) { @@ -238,14 +266,18 @@ namespace Server.Mobiles if (canAccess) { if (Poisoned) + { PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1049692, - from.NetState + @from.NetState ); // This mount is too ill to ride. + } else - Rider = from; + { + Rider = @from; + } } else if (!Controlled && !Summoned) { @@ -269,7 +301,9 @@ namespace Server.Mobiles var mount = m.Mount; if (mount != null) + { mount.Rider = null; + } } // 1040024 You are still too dazed from being knocked off your mount to ride! @@ -323,7 +357,9 @@ namespace Server.Mobiles public override DeathMoveResult OnParentDeath(Mobile parent) { if (m_Mount != null) + { m_Mount.Rider = null; + } return DeathMoveResult.RemainEquipped; } @@ -350,7 +386,9 @@ namespace Server.Mobiles m_Mount = reader.ReadMobile() as BaseMount; if (m_Mount == null) + { Delete(); + } break; } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Beetle.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Beetle.cs index 8135fe92c..2a0ed620e 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Beetle.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Beetle.cs @@ -81,13 +81,17 @@ namespace Server.Mobiles public override void OnHarmfulSpell(Mobile from) { if (!Controlled && ControlMaster == null) + { CurrentSpeed = BoostedSpeed; + } } public override void OnCombatantChange() { if (Combatant == null && !Controlled && ControlMaster == null) + { CurrentSpeed = PassiveSpeed; + } } public override void Serialize(IGenericWriter writer) @@ -107,7 +111,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } PackAnimal.CombineBackpacks(this); @@ -119,7 +125,9 @@ namespace Server.Mobiles public override bool IsSnoop(Mobile from) { if (PackAnimal.CheckAccess(this, from)) + { return false; + } return base.IsSnoop(from); } @@ -127,7 +135,9 @@ namespace Server.Mobiles public override bool OnDragDrop(Mobile from, Item item) { if (CheckFeed(from, item)) + { return true; + } if (PackAnimal.CheckAccess(this, from)) { diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs index 866d568b9..8badf02e0 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs @@ -54,7 +54,9 @@ namespace Server.Mobiles m_MountedID = value; if (m_Rider != null) + { ItemID = value; + } } } } @@ -70,7 +72,9 @@ namespace Server.Mobiles m_RegularID = value; if (m_Rider == null) + { ItemID = value; + } } } } @@ -100,7 +104,9 @@ namespace Server.Mobiles else { if (m_Rider != null) + { Dismount(m_Rider); + } Dismount(value); @@ -134,19 +140,25 @@ namespace Server.Mobiles } if (Core.ML && IsRewardItem) + { list.Add(RewardSystem.GetRewardYearLabel(this, new object[] { })); // X Year Veteran Reward + } } public void RemoveFollowers() { if (m_Rider != null) + { m_Rider.Followers -= Math.Min(m_Rider.Followers, FollowerSlots); + } } public void AddFollowers() { if (m_Rider != null) + { m_Rider.Followers += FollowerSlots; + } } public virtual bool Validate(Mobile from) @@ -158,7 +170,9 @@ namespace Server.Mobiles } if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this) || !BaseMount.CheckMountAllowed(from)) + { return false; + } if (from.Mounted) { @@ -190,7 +204,9 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (Validate(from)) - new EtherealSpell(this, from).Cast(); + { + new EtherealSpell(this, @from).Cast(); + } } public override void OnSingleClick(Mobile from) @@ -243,7 +259,9 @@ namespace Server.Mobiles m_Rider = reader.ReadMobile(); if (m_MountedID == 0x3EA2) + { m_MountedID = 0x3EAA; + } break; } @@ -252,7 +270,9 @@ namespace Server.Mobiles AddFollowers(); if (version < 3 && Weight == 0) + { Weight = -1; + } } public override DeathMoveResult OnParentDeath(Mobile parent) @@ -267,7 +287,9 @@ namespace Server.Mobiles var mount = m.Mount; if (mount != null) + { mount.Rider = null; + } } public void UnmountMe() @@ -279,7 +301,9 @@ namespace Server.Mobiles Movable = true; if (Hue == EtherealHue) + { Hue = 0; + } if (bp != null) { @@ -307,7 +331,9 @@ namespace Server.Mobiles Movable = false; if (Hue == 0) + { Hue = EtherealHue; + } ProcessDelta(); m_Rider.ProcessDelta(); @@ -364,7 +390,9 @@ namespace Server.Mobiles public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) { if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest /* || type == DisturbType.Hurt*/) + { return false; + } return true; } @@ -372,21 +400,27 @@ namespace Server.Mobiles public override void DoHurtFizzle() { if (!m_Stop) + { base.DoHurtFizzle(); + } } public override void DoFizzle() { if (!m_Stop) + { base.DoFizzle(); + } } public override void OnDisturb(DisturbType type, bool message) { if (message && !m_Stop) + { Caster.SendLocalizedMessage( 1049455 ); // You have been disrupted while attempting to summon your ethereal mount! + } // m_Mount.UnmountMe(); } @@ -394,7 +428,9 @@ namespace Server.Mobiles public override void OnCast() { if (!m_Mount.Deleted && m_Mount.Rider == null && m_Mount.Validate(m_Rider)) + { m_Mount.Rider = m_Rider; + } FinishSequence(); } @@ -430,10 +466,14 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal horse") + { Name = null; + } if (ItemID == 0x2124) + { ItemID = 0x20DD; + } } } @@ -466,7 +506,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal llama") + { Name = null; + } } } @@ -499,7 +541,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal ostard") + { Name = null; + } } } @@ -532,7 +576,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal ridgeback") + { Name = null; + } } } @@ -565,7 +611,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal unicorn") + { Name = null; + } } } @@ -598,7 +646,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal beetle") + { Name = null; + } } } @@ -631,7 +681,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal kirin") + { Name = null; + } } } @@ -664,7 +716,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Name == "an ethereal swamp dragon") + { Name = null; + } } } @@ -819,7 +873,10 @@ namespace Server.Mobiles var version = reader.ReadInt(); - if (version <= 1 && Hue != 0) Hue = 0; + if (version <= 1 && Hue != 0) + { + Hue = 0; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/FireSteed.cs b/Projects/UOContent/Mobiles/Animals/Mounts/FireSteed.cs index 3ca420c22..cc5eba47f 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/FireSteed.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/FireSteed.cs @@ -79,15 +79,22 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID <= 0) + { BaseSoundID = 0xA8; + } if (version < 1) + { for (var i = 0; i < Skills.Length; ++i) { Skills[i].Cap = Math.Max(100.0, Skills[i].Cap * 0.9); - if (Skills[i].Base > Skills[i].Cap) Skills[i].Base = Skills[i].Cap; + if (Skills[i].Base > Skills[i].Cap) + { + Skills[i].Base = Skills[i].Cap; + } } + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Hiryu.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Hiryu.cs index f5f705a83..1fec2112b 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Hiryu.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Hiryu.cs @@ -45,10 +45,14 @@ namespace Server.Mobiles MinTameSkill = 98.7; if (Utility.RandomDouble() < .33) + { PackItem(Seed.RandomBonsaiSeed()); + } if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(3)); + } } public Hiryu(Serial serial) @@ -74,31 +78,69 @@ namespace Server.Mobiles var rand = Utility.Random(1075); if (rand <= 0) + { return 0x855C; + } + if (rand <= 1) + { return 0x8490; + } + if (rand <= 3) + { return 0x8030; + } + if (rand <= 5) + { return 0x8037; + } + if (rand <= 8) + { return 0x8295; + } + if (rand <= 11) + { return 0x8123; + } + if (rand <= 16) + { return 0x8482; + } + if (rand <= 24) + { return 0x8487; + } + if (rand <= 34) + { return 0x8032; + } + if (rand <= 44) + { return 0x8899; + } + if (rand <= 54) + { return 0x8495; + } + if (rand <= 64) + { return 0x848D; + } + if (rand <= 74) + { return 0x847F; + } return 0; } @@ -124,7 +166,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { return; + } /* Grasping Claw * Start cliloc: 1070836 @@ -169,15 +213,22 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version <= 1) + { Timer.DelayCall(Fix, version); + } if (version < 2) + { for (var i = 0; i < Skills.Length; ++i) { Skills[i].Cap = Math.Max(100.0, Skills[i].Cap * 0.9); - if (Skills[i].Base > Skills[i].Cap) Skills[i].Base = Skills[i].Cap; + if (Skills[i].Base > Skills[i].Cap) + { + Skills[i].Base = Skills[i].Cap; + } } + } } private void Fix(int version) @@ -186,7 +237,11 @@ namespace Server.Mobiles { case 1: { - if (InternalItem != null) InternalItem.Hue = Hue; + if (InternalItem != null) + { + InternalItem.Hue = Hue; + } + goto case 0; } case 0: diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Kirin.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Kirin.cs index 6c6e1f898..58ae0a3fc 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Kirin.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Kirin.cs @@ -72,7 +72,9 @@ namespace Server.Mobiles public override bool DoMountAbility(int damage, Mobile attacker) { if (Rider == null || attacker == null) // sanity + { return false; + } if (Rider.Hits - damage < 30 && Rider.Map == attacker.Map && Rider.InRange(attacker, 18) ) // Range and map checked here instead of other base fuction because of abiliites that don't need to check this @@ -110,7 +112,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.35) + { c.DropItem(new KirinBrains()); + } } public override void Serialize(IGenericWriter writer) @@ -127,7 +131,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version == 0) + { AI = AIType.AI_Mage; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs b/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs index 994af5bc6..5c0201545 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/LesserHiryu.cs @@ -45,7 +45,9 @@ namespace Server.Mobiles MinTameSkill = 98.7; if (Utility.RandomDouble() < .33) + { PackItem(Seed.RandomBonsaiSeed()); + } } public LesserHiryu(Serial serial) @@ -82,15 +84,29 @@ namespace Server.Mobiles * */ if (rand <= 0) + { return 0x8258; + } + if (rand <= 1) + { return 0x88AB; + } + if (rand <= 6) + { return 0x87D4; + } + if (rand <= 16) + { return 0x8163; + } + if (rand <= 26) + { return 0x8295; + } return 0; } @@ -98,7 +114,10 @@ namespace Server.Mobiles public override bool OverrideBondingReqs() { if (ControlMaster.Skills.Bushido.Base >= 90.0) + { return true; + } + return false; } @@ -122,16 +141,24 @@ namespace Server.Mobiles { var tamingChance = base.GetControlChance(m, useBaseSkill); - if (tamingChance >= 0.95) return tamingChance; + if (tamingChance >= 0.95) + { + return tamingChance; + } var skill = useBaseSkill ? m.Skills.Bushido.Base : m.Skills.Bushido.Value; - if (skill < 90.0) return tamingChance; + if (skill < 90.0) + { + return tamingChance; + } var bushidoChance = (skill - 30.0) / 100; if (m.Skills.Bushido.Base >= 120) + { bushidoChance += 0.05; + } return bushidoChance > tamingChance ? bushidoChance : tamingChance; } @@ -141,7 +168,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { return; + } /* Grasping Claw * Start cliloc: 1070836 @@ -186,15 +215,22 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version <= 1) + { Timer.DelayCall(Fix, version); + } if (version < 2) + { for (var i = 0; i < Skills.Length; ++i) { Skills[i].Cap = Math.Max(100.0, Skills[i].Cap * 0.9); - if (Skills[i].Base > Skills[i].Cap) Skills[i].Base = Skills[i].Cap; + if (Skills[i].Base > Skills[i].Cap) + { + Skills[i].Base = Skills[i].Cap; + } } + } } private void Fix(int version) @@ -203,7 +239,11 @@ namespace Server.Mobiles { case 1: { - if (InternalItem != null) InternalItem.Hue = Hue; + if (InternalItem != null) + { + InternalItem.Hue = Hue; + } + goto case 0; } case 0: diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Nightmare.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Nightmare.cs index a700a4446..274cf9a43 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Nightmare.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Nightmare.cs @@ -101,7 +101,9 @@ namespace Server.Mobiles public override int GetAngerSound() { if (!Controlled) + { return 0x16A; + } return base.GetAngerSound(); } @@ -120,9 +122,13 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Core.AOS && BaseSoundID == 0x16A) + { BaseSoundID = 0xA8; + } else if (!Core.AOS && BaseSoundID == 0xA8) + { BaseSoundID = 0x16A; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/SwampDragon.cs b/Projects/UOContent/Mobiles/Animals/Mounts/SwampDragon.cs index e917988a7..0a5af7690 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/SwampDragon.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/SwampDragon.cs @@ -130,7 +130,9 @@ namespace Server.Mobiles m_BardingResource = value; if (m_HasBarding) + { Hue = CraftResources.GetHue(value); + } InvalidateProperties(); } @@ -165,7 +167,9 @@ namespace Server.Mobiles base.GetProperties(list); if (m_HasBarding && m_BardingExceptional && m_BardingCrafter != null) + { list.Add(1060853, m_BardingCrafter.Name); // armor exceptionally crafted by ~1_val~ + } } public override void Serialize(IGenericWriter writer) @@ -201,10 +205,14 @@ namespace Server.Mobiles } if (Hue == 0 && !m_HasBarding) + { Hue = 0x851; + } if (BaseSoundID == -1) + { BaseSoundID = 0x16A; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Unicorn.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Unicorn.cs index 3c5dcd79f..aa4e46202 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Unicorn.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Unicorn.cs @@ -71,7 +71,9 @@ namespace Server.Mobiles public override bool DoMountAbility(int damage, Mobile attacker) { if (Rider == null || attacker == null) // sanity + { return false; + } if (Rider.Poisoned && Rider.Hits - damage < 40) { @@ -84,6 +86,7 @@ namespace Server.Mobiles chanceToCure /= 100; if (chanceToCure > Utility.Random(100)) + { if (Rider.CurePoison(this) ) // TODO: Confirm if mount is the one flagged for curing it or the rider is { @@ -99,6 +102,7 @@ namespace Server.Mobiles return true; } + } } } @@ -117,7 +121,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.35) + { c.DropItem(new UnicornRibs()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Animals/Reptiles/Alligator.cs b/Projects/UOContent/Mobiles/Animals/Reptiles/Alligator.cs index ab1a45454..5522cdedc 100644 --- a/Projects/UOContent/Mobiles/Animals/Reptiles/Alligator.cs +++ b/Projects/UOContent/Mobiles/Animals/Reptiles/Alligator.cs @@ -64,7 +64,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 0x5A) + { BaseSoundID = 660; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs b/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs index 530f140f1..c4258032c 100644 --- a/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs +++ b/Projects/UOContent/Mobiles/Animals/Reptiles/GiantSerpent.cs @@ -79,7 +79,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == -1) + { BaseSoundID = 219; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Reptiles/IceSerpent.cs b/Projects/UOContent/Mobiles/Animals/Reptiles/IceSerpent.cs index a7d731da7..17183f19e 100644 --- a/Projects/UOContent/Mobiles/Animals/Reptiles/IceSerpent.cs +++ b/Projects/UOContent/Mobiles/Animals/Reptiles/IceSerpent.cs @@ -54,7 +54,9 @@ namespace Server.Mobiles ); if (Utility.RandomDouble() < 0.025) + { PackItem(new GlacialStaff()); + } } public IceSerpent(Serial serial) : base(serial) @@ -89,7 +91,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == -1) + { BaseSoundID = 219; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Reptiles/LavaSerpent.cs b/Projects/UOContent/Mobiles/Animals/Reptiles/LavaSerpent.cs index 5a27976a4..f97697978 100644 --- a/Projects/UOContent/Mobiles/Animals/Reptiles/LavaSerpent.cs +++ b/Projects/UOContent/Mobiles/Animals/Reptiles/LavaSerpent.cs @@ -75,7 +75,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == -1) + { BaseSoundID = 219; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Reptiles/SilverSerpent.cs b/Projects/UOContent/Mobiles/Animals/Reptiles/SilverSerpent.cs index 27ea25f4e..9be470ebe 100644 --- a/Projects/UOContent/Mobiles/Animals/Reptiles/SilverSerpent.cs +++ b/Projects/UOContent/Mobiles/Animals/Reptiles/SilverSerpent.cs @@ -76,7 +76,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == -1) + { BaseSoundID = 219; + } } } } diff --git a/Projects/UOContent/Mobiles/Animals/Rodents/Rabbit.cs b/Projects/UOContent/Mobiles/Animals/Rodents/Rabbit.cs index ec4cdc065..3592cb5da 100644 --- a/Projects/UOContent/Mobiles/Animals/Rodents/Rabbit.cs +++ b/Projects/UOContent/Mobiles/Animals/Rodents/Rabbit.cs @@ -8,7 +8,9 @@ namespace Server.Mobiles Body = 205; if (Utility.RandomBool()) + { Hue = Utility.RandomAnimalHue(); + } SetStr(6, 10); SetDex(26, 38); diff --git a/Projects/UOContent/Mobiles/Animals/Town Critters/Bird.cs b/Projects/UOContent/Mobiles/Animals/Town Critters/Bird.cs index 12e673eac..4f99f8350 100644 --- a/Projects/UOContent/Mobiles/Animals/Town Critters/Bird.cs +++ b/Projects/UOContent/Mobiles/Animals/Town Critters/Bird.cs @@ -73,7 +73,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Hue == 0) + { Hue = Utility.RandomBirdHue(); + } } } diff --git a/Projects/UOContent/Mobiles/Familiars/BaseFamiliar.cs b/Projects/UOContent/Mobiles/Familiars/BaseFamiliar.cs index c61e88c6a..1cddcf9bd 100644 --- a/Projects/UOContent/Mobiles/Familiars/BaseFamiliar.cs +++ b/Projects/UOContent/Mobiles/Familiars/BaseFamiliar.cs @@ -26,19 +26,25 @@ namespace Server.Mobiles public virtual void RangeCheck() { if (Deleted || ControlMaster?.Deleted != false) + { return; + } var range = RangeHome - 2; if (InRange(ControlMaster.Location, RangeHome)) + { return; + } var master = ControlMaster; var m_Loc = Point3D.Zero; if (Map != master.Map) + { return; + } var x = X > master.X ? master.X + range : master.X - range; var y = Y > master.Y ? master.Y + range : master.Y - range; @@ -50,20 +56,29 @@ namespace Server.Mobiles m_Loc.Z = Map.GetAverageZ(m_Loc.X, m_Loc.Y); - if (Map.CanSpawnMobile(m_Loc)) break; + if (Map.CanSpawnMobile(m_Loc)) + { + break; + } m_Loc = master.Location; } if (!Deleted) + { SetLocation(m_Loc, true); + } } public override void OnThink() { var master = ControlMaster; - if (Deleted) return; + if (Deleted) + { + return; + } + if (master?.Deleted != false) { DropPackContents(); @@ -74,7 +89,9 @@ namespace Server.Mobiles RangeCheck(); if (m_LastHidden != master.Hidden) + { Hidden = m_LastHidden = master.Hidden; + } if (AIObject?.WalkMobileRange(master, 5, true, 1, 1) == true) { @@ -97,13 +114,17 @@ namespace Server.Mobiles base.GetContextMenuEntries(from, list); if (from.Alive && Controlled && from == ControlMaster && from.InRange(this, 14)) - list.Add(new ReleaseEntry(from, this)); + { + list.Add(new ReleaseEntry(@from, this)); + } } public virtual void BeginRelease(Mobile from) { if (!Deleted && Controlled && from == ControlMaster && from.CheckAlive()) - EndRelease(from); + { + EndRelease(@from); + } } public virtual void EndRelease(Mobile from) @@ -135,7 +156,9 @@ namespace Server.Mobiles var list = new List(pack.Items); for (var i = 0; i < list.Count; ++i) + { list[i].MoveToWorld(Location, map); + } } } @@ -176,7 +199,9 @@ namespace Server.Mobiles { if (!m_Familiar.Deleted && m_Familiar.Controlled && m_From == m_Familiar.ControlMaster && m_From.CheckAlive()) + { m_Familiar.BeginRelease(m_From); + } } } } diff --git a/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs b/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs index a9b6783c7..ee3cfdb21 100644 --- a/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs +++ b/Projects/UOContent/Mobiles/Familiars/DarkWolf.cs @@ -48,14 +48,18 @@ namespace Server.Mobiles base.OnThink(); if (DateTime.UtcNow < m_NextRestore) + { return; + } m_NextRestore = DateTime.UtcNow + TimeSpan.FromSeconds(2.0); var caster = ControlMaster ?? SummonMaster; if (caster != null) + { ++caster.Stam; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs b/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs index 28b786ed5..39c1415cd 100644 --- a/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs +++ b/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs @@ -63,14 +63,18 @@ namespace Server.Mobiles base.OnThink(); if (DateTime.UtcNow < m_NextPickup) + { return; + } m_NextPickup = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10)); var pack = Backpack; if (pack == null) + { return; + } var eable = GetItemsInRange(2).Where(item => item.Movable && item.Stackable); @@ -79,36 +83,48 @@ namespace Server.Mobiles foreach (var item in eable) { if (!pack.CheckHold(this, item, false, true)) + { return; + } NextActionTime = Core.TickCount; Lift(item, item.Amount, out var rejected, out var _); if (rejected) + { continue; + } Drop(this, Point3D.Zero); if (++pickedUp == 3) + { break; + } } } private void ConfirmRelease_Callback(Mobile from, bool okay) { if (okay) - EndRelease(from); + { + EndRelease(@from); + } } public override void BeginRelease(Mobile from) { if (Backpack?.Items.Count > 0) - from.SendGump( - new WarningGump(1060635, 30720, 1061672, 32512, 420, 280, okay => ConfirmRelease_Callback(from, okay)) + { + @from.SendGump( + new WarningGump(1060635, 30720, 1061672, 32512, 420, 280, okay => ConfirmRelease_Callback(@from, okay)) ); + } else - EndRelease(from); + { + EndRelease(@from); + } } public override void Serialize(IGenericWriter writer) @@ -128,7 +144,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } PackAnimal.CombineBackpacks(this); @@ -140,7 +158,9 @@ namespace Server.Mobiles public override bool IsSnoop(Mobile from) { if (PackAnimal.CheckAccess(this, from)) + { return false; + } return base.IsSnoop(from); } @@ -148,7 +168,9 @@ namespace Server.Mobiles public override bool OnDragDrop(Mobile from, Item item) { if (CheckFeed(from, item)) + { return true; + } if (PackAnimal.CheckAccess(this, from)) { diff --git a/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs b/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs index d46c2ab36..5bfebe689 100644 --- a/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs +++ b/Projects/UOContent/Mobiles/Familiars/ShadowWisp.cs @@ -49,7 +49,9 @@ namespace Server.Mobiles base.OnThink(); if (DateTime.UtcNow < m_NextFlare) + { return; + } m_NextFlare = DateTime.UtcNow + TimeSpan.FromSeconds(5.0 + 25.0 * Utility.RandomDouble()); @@ -64,7 +66,9 @@ namespace Server.Mobiles var caster = ControlMaster ?? SummonMaster; if (caster == null) + { return; + } var list = GetMobilesInRange(5) .Where( @@ -79,10 +83,14 @@ namespace Server.Mobiles var friendly = true; for (var j = 0; friendly && j < caster.Aggressors.Count; ++j) + { friendly = caster.Aggressors[j].Attacker != m; + } for (var j = 0; friendly && j < caster.Aggressed.Count; ++j) + { friendly = caster.Aggressed[j].Defender != m; + } if (friendly) { diff --git a/Projects/UOContent/Mobiles/Guards/ArcherGuard.cs b/Projects/UOContent/Mobiles/Guards/ArcherGuard.cs index 36e690b11..ddcca3bae 100644 --- a/Projects/UOContent/Mobiles/Guards/ArcherGuard.cs +++ b/Projects/UOContent/Mobiles/Guards/ArcherGuard.cs @@ -82,7 +82,9 @@ namespace Server.Mobiles set { if (Deleted) + { return; + } var oldFocus = m_Focus; @@ -91,15 +93,21 @@ namespace Server.Mobiles m_Focus = value; if (value != null) + { AggressiveAction(value); + } Combatant = value; if (oldFocus?.Alive == false) + { Say("Thou hast suffered thy punishment, scoundrel."); + } if (value != null) + { Say(500131); // Thou wilt regret thine actions, swine! + } if (m_AttackTimer != null) { @@ -136,7 +144,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (m_Focus?.Alive == true) + { new AvengeTimer(m_Focus).Start(); // If a guard dies, three more guards will spawn + } return base.OnBeforeDeath(); } @@ -255,7 +265,9 @@ namespace Server.Mobiles } if (target != null && m_Owner.Combatant != target) + { m_Owner.Combatant = target; + } if (target == null) { @@ -268,13 +280,17 @@ namespace Server.Mobiles target.BoltEffect(0); if (target is BaseCreature creature) + { creature.NoKillAwards = true; + } target.Damage(target.HitsMax, m_Owner); target.Kill(); // just in case, maybe Damage is overridden on some shard if (target.Corpse != null && !target.Player) + { target.Corpse.Delete(); + } m_Owner.Focus = null; Stop(); @@ -377,7 +393,9 @@ namespace Server.Mobiles } if (m_Stage++ % 4 == 0 || !m_Owner.Move(m_Owner.Direction)) + { m_Owner.Direction = (Direction)Utility.Random(8); + } if (m_Stage > 16) { diff --git a/Projects/UOContent/Mobiles/Guards/BaseGuard.cs b/Projects/UOContent/Mobiles/Guards/BaseGuard.cs index a7938d8ba..bfce8e083 100644 --- a/Projects/UOContent/Mobiles/Guards/BaseGuard.cs +++ b/Projects/UOContent/Mobiles/Guards/BaseGuard.cs @@ -30,9 +30,12 @@ namespace Server.Mobiles public static void Spawn(Mobile caller, Mobile target, int amount = 1, bool onlyAdditional = false) { if (target?.Deleted != false) + { return; + } foreach (var m in target.GetMobilesInRange(15)) + { if (m is BaseGuard g) { if (g.Focus == null) // idling @@ -46,9 +49,12 @@ namespace Server.Mobiles --amount; } } + } while (amount-- > 0) + { caller.Region.MakeGuard(target); + } } public override bool OnBeforeDeath() diff --git a/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs b/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs index ab1ce37d7..577da5588 100644 --- a/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs +++ b/Projects/UOContent/Mobiles/Guards/WarriorGuard.cs @@ -59,7 +59,9 @@ namespace Server.Mobiles Utility.AssignRandomHair(this); if (Utility.RandomBool()) + { Utility.AssignRandomFacialHair(this, HairHue); + } var weapon = new Halberd(); @@ -98,7 +100,9 @@ namespace Server.Mobiles set { if (Deleted) + { return; + } var oldFocus = m_Focus; @@ -107,15 +111,21 @@ namespace Server.Mobiles m_Focus = value; if (value != null) + { AggressiveAction(value); + } Combatant = value; if (oldFocus?.Alive == false) + { Say("Thou hast suffered thy punishment, scoundrel."); + } if (value != null) + { Say(500131); // Thou wilt regret thine actions, swine! + } if (m_AttackTimer != null) { @@ -152,7 +162,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (m_Focus?.Alive == true) + { new AvengeTimer(m_Focus).Start(); // If a guard dies, three more guards will spawn + } return base.OnBeforeDeath(); } @@ -265,7 +277,9 @@ namespace Server.Mobiles } if (target != null && m_Owner.Combatant != target) + { m_Owner.Combatant = target; + } if (target == null) { @@ -278,13 +292,17 @@ namespace Server.Mobiles target.BoltEffect(0); if (target is BaseCreature creature) + { creature.NoKillAwards = true; + } target.Damage(target.HitsMax, m_Owner); target.Kill(); // just in case, maybe Damage is overridden on some shard if (target.Corpse != null && !target.Player) + { target.Corpse.Delete(); + } m_Owner.Focus = null; Stop(); @@ -353,7 +371,9 @@ namespace Server.Mobiles } if (m_Stage++ % 4 == 0 || !m_Owner.Move(m_Owner.Direction)) + { m_Owner.Direction = (Direction)Utility.Random(8); + } if (m_Stage > 16) { diff --git a/Projects/UOContent/Mobiles/Healers/BaseHealer.cs b/Projects/UOContent/Mobiles/Healers/BaseHealer.cs index ec2cb4102..1386b9358 100644 --- a/Projects/UOContent/Mobiles/Healers/BaseHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/BaseHealer.cs @@ -120,8 +120,13 @@ namespace Server.Mobiles m_NextResurrect = DateTime.UtcNow + ResurrectDelay; if (m.Map?.CanFit(m.Location, 16, false, false) != true) + { m.SendLocalizedMessage(502391); // Thou can not be resurrected there! - else if (CheckResurrect(m)) OfferResurrection(m); + } + else if (CheckResurrect(m)) + { + OfferResurrection(m); + } } else if (HealsYoungPlayers && m.Hits < m.HitsMax && m is PlayerMobile mobile && mobile.Young) { diff --git a/Projects/UOContent/Mobiles/Healers/EvilHealer.cs b/Projects/UOContent/Mobiles/Healers/EvilHealer.cs index 6c672108d..0fd51e5e8 100644 --- a/Projects/UOContent/Mobiles/Healers/EvilHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/EvilHealer.cs @@ -26,7 +26,9 @@ namespace Server.Mobiles public override bool CheckTeach(SkillName skill, Mobile from) { if (!base.CheckTeach(skill, from)) + { return false; + } return skill == SkillName.Forensics || skill == SkillName.Healing diff --git a/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs b/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs index e74fbdd64..20be43369 100644 --- a/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs @@ -29,7 +29,9 @@ namespace Server.Mobiles public override bool CheckTeach(SkillName skill, Mobile from) { if (!base.CheckTeach(skill, from)) + { return false; + } return skill == SkillName.Anatomy || skill == SkillName.Camping @@ -54,7 +56,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.5) + { c.DropItem(new FragmentOfAMap()); + } } public override void Serialize(IGenericWriter writer) @@ -71,7 +75,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version < 1 && Title == "the wandering healer" && Core.AOS) + { Title = "the priest of Mondain"; + } } } } diff --git a/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs b/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs index 8c4c104d6..fcc41d01f 100644 --- a/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs +++ b/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs @@ -27,7 +27,9 @@ namespace Server.Mobiles public override bool CheckTeach(SkillName skill, Mobile from) { if (!base.CheckTeach(skill, from)) + { return false; + } return skill == SkillName.Anatomy || skill == SkillName.Healing diff --git a/Projects/UOContent/Mobiles/Healers/Healer.cs b/Projects/UOContent/Mobiles/Healers/Healer.cs index d1de8dfc0..88b135812 100644 --- a/Projects/UOContent/Mobiles/Healers/Healer.cs +++ b/Projects/UOContent/Mobiles/Healers/Healer.cs @@ -8,7 +8,9 @@ namespace Server.Mobiles Title = "the healer"; if (!Core.AOS) + { NameHue = 0x35; + } SetSkill(SkillName.Forensics, 80.0, 100.0); SetSkill(SkillName.SpiritSpeak, 80.0, 100.0); @@ -27,7 +29,9 @@ namespace Server.Mobiles public override bool CheckTeach(SkillName skill, Mobile from) { if (!base.CheckTeach(skill, from)) + { return false; + } return skill == SkillName.Forensics || skill == SkillName.Healing @@ -55,7 +59,9 @@ namespace Server.Mobiles } if (m.Karma < 0) + { Say(501224); // Thou hast strayed from the path of virtue, but thou still deservest a second chance. + } return true; } @@ -74,7 +80,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Core.AOS && NameHue == 0x35) + { NameHue = -1; + } } } } diff --git a/Projects/UOContent/Mobiles/Healers/PricedHealer.cs b/Projects/UOContent/Mobiles/Healers/PricedHealer.cs index 5c4f6ad62..030c9e3e1 100644 --- a/Projects/UOContent/Mobiles/Healers/PricedHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/PricedHealer.cs @@ -10,7 +10,9 @@ namespace Server.Mobiles Price = price; if (!Core.AOS) + { NameHue = 0x35; + } } public PricedHealer(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs b/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs index a329ecc8a..cad541e0e 100644 --- a/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs @@ -27,7 +27,9 @@ namespace Server.Mobiles public override bool CheckTeach(SkillName skill, Mobile from) { if (!base.CheckTeach(skill, from)) + { return false; + } return skill == SkillName.Anatomy || skill == SkillName.Camping @@ -51,7 +53,9 @@ namespace Server.Mobiles } if (m.Karma < 0) + { Say(501224); // Thou hast strayed from the path of virtue, but thou still deservest a second chance. + } return true; } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/AbysmalHorror.cs b/Projects/UOContent/Mobiles/Monsters/AOS/AbysmalHorror.cs index b575bdc66..074700bfc 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/AbysmalHorror.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/AbysmalHorror.cs @@ -69,7 +69,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Summoned && !NoKillAwards && DemonKnight.CheckArtifactChance(this)) + { DemonKnight.DistributeArtifact(this); + } } public override void Serialize(IGenericWriter writer) @@ -84,7 +86,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 357) + { BaseSoundID = 0x451; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/DarknightCreeper.cs b/Projects/UOContent/Mobiles/Monsters/AOS/DarknightCreeper.cs index 39f063798..71c166e82 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/DarknightCreeper.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/DarknightCreeper.cs @@ -71,7 +71,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Summoned && !NoKillAwards && DemonKnight.CheckArtifactChance(this)) + { DemonKnight.DistributeArtifact(this); + } } public override void Serialize(IGenericWriter writer) @@ -86,7 +88,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 471) + { BaseSoundID = 0xE0; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs b/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs index 8843185f8..68dcf3a7b 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/DemonKnight.cs @@ -111,7 +111,9 @@ namespace Server.Mobiles public static Item CreateRandomArtifact() { if (!Core.AOS) + { return null; + } var count = ArtifactRarity10.Length * 5 + ArtifactRarity11.Length * 4; var random = Utility.Random(count); @@ -139,7 +141,9 @@ namespace Server.Mobiles var ds = rights[i]; if (!ds.m_HasRight) + { rights.RemoveAt(i); + } } return rights.RandomElement()?.m_Mobile; @@ -163,12 +167,16 @@ namespace Server.Mobiles public static void DistributeArtifact(Mobile to, Item artifact) { if (to == null || artifact == null) + { return; + } var pack = to.Backpack; if (pack?.TryDropItem(to, artifact, false) != true) + { to.BankBox.DropItem(artifact); + } to.SendLocalizedMessage( 1062317 @@ -178,15 +186,21 @@ namespace Server.Mobiles public static int GetArtifactChance(Mobile boss) { if (!Core.AOS) + { return 0; + } var luck = LootPack.GetLuckChanceForKiller(boss); int chance; if (boss is DemonKnight) + { chance = 1500 + luck / 5; + } else + { chance = 750 + luck / 10; + } return chance; } @@ -209,7 +223,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Summoned && !NoKillAwards && CheckArtifactChance(this)) + { DistributeArtifact(this); + } } public override void GenerateLoot() @@ -229,7 +245,9 @@ namespace Server.Mobiles PlaySound(0x491); if (Utility.RandomDouble() < 0.05) - Timer.DelayCall(TimeSpan.FromSeconds(1.0), CreateBones_Callback, from); + { + Timer.DelayCall(TimeSpan.FromSeconds(1.0), CreateBones_Callback, @from); + } m_InHere = false; } @@ -240,7 +258,9 @@ namespace Server.Mobiles var map = from.Map; if (map == null) + { return; + } var count = Utility.RandomMinMax(1, 3); @@ -255,7 +275,9 @@ namespace Server.Mobiles z = map.GetAverageZ(x, y); if (z == from.Z || !map.CanFit(x, y, z, 16)) + { continue; + } } var bone = new UnholyBone diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/FleshRenderer.cs b/Projects/UOContent/Mobiles/Monsters/AOS/FleshRenderer.cs index f8fb17a72..e93ebdbed 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/FleshRenderer.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/FleshRenderer.cs @@ -69,7 +69,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Summoned && !NoKillAwards && DemonKnight.CheckArtifactChance(this)) + { DemonKnight.DistributeArtifact(this); + } } public override int GetAttackSound() => 0x34C; @@ -94,7 +96,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 660) + { BaseSoundID = -1; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs b/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs index 7c09d3858..4a80a1324 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/Impaler.cs @@ -70,7 +70,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Summoned && !NoKillAwards && DemonKnight.CheckArtifactChance(this)) + { DemonKnight.DistributeArtifact(this); + } } public override void Serialize(IGenericWriter writer) @@ -85,7 +87,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 1200) + { BaseSoundID = 0x2A7; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs b/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs index 9aef148d8..93c7f7f44 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/Revenant.cs @@ -102,6 +102,7 @@ namespace Server.Mobiles var to = m_Target.Location; if (toMap != null) + { for (var i = 0; i < 5; ++i) { var loc = new Point3D(to.X - 4 + Utility.Random(9), to.Y - 4 + Utility.Random(9), to.Z); @@ -120,6 +121,7 @@ namespace Server.Mobiles break; } } + } Map = toMap; Location = to; @@ -153,7 +155,9 @@ namespace Server.Mobiles FocusMob = m_Target; if (AIObject != null) + { AIObject.Action = ActionType.Combat; + } base.OnThink(); } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/ShadowKnight.cs b/Projects/UOContent/Mobiles/Monsters/AOS/ShadowKnight.cs index 73d66a551..25bec78f7 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/ShadowKnight.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/ShadowKnight.cs @@ -78,7 +78,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Summoned && !NoKillAwards && DemonKnight.CheckArtifactChance(this)) + { DemonKnight.DistributeArtifact(this); + } } public override int GetIdleSound() => 0x2CE; @@ -94,7 +96,9 @@ namespace Server.Mobiles base.OnCombatantChange(); if (Hidden && Combatant != null) + { Combatant = null; + } } public virtual void SendTrackingSound() @@ -121,6 +125,7 @@ namespace Server.Mobiles var map = Map; if (map != null) + { for (var i = 0; i < 10; ++i) { var x = X + Utility.RandomMinMax(5, 10) * (Utility.RandomBool() ? 1 : -1); @@ -128,13 +133,17 @@ namespace Server.Mobiles var z = Z; if (!map.CanFit(x, y, z, 16, false, false)) + { continue; + } var from = Location; var to = new Point3D(x, y, z); if (!InLOS(to)) + { continue; + } Location = to; ProcessDelta(); @@ -142,7 +151,7 @@ namespace Server.Mobiles Combatant = null; Effects.SendLocationParticles( - EffectItem.Create(from, map, EffectItem.DefaultDuration), + EffectItem.Create(@from, map, EffectItem.DefaultDuration), 0x3728, 10, 10, @@ -169,6 +178,7 @@ namespace Server.Mobiles break; } + } } base.OnThink(); @@ -186,7 +196,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 357) + { BaseSoundID = -1; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/Treefellow.cs b/Projects/UOContent/Mobiles/Monsters/AOS/Treefellow.cs index 84af1c054..b2850d857 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/Treefellow.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/Treefellow.cs @@ -72,7 +72,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 442) + { BaseSoundID = -1; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/AOS/WandererOfTheVoid.cs b/Projects/UOContent/Mobiles/Monsters/AOS/WandererOfTheVoid.cs index 54283b701..13051a7f8 100644 --- a/Projects/UOContent/Mobiles/Monsters/AOS/WandererOfTheVoid.cs +++ b/Projects/UOContent/Mobiles/Monsters/AOS/WandererOfTheVoid.cs @@ -43,7 +43,9 @@ namespace Server.Mobiles var count = Utility.RandomMinMax(2, 3); for (var i = 0; i < count; ++i) + { PackItem(new TreasureMap(3, Map.Trammel)); + } } public WandererOfTheVoid(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/AntLion.cs b/Projects/UOContent/Mobiles/Monsters/Ants/AntLion.cs index ea40f7d7c..168d04296 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/AntLion.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/AntLion.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles PackItem(new FertileDirt(Utility.RandomMinMax(1, 5))); if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(2)); + } var orepile = Utility.Random(4) switch { diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs index 14e7a0b6a..b3a787080 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs @@ -67,7 +67,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckBlackFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs index 7bbe72f2b..6a89e2c20 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs @@ -68,7 +68,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckBlackFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs index f9c17e48b..c6168f6dc 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenQueen.cs @@ -43,7 +43,9 @@ namespace Server.Mobiles PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 5 : 25)); if (Utility.RandomDouble() < 0.05) + { PackItem(new BallOfSummoning()); + } } public BlackSolenQueen(Serial serial) : base(serial) @@ -73,7 +75,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckBlackFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWarrior.cs index 73c87680e..4c493f49b 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWarrior.cs @@ -43,7 +43,9 @@ namespace Server.Mobiles PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.05 ? 13 : 3)); if (Utility.RandomDouble() < 0.05) + { PackItem(new BraceletOfBinding()); + } } public BlackSolenWarrior(Serial serial) : base(serial) @@ -74,7 +76,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckBlackFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWorker.cs b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWorker.cs index 460669c72..383784b1b 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWorker.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/BlackSolenWorker.cs @@ -68,7 +68,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckBlackFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs index 0a410828a..eaaf4105f 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs @@ -66,7 +66,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckRedFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs index 566f8a77f..71584f6de 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs @@ -67,7 +67,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckRedFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs index 4de0f4a00..fbdf85c47 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenQueen.cs @@ -42,7 +42,9 @@ namespace Server.Mobiles PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 5 : 25)); if (Utility.RandomDouble() < 0.05) + { PackItem(new BallOfSummoning()); + } } public RedSolenQueen(Serial serial) : base(serial) @@ -72,7 +74,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckRedFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs index c51004b31..4a0ba00d0 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWarrior.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 3 : 13)); if (Utility.RandomDouble() < 0.05) + { PackItem(new BraceletOfBinding()); + } } public RedSolenWarrior(Serial serial) : base(serial) @@ -72,7 +74,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckRedFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWorker.cs b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWorker.cs index e323ab22d..896920266 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWorker.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/RedSolenWorker.cs @@ -67,7 +67,10 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckRedFriendship(m)) + { return false; + } + return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Ants/SolenHelper.cs b/Projects/UOContent/Mobiles/Monsters/Ants/SolenHelper.cs index 21ed67f77..2f654ba78 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ants/SolenHelper.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ants/SolenHelper.cs @@ -23,9 +23,14 @@ namespace Server.Mobiles if (m is BaseCreature bc) { if (bc.Controlled && bc.ControlMaster is PlayerMobile) + { return CheckRedFriendship(bc.ControlMaster); + } + if (bc.Summoned && bc.SummonMaster is PlayerMobile) + { return CheckRedFriendship(bc.SummonMaster); + } } return m is PlayerMobile player && player.SolenFriendship == SolenFriendship.Red; @@ -36,9 +41,14 @@ namespace Server.Mobiles if (m is BaseCreature bc) { if (bc.Controlled && bc.ControlMaster is PlayerMobile) + { return CheckBlackFriendship(bc.ControlMaster); + } + if (bc.Summoned && bc.SummonMaster is PlayerMobile) + { return CheckBlackFriendship(bc.SummonMaster); + } } return m is PlayerMobile player && player.SolenFriendship == SolenFriendship.Black; @@ -49,9 +59,13 @@ namespace Server.Mobiles if (from is BaseCreature bc) { if (bc.Controlled && bc.ControlMaster is PlayerMobile) + { OnRedDamage(bc.ControlMaster); + } else if (bc.Summoned && bc.SummonMaster is PlayerMobile) + { OnRedDamage(bc.SummonMaster); + } } if (from is PlayerMobile player && player.SolenFriendship == SolenFriendship.Red) @@ -71,9 +85,13 @@ namespace Server.Mobiles if (from is BaseCreature bc) { if (bc.Controlled && bc.ControlMaster is PlayerMobile) + { OnBlackDamage(bc.ControlMaster); + } else if (bc.Summoned && bc.SummonMaster is PlayerMobile) + { OnBlackDamage(bc.SummonMaster); + } } if (from is PlayerMobile player && player.SolenFriendship == SolenFriendship.Black) diff --git a/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/DreadSpider.cs b/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/DreadSpider.cs index 2b1345cd4..8fe4d981d 100644 --- a/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/DreadSpider.cs +++ b/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/DreadSpider.cs @@ -70,7 +70,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 263) + { BaseSoundID = 1170; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/TerathanAvenger.cs b/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/TerathanAvenger.cs index 8fa4260d5..1dca6c6c4 100644 --- a/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/TerathanAvenger.cs +++ b/Projects/UOContent/Mobiles/Monsters/Arachnid/Magic/TerathanAvenger.cs @@ -70,7 +70,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 263) + { BaseSoundID = 0x24D; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/FrostSpider.cs b/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/FrostSpider.cs index 8a1c2d732..09021bbba 100644 --- a/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/FrostSpider.cs +++ b/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/FrostSpider.cs @@ -72,7 +72,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 387) + { BaseSoundID = 0x388; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanDrone.cs b/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanDrone.cs index 4314d2139..ddc2fe0a9 100644 --- a/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanDrone.cs +++ b/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanDrone.cs @@ -69,7 +69,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 589) + { BaseSoundID = 594; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanWarrior.cs index dd5c487e8..aa48250f3 100644 --- a/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Arachnid/Melee/TerathanWarrior.cs @@ -38,7 +38,9 @@ namespace Server.Mobiles VirtualArmor = 30; if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(3)); + } } public TerathanWarrior(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AcidElemental.cs b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AcidElemental.cs index 8111796a1..b0fb9541a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AcidElemental.cs +++ b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AcidElemental.cs @@ -72,13 +72,19 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 263) + { BaseSoundID = 278; + } if (Body == 13) + { Body = 0x9E; + } if (Hue == 0x4001) + { Hue = 0; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AirElemental.cs b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AirElemental.cs index fc173824d..2e292c837 100644 --- a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AirElemental.cs +++ b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/AirElemental.cs @@ -73,7 +73,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 263) + { BaseSoundID = 655; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/Efreet.cs b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/Efreet.cs index bbf975ea9..469f59827 100644 --- a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/Efreet.cs +++ b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/Efreet.cs @@ -55,6 +55,7 @@ namespace Server.Mobiles AddLoot(LootPack.Gems); if (Utility.RandomDouble() < 0.02) + { switch (Utility.Random(5)) { case 0: @@ -73,6 +74,7 @@ namespace Server.Mobiles PackItem(new DaemonHelm()); break; } + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/FireElemental.cs b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/FireElemental.cs index d9baf6382..e8ad5fb70 100644 --- a/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/FireElemental.cs +++ b/Projects/UOContent/Mobiles/Monsters/Elemental/Magic/FireElemental.cs @@ -76,7 +76,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 274) + { BaseSoundID = 838; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs index 2d48d2cab..02a47d00a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs @@ -47,7 +47,9 @@ namespace Server.Mobiles PackItem(new PowerCrystal()); if (Utility.RandomDouble() < 0.02) + { PackItem(new BlackthornWelcomeBook()); + } m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); } @@ -76,9 +78,13 @@ namespace Server.Mobiles if (!IsParagon) { if (Utility.RandomDouble() < 0.75) + { c.DropItem(DawnsMusicGear.RandomCommon); + } else + { c.DropItem(DawnsMusicGear.RandomUncommon); + } } else { @@ -118,7 +124,9 @@ namespace Server.Mobiles ); if (Weapon is BaseWeapon weapon) + { weapon.OnHit(this, defender); + } if (defender.Alive) { @@ -142,7 +150,9 @@ namespace Server.Mobiles if (DateTime.UtcNow < m_NextAbilityTime || combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 3) || !CanBeHarmful(combatant) || !InLOS(combatant)) + { return; + } m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); @@ -152,8 +162,12 @@ namespace Server.Mobiles PlaySound(0x1DE); foreach (var m in GetMobilesInRange(2)) + { if (m != this && IsEnemy(m)) + { m.ApplyPoison(this, Poison.Deadly); + } + } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/EvilMageLord.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/EvilMageLord.cs index 56a5b9a50..508da8ef4 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/EvilMageLord.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/EvilMageLord.cs @@ -42,9 +42,13 @@ namespace Server.Mobiles VirtualArmor = 16; PackReg(23); if (Utility.RandomBool()) + { PackItem(new Shoes()); + } else + { PackItem(new Sandals()); + } } public EvilMageLord(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs index 80abd8f1d..599390b49 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs @@ -37,7 +37,9 @@ namespace Server.Mobiles VirtualArmor = 32; if (Utility.RandomDouble() < 0.025) + { PackItem(new GargoylesPickaxe()); + } } public Gargoyle(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs index 807e5b675..cf5e47c5e 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles VirtualArmor = 50; if (Utility.RandomDouble() < 0.2) + { PackItem(new GargoylesPickaxe()); + } } public GargoyleDestroyer(Serial serial) : base(serial) @@ -66,7 +68,9 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { if (from?.Alive == true && Utility.RandomDouble() < 0.4) - ThrowHatchet(from); + { + ThrowHatchet(@from); + } } public override void OnGotMeleeAttack(Mobile attacker) @@ -74,7 +78,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (attacker?.Alive == true && attacker.Weapon is BaseRanged && Utility.RandomDouble() < 0.4) + { ThrowHatchet(attacker); + } } public void ThrowHatchet(Mobile to) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs index 7db1f1ad8..242c8dffc 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs @@ -39,7 +39,9 @@ namespace Server.Mobiles VirtualArmor = 50; if (Utility.RandomDouble() < 0.2) + { PackItem(new GargoylesPickaxe()); + } } public GargoyleEnforcer(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GolemController.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GolemController.cs index c9ca8d5cd..b76607323 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GolemController.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/GolemController.cs @@ -47,7 +47,9 @@ namespace Server.Mobiles VirtualArmor = 16; if (Utility.RandomDouble() < 0.7) + { PackItem(new ArcaneGem()); + } } public GolemController(Serial serial) : base(serial) @@ -67,7 +69,10 @@ namespace Server.Mobiles public void AddArcane(Item item) { - if (item is IArcaneEquip eq) eq.CurArcaneCharges = eq.MaxArcaneCharges = 20; + if (item is IArcaneEquip eq) + { + eq.CurArcaneCharges = eq.MaxArcaneCharges = 20; + } item.Hue = ArcaneGem.DefaultArcaneHue; item.LootType = LootType.Newbied; diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs index 3b7d34c91..0eb72f21c 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles PackReg(6); if (Utility.RandomDouble() < 0.05) + { PackItem(new OrcishKinMask()); + } } public OrcishMage(Serial serial) : base(serial) @@ -68,7 +70,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask) + { return false; + } return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs index 130c94b27..c9c3944f3 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles PackReg(6); if (Utility.RandomDouble() < 0.02) + { PackStatue(); + } } public RatmanMage(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs index 89a90135e..50b08d09a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs @@ -13,9 +13,13 @@ namespace Server.Mobiles Name = NameList.RandomName("savage shaman"); if (Utility.RandomBool()) + { Body = 184; + } else + { Body = 183; + } SetStr(126, 145); SetDex(91, 110); @@ -48,7 +52,9 @@ namespace Server.Mobiles PackItem(new Bandage(Utility.RandomMinMax(1, 15))); if (Utility.RandomDouble() < 0.1) + { PackItem(new TribalBerry()); + } AddItem(new BoneArms()); AddItem(new BoneLegs()); @@ -75,7 +81,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.BodyMod == 183 || m.BodyMod == 184) + { return false; + } return base.IsEnemy(m); } @@ -94,7 +102,9 @@ namespace Server.Mobiles aggressor.SendLocalizedMessage(1040008); // Your skin is scorched as the tribal paint burns away! if (aggressor is PlayerMobile mobile) + { mobile.SavagePaintExpiration = TimeSpan.Zero; + } } } @@ -102,7 +112,9 @@ namespace Server.Mobiles { if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || to is LesserHiryu || to is Daemon) + { damage *= 3; + } } public override void OnGotMeleeAttack(Mobile attacker) @@ -110,24 +122,34 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() < 0.1) + { BeginSavageDance(); + } } public void BeginSavageDance() { if (Map == null) + { return; + } var list = new List(); foreach (var m in GetMobilesInRange(8)) + { if (m != this && m is SavageShaman ss) + { list.Add(ss); + } + } Animate(111, 5, 1, true, false, 0); // Do a little dance... if (AIObject != null) + { AIObject.NextMove = Core.TickCount + 1000; + } if (list.Count >= 3) { @@ -138,7 +160,9 @@ namespace Server.Mobiles dancer.Animate(111, 5, 1, true, false, 0); // Get down tonight... if (dancer.AIObject != null) + { dancer.AIObject.NextMove = Core.TickCount + 1000; + } } Timer.DelayCall(TimeSpan.FromSeconds(1.0), EndSavageDance); @@ -148,7 +172,9 @@ namespace Server.Mobiles public void EndSavageDance() { if (Deleted) + { return; + } var eable = GetMobilesInRange(8); @@ -161,10 +187,14 @@ namespace Server.Mobiles var isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; if (!isFriendly) + { continue; + } if (m.Poisoned || MortalStrike.IsWounded(m) || !CanBeBeneficial(m)) + { continue; + } DoBeneficial(m); @@ -188,10 +218,14 @@ namespace Server.Mobiles var isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; if (isFriendly) + { continue; + } if (!CanBeHarmful(m)) + { continue; + } DoHarmful(m); @@ -222,10 +256,14 @@ namespace Server.Mobiles var isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; if (isFriendly) + { continue; + } if (!CanBeHarmful(m)) + { continue; + } DoHarmful(m); @@ -238,18 +276,28 @@ namespace Server.Mobiles var dist = GetDistanceToSqrt(m); if (dist >= 3.0) + { total -= (dist - 3.0) * 10.0; + } int level; if (total >= 200.0 && Utility.Random(1, 100) <= 10) + { level = 3; + } else if (total > 170.0) + { level = 2; + } else if (total > 130.0) + { level = 1; + } else + { level = 0; + } m.ApplyPoison(this, Poison.GetPoison(level)); diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Succubus.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Succubus.cs index 94e7dc538..2af283bf4 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Succubus.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Succubus.cs @@ -63,7 +63,9 @@ namespace Server.Mobiles if (m == this || !CanBeHarmful(m) || !(m.Player || m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != Team))) + { continue; + } DoHarmful(m); @@ -86,7 +88,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() <= 0.1) + { DrainLife(); + } } public override void OnGotMeleeAttack(Mobile attacker) @@ -94,7 +98,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() <= 0.1) + { DrainLife(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Titan.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Titan.cs index 136a8ca50..3dba46e41 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Titan.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/Titan.cs @@ -38,7 +38,9 @@ namespace Server.Mobiles VirtualArmor = 40; if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(1)); + } } public Titan(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Brigand.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Brigand.cs index b48309dc9..936c0397a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Brigand.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Brigand.cs @@ -73,7 +73,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.9) + { c.DropItem(new SeveredHumanEars()); + } } public override void GenerateLoot() diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs index ca204c17f..6e12d56d4 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs @@ -92,7 +92,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.9) + { c.DropItem(new SeveredElfEars()); + } } public override void GenerateLoot() diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs index 74b565b89..22111a70d 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs @@ -34,7 +34,9 @@ namespace Server.Mobiles VirtualArmor = 35; if (Utility.RandomDouble() < 0.2) + { PackItem(new GargoylesPickaxe()); + } } public EnslavedGargoyle(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs index c71e3091f..bac1a1ab6 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs @@ -42,10 +42,14 @@ namespace Server.Mobiles VirtualArmor = 70; if (Utility.RandomDouble() < 0.1) + { PackItem(new PowerCrystal()); + } if (Utility.RandomDouble() < 0.4) + { PackItem(new ClockworkAssembly()); + } } public Juggernaut(Serial serial) : base(serial) @@ -72,9 +76,13 @@ namespace Server.Mobiles if (!IsParagon) { if (Utility.RandomDouble() < 0.75) + { c.DropItem(DawnsMusicGear.RandomCommon); + } else + { c.DropItem(DawnsMusicGear.RandomUncommon); + } } else { @@ -113,7 +121,9 @@ namespace Server.Mobiles ); if (Weapon is BaseWeapon weapon) + { weapon.OnHit(this, defender); + } if (defender.Alive) { diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs index dd5217b98..925527280 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs @@ -77,11 +77,15 @@ namespace Server.Mobiles var lastKiller = m.LastKiller; if (lastKiller is BaseCreature creature) + { lastKiller = creature.GetMaster(); + } if (IsInsideKhaldun(m) && IsInsideKhaldun(lastKiller) && lastKiller.Player && !m_Set.Contains(lastKiller) && m.Aggressors.Any(ai => ai.Attacker == lastKiller && ai.CanReportMurder)) + { SummonRevenant(m, lastKiller); + } } public static void SummonRevenant(Mobile victim, Mobile killer) @@ -120,7 +124,9 @@ namespace Server.Mobiles // FocusMob = m_Target; if (AIObject != null) + { AIObject.Action = ActionType.Combat; + } base.OnThink(); } @@ -134,7 +140,9 @@ namespace Server.Mobiles public override void OnDelete() { if (m_Target != null) + { m_Set.Remove(m_Target); + } base.OnDelete(); } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Mummy.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Mummy.cs index 884f361ea..d345cf974 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Mummy.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Mummy.cs @@ -38,7 +38,9 @@ namespace Server.Mobiles VirtualArmor = 50; if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(2)); + } PackItem(new Garlic(5)); PackItem(new Bandage(10)); diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Orc.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Orc.cs index cec0a1cfb..acb5c1e3b 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Orc.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Orc.cs @@ -62,7 +62,9 @@ namespace Server.Mobiles ); if (Utility.RandomDouble() < 0.2) + { PackItem(new BolaBall()); + } } public Orc(Serial serial) : base(serial) @@ -86,7 +88,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask) + { return false; + } return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs index 4d4acbff4..9a6f8be54 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs @@ -49,7 +49,9 @@ namespace Server.Mobiles PackItem(new LesserExplosionPotion()); if (Utility.RandomDouble() < 0.2) + { PackItem(new BolaBall()); + } } public OrcBomber(Serial serial) : base(serial) @@ -74,7 +76,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask) + { return false; + } return base.IsEnemy(m); } @@ -100,7 +104,9 @@ namespace Server.Mobiles if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) || !CanBeHarmful(combatant) || !InLOS(combatant)) + { return; + } if (DateTime.UtcNow >= m_NextBomb) { @@ -109,9 +115,13 @@ namespace Server.Mobiles m_Thrown++; if (Utility.RandomDouble() <= 0.75 && m_Thrown % 2 == 1) // 75% chance to quickly throw another bomb + { m_NextBomb = DateTime.UtcNow + TimeSpan.FromSeconds(3.0); + } else + { m_NextBomb = DateTime.UtcNow + TimeSpan.FromSeconds(5.0 + 10.0 * Utility.RandomDouble()); // 5-15 seconds + } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs index 55fa18d35..d07b31a81 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs @@ -43,10 +43,14 @@ namespace Server.Mobiles PackItem(new IronIngot(10)); if (Utility.RandomDouble() < 0.05) + { PackItem(new OrcishKinMask()); + } if (Utility.RandomDouble() < 0.2) + { PackItem(new BolaBall()); + } } public OrcBrute(Serial serial) : base(serial) @@ -74,7 +78,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask) + { return false; + } return base.IsEnemy(m); } @@ -97,7 +103,9 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile caster) { if (caster == this) + { return; + } SpawnOrcLord(caster); } @@ -107,7 +115,9 @@ namespace Server.Mobiles var map = target.Map; if (map == null) + { return; + } var eable = GetMobilesInRange(10); diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcCaptain.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcCaptain.cs index 2c69243c8..417de8bca 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcCaptain.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcCaptain.cs @@ -52,7 +52,9 @@ namespace Server.Mobiles ); if (Core.AOS) + { PackItem(Loot.RandomNecromancyReagent()); + } } public OrcCaptain(Serial serial) : base(serial) @@ -73,7 +75,9 @@ namespace Server.Mobiles // TODO: Check drop rate if (Utility.RandomDouble() < 0.05) + { c.DropItem(new StoutWhip()); + } } public override void GenerateLoot() @@ -84,7 +88,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask) + { return false; + } return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs index ad235e6f1..e43631519 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs @@ -49,10 +49,14 @@ namespace Server.Mobiles PackItem(new RingmailChest()); if (Utility.RandomDouble() < 0.3) + { PackItem(Loot.RandomPossibleReagent()); + } if (Utility.RandomDouble() < 0.2) + { PackItem(new BolaBall()); + } } public OrcishLord(Serial serial) : base(serial) @@ -80,7 +84,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.Player && m.FindItemOnLayer(Layer.Helm) is OrcishKinMask) + { return false; + } return base.IsEnemy(m); } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs index 38296fd86..dfcae9946 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs @@ -63,8 +63,12 @@ namespace Server.Mobiles base.GetContextMenuEntries(from, list); for (var i = 0; i < list.Count; ++i) + { if (list[i] is PaperdollEntry) + { list.RemoveAt(i--); + } + } } public override int GetIdleSound() => 0x107; @@ -80,7 +84,10 @@ namespace Server.Mobiles { var qs = player.Quest; - if (qs is UzeraanTurmoilQuest && qs.IsObjectiveInProgress(typeof(FindSchmendrickObjective))) return false; + if (qs is UzeraanTurmoilQuest && qs.IsObjectiveInProgress(typeof(FindSchmendrickObjective))) + { + return false; + } } return base.IsEnemy(m); diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs index 79049d39a..100dc84e7 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs @@ -11,9 +11,13 @@ namespace Server.Mobiles Name = NameList.RandomName("savage"); if (Female = Utility.RandomBool()) + { Body = 184; + } else + { Body = 183; + } SetStr(96, 115); SetDex(86, 105); @@ -36,18 +40,26 @@ namespace Server.Mobiles PackItem(new Bandage(Utility.RandomMinMax(1, 15))); if (Female && Utility.RandomDouble() < 0.1) + { PackItem(new TribalBerry()); + } else if (!Female && Utility.RandomDouble() < 0.1) + { PackItem(new BolaBall()); + } AddItem(new Spear()); AddItem(new BoneArms()); AddItem(new BoneLegs()); if (Utility.RandomDouble() < 0.5) + { AddItem(new SavageMask()); + } else if (Utility.RandomDouble() < 0.1) + { AddItem(new OrcishKinMask()); + } } public Savage(Serial serial) : base(serial) @@ -70,7 +82,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.BodyMod == 183 || m.BodyMod == 184) + { return false; + } return base.IsEnemy(m); } @@ -89,7 +103,9 @@ namespace Server.Mobiles aggressor.SendLocalizedMessage(1040008); // Your skin is scorched as the tribal paint burns away! if (aggressor is PlayerMobile mobile) + { mobile.SavagePaintExpiration = TimeSpan.Zero; + } } } @@ -97,7 +113,9 @@ namespace Server.Mobiles { if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || to is LesserHiryu || to is Daemon) + { damage *= 3; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs index a8ebb8a0c..bfa2b98b1 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs @@ -11,9 +11,13 @@ namespace Server.Mobiles Name = NameList.RandomName("savage rider"); if (Female = Utility.RandomBool()) + { Body = 186; + } else + { Body = 185; + } SetStr(151, 170); SetDex(92, 130); @@ -37,7 +41,9 @@ namespace Server.Mobiles PackItem(new Bandage(Utility.RandomMinMax(1, 15))); if (Utility.RandomDouble() < 0.1) + { PackItem(new BolaBall()); + } AddItem(new TribalSpear()); AddItem(new BoneArms()); @@ -69,10 +75,14 @@ namespace Server.Mobiles var mount = Mount; if (mount != null) + { mount.Rider = null; + } if (mount is Mobile mobile) + { mobile.Delete(); + } return base.OnBeforeDeath(); } @@ -80,7 +90,9 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { if (m.BodyMod == 183 || m.BodyMod == 184) + { return false; + } return base.IsEnemy(m); } @@ -99,7 +111,9 @@ namespace Server.Mobiles aggressor.SendLocalizedMessage(1040008); // Your skin is scorched as the tribal paint burns away! if (aggressor is PlayerMobile mobile) + { mobile.SavagePaintExpiration = TimeSpan.Zero; + } } } @@ -107,7 +121,9 @@ namespace Server.Mobiles { if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || to is LesserHiryu || to is Daemon) + { damage *= 3; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs index 25be8c22f..635b9f15e 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs @@ -117,9 +117,13 @@ namespace Server.Mobiles } foreach (var m in m_Owner.GetMobilesInRange(3)) + { if (m != m_Owner && m.Player && m.Hidden && m_Owner.CanBeHarmful(m) && m.AccessLevel == AccessLevel.Player) + { m.Hidden = false; + } + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SpectralArmour.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SpectralArmour.cs index 3b151c88c..7c46d85f5 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SpectralArmour.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SpectralArmour.cs @@ -58,7 +58,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } var gold = new Gold(Utility.RandomMinMax(240, 375)); gold.MoveToWorld(Location, Map); diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs index 345070909..fe65c0fb5 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs @@ -38,7 +38,9 @@ namespace Server.Mobiles PackItem(new IronIngot(12)); if (Utility.RandomDouble() < 0.05) + { PackItem(new GargoylesPickaxe()); + } } public StoneGargoyle(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs index 54767ccfd..8bb9b26b9 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs @@ -89,18 +89,25 @@ namespace Server.Mobiles public override void AlterMeleeDamageFrom(Mobile from, ref int damage) { if (FieldActive) + { damage = 0; // no melee damage when the field is up + } } public override void AlterSpellDamageFrom(Mobile from, ref int damage) { if (!FieldActive) + { damage = 0; // no spell damage when the field is down + } } public override void OnDamagedBySpell(Mobile from) { - if (from?.Alive == true && Utility.RandomDouble() < 0.4) SendEBolt(from); + if (from?.Alive == true && Utility.RandomDouble() < 0.4) + { + SendEBolt(@from); + } if (!FieldActive) { @@ -130,7 +137,9 @@ namespace Server.Mobiles } if (attacker?.Alive == true && attacker.Weapon is BaseRanged && Utility.RandomDouble() < 0.4) + { SendEBolt(attacker); + } } public override void OnThink() @@ -139,7 +148,9 @@ namespace Server.Mobiles // TODO: an OSI bug prevents to verify if the field can regenerate or not if (!FieldActive && !IsHurt()) + { FieldActive = true; + } } public override bool Move(Direction d) @@ -147,7 +158,9 @@ namespace Server.Mobiles var move = base.Move(d); if (move && FieldActive && Combatant != null) + { FixedParticles(0, 10, 0, 0x2530, EffectLayer.Waist); + } return move; } @@ -174,7 +187,9 @@ namespace Server.Mobiles FieldActive = CanUseField; if (Name == "Exodus Minion") + { Name = null; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs index 42e5796e3..742367266 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs @@ -35,9 +35,13 @@ namespace Server.Mobiles VirtualArmor = 50; if (Utility.Random(2) == 0) + { PackItem(new PowerCrystal()); + } else + { PackItem(new ArcaneGem()); + } FieldActive = CanUseField; } @@ -79,18 +83,25 @@ namespace Server.Mobiles public override void AlterMeleeDamageFrom(Mobile from, ref int damage) { if (FieldActive) + { damage = 0; // no melee damage when the field is up + } } public override void AlterSpellDamageFrom(Mobile caster, ref int damage) { if (!FieldActive) + { damage = 0; // no spell damage when the field is down + } } public override void OnDamagedBySpell(Mobile from) { - if (from?.Alive == true && Utility.RandomDouble() < 0.4) SendEBolt(from); + if (from?.Alive == true && Utility.RandomDouble() < 0.4) + { + SendEBolt(@from); + } if (!FieldActive) { @@ -120,7 +131,9 @@ namespace Server.Mobiles } if (attacker?.Alive == true && attacker.Weapon is BaseRanged && Utility.RandomDouble() < 0.4) + { SendEBolt(attacker); + } } public override void OnThink() @@ -129,7 +142,9 @@ namespace Server.Mobiles // TODO: an OSI bug prevents to verify if the field can regenerate or not if (!FieldActive && !IsHurt()) + { FieldActive = true; + } } public override bool Move(Direction d) @@ -137,7 +152,9 @@ namespace Server.Mobiles var move = base.Move(d); if (move && FieldActive && Combatant != null) + { FixedParticles(0, 10, 0, 0x2530, EffectLayer.Waist); + } return move; } @@ -164,7 +181,9 @@ namespace Server.Mobiles FieldActive = CanUseField; if (Name == "Exodus Overseer") + { Name = null; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs index 817a1d3a6..d64dc7a4f 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs @@ -120,7 +120,9 @@ namespace Server.Mobiles var mount = Mount; if (mount != null) + { mount.Rider = null; + } return base.OnBeforeDeath(); } @@ -129,7 +131,9 @@ namespace Server.Mobiles { if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || to is LesserHiryu || to is Daemon) + { damage *= 3; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs index cb29c77ee..9e1aab189 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs @@ -139,7 +139,9 @@ namespace Server.Mobiles if (mount != null) { if (mount is SwampDragon dragon) + { dragon.HasBarding = false; + } mount.Rider = null; } @@ -151,7 +153,9 @@ namespace Server.Mobiles { if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || to is LesserHiryu || to is Daemon) + { damage *= 3; + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs index 2142798dc..dbf31f060 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaMage.cs @@ -52,10 +52,14 @@ namespace Server.Mobiles var item = Loot.RandomReagent(); if (item == null) + { continue; + } if (!bag.TryDropItem(this, item, false)) + { item.Delete(); + } } PackItem(bag); @@ -63,7 +67,9 @@ namespace Server.Mobiles PackItem(new ArcaneGem()); if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(4)); + } m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5)); } @@ -100,12 +106,14 @@ namespace Server.Mobiles JukaLord toBuff = null; foreach (var m in GetMobilesInRange(8)) + { if (m is JukaLord lord && IsFriend(lord) && lord.Combatant != null && CanBeBeneficial(lord) && lord.CanBeginAction() && InLOS(lord)) { toBuff = lord; break; } + } if (toBuff != null) { @@ -131,7 +139,9 @@ namespace Server.Mobiles toScale = toBuff.RawStr; if (toScale > 0) + { toBuff.RawStr += AOS.Scale(toScale, 50); + } toScale = toBuff.RawDex; @@ -171,7 +181,9 @@ namespace Server.Mobiles toDebuff.EndAction(); if (toDebuff.Deleted) + { return; + } toDebuff.HitsMaxSeed = hitsMaxSeed; toDebuff.RawStr = rawStr; diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs index a62b0b35d..57d256753 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs @@ -40,7 +40,9 @@ namespace Server.Mobiles VirtualArmor = 22; if (Utility.RandomDouble() < 0.1) + { PackItem(new ArcaneGem()); + } } public JukaWarrior(Serial serial) : base(serial) @@ -74,7 +76,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() > 0.2) + { return; + } switch (Utility.Random(3)) { diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs index 11eaae8a3..d6b4fbfb6 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs @@ -165,9 +165,14 @@ namespace Server.Mobiles */ if (Str < Hits) + { Str = Hits; + } + if (Dex < Stam) + { Dex = Stam; + } Karma = -1000; Tamable = false; @@ -203,7 +208,9 @@ namespace Server.Mobiles else if (!Combat(SummonMaster)) { if (Combatant.Player || Combatant is BaseCreature bc && (bc.Controlled || bc.SummonMaster != null)) + { SummonMaster.Combatant = Combatant; + } } else { diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs index 4308a7eb8..b0c9beddb 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs @@ -66,10 +66,14 @@ namespace Server.Mobiles var item = Loot.RandomReagent(); if (item == null) + { continue; + } if (!bag.TryDropItem(this, item, false)) + { item.Delete(); + } } pack.DropItem(bag); @@ -122,7 +126,9 @@ namespace Server.Mobiles { if (!(m is MeerWarrior) || !IsFriend(m) || !CanBeBeneficial(m) || m.Hits >= m.HitsMax || m.Poisoned || MortalStrike.IsWounded(m)) + { continue; + } DoBeneficial(m); diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs index 0105fa7c7..7adefd005 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerEternal.cs @@ -96,11 +96,17 @@ namespace Server.Mobiles double scalar; if (list.Count == 1) + { scalar = 0.75; + } else if (list.Count == 2) + { scalar = 0.50; + } else + { scalar = 0.25; + } for (var i = 0; i < list.Count; ++i) { diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs index afdf14575..a9a22cc9a 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerMage.cs @@ -86,10 +86,16 @@ namespace Server.Mobiles m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30)); if (combatant is BaseCreature bc) + { if (bc.Controlled && bc.ControlMaster?.Deleted == false && bc.ControlMaster.Alive) + { if (bc.ControlMaster.Map == Map && bc.ControlMaster.InRange(this, 12) && !UnderEffect(bc.ControlMaster)) + { Combatant = combatant = bc.ControlMaster; + } + } + } if (Utility.RandomDouble() < .1) { @@ -106,7 +112,9 @@ namespace Server.Mobiles var loc = new Point3D(x, y, combatant.Map.GetAverageZ(x, y)); if (!combatant.Map.CanSpawnMobile(loc)) + { continue; + } var rabid = i switch { @@ -149,12 +157,14 @@ namespace Server.Mobiles if (m_Table.Remove(m, out var timer)) { if (message) + { m.PublicOverheadMessage( MessageType.Emote, m.SpeechHue, true, "* The open flame begins to scatter the swarm of insects *" ); + } timer.Stop(); } @@ -197,7 +207,9 @@ namespace Server.Mobiles AOS.Damage(m, this, Utility.RandomMinMax(30, 40) - (Core.AOS ? 0 : 10), 100, 0, 0, 0, 0); if (!m.Alive) + { StopEffect(m, false); + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Animal/CuSidhe.cs b/Projects/UOContent/Mobiles/Monsters/ML/Animal/CuSidhe.cs index e2d8c06fd..ff7c2ff5f 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Animal/CuSidhe.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Animal/CuSidhe.cs @@ -10,11 +10,17 @@ namespace Server.Mobiles var chance = Utility.RandomDouble() * 23301; if (chance <= 1) + { Hue = 0x489; + } else if (chance < 50) + { Hue = Utility.RandomList(0x657, 0x515, 0x4B1, 0x481, 0x482, 0x455); + } else if (chance < 500) + { Hue = Utility.RandomList(0x97A, 0x978, 0x901, 0x8AC, 0x5A7, 0x527); + } SetStr(1200, 1225); SetDex(150, 170); @@ -48,7 +54,9 @@ namespace Server.Mobiles MinTameSkill = 101.1; if (Utility.RandomDouble() < 0.2) + { PackItem(new TreasureMap(5, Map.Trammel)); + } // if (Utility.RandomDouble() < 0.1) // PackItem( new ParrotItem() ); @@ -124,7 +132,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version < 1 && Name == "a Cu Sidhe") + { Name = null; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Animal/Ferret.cs b/Projects/UOContent/Mobiles/Monsters/ML/Animal/Ferret.cs index 9e17963ec..deb5ff324 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Animal/Ferret.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Animal/Ferret.cs @@ -59,7 +59,9 @@ namespace Server.Mobiles public override void OnMovement(Mobile m, Point3D oldLocation) { if (m is Ferret ferret && ferret.InRange(this, 3) && ferret.Alive) + { Talk(ferret); + } } public void Talk() @@ -72,12 +74,16 @@ namespace Server.Mobiles if (m_CanTalk) { if (to != null) + { QuestSystem.FocusTo(this, to); + } Say(m_Vocabulary.RandomElement()); if (to != null && Utility.RandomBool()) + { Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 8)), to.Talk); + } m_CanTalk = false; diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs index 73d3dfb81..94c699557 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs @@ -74,10 +74,14 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { return; + } if (m_Table.TryGetValue(defender, out var timer)) + { timer.DoExpire(); + } defender.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot); defender.PlaySound(0x208); diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs index 60c4aac8c..d93b18af8 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs @@ -37,9 +37,13 @@ namespace Server.Mobiles Karma = -18000; if (Utility.RandomBool()) + { PackNecroScroll(Utility.RandomMinMax(5, 9)); + } else + { PackScroll(4, 7); + } PackReg(7); PackReg(7); diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs index 28527f0cd..6fbec7e94 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs @@ -37,9 +37,13 @@ namespace Server.Mobiles Karma = -18000; if (Utility.RandomBool()) + { PackNecroScroll(Utility.RandomMinMax(5, 9)); + } else + { PackScroll(4, 7); + } PackReg(3); PackNecroReg(1, 10); diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterTheophilus.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterTheophilus.cs index dc325b2af..51c49d1c9 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterTheophilus.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/MasterTheophilus.cs @@ -44,10 +44,16 @@ namespace Server.Mobiles AddItem(new Robe(0x452)); for (var i = 0; i < 2; ++i) + { if (Utility.RandomBool()) + { PackNecroScroll(Utility.RandomMinMax(5, 9)); + } else + { PackScroll(4, 7); + } + } PackReg(7); PackReg(7); diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/RedDeath.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/RedDeath.cs index 36e8d2132..dc6f278a0 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/RedDeath.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/RedDeath.cs @@ -43,9 +43,13 @@ namespace Server.Mobiles Karma = -28000; if (Utility.RandomBool()) + { PackNecroScroll(Utility.RandomMinMax(5, 9)); + } else + { PackScroll(4, 7); + } } public RedDeath(Serial serial) diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs index a7ccfc9ee..98aaa1f2c 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs @@ -71,7 +71,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() < 0.1) + { DrainLife(); + } } public override void OnGotMeleeAttack(Mobile attacker) @@ -79,7 +81,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() < 0.1) + { DrainLife(); + } } public virtual void DrainLife() @@ -89,12 +93,16 @@ namespace Server.Mobiles foreach (var m in GetMobilesInRange(2)) { if (m == this || !CanBeHarmful(m, false) || Core.AOS && !InLOS(m)) + { continue; + } if (m is BaseCreature bc) { if (bc.Controlled || bc.Summoned || bc.Team != Team) + { list.Add(bc); + } } else if (m.Player) { diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Blighted Grove/Tangle.cs b/Projects/UOContent/Mobiles/Monsters/ML/Blighted Grove/Tangle.cs index aa46d54a3..400f7d81d 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Blighted Grove/Tangle.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Blighted Grove/Tangle.cs @@ -57,7 +57,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.3) + { c.DropItem(new TaintedSeeds()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs index 94da8ee6c..82ced789a 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs @@ -81,7 +81,9 @@ namespace Server.Mobiles public override void OnDamage(int amount, Mobile from, bool willKill) { if (Utility.RandomDouble() < 0.1) + { DropOoze(); + } base.OnDamage(amount, from, willKill); } @@ -93,7 +95,9 @@ namespace Server.Mobiles public virtual Point3D GetSpawnPosition(Point3D from, Map map, int range) { if (map == null) - return from; + { + return @from; + } var loc = new Point3D(RandomPoint(X), RandomPoint(Y), Z); @@ -117,7 +121,9 @@ namespace Server.Mobiles p = GetSpawnPosition(2); if (!Map.GetItemsInRange(p, 0).OfType().Any()) + { break; + } } ooze.MoveToWorld(p, Map); @@ -126,9 +132,13 @@ namespace Server.Mobiles if (Combatant != null) { if (corrosive) + { Combatant.SendLocalizedMessage(1072071); // A corrosive gas seeps out of your enemy's skin! + } else + { Combatant.SendLocalizedMessage(1072072); // A poisonous gas seeps out of your enemy's skin! + } } } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs index 503bf7134..713f55f93 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs @@ -45,7 +45,9 @@ namespace Server.Mobiles VirtualArmor = 28; // Don't know what it should be if (Core.ML && Utility.RandomDouble() < .60) + { PackItem(Seed.RandomPeculiarSeed(1)); + } PackArcanceScroll(0.05); } @@ -93,7 +95,9 @@ namespace Server.Mobiles public void AreaPeace() { if (Combatant == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || Utility.RandomDouble() > 0.1) + { return; + } var duration = TimeSpan.FromSeconds(Utility.RandomMinMax(20, 80)); @@ -121,9 +125,12 @@ namespace Server.Mobiles public void AreaUndress() { if (Combatant == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || Utility.RandomDouble() > 0.005) + { return; + } foreach (var m in GetMobilesInRange(RangePerception)) + { if (m?.Player == true && !m.Female && !m.Hidden && m.AccessLevel == AccessLevel.Player && CanBeHarmful(m)) { @@ -137,6 +144,7 @@ namespace Server.Mobiles 1072197 ); // The dryad's beauty makes your blood race. Your clothing is too confining. } + } m_NextUndress = DateTime.UtcNow + TimeSpan.FromMinutes(1); } @@ -146,7 +154,9 @@ namespace Server.Mobiles var item = m.FindItemOnLayer(layer); if (item?.Movable == true) + { m.PlaceInBackpack(item); + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs index c3545a8a1..38714ac45 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs @@ -91,7 +91,9 @@ namespace Server.Mobiles public void Peace(Mobile target) { if (target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || Utility.RandomDouble() > 0.1) + { return; + } if (target is PlayerMobile p && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful(p)) { @@ -110,7 +112,9 @@ namespace Server.Mobiles { if (target == null || m_Suppressed.ContainsKey(target) || Deleted || !Alive || m_NextSuppress > DateTime.UtcNow || Utility.RandomDouble() > 0.1) + { return; + } var delay = TimeSpan.FromSeconds(Utility.RandomMinMax(20, 80)); @@ -139,12 +143,16 @@ namespace Server.Mobiles public static void SuppressRemove(Mobile target) { if (target == null) + { return; + } if (m_Suppressed.TryGetValue(target, out var t)) { if (t.Running) + { t.Stop(); + } m_Suppressed.Remove(target); } @@ -153,7 +161,9 @@ namespace Server.Mobiles public void Undress(Mobile target) { if (target == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || Utility.RandomDouble() > 0.005) + { return; + } if (target.Player && target.Female && !target.Hidden && CanBeHarmful(target)) { @@ -176,29 +186,39 @@ namespace Server.Mobiles var item = m.FindItemOnLayer(layer); if (item?.Movable == true) + { m.PlaceInBackpack(item); + } } public void Provoke(Mobile target) { if (target == null || Deleted || !Alive || m_NextProvoke > DateTime.UtcNow || Utility.RandomDouble() > 0.05) + { return; + } foreach (var m in GetMobilesInRange(RangePerception)) + { if (m is BaseCreature c) { if (c == this || c == target || c.Unprovokable || c.IsParagon || c.BardProvoked || c.AccessLevel != AccessLevel.Player || !c.CanBeHarmful(target)) + { continue; + } c.Provoke(this, target, true); if (target.Player) + { target.SendLocalizedMessage(1072062); // You hear angry music, and start to fight. + } PlaySound(0x58A); break; } + } m_NextProvoke = DateTime.UtcNow + TimeSpan.FromSeconds(10); } @@ -217,9 +237,13 @@ namespace Server.Mobiles protected override void OnTick() { if (m_Owner.Deleted || !m_Owner.Alive || m_Count-- < 0) + { SuppressRemove(m_Owner); + } else + { m_Owner.FixedParticles(0x376A, 1, 32, 0x15BD, EffectLayer.Waist); + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/CorruptedSoul.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/CorruptedSoul.cs index 2cf934006..9c1ab08a5 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/CorruptedSoul.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/CorruptedSoul.cs @@ -66,7 +66,9 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } // 1 in 20 chance that a Thread of Fate will appear in the killer's pack diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/Troglodyte.cs b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/Troglodyte.cs index 51b659db9..e47f077c2 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/Troglodyte.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Humanoid/Melee/Troglodyte.cs @@ -60,7 +60,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.1) + { c.DropItem(new PrimitiveFetish()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Pyre.cs b/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Pyre.cs index 7f7634a5b..1e226fd11 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Pyre.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Pyre.cs @@ -61,7 +61,10 @@ namespace Server.Mobiles public override WeaponAbility GetWeaponAbility() { if (Utility.RandomBool()) + { return WeaponAbility.ParalyzingBlow; + } + return WeaponAbility.BleedAttack; } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Rend.cs b/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Rend.cs index 045d6eef6..c7f78e859 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Rend.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Labyrinth/Rend.cs @@ -56,7 +56,10 @@ namespace Server.Mobiles public override WeaponAbility GetWeaponAbility() { if (Utility.RandomBool()) + { return WeaponAbility.ParalyzingBlow; + } + return WeaponAbility.BleedAttack; } diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs b/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs index de9a09e82..c0af63279 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs @@ -77,7 +77,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() < 0.1) + { Drain(defender); + } } public override void OnGotMeleeAttack(Mobile attacker) @@ -85,7 +87,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() < 0.1) + { Drain(attacker); + } } public virtual void Drain(Mobile m) diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/Protector.cs b/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/Protector.cs index 5a9101cb3..6b57008a1 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/Protector.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Prism of Light/Protector.cs @@ -68,7 +68,9 @@ namespace Server.Mobiles public override void GenerateLoot(bool spawning) { if (spawning) + { return; // No loot/backpack on spawn + } base.GenerateLoot(true); base.GenerateLoot(false); diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Special/Ilhenir.cs b/Projects/UOContent/Mobiles/Monsters/ML/Special/Ilhenir.cs index 3c395a9be..d23c9d139 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Special/Ilhenir.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Special/Ilhenir.cs @@ -98,6 +98,7 @@ namespace Server.Mobiles public virtual void PackResources(int amount) { for (var i = 0; i < amount; i++) + { PackItem( Utility.Random(6) switch { @@ -109,12 +110,15 @@ namespace Server.Mobiles _ => new Muculent() // 5 } ); + } } public virtual void PackItems(Item item, int amount) { for (var i = 0; i < amount; i++) + { PackItem(item); + } } public virtual void PackTalismans(int amount) @@ -122,7 +126,9 @@ namespace Server.Mobiles var count = Utility.Random(amount); for (var i = 0; i < count; i++) + { PackItem(new RandomTalisman()); + } } public override void GenerateLoot() @@ -143,10 +149,14 @@ namespace Server.Mobiles c.DropItem( new ParrotItem() ); */ if (Utility.RandomDouble() < 0.05) + { c.DropItem(new GrizzledMareStatuette()); + } if (Utility.RandomDouble() < 0.025) + { c.DropItem(new CrimsonCincture()); + } // TODO: Armor sets /*if (Utility.RandomDouble() < 0.05) @@ -168,13 +178,17 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() < 0.25) + { CacophonicAttack(defender); + } } public override void OnDamage(int amount, Mobile from, bool willKill) { if (Utility.RandomDouble() < 0.1) + { DropOoze(); + } base.OnDamage(amount, from, willKill); } @@ -239,7 +253,9 @@ namespace Server.Mobiles p = GetSpawnPosition(2); if (!Map.GetItemsInRange(p, 0).OfType().Any()) + { break; + } } ooze.MoveToWorld(p, Map); @@ -248,9 +264,13 @@ namespace Server.Mobiles if (Combatant != null) { if (corrosive) + { Combatant.SendLocalizedMessage(1072071); // A corrosive gas seeps out of your enemy's skin! + } else + { Combatant.SendLocalizedMessage(1072072); // A poisonous gas seeps out of your enemy's skin! + } } } @@ -261,7 +281,9 @@ namespace Server.Mobiles public virtual Point3D GetSpawnPosition(Point3D from, Map map, int range) { if (map == null) - return from; + { + return @from; + } var loc = new Point3D(RandomPoint(X), RandomPoint(Y), Z); @@ -313,7 +335,9 @@ namespace Server.Mobiles if (m is BaseCreature bc) { if (!bc.Controlled && !bc.Summoned) + { continue; + } } else if (!m.Player) { @@ -321,18 +345,26 @@ namespace Server.Mobiles } if (m.Alive && !m.IsDeadBondedPet && m.CanBeDamaged()) + { toDamage.Add(m); + } } for (var i = 0; i < toDamage.Count; ++i) + { Damage(toDamage[i]); + } ++m_Ticks; if (m_Ticks >= 35) + { Delete(); + } else if (m_Ticks == 30) + { ItemID = 0x122B; + } } public void Damage(Mobile m) @@ -343,11 +375,13 @@ namespace Server.Mobiles var damaged = false; for (var i = 0; i < items.Count; ++i) + { if (items[i] is IDurability wearable && wearable.HitPoints >= 10 && Utility.RandomDouble() < 0.25) { wearable.HitPoints -= wearable.HitPoints == 10 ? Utility.Random(1, 5) : 10; damaged = true; } + } if (damaged) { diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs b/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs index c2a5abbfc..3c05abaf5 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Special/Meraktus.cs @@ -89,6 +89,7 @@ namespace Server.Mobiles public virtual void PackResources(int amount) { for (var i = 0; i < amount; i++) + { PackItem( Utility.Random(6) switch { @@ -100,6 +101,7 @@ namespace Server.Mobiles _ => new Muculent() // 5 } ); + } } public virtual void PackTalismans(int amount) @@ -107,7 +109,9 @@ namespace Server.Mobiles var count = Utility.Random(amount); for (var i = 0; i < count; i++) + { PackItem(new RandomTalisman()); + } } public override void OnDeath(Container c) @@ -115,7 +119,9 @@ namespace Server.Mobiles base.OnDeath(c); if (!Core.ML) + { return; + } c.DropItem(new MalletAndChisel()); @@ -129,16 +135,22 @@ namespace Server.Mobiles ); if (Utility.RandomBool()) + { c.DropItem(new TormentedChains()); + } if (Utility.RandomDouble() < 0.025) + { c.DropItem(new CrimsonCincture()); + } } public override void GenerateLoot() { if (Core.ML) + { AddLoot(LootPack.AosSuperBoss, 5); // Need to verify + } } public override int GetAngerSound() => 0x597; @@ -156,7 +168,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() <= 0.2) + { Earthquake(); + } } public void Earthquake() @@ -167,20 +181,31 @@ namespace Server.Mobiles { if (m == this || !CanBeHarmful(m) || m.Deleted || !m.Player && !(m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != Team))) + { continue; + } if (m is PlayerMobile pm && pm.Mounted) + { pm.Mount.Rider = null; + } var damage = (int)(m.Hits * 0.6); if (damage < 10) + { damage = 10; + } else if (damage > 75) + { damage = 75; + } + DoHarmful(m); AOS.Damage(m, this, damage, 100, 0, 0, 0, 0); if (m.Alive && m.Body.IsHuman && !m.Mounted) + { m.Animate(20, 7, 1, true, false, 0); // take hit + } } eable.Free(); diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs b/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs index 55aef6f6a..5108acfbc 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Special/Twaulo.cs @@ -86,7 +86,9 @@ namespace Server.Mobiles var map = Map; if (map == null) + { return; + } var newPixies = Utility.RandomMinMax(3, 6); @@ -102,7 +104,9 @@ namespace Server.Mobiles public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { if (Utility.RandomDouble() <= 0.1) + { SpawnPixies(caster); + } } public override void OnGaveMeleeAttack(Mobile defender) @@ -119,7 +123,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() <= 0.1) + { SpawnPixies(attacker); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs index 21c91054f..9ac704405 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Changeling.cs @@ -87,7 +87,9 @@ namespace Server.Mobiles set { if (value == this) + { value = null; + } if (m_MorphedInto != value) { @@ -133,7 +135,9 @@ namespace Server.Mobiles } if (Combatant.Player && m_MorphedInto != Combatant && Utility.RandomDouble() < 0.05) + { MorphedInto = Combatant; + } } } @@ -142,7 +146,9 @@ namespace Server.Mobiles var idle = base.CheckIdle(); if (idle && m_MorphedInto != null && DateTime.UtcNow - m_LastMorph > TimeSpan.FromSeconds(30)) + { MorphedInto = null; + } return idle; } @@ -157,7 +163,9 @@ namespace Server.Mobiles p.Y += offsets[i + 1]; if (SpellHelper.AdjustField(ref p, Map, 12, false)) + { Effects.SendLocationEffect(p, Map, itemID, 50); + } } } @@ -184,8 +192,12 @@ namespace Server.Mobiles // TODO: Skills? foreach (var item in m.Items) + { if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) + { AddItem(new ClonedItem(item)); // TODO: Clone weapon/armor attributes + } + } PlaySound(0x511); FixedParticles(0x376A, 1, 14, 5045, EffectLayer.Waist); @@ -218,17 +230,23 @@ namespace Server.Mobiles var item = Items[i]; if (item is ClonedItem) + { item.Delete(); + } } if (Backpack != null) + { for (var i = Backpack.Items.Count - 1; i >= 0; --i) { var item = Backpack.Items[i]; if (item is ClonedItem) + { item.Delete(); + } } + } } public override void OnAfterDelete() @@ -257,7 +275,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (reader.ReadBool()) + { ValidationQueue.Add(this); + } } public void Validate() diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Guile.cs b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Guile.cs index 47909f87b..da785c6a8 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Guile.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Guile.cs @@ -54,12 +54,14 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomBool()) + { if (!Kappa.IsBeingDrained(defender) && Mana > 14) { defender.SendLocalizedMessage(1070848); // You feel your life force being stolen away. Kappa.BeginLifeDrain(defender, this); Mana -= 15; } + } } public override void GenerateLoot() diff --git a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs index 6c5c52e9b..90714c2bb 100644 --- a/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs +++ b/Projects/UOContent/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs @@ -101,7 +101,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { return; + } if (m_Table.TryGetValue(defender, out var timer)) { diff --git a/Projects/UOContent/Mobiles/Monsters/Mammal/Melee/VorpalBunny.cs b/Projects/UOContent/Mobiles/Monsters/Mammal/Melee/VorpalBunny.cs index 6369c875c..8e3178483 100644 --- a/Projects/UOContent/Mobiles/Monsters/Mammal/Melee/VorpalBunny.cs +++ b/Projects/UOContent/Mobiles/Monsters/Mammal/Melee/VorpalBunny.cs @@ -36,7 +36,9 @@ namespace Server.Mobiles PackItem(new Carrot(carrots)); if (Utility.Random(5) == 0) + { PackItem(new BrightlyColoredEggs()); + } PackStatue(); @@ -68,7 +70,9 @@ namespace Server.Mobiles public virtual void BeginTunnel() { if (Deleted) + { return; + } new BunnyHole().MoveToWorld(Location, Map); diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs index 5478daf09..36b3a5c91 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs @@ -67,20 +67,24 @@ namespace Server.Mobiles public override void OnMovement(Mobile from, Point3D oldLocation) { if (!from.Alive && from is PlayerMobile) - if (!from.Frozen && DateTime.UtcNow >= m_NextResurrect && InRange(from, 4) && !InRange(oldLocation, 4) && - InLOS(from)) + { + if (!@from.Frozen && DateTime.UtcNow >= m_NextResurrect && InRange(@from, 4) && !InRange(oldLocation, 4) && + InLOS(@from)) { m_NextResurrect = DateTime.UtcNow + ResurrectDelay; - if (!from.Criminal && from.Kills < 5 && from.Karma > 0) - if (from.Map?.CanFit(from.Location, 16, false, false) == true) + if (!@from.Criminal && @from.Kills < 5 && @from.Karma > 0) + { + if (@from.Map?.CanFit(@from.Location, 16, false, false) == true) { - Direction = GetDirectionTo(from); - from.PlaySound(0x1F2); - from.FixedEffect(0x376A, 10, 16); - from.CloseGump(); - from.SendGump(new ResurrectGump(from, ResurrectMessage.Healer)); + Direction = GetDirectionTo(@from); + @from.PlaySound(0x1F2); + @from.FixedEffect(0x376A, 10, 16); + @from.CloseGump(); + @from.SendGump(new ResurrectGump(@from, ResurrectMessage.Healer)); } + } } + } } public override int GetAngerSound() => 0x2F8; diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Pixie.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Pixie.cs index 5a2e2a851..245d76f30 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Pixie.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Pixie.cs @@ -39,7 +39,9 @@ namespace Server.Mobiles VirtualArmor = 100; if (Utility.RandomDouble() < 0.02) + { PackStatue(); + } } public Pixie(Serial serial) : base(serial) @@ -66,7 +68,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Utility.RandomDouble() < 0.35) + { c.DropItem(new PixieLeg()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Wisp.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Wisp.cs index e66eb3186..613b6b574 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Wisp.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Magic/Wisp.cs @@ -44,7 +44,9 @@ namespace Server.Mobiles VirtualArmor = 40; if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(3)); + } AddItem(new LightSource()); } diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/AnimatedWeapon.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/AnimatedWeapon.cs index 091b1c3db..dc3d09d98 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/AnimatedWeapon.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/AnimatedWeapon.cs @@ -19,21 +19,37 @@ namespace Server.Mobiles SetMana(0); if (level >= 120) + { SetDamage(14, 18); + } else if (level >= 105) + { SetDamage(13, 17); + } else if (level >= 90) + { SetDamage(12, 15); + } else if (level >= 75) + { SetDamage(11, 14); + } else if (level >= 60) + { SetDamage(10, 12); + } else if (level >= 45) + { SetDamage(9, 11); + } else if (level >= 30) + { SetDamage(8, 9); + } else + { SetDamage(7, 8); + } SetDamageType(ResistanceType.Physical, 60); SetDamageType(ResistanceType.Poison, 20); diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Centaur.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Centaur.cs index 9024dcc7a..7ac9b6286 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Centaur.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Centaur.cs @@ -79,7 +79,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 678) + { BaseSoundID = 679; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs index b22b19534..a1505e2a0 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs @@ -110,7 +110,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 263) + { BaseSoundID = 0; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Golem.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Golem.cs index 5354f9826..3ffa0917a 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Golem.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/Golem.cs @@ -14,7 +14,9 @@ namespace Server.Mobiles Body = 752; if (summoned) + { Hue = 2101; + } SetStr((int)(251 * scalar), (int)(350 * scalar)); SetDex((int)(76 * scalar), (int)(100 * scalar)); @@ -29,9 +31,13 @@ namespace Server.Mobiles SetResistance(ResistanceType.Physical, (int)(35 * scalar), (int)(55 * scalar)); if (summoned) + { SetResistance(ResistanceType.Fire, (int)(50 * scalar), (int)(60 * scalar)); + } else + { SetResistance(ResistanceType.Fire, (int)(100 * scalar)); + } SetResistance(ResistanceType.Cold, (int)(10 * scalar), (int)(30 * scalar)); SetResistance(ResistanceType.Poison, (int)(10 * scalar), (int)(25 * scalar)); @@ -57,16 +63,24 @@ namespace Server.Mobiles PackItem(new IronIngot(Utility.RandomMinMax(13, 21))); if (Utility.RandomDouble() < 0.1) + { PackItem(new PowerCrystal()); + } if (Utility.RandomDouble() < 0.15) + { PackItem(new ClockworkAssembly()); + } if (Utility.RandomDouble() < 0.2) + { PackItem(new ArcaneGem()); + } if (Utility.RandomDouble() < 0.25) + { PackItem(new Gears()); + } } ControlSlots = 3; @@ -106,9 +120,13 @@ namespace Server.Mobiles if (!IsParagon) { if (Utility.RandomDouble() < 0.75) + { c.DropItem(DawnsMusicGear.RandomCommon); + } else + { c.DropItem(DawnsMusicGear.RandomUncommon); + } } else { @@ -122,7 +140,9 @@ namespace Server.Mobiles public override int GetIdleSound() { if (!Controlled) + { return 542; + } return base.GetIdleSound(); } @@ -130,7 +150,9 @@ namespace Server.Mobiles public override int GetDeathSound() { if (!Controlled) + { return 545; + } return base.GetDeathSound(); } @@ -140,7 +162,9 @@ namespace Server.Mobiles public override int GetHurtSound() { if (Controlled) + { return 320; + } return base.GetHurtSound(); } @@ -163,7 +187,9 @@ namespace Server.Mobiles ); if (Weapon is BaseWeapon weapon) + { weapon.OnHit(this, defender); + } if (defender.Alive) { diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs index d9f05c91c..263e86462 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs @@ -41,10 +41,14 @@ namespace Server.Mobiles VirtualArmor = 30; PackArmor(1, 5); if (Utility.RandomDouble() < 0.80) + { PackItem(new PlagueBeastGland()); + } if (Core.ML && Utility.RandomDouble() < 0.33) + { PackItem(Seed.RandomPeculiarSeed(4)); + } TotalDevoured = 0; m_DevourGoal = Utility.RandomMinMax(15, 25); // How many corpses must be devoured before a metal chest is awarded @@ -77,10 +81,14 @@ namespace Server.Mobiles public bool Devour(Corpse corpse) { if (corpse?.Owner == null) // sorry we can't devour because the corpse's owner is null + { return false; + } if (corpse.Owner.Body.IsHuman) + { corpse.TurnToBones(); // Not bones yet, and we are a human body therefore we turn to bones. + } IncreaseHits((int)Math.Ceiling(corpse.Owner.HitsMax * 0.75)); TotalDevoured++; @@ -192,12 +200,16 @@ namespace Server.Mobiles foreach (var item in eable) // Ensure that the corpse was killed by us + { if (item.Killer == this && item.Owner != null && !item.DevourCorpse() && !item.Devoured) + { PublicOverheadMessage( MessageType.Emote, 0x3B2, 1053032 ); // * The plague beast attempts to absorb the remains, but cannot! * + } + } eable.Free(); } @@ -207,10 +219,14 @@ namespace Server.Mobiles var maxhits = 2000; if (IsParagon) + { maxhits = (int)(maxhits * Paragon.HitsBuff); + } if (hp < 1000 && !Core.AOS) + { hp = hp * 100 / 60; + } if (HitsMaxSeed >= maxhits) { diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs index 134ad9f86..041fab9a1 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs @@ -60,9 +60,15 @@ namespace Server.Mobiles var pack = Backpack; if (pack != null) + { for (var i = 0; i < pack.Items.Count; i++) + { if (pack.Items[i] is PlagueBeastBlood blood && !blood.Patched) + { return true; + } + } + } return false; } @@ -79,7 +85,9 @@ namespace Server.Mobiles m_Timer ??= new DecayTimer(this); if (!m_Timer.Running) + { m_Timer.Start(); + } m_Timer.StartDissolving(); @@ -92,13 +100,15 @@ namespace Server.Mobiles var m = state.Mobile; if (m?.Player == true && m != from) + { PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1071919, - from.Name, + @from.Name, m.NetState ); // * ~1_VAL~ slices through the plague beast's amorphous tissue * + } } from.LocalOverheadMessage( @@ -113,11 +123,13 @@ namespace Server.Mobiles public virtual bool Scissor(Mobile from, Scissors scissors) { if (IsAccessibleTo(from)) + { scissors.PublicOverheadMessage( MessageType.Regular, 0x3B2, 1071918 ); // You can't cut through the plague beast's amorphous skin with scissors! + } return false; } @@ -127,21 +139,27 @@ namespace Server.Mobiles if (IsAccessibleTo(from)) { if (OpenedBy != null && Backpack != null) - Backpack.DisplayTo(from); + { + Backpack.DisplayTo(@from); + } else + { PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1071917, - from.NetState + @from.NetState ); // * You attempt to tear open the amorphous flesh, but it resists * + } } } public override bool OnDragDrop(Mobile from, Item dropped) { if (IsAccessibleTo(from) && (dropped is PlagueBeastInnard || dropped is PlagueBeastGland)) - return base.OnDragDrop(from, dropped); + { + return base.OnDragDrop(@from, dropped); + } return false; } @@ -151,18 +169,24 @@ namespace Server.Mobiles base.OnDeath(c); for (var i = c.Items.Count - 1; i >= 0; i--) + { c.Items[i].Delete(); + } } public override void OnDelete() { if (OpenedBy?.Holding is PlagueBeastInnard) + { OpenedBy.Holding.Delete(); + } if (Backpack != null) { for (var i = Backpack.Items.Count - 1; i >= 0; i--) + { Backpack.Items[i].Delete(); + } Backpack.Delete(); } @@ -175,7 +199,9 @@ namespace Server.Mobiles base.OnMovement(m, oldLocation); if (Backpack != null && IsAccessibleTo(m) && m.InRange(oldLocation, 3) && !m.InRange(this, 3)) + { Backpack.SendRemovePacket(); + } } public override bool CheckNonlocalLift(Mobile from, Item item) => true; @@ -220,19 +246,27 @@ namespace Server.Mobiles public virtual bool IsAccessibleTo(Mobile check) { if (check.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (!InRange(check, 2)) + { PrivateOverheadMessage(MessageType.Label, 0x3B2, 500446, check.NetState); // That is too far away. + } else if (OpenedBy != null && OpenedBy != check) + { PrivateOverheadMessage( MessageType.Label, 0x3B2, 500365, check.NetState ); // That is being used by someone else + } else if (Frozen) + { return true; + } return false; } @@ -244,7 +278,9 @@ namespace Server.Mobiles Blessed = false; if (OpenedBy == null) + { Hue = 0; + } } public override void Serialize(IGenericWriter writer) @@ -285,7 +321,9 @@ namespace Server.Mobiles } if (FightMode == FightMode.None) + { Frozen = true; + } } private class DecayTimer : Timer @@ -317,11 +355,13 @@ namespace Server.Mobiles if (Count + 15 == Deadline) { if (m_Lord.OpenedBy != null) + { m_Lord.PublicOverheadMessage( MessageType.Regular, 0x3B2, 1071921 ); // * The plague beast begins to bubble and dissolve! * + } m_Lord.PlaySound(0x103); } @@ -338,7 +378,9 @@ namespace Server.Mobiles m_Lord.Unfreeze(); if (m_Lord.OpenedBy != null) + { m_Lord.Kill(); + } Stop(); } diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs index eee430bcc..b2254aed4 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs @@ -92,8 +92,12 @@ namespace Server.Mobiles base.GetContextMenuEntries(from, list); for (var i = 0; i < list.Count; ++i) + { if (list[i] is PaperdollEntry) + { list.RemoveAt(i--); + } + } } public override void OnThink() diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs index 5e0f86ec0..21d72b10e 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs @@ -59,7 +59,9 @@ namespace Server.Mobiles if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) || !CanBeHarmful(combatant) || !InLOS(combatant)) + { return; + } if (DateTime.UtcNow >= m_NextAttack) { diff --git a/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs b/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs index 74caf790b..c3d4b32e2 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs @@ -62,7 +62,9 @@ namespace Server.Mobiles public override void AlterMeleeDamageFrom(Mobile from, ref int damage) { if (from is BaseCreature bc && (bc.Controlled || bc.BardTarget == this)) + { damage = 0; // Immune to pets and provoked creatures + } } public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) diff --git a/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs b/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs index 879f44ef1..6c4654249 100644 --- a/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs +++ b/Projects/UOContent/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs @@ -64,8 +64,12 @@ namespace Server.Mobiles public override void AlterMeleeDamageFrom(Mobile from, ref int damage) { if (from is BaseCreature bc) + { if (bc.Controlled || bc.BardTarget == this) + { damage = 0; // Immune to pets and provoked creatures + } + } } public override void CheckReflect(Mobile caster, ref bool reflect) diff --git a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs index 24f017335..8f7528997 100644 --- a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs +++ b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/BogThing.cs @@ -38,9 +38,13 @@ namespace Server.Mobiles VirtualArmor = 28; if (Utility.RandomDouble() < 0.25) + { PackItem(new Board(10)); + } else + { PackItem(new Log(10)); + } PackReg(3); PackItem(new Seed()); @@ -79,7 +83,9 @@ namespace Server.Mobiles var map = Map; if (map == null) + { return; + } var spawned = new Bogling { Team = Team }; @@ -95,7 +101,9 @@ namespace Server.Mobiles foreach (var bogling in eable) { if (Hits >= HitsMax) + { break; + } if (sound) { @@ -117,7 +125,9 @@ namespace Server.Mobiles if (Hits > HitsMax / 4) { if (Utility.RandomDouble() <= 0.25) + { SpawnBogling(attacker); + } } else if (Utility.RandomDouble() <= 0.25) { diff --git a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Corpser.cs b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Corpser.cs index 3ec4eedb0..16917fa89 100644 --- a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Corpser.cs +++ b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Corpser.cs @@ -37,9 +37,13 @@ namespace Server.Mobiles VirtualArmor = 18; if (Utility.RandomDouble() < 0.25) + { PackItem(new Board(10)); + } else + { PackItem(new Log(10)); + } PackItem(new MandrakeRoot(3)); } @@ -71,7 +75,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 352) + { BaseSoundID = 684; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Quagmire.cs b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Quagmire.cs index eda42b053..851e8789d 100644 --- a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Quagmire.cs +++ b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/Quagmire.cs @@ -65,7 +65,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == -1) + { BaseSoundID = 352; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs index 1c62490cd..fe57af0ba 100644 --- a/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs +++ b/Projects/UOContent/Mobiles/Monsters/Plant/Melee/WhippingVine.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles PackItem(new FertileDirt(Utility.RandomMinMax(1, 10))); if (Utility.RandomDouble() <= 0.2) + { PackItem(new ExecutionersCap()); + } PackItem(new Vines()); } diff --git a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs index 8218b19c0..f96df532b 100644 --- a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs +++ b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs @@ -40,9 +40,13 @@ namespace Server.Mobiles CantWalk = true; if (Utility.RandomBool()) + { PackItem(new SulfurousAsh(4)); + } else + { PackItem(new BlackPearl(4)); + } // PackItem( new SpecialFishingNet() ); } diff --git a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/Leviathan.cs b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/Leviathan.cs index ee77d2c31..a66b989df 100644 --- a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/Leviathan.cs +++ b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/Leviathan.cs @@ -133,15 +133,21 @@ namespace Server.Mobiles var item = Loot.Construct(Artifacts); if (item == null) + { return; + } // TODO: Confirm messages if (m.AddToBackpack(item)) + { m.SendMessage("As a reward for slaying the mighty leviathan, an artifact has been placed in your backpack."); + } else + { m.SendMessage( "As your backpack is full, your reward for destroying the legendary leviathan has been placed at your feet." ); + } } public override void OnKilledBy(Mobile mob) @@ -153,7 +159,9 @@ namespace Server.Mobiles GiveArtifactTo(mob); if (mob == Fisher) + { Fisher = null; + } } } @@ -162,7 +170,9 @@ namespace Server.Mobiles base.OnDeath(c); if (Fisher != null && Utility.Random(100) < 25) + { GiveArtifactTo(Fisher); + } Fisher = null; } diff --git a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs index 94c72b1e6..e142dfb0b 100644 --- a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs +++ b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs @@ -41,9 +41,13 @@ namespace Server.Mobiles CantWalk = true; if (Utility.RandomBool()) + { PackItem(new SulfurousAsh(4)); + } else + { PackItem(new BlackPearl(4)); + } PackItem(new RawFishSteak()); diff --git a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs index 45d562f14..16e103d6f 100644 --- a/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs +++ b/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs @@ -40,7 +40,9 @@ namespace Server.Mobiles VirtualArmor = 36; if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(2)); + } } public SerpentineDragon(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Kraken.cs b/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Kraken.cs index 149d3e583..119930286 100644 --- a/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Kraken.cs +++ b/Projects/UOContent/Mobiles/Monsters/Reptile/Melee/Kraken.cs @@ -45,7 +45,9 @@ namespace Server.Mobiles PackItem(rope); if (Utility.RandomDouble() < .05) + { PackItem(new MessageInABottle()); + } PackItem(new SpecialFishingNet()); // Confirm? } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs b/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs index d864d3123..a8bb2b555 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs @@ -47,7 +47,9 @@ namespace Server.Mobiles MinTameSkill = 80.7; if (Utility.RandomDouble() < .25) + { PackItem(Seed.RandomBonsaiSeed()); + } } public BakeKitsune(Serial serial) : base(serial) @@ -75,7 +77,9 @@ namespace Server.Mobiles public override void OnCombatantChange() { if (Combatant == null && !IsBodyMod && !Controlled && m_DisguiseTimer == null && Utility.RandomBool()) + { m_DisguiseTimer = Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(15, 30)), Disguise); + } } public override bool OnBeforeDeath() @@ -90,7 +94,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { return; + } /* Blood Bath * Start cliloc 1070826 @@ -151,7 +157,9 @@ namespace Server.Mobiles public void Disguise() { if (Combatant != null || IsBodyMod || Controlled) + { return; + } FixedEffect(0x376A, 8, 32); PlaySound(0x1FE); @@ -200,7 +208,9 @@ namespace Server.Mobiles public void RemoveDisguise() { if (!IsBodyMod) + { return; + } Name = null; Title = null; @@ -244,9 +254,13 @@ namespace Server.Mobiles public void DrainLife() { if (m_Mobile.Alive) + { m_Mobile.Damage(2, m_From); + } else + { DoExpire(); + } } protected override void OnTick() diff --git a/Projects/UOContent/Mobiles/Monsters/SE/DeathWatchBeetle.cs b/Projects/UOContent/Mobiles/Monsters/SE/DeathWatchBeetle.cs index a9395aa2b..90d36b4fc 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/DeathWatchBeetle.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/DeathWatchBeetle.cs @@ -59,7 +59,9 @@ namespace Server.Mobiles } if (Utility.RandomDouble() < .5) + { PackItem(Seed.RandomBonsaiSeed()); + } Tamable = true; MinTameSkill = 41.1; @@ -112,10 +114,14 @@ namespace Server.Mobiles if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) || !CanBeHarmful(combatant) || !InLOS(combatant)) + { return; + } if (Utility.Random(10) == 0) + { PoisonAttack(combatant); + } base.OnDamage(amount, from, willKill); } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/EliteNinja.cs b/Projects/UOContent/Mobiles/Monsters/SE/EliteNinja.cs index d6703580d..dc87d356d 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/EliteNinja.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/EliteNinja.cs @@ -59,7 +59,9 @@ namespace Server.Mobiles AddItem(new LeatherNinjaMitts()); if (Utility.RandomDouble() < 0.33) + { AddItem(new SmokeBomb()); + } AddItem( Utility.Random(8) switch diff --git a/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs b/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs index ea73129a6..bb59e2a2a 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/FanDancer.cs @@ -44,12 +44,16 @@ namespace Server.Mobiles Karma = -9000; if (Utility.RandomDouble() < .33) + { PackItem(Seed.RandomBonsaiSeed()); + } AddItem(new Tessen()); if (Utility.RandomDouble() <= 0.02) + { PackItem(new OrigamiPaper()); + } } public FanDancer(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/SE/FireBeetle.cs b/Projects/UOContent/Mobiles/Monsters/SE/FireBeetle.cs index 49249f6c7..9e24b2336 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/FireBeetle.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/FireBeetle.cs @@ -59,13 +59,17 @@ namespace Server.Mobiles public override void OnHarmfulSpell(Mobile from) { if (!Controlled && ControlMaster == null) + { CurrentSpeed = BoostedSpeed; + } } public override void OnCombatantChange() { if (Combatant == null && !Controlled && ControlMaster == null) + { CurrentSpeed = PassiveSpeed; + } } public override bool OverrideBondingReqs() => true; @@ -96,7 +100,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version == 0) + { Hue = 0x489; + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/Kappa.cs b/Projects/UOContent/Mobiles/Monsters/SE/Kappa.cs index 908b20112..6b56b71d3 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/Kappa.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/Kappa.cs @@ -41,6 +41,7 @@ namespace Server.Mobiles PackItem(new RawFishSteak(3)); for (var i = 0; i < 2; i++) + { switch (Utility.Random(6)) { case 0: @@ -53,9 +54,12 @@ namespace Server.Mobiles PackItem(new Axle()); break; } + } if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(4)); + } } public Kappa(Serial serial) : base(serial) @@ -86,12 +90,14 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomBool()) + { if (!IsBeingDrained(defender) && Mana > 14) { defender.SendLocalizedMessage(1070848); // You feel your life force being stolen away. BeginLifeDrain(defender, this); Mana -= 15; } + } } public static bool IsBeingDrained(Mobile m) => m_Table.ContainsKey(m); @@ -134,7 +140,11 @@ namespace Server.Mobiles var amt = 0; Mobile target = this; var rand = Utility.Random(1, 100); - if (willKill) amt = ((rand % 5) >> 2) + 3; + if (willKill) + { + amt = ((rand % 5) >> 2) + 3; + } + if (Hits < 100 && rand < 21) { target = rand % 2 < 1 ? this : from; @@ -146,7 +156,9 @@ namespace Server.Mobiles SpillAcid(target, amt); from.SendLocalizedMessage(1070820); if (Mana > 14) + { Mana -= 15; + } } } @@ -185,7 +197,9 @@ namespace Server.Mobiles DrainLife(m_Mobile, m_From); if (Running && ++m_Count == 5) + { EndLifeDrain(m_Mobile); + } } } } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/KazeKemono.cs b/Projects/UOContent/Mobiles/Monsters/SE/KazeKemono.cs index b12cd2d8a..ed2407e17 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/KazeKemono.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/KazeKemono.cs @@ -170,9 +170,13 @@ namespace Server.Mobiles protected override void OnTick() { if (m_Mod.Type == ResistanceType.Physical) + { m_Mobile.SendLocalizedMessage(1070852); // Your resistance to physical attacks has returned. + } else + { m_Mobile.SendLocalizedMessage(1070829); // Your resistance to energy attacks has returned. + } DoExpire(); } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs b/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs index ed2a302ea..f002cc3e4 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/LadyOfTheSnow.cs @@ -47,7 +47,9 @@ namespace Server.Mobiles PackItem(new Necklace()); if (Utility.RandomDouble() < 0.25) + { PackItem(Seed.RandomBonsaiSeed()); + } } public LadyOfTheSnow(Serial serial) @@ -77,7 +79,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { 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" @@ -139,9 +143,13 @@ namespace Server.Mobiles public void DrainLife() { if (m_Mobile.Alive) + { m_Mobile.Damage(2, m_From); + } else + { DoExpire(); + } } protected override void OnTick() diff --git a/Projects/UOContent/Mobiles/Monsters/SE/Oni.cs b/Projects/UOContent/Mobiles/Monsters/SE/Oni.cs index 08d108e82..a75708399 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/Oni.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/Oni.cs @@ -38,7 +38,9 @@ namespace Server.Mobiles Karma = -12000; if (Utility.RandomDouble() < .33) + { PackItem(Seed.RandomBonsaiSeed()); + } // TODO: Brain (0x1CF0) or Skull (0x1AE3) or Body Part (0x1CE3) } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs b/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs index 4154ba551..16080363b 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/RaiJu.cs @@ -61,7 +61,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1 || m_Table.Contains(defender)) + { return; + } /* Lightning Fist * Cliloc: 1070839 diff --git a/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs b/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs index 6982119a1..b7c8e51b6 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/Ronin.cs @@ -76,9 +76,13 @@ namespace Server.Mobiles } if (Utility.RandomDouble() > .2) + { AddItem(new NoDachi()); + } else + { AddItem(new Halberd()); + } PackItem(new Wakizashi()); PackItem(new Longsword()); diff --git a/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs b/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs index c2a037e44..ac083e332 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/RuneBeetle.cs @@ -43,7 +43,9 @@ namespace Server.Mobiles Karma = -15000; if (Utility.RandomDouble() < .25) + { PackItem(Seed.RandomBonsaiSeed()); + } PackItem( Utility.Random(10) switch @@ -98,7 +100,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.05) + { return; + } /* Rune Corruption * Start cliloc: 1070846 "The creature magically corrupts your armor!" @@ -121,65 +125,87 @@ namespace Server.Mobiles 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 (var i = 0; i < mods.Count; ++i) + { defender.AddResistanceMod(mods[i]); + } defender.FixedEffect(0x37B9, 10, 5); @@ -200,12 +226,17 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (version < 1) + { for (var i = 0; i < Skills.Length; ++i) { Skills[i].Cap = Math.Max(100.0, Skills[i].Cap * 0.9); - if (Skills[i].Base > Skills[i].Cap) Skills[i].Base = Skills[i].Cap; + if (Skills[i].Base > Skills[i].Cap) + { + Skills[i].Base = Skills[i].Cap; + } } + } } private class ExpireTimer : Timer @@ -223,7 +254,9 @@ namespace Server.Mobiles public void DoExpire() { for (var i = 0; i < m_Mods.Count; ++i) + { m_Mobile.RemoveResistanceMod(m_Mods[i]); + } Stop(); m_Table.Remove(m_Mobile); diff --git a/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs b/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs index 93c395d36..69ecc999c 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs @@ -44,7 +44,9 @@ namespace Server.Mobiles Karma = -8500; if (Core.ML && Utility.RandomDouble() < .33) + { PackItem(Seed.RandomPeculiarSeed(1)); + } PackItem( Utility.Random(10) switch @@ -82,7 +84,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() >= 0.1) + { return; + } /* Blood Bath * Start cliloc 1070826 @@ -154,9 +158,13 @@ namespace Server.Mobiles public void DrainLife() { if (m_Mobile.Alive) + { m_Mobile.Damage(2, m_From); + } else + { DoExpire(); + } } protected override void OnTick() diff --git a/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs b/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs index 3c865fd04..af50366b0 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs @@ -39,7 +39,9 @@ namespace Server.Mobiles Karma = -22000; if (Utility.RandomDouble() < .50) + { PackItem(Seed.RandomBonsaiSeed()); + } PackItem(new Eggs(2)); } @@ -83,10 +85,14 @@ namespace Server.Mobiles private void DoCounter(Mobile attacker) { if (Map == null) + { return; + } if (attacker is BaseCreature creature && creature.BardProvoked) + { return; + } if (Utility.RandomDouble() < 0.2) { @@ -104,11 +110,15 @@ namespace Server.Mobiles var m = baseCreature.GetMaster(); if (m != null) + { target = m; + } } if (target?.InRange(this, 18) != true) + { target = attacker; + } Animate(10, 4, 1, true, false, 0); @@ -117,10 +127,14 @@ namespace Server.Mobiles foreach (var m in eable) { if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + { continue; + } if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + { continue; + } DoHarmful(m); diff --git a/Projects/UOContent/Mobiles/Monsters/SE/YomotsuElder.cs b/Projects/UOContent/Mobiles/Monsters/SE/YomotsuElder.cs index f95b3eb98..b323bbb82 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/YomotsuElder.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/YomotsuElder.cs @@ -60,7 +60,9 @@ namespace Server.Mobiles ); if (Utility.RandomDouble() < .25) + { PackItem(Seed.RandomBonsaiSeed()); + } } public YomotsuElder(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/SE/YomotsuPriest.cs b/Projects/UOContent/Mobiles/Monsters/SE/YomotsuPriest.cs index 4e27ae6dd..e443a15a4 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/YomotsuPriest.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/YomotsuPriest.cs @@ -67,7 +67,10 @@ namespace Server.Mobiles break; } - if (Utility.RandomDouble() < .25) PackItem(Seed.RandomBonsaiSeed()); + if (Utility.RandomDouble() < .25) + { + PackItem(Seed.RandomBonsaiSeed()); + } } public YomotsuPriest(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/SE/YomotsuWarrior.cs b/Projects/UOContent/Mobiles/Monsters/SE/YomotsuWarrior.cs index 7076737b0..b4bcac395 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/YomotsuWarrior.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/YomotsuWarrior.cs @@ -41,9 +41,13 @@ namespace Server.Mobiles PackItem(new ExecutionersAxe()); if (Utility.RandomBool()) + { PackItem(new LongPants()); + } else + { PackItem(new ShortPants()); + } switch (Utility.Random(4)) { @@ -62,7 +66,9 @@ namespace Server.Mobiles } if (Utility.RandomDouble() < .25) + { PackItem(Seed.RandomBonsaiSeed()); + } } public YomotsuWarrior(Serial serial) : base(serial) diff --git a/Projects/UOContent/Mobiles/Monsters/Summons/SummonedAirElemental.cs b/Projects/UOContent/Mobiles/Monsters/Summons/SummonedAirElemental.cs index ed028e3bc..bc733ae92 100644 --- a/Projects/UOContent/Mobiles/Monsters/Summons/SummonedAirElemental.cs +++ b/Projects/UOContent/Mobiles/Monsters/Summons/SummonedAirElemental.cs @@ -59,7 +59,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (BaseSoundID == 263) + { BaseSoundID = 655; + } } } } diff --git a/Projects/UOContent/Mobiles/Special/Barracoon.cs b/Projects/UOContent/Mobiles/Special/Barracoon.cs index f4eacd17c..84983dc40 100644 --- a/Projects/UOContent/Mobiles/Special/Barracoon.cs +++ b/Projects/UOContent/Mobiles/Special/Barracoon.cs @@ -93,27 +93,37 @@ namespace Server.Mobiles public void Polymorph(Mobile m) { if (!m.CanBeginAction() || !m.CanBeginAction() || m.IsBodyMod) + { return; + } var mount = m.Mount; if (mount != null) + { mount.Rider = null; + } if (m.Mounted) + { return; + } if (m.BeginAction()) { var disarm = m.FindItemOnLayer(Layer.OneHanded); if (disarm?.Movable == true) + { m.AddToBackpack(disarm); + } disarm = m.FindItemOnLayer(Layer.TwoHanded); if (disarm?.Movable == true) + { m.AddToBackpack(disarm); + } m.BodyMod = 42; m.HueMod = 0; @@ -127,14 +137,18 @@ namespace Server.Mobiles var map = Map; if (map == null) + { return; + } var eable = GetMobilesInRange(10); var rats = eable.Aggregate(0, (c, m) => c + (m is Ratman || m is RatmanArcher || m is RatmanMage ? 1 : 0)); eable.Free(); if (rats >= 16) + { return; + } PlaySound(0x3D); @@ -159,16 +173,24 @@ namespace Server.Mobiles public void DoSpecialAbility(Mobile target) { if (target?.Deleted != false) // sanity + { return; + } if (Utility.RandomDouble() <= 0.6) // 60% chance to polymorph attacker into a ratman + { Polymorph(target); + } if (Utility.RandomDouble() <= 0.2) // 20% chance to more ratmen + { SpawnRatmen(target); + } if (Hits < 500 && !IsBodyMod) // Baracoon is low on life, polymorph into a ratman + { Polymorph(this); + } } public override void OnGotMeleeAttack(Mobile attacker) diff --git a/Projects/UOContent/Mobiles/Special/BaseChampion.cs b/Projects/UOContent/Mobiles/Special/BaseChampion.cs index e40701ddc..995ecb053 100644 --- a/Projects/UOContent/Mobiles/Special/BaseChampion.cs +++ b/Projects/UOContent/Mobiles/Special/BaseChampion.cs @@ -45,11 +45,19 @@ namespace Server.Mobiles { var random = Utility.RandomDouble(); if (random <= 0.05) + { return CreateArtifact(UniqueList); + } + if (random <= 0.15) + { return CreateArtifact(SharedList); + } + if (random <= 0.30) + { return CreateArtifact(DecorativeList); + } return null; } @@ -57,7 +65,9 @@ namespace Server.Mobiles public Item CreateArtifact(Type[] list) { if (list.Length == 0) + { return null; + } var type = list.RandomElement(); @@ -78,11 +88,17 @@ namespace Server.Mobiles var random = Utility.RandomDouble(); if (random <= 0.05) + { level = 20; + } else if (random <= 0.4) + { level = 15; + } else + { level = 10; + } return PowerScroll.CreateRandomNoCraft(level, level); } @@ -90,7 +106,9 @@ namespace Server.Mobiles public void GivePowerScrolls() { if (Map != Map.Felucca) + { return; + } var toGive = new List(); var rights = GetLootingRights(DamageEntries, HitsMax); @@ -100,18 +118,24 @@ namespace Server.Mobiles var ds = rights[i]; if (ds.m_HasRight) + { toGive.Add(ds.m_Mobile); + } } if (toGive.Count == 0) + { return; + } for (var i = 0; i < toGive.Count; i++) { var m = toGive[i]; if (!(m is PlayerMobile)) + { continue; + } var gainedPath = false; @@ -120,9 +144,13 @@ namespace Server.Mobiles if (VirtueHelper.Award(m, VirtueName.Valor, pointsToGain, ref gainedPath)) { if (gainedPath) + { m.SendLocalizedMessage(1054032); // You have gained a path in Valor! + } else + { m.SendLocalizedMessage(1054030); // You have gained in Valor! + } // No delay on Valor gains } @@ -144,7 +172,9 @@ namespace Server.Mobiles public static void GivePowerScrollTo(Mobile m, PowerScroll ps) { if (ps == null || m == null) // sanity + { return; + } m.SendLocalizedMessage(1049524); // You have received a scroll of power! @@ -155,20 +185,28 @@ namespace Server.Mobiles else { if (m.Corpse?.Deleted == false) + { m.Corpse.DropItem(ps); + } else + { m.AddToBackpack(ps); + } } if (!(m is PlayerMobile pm)) + { return; + } for (var j = 0; j < pm.JusticeProtectors.Count; ++j) { var prot = pm.JusticeProtectors[j]; if (prot.Map != pm.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(pm, prot)) + { continue; + } var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch { @@ -191,9 +229,13 @@ namespace Server.Mobiles else { if (prot.Corpse?.Deleted == false) + { prot.Corpse.DropItem(powerScroll); + } else + { prot.AddToBackpack(powerScroll); + } } } } @@ -206,19 +248,27 @@ namespace Server.Mobiles GivePowerScrolls(); if (NoGoodies) + { return base.OnBeforeDeath(); + } var map = Map; if (map != null) + { for (var x = -12; x <= 12; ++x) + { for (var y = -12; y <= 12; ++y) { var dist = Math.Sqrt(x * x + y * y); if (dist <= 12) + { new GoodiesTimer(map, X + x, Y + y).Start(); + } } + } + } } return base.OnBeforeDeath(); @@ -237,13 +287,19 @@ namespace Server.Mobiles var ds = rights[i]; if (ds.m_HasRight) + { toGive.Add(ds.m_Mobile); + } } if (toGive.Count > 0) + { toGive.RandomElement().AddToBackpack(new ChampionSkull(SkullType)); + } else + { c.DropItem(new ChampionSkull(SkullType)); + } } base.OnDeath(c); @@ -272,17 +328,22 @@ namespace Server.Mobiles canFit = m_Map.CanFit(m_X, m_Y, z + i, 6, false, false); if (canFit) + { z += i; + } } if (!canFit) + { return; + } var g = new Gold(500, 1000); g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); if (Utility.RandomDouble() <= 0.5) + { switch (Utility.Random(3)) { case 0: // Fire column @@ -324,6 +385,7 @@ namespace Server.Mobiles break; } } + } } } } diff --git a/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs b/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs index a4d1e005d..908d47c1a 100644 --- a/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs +++ b/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs @@ -68,7 +68,9 @@ namespace Server.Mobiles Utility.AssignRandomHair(this); if (Utility.RandomBool()) + { Utility.AssignRandomFacialHair(this, HairHue); + } var weapon = new VikingSword(); weapon.Movable = false; @@ -99,7 +101,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.InRange(Location, 2)) + { return true; + } return base.HandlesOnSpeech(from); } diff --git a/Projects/UOContent/Mobiles/Special/Dummy.cs b/Projects/UOContent/Mobiles/Special/Dummy.cs index 80800cf88..9a45f9e5b 100644 --- a/Projects/UOContent/Mobiles/Special/Dummy.cs +++ b/Projects/UOContent/Mobiles/Special/Dummy.cs @@ -72,7 +72,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } return base.HandlesOnSpeech(from); } @@ -82,12 +84,14 @@ namespace Server.Mobiles base.OnSpeech(e); if (e.Mobile.AccessLevel >= AccessLevel.GameMaster) + { if (e.Speech == "kill") { m_Timer.Stop(); m_Timer.Delay = TimeSpan.FromSeconds(Utility.Random(1, 5)); m_Timer.Start(); } + } } public override void OnTeamChange() @@ -98,34 +102,46 @@ namespace Server.Mobiles var item = FindItemOnLayer(Layer.OuterTorso); if (item != null) + { item.Hue = jHue; + } item = FindItemOnLayer(Layer.Helm); if (item != null) + { item.Hue = iHue; + } item = FindItemOnLayer(Layer.Gloves); if (item != null) + { item.Hue = iHue; + } item = FindItemOnLayer(Layer.Shoes); if (item != null) + { item.Hue = iHue; + } HairHue = iHue; item = FindItemOnLayer(Layer.MiddleTorso); if (item != null) + { item.Hue = iHue; + } item = FindItemOnLayer(Layer.OuterLegs); if (item != null) + { item.Hue = iHue; + } } private class AutokillTimer : Timer diff --git a/Projects/UOContent/Mobiles/Special/Harrower.cs b/Projects/UOContent/Mobiles/Special/Harrower.cs index abad1d6ef..f1dc6ea65 100644 --- a/Projects/UOContent/Mobiles/Special/Harrower.cs +++ b/Projects/UOContent/Mobiles/Special/Harrower.cs @@ -114,7 +114,9 @@ namespace Server.Mobiles public static Harrower Spawn(Point3D platLoc, Map platMap) { if (Instances.Count > 0) + { return null; + } var entry = m_Entries.RandomElement(); @@ -136,7 +138,9 @@ namespace Server.Mobiles public void Morph() { if (m_TrueForm) + { return; + } m_TrueForm = true; @@ -155,6 +159,7 @@ namespace Server.Mobiles var map = Map; if (map != null) + { for (var i = 0; i < m_Offsets.Length; i += 2) { var rx = m_Offsets[i]; @@ -173,16 +178,24 @@ namespace Server.Mobiles z = map.GetAverageZ(x, y); if (!(ok = map.CanFit(x, y, Z, 16, false, false))) + { ok = map.CanFit(x, y, z, 16, false, false); + } if (dist >= 0) + { dist = -(dist + 1); + } else + { dist = -(dist - 1); + } } if (!ok) + { continue; + } var spawn = new HarrowerTentacles(this) { Team = Team }; @@ -190,6 +203,7 @@ namespace Server.Mobiles m_Tentacles.Add(spawn); } + } } public override void OnAfterDelete() @@ -242,11 +256,15 @@ namespace Server.Mobiles var ds = rights[i]; if (ds.m_HasRight) + { toGive.Add(ds.m_Mobile); + } } if (toGive.Count == 0) + { return; + } toGive.Shuffle(); @@ -256,15 +274,25 @@ namespace Server.Mobiles var random = Utility.RandomDouble(); if (random <= 0.1) + { level = 25; + } else if (random <= 0.25) + { level = 20; + } else if (random <= 0.45) + { level = 15; + } else if (random <= 0.70) + { level = 10; + } else + { level = 5; + } var m = toGive[i % toGive.Count]; @@ -272,13 +300,16 @@ namespace Server.Mobiles m.AddToBackpack(new StatCapScroll(225 + level)); if (m is PlayerMobile pm) + { for (var j = 0; j < pm.JusticeProtectors.Count; ++j) { var prot = pm.JusticeProtectors[j]; if (prot.Map != pm.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(pm, prot)) + { continue; + } var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch { @@ -294,6 +325,7 @@ namespace Server.Mobiles prot.AddToBackpack(new StatCapScroll(225 + level)); } } + } } } @@ -308,7 +340,9 @@ namespace Server.Mobiles var ds = rights[i]; if (ds.m_HasRight && ds.m_Mobile is PlayerMobile mobile) + { PlayerMobile.ChampionTitleInfo.AwardHarrowerTitle(mobile); + } } if (!NoKillAwards) @@ -318,14 +352,20 @@ namespace Server.Mobiles var map = Map; if (map != null) + { for (var x = -16; x <= 16; ++x) + { for (var y = -16; y <= 16; ++y) { var dist = Math.Sqrt(x * x + y * y); if (dist <= 16) + { new GoodiesTimer(map, X + x, Y + y).Start(); + } } + } + } m_DamageEntries = new Dictionary(); @@ -334,7 +374,9 @@ namespace Server.Mobiles Mobile m = m_Tentacles[i]; if (!m.Deleted) + { m.Kill(); + } RegisterDamageTo(m); } @@ -357,7 +399,9 @@ namespace Server.Mobiles public virtual void RegisterDamageTo(Mobile m) { if (m == null) + { return; + } foreach (var de in m.DamageEntries) { @@ -366,7 +410,9 @@ namespace Server.Mobiles var master = damager.GetDamageMaster(m); if (master != null) + { damager = master; + } RegisterDamage(damager, de.DamageGiven); } @@ -375,7 +421,9 @@ namespace Server.Mobiles public void RegisterDamage(Mobile from, int amount) { if (from?.Player != true) + { return; + } m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out var value) ? value : 0); @@ -385,18 +433,22 @@ namespace Server.Mobiles public void AwardArtifact(Item artifact) { if (artifact == null) + { return; + } var totalDamage = 0; var validEntries = new Dictionary(); foreach (var kvp in m_DamageEntries) + { if (IsEligible(kvp.Key, artifact)) { validEntries.Add(kvp.Key, kvp.Value); totalDamage += kvp.Value; } + } var randomDamage = Utility.RandomMinMax(1, totalDamage); @@ -419,16 +471,22 @@ namespace Server.Mobiles public void GiveArtifact(Mobile to, Item artifact) { if (to == null || artifact == null) + { return; + } var pack = to.Backpack; if (pack?.TryDropItem(to, artifact, false) != true) + { artifact.Delete(); + } else + { to.SendLocalizedMessage( 1062317 ); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. + } } public bool IsEligible(Mobile m, Item artifact) => @@ -439,11 +497,19 @@ namespace Server.Mobiles { var random = Utility.RandomDouble(); if (random <= 0.05) + { return CreateArtifact(UniqueList); + } + if (random <= 0.15) + { return CreateArtifact(SharedList); + } + if (random <= 0.30) + { return CreateArtifact(DecorativeList); + } return null; } @@ -496,16 +562,22 @@ namespace Server.Mobiles var map = m_Owner.Map; if (map == null) + { return; + } if (Utility.RandomDouble() > 0.25) + { return; + } var toTeleport = m_Owner.GetMobilesInRange(16) .FirstOrDefault(mob => mob != m_Owner && mob.Player && m_Owner.CanBeHarmful(mob) && m_Owner.CanSee(mob)); if (toTeleport == null) + { return; + } var offset = Utility.Random(8) * 2; @@ -588,17 +660,22 @@ namespace Server.Mobiles canFit = m_Map.CanFit(m_X, m_Y, z + i, 6, false, false); if (canFit) + { z += i; + } } if (!canFit) + { return; + } var g = new Gold(750, 1250); g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); if (Utility.RandomDouble() <= 0.5) + { switch (Utility.Random(3)) { case 0: // Fire column @@ -640,6 +717,7 @@ namespace Server.Mobiles break; } } + } } } } diff --git a/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs b/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs index def121238..8bfe3723b 100644 --- a/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs +++ b/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs @@ -148,10 +148,14 @@ namespace Server.Mobiles foreach (var m in eable) { if (m == m_Owner || !(m_Owner.CanBeHarmful(m) || m.Player && m.Alive)) + { continue; + } if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != m_Owner.Team)) + { continue; + } m_Owner.DoHarmful(m); @@ -163,7 +167,9 @@ namespace Server.Mobiles m_Owner.Hits += drain; if (m_Owner.Harrower != null) + { m_Owner.Harrower.Hits += drain; + } m.Damage(drain, m_Owner); } diff --git a/Projects/UOContent/Mobiles/Special/LordOaks.cs b/Projects/UOContent/Mobiles/Special/LordOaks.cs index e77357396..d6b82cf78 100644 --- a/Projects/UOContent/Mobiles/Special/LordOaks.cs +++ b/Projects/UOContent/Mobiles/Special/LordOaks.cs @@ -94,7 +94,9 @@ namespace Server.Mobiles var map = Map; if (map == null) + { return; + } Say(1042154); // You shall never defeat me as long as I have my queen! @@ -122,7 +124,9 @@ namespace Server.Mobiles public void CheckQueen() { if (Map == null) + { return; + } if (!m_SpawnedQueen) { @@ -148,7 +152,9 @@ namespace Server.Mobiles scalar *= 0.1; if (Utility.RandomDouble() <= 0.1) + { SpawnPixies(caster); + } } } @@ -168,7 +174,9 @@ namespace Server.Mobiles CheckQueen(); if (m_Queen != null && Utility.RandomDouble() <= 0.1) + { SpawnPixies(attacker); + } attacker.Damage(Utility.Random(20, 10), this); attacker.Stam -= Utility.Random(20, 10); diff --git a/Projects/UOContent/Mobiles/Special/Neira.cs b/Projects/UOContent/Mobiles/Special/Neira.cs index 199c80af2..21621058a 100644 --- a/Projects/UOContent/Mobiles/Special/Neira.cs +++ b/Projects/UOContent/Mobiles/Special/Neira.cs @@ -106,7 +106,9 @@ namespace Server.Mobiles var mount = Mount; if (mount != null) + { mount.Rider = null; + } (mount as Mobile)?.Delete(); @@ -143,7 +145,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone + { AddUnholyBone(defender, 0.25); + } CheckSpeedBoost(); } @@ -153,7 +157,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone + { AddUnholyBone(attacker, 0.25); + } } public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) @@ -161,13 +167,17 @@ namespace Server.Mobiles base.AlterDamageScalarFrom(caster, ref scalar); if (Utility.RandomDouble() <= 0.1) // 10% chance to throw an unholy bone + { AddUnholyBone(caster, 1.0); + } } public void AddUnholyBone(Mobile target, double chanceToThrow) { if (Map == null) + { return; + } if (chanceToThrow >= Utility.RandomDouble()) { @@ -263,7 +273,9 @@ namespace Server.Mobiles Rider = reader.ReadMobile(); if (Rider == null) + { Delete(); + } } } diff --git a/Projects/UOContent/Mobiles/Special/Paragon.cs b/Projects/UOContent/Mobiles/Special/Paragon.cs index c5b90076b..63330a26f 100644 --- a/Projects/UOContent/Mobiles/Special/Paragon.cs +++ b/Projects/UOContent/Mobiles/Special/Paragon.cs @@ -49,12 +49,16 @@ namespace Server.Mobiles public static void Convert(BaseCreature bc) { if (bc.IsParagon) + { return; + } bc.Hue = Hue; if (bc.HitsMaxSeed >= 0) + { bc.HitsMaxSeed = (int)(bc.HitsMaxSeed * HitsBuff); + } bc.RawStr = (int)(bc.RawStr * StrBuff); bc.RawInt = (int)(bc.RawInt * IntBuff); @@ -69,7 +73,9 @@ namespace Server.Mobiles var skill = bc.Skills[i]; if (skill.Base > 0.0) + { skill.Base *= SkillsBuff; + } } bc.PassiveSpeed /= SpeedBuff; @@ -80,10 +86,14 @@ namespace Server.Mobiles bc.DamageMax += DamageBuff; if (bc.Fame > 0) + { bc.Fame = (int)(bc.Fame * FameBuff); + } if (bc.Fame > 32000) + { bc.Fame = 32000; + } // TODO: Mana regeneration rate = Sqrt( buffedFame ) / 4 @@ -92,7 +102,9 @@ namespace Server.Mobiles bc.Karma = (int)(bc.Karma * KarmaBuff); if (Math.Abs(bc.Karma) > 32000) + { bc.Karma = 32000 * Math.Sign(bc.Karma); + } } new ParagonStamRegen(bc).Start(); @@ -101,12 +113,16 @@ namespace Server.Mobiles public static void UnConvert(BaseCreature bc) { if (!bc.IsParagon) + { return; + } bc.Hue = 0; if (bc.HitsMaxSeed >= 0) + { bc.HitsMaxSeed = (int)(bc.HitsMaxSeed / HitsBuff); + } bc.RawStr = (int)(bc.RawStr / StrBuff); bc.RawInt = (int)(bc.RawInt / IntBuff); @@ -121,7 +137,9 @@ namespace Server.Mobiles var skill = bc.Skills[i]; if (skill.Base > 0.0) + { skill.Base /= SkillsBuff; + } } bc.PassiveSpeed *= SpeedBuff; @@ -132,9 +150,14 @@ namespace Server.Mobiles bc.DamageMax -= DamageBuff; if (bc.Fame > 0) + { bc.Fame = (int)(bc.Fame / FameBuff); + } + if (bc.Karma != 0) + { bc.Karma = (int)(bc.Karma / KarmaBuff); + } } public static bool CheckConvert(BaseCreature bc) => CheckConvert(bc, bc.Location, bc.Map); @@ -142,19 +165,27 @@ namespace Server.Mobiles public static bool CheckConvert(BaseCreature bc, Point3D location, Map m) { if (!Core.AOS) + { return false; + } if (Array.IndexOf(Maps, m) == -1) + { return false; + } if (bc is BaseChampion || bc is Harrower || bc is BaseVendor || bc is BaseEscortable || bc is Clone || bc.IsParagon) + { return false; + } var fame = bc.Fame; if (fame > 32000) + { fame = 32000; + } var chance = 1 / Math.Round(20.0 - fame / 3200); @@ -164,12 +195,16 @@ namespace Server.Mobiles public static bool CheckArtifactChance(Mobile m, BaseCreature bc) { if (!Core.AOS) + { return false; + } double fame = bc.Fame; if (fame > 32000) + { fame = 32000; + } var chance = 1 / (Math.Max(10, 100 * (0.83 - Math.Round(Math.Log(Math.Round(fame / 6000, 3) + 0.001, 10), 3))) * @@ -183,11 +218,15 @@ namespace Server.Mobiles var item = (Item)ActivatorUtil.CreateInstance(Artifacts.RandomElement()); if (m.AddToBackpack(item)) + { m.SendMessage("As a reward for slaying the mighty paragon, an artifact has been placed in your backpack."); + } else + { m.SendMessage( "As your backpack is full, your reward for destroying the legendary paragon has been placed at your feet." ); + } } private class ParagonStamRegen : Timer diff --git a/Projects/UOContent/Mobiles/Special/Rikktor.cs b/Projects/UOContent/Mobiles/Special/Rikktor.cs index c829ce608..dc00a7381 100644 --- a/Projects/UOContent/Mobiles/Special/Rikktor.cs +++ b/Projects/UOContent/Mobiles/Special/Rikktor.cs @@ -84,7 +84,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() <= 0.2) + { Earthquake(); + } } public void Earthquake() @@ -92,7 +94,9 @@ namespace Server.Mobiles var map = Map; if (map == null) + { return; + } PlaySound(0x2F3); @@ -101,24 +105,34 @@ namespace Server.Mobiles foreach (var m in eable) { if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + { continue; + } if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + { continue; + } var damage = m.Hits * 0.6; if (damage < 10.0) + { damage = 10.0; + } else if (damage > 75.0) + { damage = 75.0; + } DoHarmful(m); AOS.Damage(m, this, (int)damage, 100, 0, 0, 0, 0); if (m.Alive && m.Body.IsHuman && !m.Mounted) + { m.Animate(20, 7, 1, true, false, 0); // take hit + } } eable.Free(); diff --git a/Projects/UOContent/Mobiles/Special/Semidar.cs b/Projects/UOContent/Mobiles/Special/Semidar.cs index dec0495e8..9be951af2 100644 --- a/Projects/UOContent/Mobiles/Special/Semidar.cs +++ b/Projects/UOContent/Mobiles/Special/Semidar.cs @@ -72,29 +72,39 @@ namespace Server.Mobiles public override void CheckReflect(Mobile caster, ref bool reflect) { if (caster.Body.IsMale) + { reflect = true; // Always reflect if caster isn't female + } } public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { if (caster.Body.IsMale) + { scalar = 20; // Male bodies always reflect.. damage scaled 20x + } } public void DrainLife() { if (Map == null) + { return; + } var eable = GetMobilesInRange(2); foreach (var m in eable) { if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + { continue; + } if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + { continue; + } DoHarmful(m); @@ -117,7 +127,9 @@ namespace Server.Mobiles base.OnGaveMeleeAttack(defender); if (Utility.RandomDouble() <= 0.25) + { DrainLife(); + } } public override void OnGotMeleeAttack(Mobile attacker) @@ -125,7 +137,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() <= 0.25) + { DrainLife(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Special/Serado.cs b/Projects/UOContent/Mobiles/Special/Serado.cs index 44f558681..0f4d2aef6 100644 --- a/Projects/UOContent/Mobiles/Special/Serado.cs +++ b/Projects/UOContent/Mobiles/Special/Serado.cs @@ -119,17 +119,23 @@ namespace Server.Mobiles private void DoCounter(Mobile attacker) { if (Map == null) + { return; + } if (!(Utility.RandomDouble() < 0.2)) + { return; + } Mobile target = null; if (attacker is BaseCreature bcAttacker) { if (bcAttacker.BardProvoked) + { return; + } target = bcAttacker.GetMaster(); } @@ -142,7 +148,9 @@ namespace Server.Mobiles */ if (target?.InRange(this, 25) != true) + { target = attacker; + } Animate(10, 4, 1, true, false, 0); @@ -151,10 +159,14 @@ namespace Server.Mobiles foreach (var m in eable) { if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + { continue; + } if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + { continue; + } DoHarmful(m); diff --git a/Projects/UOContent/Mobiles/Special/Silvani.cs b/Projects/UOContent/Mobiles/Special/Silvani.cs index 6f3e3283e..d23bd0221 100644 --- a/Projects/UOContent/Mobiles/Special/Silvani.cs +++ b/Projects/UOContent/Mobiles/Special/Silvani.cs @@ -61,7 +61,9 @@ namespace Server.Mobiles var map = Map; if (map == null) + { return; + } var newPixies = Utility.RandomMinMax(3, 6); @@ -77,7 +79,9 @@ namespace Server.Mobiles public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { if (Utility.RandomDouble() <= 0.1) + { SpawnPixies(caster); + } } public override void OnGaveMeleeAttack(Mobile defender) @@ -94,7 +98,9 @@ namespace Server.Mobiles base.OnGotMeleeAttack(attacker); if (Utility.RandomDouble() <= 0.1) + { SpawnPixies(attacker); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Special/Wanderer.cs b/Projects/UOContent/Mobiles/Special/Wanderer.cs index d2fbd0b56..62bbd553a 100644 --- a/Projects/UOContent/Mobiles/Special/Wanderer.cs +++ b/Projects/UOContent/Mobiles/Special/Wanderer.cs @@ -54,7 +54,10 @@ namespace Server.Mobiles protected override void OnTick() { - if ((m_Count++ & 0x3) == 0) m_Owner.Direction = (Direction)(Utility.Random(8) | 0x80); + if ((m_Count++ & 0x3) == 0) + { + m_Owner.Direction = (Direction)(Utility.Random(8) | 0x80); + } m_Owner.Move(m_Owner.Direction); } diff --git a/Projects/UOContent/Mobiles/Townfolk/Banker.cs b/Projects/UOContent/Mobiles/Townfolk/Banker.cs index 21224554d..5985d9d8d 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Banker.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Banker.cs @@ -37,7 +37,10 @@ namespace Server.Mobiles if (AccountGold.Enabled && m.Account != null) { balance = m.Account.GetTotalGold(); - if (balance >= int.MaxValue) return int.MaxValue; + if (balance >= int.MaxValue) + { + return int.MaxValue; + } } Container bank = m.FindBankNoCreate(); @@ -49,7 +52,10 @@ namespace Server.Mobiles balance += gold.Aggregate(0L, (c, t) => c + t.Amount); if (balance >= int.MaxValue) + { return int.MaxValue; + } + balance += checks.Aggregate(0L, (c, t) => c + t.Worth); } @@ -79,7 +85,11 @@ namespace Server.Mobiles checks = bank.FindItemsByType(typeof(BankCheck)); balance += gold.OfType().Aggregate(0L, (c, t) => c + t.Amount); - if (balance >= int.MaxValue) return int.MaxValue; + if (balance >= int.MaxValue) + { + return int.MaxValue; + } + balance += checks.OfType().Aggregate(0L, (c, t) => c + t.Worth); } else @@ -93,13 +103,20 @@ namespace Server.Mobiles public static bool Withdraw(Mobile from, int amount) { // If for whatever reason the TOL checks fail, we should still try old methods for withdrawing currency. - if (AccountGold.Enabled && from.Account?.WithdrawGold(amount) == true) return true; + if (AccountGold.Enabled && from.Account?.WithdrawGold(amount) == true) + { + return true; + } var balance = GetBalance(from, out var gold, out var checks); - if (balance < amount) return false; + if (balance < amount) + { + return false; + } for (var i = 0; amount > 0 && i < gold.Length; ++i) + { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; @@ -110,6 +127,7 @@ namespace Server.Mobiles gold[i].Amount -= amount; amount = 0; } + } for (var i = 0; amount > 0 && i < checks.Length; ++i) { @@ -133,11 +151,17 @@ namespace Server.Mobiles public static bool Deposit(Mobile from, int amount) { // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency. - if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true) return true; + if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true) + { + return true; + } var box = from.FindBankNoCreate(); - if (box == null) return false; + if (box == null) + { + return false; + } var items = new List(); @@ -167,7 +191,10 @@ namespace Server.Mobiles else { item.Delete(); - foreach (var curItem in items) curItem.Delete(); + foreach (var curItem in items) + { + curItem.Delete(); + } return false; } @@ -179,11 +206,17 @@ namespace Server.Mobiles public static int DepositUpTo(Mobile from, int amount) { // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency. - if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true) return amount; + if (AccountGold.Enabled && from.Account?.DepositGold(amount) == true) + { + return amount; + } var box = from.FindBankNoCreate(); - if (box == null) return 0; + if (box == null) + { + return 0; + } var amountLeft = amount; while (amountLeft > 0) @@ -250,7 +283,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.InRange(Location, 12)) + { return true; + } return base.HandlesOnSpeech(from); } @@ -258,6 +293,7 @@ namespace Server.Mobiles public override void OnSpeech(SpeechEventArgs e) { if (!e.Handled && e.Mobile.InRange(Location, 12)) + { for (var i = 0; i < e.Keywords.Length; ++i) { var keyword = e.Keywords[i]; @@ -281,7 +317,9 @@ namespace Server.Mobiles var pack = e.Mobile.Backpack; if (!int.TryParse(split[1], out var amount)) + { break; + } if (!Core.ML && amount > 5000 || Core.ML && amount > 60000) { @@ -322,15 +360,19 @@ namespace Server.Mobiles } if (AccountGold.Enabled && e.Mobile.Account != null) + { Say( 1155855, $"{e.Mobile.Account.TotalPlat:#,0}\t{e.Mobile.Account.TotalGold:#,0}" ); // Thy current bank balance is ~1_AMOUNT~ platinum and ~2_AMOUNT~ gold. + } else + { Say( 1042759, GetBalance(e.Mobile).ToString("#,0") ); // Thy current bank balance is ~1_AMOUNT~ gold. + } break; } @@ -353,7 +395,9 @@ namespace Server.Mobiles e.Handled = true; if (AccountGold.Enabled) + { break; + } if (e.Mobile.Criminal) { @@ -366,7 +410,9 @@ namespace Server.Mobiles if (split.Length >= 2) { if (!int.TryParse(split[1], out var amount)) + { break; + } if (amount < 5000) { @@ -408,6 +454,7 @@ namespace Server.Mobiles } } } + } base.OnSpeech(e); } @@ -415,7 +462,9 @@ namespace Server.Mobiles public override void AddCustomContextEntries(Mobile from, List list) { if (from.Alive) - list.Add(new OpenBankEntry(from, this)); + { + list.Add(new OpenBankEntry(@from, this)); + } base.AddCustomContextEntries(from, list); } diff --git a/Projects/UOContent/Mobiles/Townfolk/BrideGroom.cs b/Projects/UOContent/Mobiles/Townfolk/BrideGroom.cs index 19a385499..bd3caafd7 100644 --- a/Projects/UOContent/Mobiles/Townfolk/BrideGroom.cs +++ b/Projects/UOContent/Mobiles/Townfolk/BrideGroom.cs @@ -8,9 +8,13 @@ namespace Server.Mobiles public BrideGroom() { if (Female) + { Title = "the bride"; + } else + { Title = "the groom"; + } } public BrideGroom(Serial serial) : base(serial) @@ -37,23 +41,35 @@ namespace Server.Mobiles public override void InitOutfit() { if (Female) + { AddItem(new FancyDress()); + } else + { AddItem(new FancyShirt()); + } var lowHue = GetRandomHue(); AddItem(new LongPants(lowHue)); if (Female) + { AddItem(new Shoes(lowHue)); + } else + { AddItem(new Boots(lowHue)); + } if (Utility.RandomBool()) + { HairItemID = 0x203B; + } else + { HairItemID = 0x203C; + } HairHue = Race.RandomHairHue(); diff --git a/Projects/UOContent/Mobiles/Townfolk/EscortableMage.cs b/Projects/UOContent/Mobiles/Townfolk/EscortableMage.cs index b5a001c3b..764a44e2f 100644 --- a/Projects/UOContent/Mobiles/Townfolk/EscortableMage.cs +++ b/Projects/UOContent/Mobiles/Townfolk/EscortableMage.cs @@ -45,9 +45,13 @@ namespace Server.Mobiles AddItem(new ShortPants(lowHue)); if (Female) + { AddItem(new ThighBoots(lowHue)); + } else + { AddItem(new Boots(lowHue)); + } Utility.AssignRandomHair(this); diff --git a/Projects/UOContent/Mobiles/Townfolk/Merchant.cs b/Projects/UOContent/Mobiles/Townfolk/Merchant.cs index 6f46f9631..1628535e1 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Merchant.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Merchant.cs @@ -37,22 +37,33 @@ namespace Server.Mobiles public override void InitOutfit() { if (Female) + { AddItem(new PlainDress()); + } else + { AddItem(new Shirt(GetRandomHue())); + } var lowHue = GetRandomHue(); AddItem(new ThighBoots()); if (Female) + { AddItem(new FancyDress(lowHue)); + } else + { AddItem(new FancyShirt(lowHue)); + } + AddItem(new LongPants(lowHue)); if (!Female) + { AddItem(new BodySash(lowHue)); + } // if (!Female) // AddItem( new Longsword() ); diff --git a/Projects/UOContent/Mobiles/Townfolk/Messenger.cs b/Projects/UOContent/Mobiles/Townfolk/Messenger.cs index 633305abc..6410e45fe 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Messenger.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Messenger.cs @@ -30,18 +30,26 @@ namespace Server.Mobiles public override void InitOutfit() { if (Female) + { AddItem(new PlainDress()); + } else + { AddItem(new Shirt(GetRandomHue())); + } var lowHue = GetRandomHue(); AddItem(new ShortPants(lowHue)); if (Female) + { AddItem(new Boots(lowHue)); + } else + { AddItem(new Shoes(lowHue)); + } var randomHair = Utility.Random(4); HairItemID = randomHair == 4 ? 0x203B : 0x2048 + randomHair; diff --git a/Projects/UOContent/Mobiles/Townfolk/Ninja.cs b/Projects/UOContent/Mobiles/Townfolk/Ninja.cs index fd7c64c7b..91f4e0667 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Ninja.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Ninja.cs @@ -34,7 +34,9 @@ namespace Server.Mobiles } if (!Female) + { AddItem(new LeatherNinjaHood()); + } AddItem(new LeatherNinjaPants()); AddItem(new LeatherNinjaBelt()); @@ -46,7 +48,9 @@ namespace Server.Mobiles Utility.AssignRandomHair(this, hairHue); if (Utility.Random(7) != 0) + { Utility.AssignRandomFacialHair(this, hairHue); + } PackGold(250, 300); } diff --git a/Projects/UOContent/Mobiles/Townfolk/Noble.cs b/Projects/UOContent/Mobiles/Townfolk/Noble.cs index c5f0b4417..85af8457d 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Noble.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Noble.cs @@ -38,26 +38,38 @@ namespace Server.Mobiles public override void InitOutfit() { if (Female) + { AddItem(new FancyDress()); + } else + { AddItem(new FancyShirt(GetRandomHue())); + } var lowHue = GetRandomHue(); AddItem(new ShortPants(lowHue)); if (Female) + { AddItem(new ThighBoots(lowHue)); + } else + { AddItem(new Boots(lowHue)); + } if (!Female) + { AddItem(new BodySash(lowHue)); + } AddItem(new Cloak(GetRandomHue())); if (!Female) + { AddItem(new Longsword()); + } Utility.AssignRandomHair(this); diff --git a/Projects/UOContent/Mobiles/Townfolk/Peasant.cs b/Projects/UOContent/Mobiles/Townfolk/Peasant.cs index 4f9108e7a..a25c68234 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Peasant.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Peasant.cs @@ -31,18 +31,26 @@ namespace Server.Mobiles public override void InitOutfit() { if (Female) + { AddItem(new PlainDress()); + } else + { AddItem(new Shirt(GetRandomHue())); + } var lowHue = GetRandomHue(); AddItem(new ShortPants(lowHue)); if (Female) + { AddItem(new Boots(lowHue)); + } else + { AddItem(new Shoes(lowHue)); + } // if (!Female) // AddItem( new BodySash( lowHue ) ); diff --git a/Projects/UOContent/Mobiles/Townfolk/Prisoner.cs b/Projects/UOContent/Mobiles/Townfolk/Prisoner.cs index adb36e885..e4615d149 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Prisoner.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Prisoner.cs @@ -35,9 +35,13 @@ namespace Server.Mobiles.Townfolk } if (Utility.RandomBool()) + { AddItem(new Boots()); + } else + { AddItem(new ThighBoots()); + } Utility.AssignRandomHair(this); Utility.AssignRandomFacialHair(this, HairHue); @@ -62,7 +66,9 @@ namespace Server.Mobiles.Townfolk base.OnMovement(m, oldLocation); if (CantWalk && InRange(m, 1) && !InRange(oldLocation, 1) && (!m.Hidden || m.AccessLevel == AccessLevel.Player)) + { Say(502268); // Quickly, I beg thee! Unlock my chains! If thou dost look at me close thou canst see them. + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Townfolk/Samurai.cs b/Projects/UOContent/Mobiles/Townfolk/Samurai.cs index 1450d6467..86d28bae2 100644 --- a/Projects/UOContent/Mobiles/Townfolk/Samurai.cs +++ b/Projects/UOContent/Mobiles/Townfolk/Samurai.cs @@ -82,7 +82,9 @@ namespace Server.Mobiles Utility.AssignRandomHair(this, hairHue); if (Utility.Random(7) != 0) + { Utility.AssignRandomFacialHair(this, hairHue); + } PackGold(250, 300); } diff --git a/Projects/UOContent/Mobiles/Townfolk/SeekerOfAdventure.cs b/Projects/UOContent/Mobiles/Townfolk/SeekerOfAdventure.cs index ab39de4ad..59bd0b575 100644 --- a/Projects/UOContent/Mobiles/Townfolk/SeekerOfAdventure.cs +++ b/Projects/UOContent/Mobiles/Townfolk/SeekerOfAdventure.cs @@ -29,7 +29,10 @@ namespace Server.Mobiles public override string[] GetPossibleDestinations() { if (Core.ML) + { return m_MLDestinations; + } + return m_Dungeons; } @@ -50,21 +53,31 @@ namespace Server.Mobiles public override void InitOutfit() { if (Female) + { AddItem(new FancyDress(GetRandomHue())); + } else + { AddItem(new FancyShirt(GetRandomHue())); + } var lowHue = GetRandomHue(); AddItem(new ShortPants(lowHue)); if (Female) + { AddItem(new ThighBoots(lowHue)); + } else + { AddItem(new Boots(lowHue)); + } if (!Female) + { AddItem(new BodySash(lowHue)); + } AddItem(new Cloak(GetRandomHue())); diff --git a/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs b/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs index e005e917d..0a31f5634 100644 --- a/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs +++ b/Projects/UOContent/Mobiles/Townfolk/TownCrier.cs @@ -29,17 +29,23 @@ namespace Server.Mobiles public TownCrierEntry GetRandomEntry() { if (Entries == null || Entries.Count == 0) + { return null; + } for (var i = Entries.Count - 1; Entries != null && i >= 0; --i) { if (i >= Entries.Count) + { continue; + } var tce = Entries[i]; if (tce.Expired) + { RemoveEntry(tce); + } } return Entries.RandomElement(); @@ -56,7 +62,9 @@ namespace Server.Mobiles var instances = TownCrier.Instances; for (var i = 0; i < instances.Count; ++i) + { instances[i].ForceBeginAutoShout(); + } return tce; } @@ -64,12 +72,16 @@ namespace Server.Mobiles public void RemoveEntry(TownCrierEntry tce) { if (Entries == null) + { return; + } Entries.Remove(tce); if (Entries.Count == 0) + { Entries = null; + } } public static void Initialize() @@ -92,9 +104,13 @@ namespace Server.Mobiles Lines = lines; if (duration < TimeSpan.Zero) + { duration = TimeSpan.Zero; + } else if (duration > TimeSpan.FromDays(365.0)) + { duration = TimeSpan.FromDays(365.0); + } ExpireTime = DateTime.UtcNow + duration; } @@ -122,7 +138,9 @@ namespace Server.Mobiles } if (ts < TimeSpan.Zero) + { ts = TimeSpan.Zero; + } from.SendMessage("Duration set to: {0}", ts); from.SendMessage("Enter the first line to shout:"); @@ -163,7 +181,9 @@ namespace Server.Mobiles public override void OnCancel(Mobile from) { if (m_Entry != null) + { m_Owner.RemoveEntry(m_Entry); + } if (m_Lines.Count > 0) { @@ -173,9 +193,13 @@ namespace Server.Mobiles else { if (m_Entry != null) - from.SendMessage("Message deleted."); + { + @from.SendMessage("Message deleted."); + } else - from.SendLocalizedMessage(502980); // Message entry cancelled. + { + @from.SendLocalizedMessage(502980); // Message entry cancelled. + } } from.SendGump(new TownCrierGump(from, m_Owner)); @@ -210,8 +234,11 @@ namespace Server.Mobiles AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1); if (count == 0) + { AddHtml(8, 30, 284, 20, "The crier has no news."); + } else + { for (var i = 0; i < entries.Count; ++i) { var tce = entries[i]; @@ -219,7 +246,9 @@ namespace Server.Mobiles var toExpire = tce.ExpireTime - DateTime.UtcNow; if (toExpire < TimeSpan.Zero) + { toExpire = TimeSpan.Zero; + } var sb = new StringBuilder(); @@ -244,7 +273,9 @@ namespace Server.Mobiles for (var j = 0; j < tce.Lines.Length; ++j) { if (j > 0) + { sb.Append("
"); + } sb.Append(tce.Lines[j]); } @@ -253,6 +284,7 @@ namespace Server.Mobiles AddButton(300 - 8 - 26, 35 + i * 85, 0x15E1, 0x15E5, 2 + i); } + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -273,7 +305,9 @@ namespace Server.Mobiles var ts = tce.ExpireTime - DateTime.UtcNow; if (ts < TimeSpan.Zero) + { ts = TimeSpan.Zero; + } m_From.SendMessage("Editing entry #{0}.", index + 1); m_From.SendMessage("Enter the first line to shout:"); @@ -299,7 +333,9 @@ namespace Server.Mobiles Hue = Race.Human.RandomSkinHue(); if (!Core.AOS) + { NameHue = 0x35; + } if (Female = Utility.RandomBool()) { @@ -351,21 +387,29 @@ namespace Server.Mobiles public TownCrierEntry GetRandomEntry() { if (Entries == null || Entries.Count == 0) + { return GlobalTownCrierEntryList.Instance.GetRandomEntry(); + } for (var i = Entries.Count - 1; Entries != null && i >= 0; --i) { if (i >= Entries.Count) + { continue; + } var tce = Entries[i]; if (tce.Expired) + { RemoveEntry(tce); + } } if (Entries == null || Entries.Count == 0) + { return GlobalTownCrierEntryList.Instance.GetRandomEntry(); + } var entry = GlobalTownCrierEntryList.Instance.GetRandomEntry(); @@ -388,12 +432,16 @@ namespace Server.Mobiles public void RemoveEntry(TownCrierEntry tce) { if (Entries == null) + { return; + } Entries.Remove(tce); if (Entries.Count == 0) + { Entries = null; + } if (Entries == null && GlobalTownCrierEntryList.Instance.IsEmpty) { @@ -446,9 +494,13 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (from.AccessLevel >= AccessLevel.GameMaster) - from.SendGump(new TownCrierGump(from, this)); + { + @from.SendGump(new TownCrierGump(@from, this)); + } else - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override bool HandlesOnSpeech(Mobile from) => m_NewsTimer == null && from.Alive && InRange(from, 12); @@ -500,7 +552,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Core.AOS && NameHue == 0x35) + { NameHue = -1; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs index ab9dc5b52..d0c930692 100644 --- a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs @@ -102,16 +102,22 @@ namespace Server.Mobiles var buyInfo = GetBuyInfo(); foreach (var bii in buyInfo) + { bii.OnRestock(); + } } public virtual bool OnBuyItems(Mobile buyer, List list) { if (!IsActiveSeller) + { return false; + } if (!buyer.CheckAlive()) + { return false; + } if (!CheckVendorAccess(buyer)) { @@ -140,7 +146,9 @@ namespace Server.Mobiles var item = World.FindItem(ser); if (item == null) + { continue; + } var gbi = LookupDisplayObject(item); @@ -151,19 +159,27 @@ namespace Server.Mobiles else if (item != BuyPack && item.IsChildOf(BuyPack)) { if (amount > item.Amount) + { amount = item.Amount; + } if (amount <= 0) + { continue; + } foreach (var ssi in info) + { if (ssi.IsSellable(item)) + { if (ssi.IsResellable(item)) { totalCost += ssi.GetBuyPriceFor(item) * amount; validBuy.Add(buy); break; } + } + } } } else if (ser.IsMobile) @@ -171,22 +187,32 @@ namespace Server.Mobiles var mob = World.FindMobile(ser); if (mob == null) + { continue; + } var gbi = LookupDisplayObject(mob); if (gbi != null) + { ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost); + } } } // foreach if (fullPurchase && validBuy.Count == 0) + { SayTo(buyer, 500190); // Thou hast bought nothing! + } else if (validBuy.Count == 0) + { SayTo(buyer, 500187); // Your order cannot be fulfilled, please try again. + } if (validBuy.Count == 0) + { return false; + } bought = buyer.AccessLevel >= AccessLevel.GameMaster; @@ -194,9 +220,13 @@ namespace Server.Mobiles if (!bought && cont != null) { if (cont.ConsumeTotal(typeof(Gold), totalCost)) + { bought = true; + } else if (totalCost < 2000) + { SayTo(buyer, 500192); // Begging thy pardon, but thou canst not afford that. + } } if (!bought && totalCost >= 2000) @@ -214,7 +244,9 @@ namespace Server.Mobiles } if (!bought) + { return false; + } buyer.PlaySound(0x32); @@ -226,14 +258,18 @@ namespace Server.Mobiles var amount = buy.Amount; if (amount < 1) + { continue; + } if (ser.IsItem) { var item = World.FindItem(ser); if (item == null) + { continue; + } var gbi = LookupDisplayObject(item); @@ -244,23 +280,35 @@ namespace Server.Mobiles else { if (amount > item.Amount) + { amount = item.Amount; + } foreach (var ssi in info) + { if (ssi.IsSellable(item)) + { if (ssi.IsResellable(item)) { Item buyItem; if (amount >= item.Amount) + { buyItem = item; + } else + { buyItem = LiftItemDupe(item, item.Amount - amount) ?? item; + } if (cont?.TryDropItem(buyer, buyItem, false) != true) + { buyItem.MoveToWorld(buyer.Location, buyer.Map); + } break; } + } + } } } else if (ser.IsMobile) @@ -268,55 +316,71 @@ namespace Server.Mobiles var mob = World.FindMobile(ser); if (mob == null) + { continue; + } var gbi = LookupDisplayObject(mob); if (gbi != null) + { ProcessValidPurchase(amount, gbi, buyer, cont); + } } } // foreach if (fullPurchase) { if (buyer.AccessLevel >= AccessLevel.GameMaster) + { SayTo(buyer, true, "I would not presume to charge thee anything. Here are the goods you requested."); + } else if (fromBank) + { SayTo( buyer, 1151638, totalCost .ToString() ); // The total of your purchase is ~1_val~ gold, which has been drawn from your bank account. My thanks for the patronage. + } else + { SayTo( buyer, 1151639, totalCost.ToString() ); // The total of your purchase is ~1_val~ gold. My thanks for the patronage. + } } else { if (buyer.AccessLevel >= AccessLevel.GameMaster) + { SayTo( buyer, true, "I would not presume to charge thee anything. Unfortunately, I could not sell you all the goods you requested." ); + } else if (fromBank) + { SayTo( buyer, true, "The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.", totalCost ); + } else + { SayTo( buyer, true, "The total of thy purchase is {0} gold. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.", totalCost ); + } } return true; @@ -325,10 +389,14 @@ namespace Server.Mobiles public virtual bool OnSellItems(Mobile seller, List list) { if (!IsActiveBuyer) + { return false; + } if (!seller.CheckAlive()) + { return false; + } if (!CheckVendorAccess(seller)) { @@ -347,14 +415,18 @@ namespace Server.Mobiles { if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || resp.Item is Container container && container.Items.Count != 0) + { continue; + } foreach (var ssi in info) + { if (ssi.IsSellable(resp.Item)) { Sold++; break; } + } } if (Sold > MaxSell) @@ -363,27 +435,36 @@ namespace Server.Mobiles return false; } - if (Sold == 0) return true; + if (Sold == 0) + { + return true; + } foreach (var resp in list) { if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable || resp.Item is Container container && container.Items.Count != 0) + { continue; + } foreach (var ssi in info) + { if (ssi.IsSellable(resp.Item)) { var amount = resp.Amount; if (amount > resp.Item.Amount) + { amount = resp.Item.Amount; + } if (ssi.IsResellable(resp.Item)) { var found = false; foreach (var bii in buyInfo) + { if (bii.Restock(resp.Item, amount)) { resp.Item.Consume(amount); @@ -391,6 +472,7 @@ namespace Server.Mobiles break; } + } if (!found) { @@ -421,14 +503,19 @@ namespace Server.Mobiles else { if (amount < resp.Item.Amount) + { resp.Item.Amount -= amount; + } else + { resp.Item.Delete(); + } } GiveGold += ssi.GetSellPriceFor(resp.Item) * amount; break; } + } } if (GiveGold > 0) @@ -448,9 +535,13 @@ namespace Server.Mobiles var bulkOrder = CreateBulkOrder(seller, false); if (bulkOrder is LargeBOD largeBod) + { seller.SendGump(new LargeBODAcceptGump(seller, largeBod)); + } else if (bulkOrder is SmallBOD smallBod) + { seller.SendGump(new SmallBODAcceptGump(seller, smallBod)); + } } } // no cliloc for this? @@ -478,8 +569,12 @@ namespace Server.Mobiles LastRestock = DateTime.UtcNow; for (var i = 0; i < m_ArmorBuyInfo.Count; ++i) + { if (m_ArmorBuyInfo[i] is GenericBuyInfo buy) + { buy.DeleteDisplayEntity(); + } + } SBInfos.Clear(); @@ -534,10 +629,14 @@ namespace Server.Mobiles public virtual void CheckMorph() { if (CheckGargoyle()) + { return; + } if (CheckNecromancer()) + { return; + } CheckTokuno(); } @@ -545,12 +644,16 @@ namespace Server.Mobiles public virtual bool CheckTokuno() { if (Map != Map.Tokuno) + { return false; + } var n = NameList.GetNameList(Female ? "tokuno female" : "tokuno male"); if (!n.ContainsName(Name)) + { TurnToTokuno(); + } return true; } @@ -565,13 +668,19 @@ namespace Server.Mobiles var map = Map; if (map != Map.Ilshenar) + { return false; + } if (!Region.IsPartOf("Gargoyle City")) + { return false; + } if (Body != 0x2F6 || (Hue & 0x8000) == 0) + { TurnToGargoyle(); + } return true; } @@ -581,13 +690,19 @@ namespace Server.Mobiles var map = Map; if (map != Map.Malas) + { return false; + } if (!Region.IsPartOf("Umbra")) + { return false; + } if (Hue != 0x83E8) + { TurnToNecromancer(); + } return true; } @@ -622,7 +737,9 @@ namespace Server.Mobiles { var item = Items[i]; if (item is BaseClothing || item is BaseWeapon || item is BaseArmor || item is BaseTool) + { item.Hue = GetRandomNecromancerHue(); + } } HairHue = 0; @@ -638,7 +755,9 @@ namespace Server.Mobiles var item = Items[i]; if (item is BaseClothing) + { item.Delete(); + } } HairItemID = 0; @@ -656,19 +775,27 @@ namespace Server.Mobiles var title = Title; if (title == null) + { return; + } var split = title.Split(' '); for (var i = 0; i < split.Length; ++i) { if (Insensitive.Equals(split[i], "the")) + { continue; + } if (split[i].Length > 1) + { split[i] = char.ToUpper(split[i][0]) + split[i].Substring(1); + } else if (split[i].Length > 0) + { split[i] = char.ToUpper(split[i][0]).ToString(); + } } Title = string.Join(" ", split); @@ -703,6 +830,7 @@ namespace Server.Mobiles Utility.AssignRandomFacialHair(this, hairHue); if (Female) + { AddItem( Utility.Random(6) switch { @@ -712,8 +840,11 @@ namespace Server.Mobiles _ => new Skirt(GetRandomHue()) // 3-5 } ); + } else + { AddItem(Utility.RandomBool() ? (Item)new LongPants(GetRandomHue()) : new ShortPants(GetRandomHue())); + } PackGold(100, 200); } @@ -721,10 +852,14 @@ namespace Server.Mobiles public virtual void VendorBuy(Mobile from) { if (!IsActiveSeller) + { return; + } if (!from.CheckAlive()) + { return; + } if (!CheckVendorAccess(from)) { @@ -733,7 +868,9 @@ namespace Server.Mobiles } if (DateTime.UtcNow - LastRestock > RestockDelay) + { Restock(); + } UpdateBuyInfo(); @@ -750,10 +887,14 @@ namespace Server.Mobiles var buyItem = buyInfo[idx]; if (buyItem.Amount <= 0 || list.Count >= 250) + { continue; + } if (!(buyItem is GenericBuyInfo gbi)) + { return; + } var disp = gbi.GetDisplayEntity(); @@ -770,9 +911,13 @@ namespace Server.Mobiles ); if (disp is Item item) + { opls.Add(item.PropertyList); + } else if (disp is Mobile mobile) + { opls.Add(mobile.PropertyList); + } } var playerItems = cont.Items; @@ -780,12 +925,16 @@ namespace Server.Mobiles for (var i = playerItems.Count - 1; i >= 0; --i) { if (i >= playerItems.Count) + { continue; + } var item = playerItems[i]; if (item.LastMoved + InventoryDecayTime <= DateTime.UtcNow) + { item.Delete(); + } } for (var i = 0; i < playerItems.Count; ++i) @@ -796,12 +945,14 @@ namespace Server.Mobiles string name = null; foreach (var ssi in sellInfo) + { if (ssi.IsSellable(item)) { price = ssi.GetBuyPriceFor(item); name = ssi.GetNameFor(item); break; } + } if (name != null && list.Count < 250) { @@ -815,7 +966,9 @@ namespace Server.Mobiles // Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this ); if (list.Count <= 0) + { return; + } list.Sort(new BuyItemStateComparer()); @@ -824,24 +977,36 @@ namespace Server.Mobiles var ns = from.NetState; if (ns == null) + { return; + } if (ns.ContainerGridLines) - from.Send(new VendorBuyContent6017(list)); + { + @from.Send(new VendorBuyContent6017(list)); + } else - from.Send(new VendorBuyContent(list)); + { + @from.Send(new VendorBuyContent(list)); + } from.Send(new VendorBuyList(this, list)); if (ns.HighSeas) - from.Send(new DisplayBuyListHS(this)); + { + @from.Send(new DisplayBuyListHS(this)); + } else - from.Send(new DisplayBuyList(this)); + { + @from.Send(new DisplayBuyList(this)); + } from.Send(new MobileStatusExtended(from)); // make sure their gold amount is sent for (var i = 0; i < opls.Count; ++i) - from.Send(opls[i]); + { + @from.Send(opls[i]); + } SayTo(from, 500186); // Greetings. Have a look around. } @@ -861,7 +1026,9 @@ namespace Server.Mobiles pack = FindItemOnLayer(Layer.ShopSell); if (pack != null) - from.Send(new EquipUpdate(pack)); + { + @from.Send(new EquipUpdate(pack)); + } pack = FindItemOnLayer(Layer.ShopResale); @@ -877,10 +1044,14 @@ namespace Server.Mobiles public virtual void VendorSell(Mobile from) { if (!IsActiveBuyer) + { return; + } if (!from.CheckAlive()) + { return; + } if (!CheckVendorAccess(from)) { @@ -891,21 +1062,29 @@ namespace Server.Mobiles var pack = from.Backpack; if (pack == null) + { return; + } var info = GetSellInfo(); var list = new List(); foreach (var ssi in info) + { foreach (var item in pack.FindItemsByType(ssi.Types)) { if (item is Container container && container.Items.Count != 0) + { continue; + } if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item)) + { list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item))); + } } + } if (list.Count > 0) { @@ -927,7 +1106,9 @@ namespace Server.Mobiles var largeBod = dropped as LargeBOD; if (!(smallBod != null || largeBod != null)) - return base.OnDragDrop(from, dropped); + { + return base.OnDragDrop(@from, dropped); + } var pm = from as PlayerMobile; @@ -953,28 +1134,40 @@ namespace Server.Mobiles int gold, fame; if (smallBod != null) + { smallBod.GetRewards(out reward, out gold, out fame); + } else + { largeBod.GetRewards(out reward, out gold, out fame); + } from.SendSound(0x3D); SayTo(from, 1045132); // Thank you so much! Here is a reward for your effort. if (reward != null) - from.AddToBackpack(reward); + { + @from.AddToBackpack(reward); + } if (gold > 1000) - from.AddToBackpack(new BankCheck(gold)); + { + @from.AddToBackpack(new BankCheck(gold)); + } else if (gold > 0) - from.AddToBackpack(new Gold(gold)); + { + @from.AddToBackpack(new Gold(gold)); + } Titles.AwardFame(from, fame, true); OnSuccessfulBulkOrderReceive(from); if (Core.ML && pm != null) + { pm.NextBODTurnInTime = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + } dropped.Delete(); return true; @@ -985,8 +1178,12 @@ namespace Server.Mobiles var buyInfo = GetBuyInfo(); for (var i = 0; i < buyInfo.Length; ++i) + { if (buyInfo[i] is GenericBuyInfo gbi && gbi.GetDisplayEntity() == obj) + { return gbi; + } + } return null; } @@ -999,10 +1196,14 @@ namespace Server.Mobiles var amount = buy.Amount; if (amount > bii.Amount) + { amount = bii.Amount; + } if (amount <= 0) + { return; + } var slots = bii.ControlSlots * amount; @@ -1023,10 +1224,14 @@ namespace Server.Mobiles private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont) { if (amount > bii.Amount) + { amount = bii.Amount; + } if (amount < 1) + { return; + } bii.Amount -= amount; @@ -1039,23 +1244,31 @@ namespace Server.Mobiles item.Amount = amount; if (cont?.TryDropItem(buyer, item, false) != true) + { item.MoveToWorld(buyer.Location, buyer.Map); + } } else { item.Amount = 1; if (cont?.TryDropItem(buyer, item, false) != true) + { item.MoveToWorld(buyer.Location, buyer.Map); + } for (var i = 1; i < amount; i++) + { if (bii.GetEntity() is Item newItem) { newItem.Amount = 1; if (cont?.TryDropItem(buyer, newItem, false) != true) + { newItem.MoveToWorld(buyer.Location, buyer.Map); + } } + } } } else if (o is Mobile m) @@ -1071,6 +1284,7 @@ namespace Server.Mobiles } for (var i = 1; i < amount; ++i) + { if (bii.GetEntity() is Mobile newMobile) { newMobile.Direction = (Direction)Utility.Random(8); @@ -1082,6 +1296,7 @@ namespace Server.Mobiles newBc.ControlOrder = OrderType.Stop; } } + } } } @@ -1187,7 +1402,9 @@ namespace Server.Mobiles } if (IsParagon) + { IsParagon = false; + } Timer.DelayCall(CheckMorph); } @@ -1197,13 +1414,19 @@ namespace Server.Mobiles if (from.Alive && IsActiveVendor) { if (SupportsBulkOrders(from)) - list.Add(new BulkOrderInfoEntry(from, this)); + { + list.Add(new BulkOrderInfoEntry(@from, this)); + } if (IsActiveSeller) - list.Add(new VendorBuyEntry(from, this)); + { + list.Add(new VendorBuyEntry(@from, this)); + } if (IsActiveBuyer) - list.Add(new VendorSellEntry(from, this)); + { + list.Add(new VendorSellEntry(@from, this)); + } } base.AddCustomContextEntries(from, list); @@ -1220,7 +1443,9 @@ namespace Server.Mobiles var priceScalar = GetPriceScalar(); foreach (var info in m_ArmorBuyInfo.ToArray()) + { info.PriceScalar = priceScalar; + } } private class BulkOrderInfoEntry : ContextMenuEntry @@ -1254,9 +1479,13 @@ namespace Server.Mobiles var bulkOrder = m_Vendor.CreateBulkOrder(m_From, true); if (bulkOrder is LargeBOD bod) + { m_From.SendGump(new LargeBODAcceptGump(m_From, bod)); + } else if (bulkOrder is SmallBOD smallBod) + { m_From.SendGump(new SmallBODAcceptGump(m_From, smallBod)); + } } } else @@ -1265,17 +1494,21 @@ namespace Server.Mobiles m_Vendor.SpeechHue = 0x3B2; if (Core.SE) + { m_Vendor.SayTo( m_From, 1072058, totalMinutes.ToString() ); // An offer may be available in about ~1_minutes~ minutes. + } else + { m_Vendor.SayTo( m_From, 1049039, totalHours.ToString() ); // An offer may be available in about ~1_hours~ hours. + } m_Vendor.SpeechHue = oldSpeechHue; } diff --git a/Projects/UOContent/Mobiles/Vendors/BeverageBuy.cs b/Projects/UOContent/Mobiles/Vendors/BeverageBuy.cs index b5648579a..90e882d65 100644 --- a/Projects/UOContent/Mobiles/Vendors/BeverageBuy.cs +++ b/Projects/UOContent/Mobiles/Vendors/BeverageBuy.cs @@ -26,11 +26,17 @@ namespace Server.Mobiles m_Content = content; if (type == typeof(Pitcher)) + { Name = (1048128 + (int)content).ToString(); + } else if (type == typeof(BeverageBottle)) + { Name = (1042959 + (int)content).ToString(); + } else if (type == typeof(Jug)) + { Name = (1042965 + (int)content).ToString(); + } } public override bool CanCacheDisplay => false; diff --git a/Projects/UOContent/Mobiles/Vendors/GenericBuy.cs b/Projects/UOContent/Mobiles/Vendors/GenericBuy.cs index 74856f263..603a140cf 100644 --- a/Projects/UOContent/Mobiles/Vendors/GenericBuy.cs +++ b/Projects/UOContent/Mobiles/Vendors/GenericBuy.cs @@ -69,7 +69,9 @@ namespace Server.Mobiles price /= 100; if (price > int.MaxValue) + { price = int.MaxValue; + } return (int)price; } @@ -98,7 +100,9 @@ namespace Server.Mobiles public virtual IEntity GetEntity() { if (Args == null || Args.Length == 0) + { return (IEntity)ActivatorUtil.CreateInstance(Type); + } return (IEntity)ActivatorUtil.CreateInstance(Type, Args); // return (Item)ActivatorUtil.CreateInstance( m_Type ); @@ -121,9 +125,13 @@ namespace Server.Mobiles object Obj_Disp = GetDisplayEntity(); if (Core.ML && Obj_Disp is Item item && !item.Stackable) + { MaxAmount = Math.Min(20, MaxAmount); + } else + { MaxAmount = Math.Min(999, MaxAmount * 2); + } } else { @@ -136,12 +144,18 @@ namespace Server.Mobiles var halfQuantity = MaxAmount; if (halfQuantity >= 999) + { halfQuantity = 640; + } else if (halfQuantity > 20) + { halfQuantity /= 2; + } if (m_Amount >= halfQuantity) + { MaxAmount = halfQuantity; + } } m_Amount = MaxAmount; @@ -152,7 +166,9 @@ namespace Server.Mobiles public void DeleteDisplayEntity() { if (m_DisplayEntity == null) + { return; + } m_DisplayEntity.Delete(); m_DisplayEntity = null; @@ -161,15 +177,21 @@ namespace Server.Mobiles public IEntity GetDisplayEntity() { if (m_DisplayEntity != null && !IsDeleted(m_DisplayEntity)) + { return m_DisplayEntity; + } var canCache = CanCacheDisplay; if (canCache) + { m_DisplayEntity = DisplayCache.Cache.Lookup(Type); + } if (m_DisplayEntity == null || IsDeleted(m_DisplayEntity)) + { m_DisplayEntity = GetEntity(); + } DisplayCache.Cache.Store(Type, m_DisplayEntity, canCache); @@ -198,7 +220,9 @@ namespace Server.Mobiles get { if (m_Cache?.Deleted != false) + { m_Cache = new DisplayCache(); + } return m_Cache; } @@ -213,12 +237,18 @@ namespace Server.Mobiles public void Store(Type key, IEntity obj, bool cache) { if (cache) + { m_Table[key] = obj; + } if (obj is Item item) + { AddItem(item); + } else if (obj is Mobile mobile) + { m_Mobiles.Add(mobile); + } } public override void OnAfterDelete() @@ -226,16 +256,24 @@ namespace Server.Mobiles base.OnAfterDelete(); for (var i = 0; i < m_Mobiles.Count; ++i) + { m_Mobiles[i].Delete(); + } m_Mobiles.Clear(); for (var i = Items.Count - 1; i >= 0; --i) + { if (i < Items.Count) + { Items[i].Delete(); + } + } if (m_Cache == this) + { m_Cache = null; + } } public override void Serialize(IGenericWriter writer) @@ -256,18 +294,28 @@ namespace Server.Mobiles m_Mobiles = reader.ReadStrongMobileList(); for (var i = 0; i < m_Mobiles.Count; ++i) + { m_Mobiles[i].Delete(); + } m_Mobiles.Clear(); for (var i = Items.Count - 1; i >= 0; --i) + { if (i < Items.Count) + { Items[i].Delete(); + } + } if (m_Cache == null) + { m_Cache = this; + } else + { Delete(); + } m_Table = new Dictionary(); } diff --git a/Projects/UOContent/Mobiles/Vendors/GenericSell.cs b/Projects/UOContent/Mobiles/Vendors/GenericSell.cs index e15ec1d7a..a55cf2e6d 100644 --- a/Projects/UOContent/Mobiles/Vendors/GenericSell.cs +++ b/Projects/UOContent/Mobiles/Vendors/GenericSell.cs @@ -16,30 +16,42 @@ namespace Server.Mobiles if (item is BaseArmor armor) { if (armor.Quality == ArmorQuality.Low) + { price = (int)(price * 0.60); + } else if (armor.Quality == ArmorQuality.Exceptional) + { price = (int)(price * 1.25); + } price += 100 * (int)armor.Durability; price += 100 * (int)armor.ProtectionLevel; if (price < 1) + { price = 1; + } } else if (item is BaseWeapon weapon) { if (weapon.Quality == WeaponQuality.Low) + { price = (int)(price * 0.60); + } else if (weapon.Quality == WeaponQuality.Exceptional) + { price = (int)(price * 1.25); + } price += 100 * (int)weapon.DurabilityLevel; price += 100 * (int)weapon.DamageLevel; if (price < 1) + { price = 1; + } } else if (item is BaseBeverage bev) { @@ -62,9 +74,13 @@ namespace Server.Mobiles } if (bev.IsEmpty || bev.Content == BeverageType.Milk) + { price = price1; + } else + { price = price2; + } } return price; @@ -89,14 +105,19 @@ namespace Server.Mobiles public string GetNameFor(Item item) { if (item.Name != null) + { return item.Name; + } + return item.LabelNumber.ToString(); } public bool IsSellable(Item item) { if (item.Nontransferable) + { return false; + } // if (item.Hue != 0) // return false; @@ -107,7 +128,9 @@ namespace Server.Mobiles public bool IsResellable(Item item) { if (item.Nontransferable) + { return false; + } // if (item.Hue != 0) // return false; diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs index 435eab8ab..3ac08ed27 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs @@ -48,7 +48,9 @@ namespace Server.Mobiles list.Add(new StableEntry(this, from)); if (from.Stabled.Count > 0) - list.Add(new ClaimAllEntry(this, from)); + { + list.Add(new ClaimAllEntry(this, @from)); + } } base.AddCustomContextEntries(from, list); @@ -64,22 +66,36 @@ namespace Server.Mobiles int max; if (sklsum >= 240.0) + { max = 5; + } else if (sklsum >= 200.0) + { max = 4; + } else if (sklsum >= 160.0) + { max = 3; + } else + { max = 2; + } if (taming >= 100.0) + { max += (int)((taming - 90.0) / 10); + } if (anlore >= 100.0) + { max += (int)((anlore - 90.0) / 10); + } if (vetern >= 100.0) + { max += (int)((vetern - 90.0) / 10); + } return max; } @@ -92,7 +108,9 @@ namespace Server.Mobiles public void BeginClaimList(Mobile from) { if (Deleted || !from.CheckAlive()) + { return; + } var list = new List(); @@ -117,15 +135,21 @@ namespace Server.Mobiles } if (list.Count > 0) - from.SendGump(new ClaimListGump(this, from, list)); + { + @from.SendGump(new ClaimListGump(this, @from, list)); + } else - SayTo(from, 502671); // But I have no animals stabled with me at the moment! + { + SayTo(@from, 502671); // But I have no animals stabled with me at the moment! + } } public void EndClaimList(Mobile from, BaseCreature pet) { if (pet?.Deleted != false || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive()) + { return; + } if (!from.InRange(this, 14)) { @@ -150,7 +174,9 @@ namespace Server.Mobiles public void BeginStable(Mobile from) { if (Deleted || !from.CheckAlive()) + { return; + } Container bank = from.FindBankNoCreate(); @@ -174,7 +200,9 @@ namespace Server.Mobiles public void EndStable(Mobile from, BaseCreature pet) { if (Deleted || !from.CheckAlive()) + { return; + } if (pet.Body.IsHuman) { @@ -232,7 +260,9 @@ namespace Server.Mobiles pet.StabledBy = from; if (Core.SE) + { pet.Loyalty = MaxLoyalty; // Wonderfully happy + } from.Stabled.Add(pet); @@ -253,7 +283,9 @@ namespace Server.Mobiles public void Claim(Mobile from, string petName = null) { if (Deleted || !from.CheckAlive()) + { return; + } var claimed = false; var stabled = 0; @@ -276,7 +308,9 @@ namespace Server.Mobiles ++stabled; if (claimByName && !Insensitive.Equals(pet.Name, petName)) + { continue; + } if (CanClaim(from, pet)) { @@ -297,11 +331,17 @@ namespace Server.Mobiles } if (claimed) - SayTo(from, 1042559); // Here you go... and good day to you! + { + SayTo(@from, 1042559); // Here you go... and good day to you! + } else if (stabled == 0) - SayTo(from, 502671); // But I have no animals stabled with me at the moment! + { + SayTo(@from, 502671); // But I have no animals stabled with me at the moment! + } else if (claimByName) - BeginClaimList(from); + { + BeginClaimList(@from); + } } public bool CanClaim(Mobile from, BaseCreature pet) => from.Followers + pet.ControlSlots <= from.FollowersMax; @@ -311,7 +351,9 @@ namespace Server.Mobiles pet.SetControlMaster(from); if (pet.Summoned) - pet.SummonMaster = from; + { + pet.SummonMaster = @from; + } pet.ControlTarget = from; pet.ControlOrder = OrderType.Follow; @@ -322,7 +364,9 @@ namespace Server.Mobiles pet.StabledBy = null; if (Core.SE) + { pet.Loyalty = MaxLoyalty; // Wonderfully Happy + } } public override bool HandlesOnSpeech(Mobile from) => true; @@ -345,9 +389,13 @@ namespace Server.Mobiles var index = e.Speech.IndexOf(' '); if (index != -1) + { Claim(e.Mobile, e.Speech.Substring(index).Trim()); + } else + { Claim(e.Mobile); + } } else { @@ -412,7 +460,9 @@ namespace Server.Mobiles var pet = list[i]; if (pet?.Deleted != false) + { continue; + } AddButton(15, 39 + i * 20, 10006, 10006, i + 1); AddHtml(32, 35 + i * 20, 275, 18, $"{pet.Name}"); @@ -424,7 +474,9 @@ namespace Server.Mobiles var index = info.ButtonID - 1; if (index >= 0 && index < m_List.Count) + { m_Trainer.EndClaimList(m_From, m_List[index]); + } } } @@ -454,11 +506,17 @@ namespace Server.Mobiles protected override void OnTarget(Mobile from, object targeted) { if (targeted is BaseCreature creature) - m_Trainer.EndStable(from, creature); + { + m_Trainer.EndStable(@from, creature); + } else if (targeted == from) - m_Trainer.SayTo(from, 502672); // HA HA HA! Sorry, I am not an inn. + { + m_Trainer.SayTo(@from, 502672); // HA HA HA! Sorry, I am not an inn. + } else - m_Trainer.SayTo(from, 1048053); // You can't stable that! + { + m_Trainer.SayTo(@from, 1048053); // You can't stable that! + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Architect.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Architect.cs index 182fa2d4c..24572647d 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Architect.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Architect.cs @@ -22,7 +22,9 @@ namespace Server.Mobiles public override void InitSBInfo() { if (!Core.AOS) + { m_SBInfos.Add(new SBHouseDeed()); + } m_SBInfos.Add(new SBArchitect()); } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs index c0b041a2b..2fef4386f 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs @@ -73,7 +73,9 @@ namespace Server.Mobiles } if (item == null) + { AddItem(new FullApron()); + } AddItem(new Bascinet()); AddItem(new SmithHammer()); @@ -101,14 +103,22 @@ namespace Server.Mobiles var theirSkill = pm.Skills.Blacksmith.Base; if (theirSkill >= 70.1) + { pm.NextSmithBulkOrder = TimeSpan.FromHours(6.0); + } else if (theirSkill >= 50.1) + { pm.NextSmithBulkOrder = TimeSpan.FromHours(2.0); + } else + { pm.NextSmithBulkOrder = TimeSpan.FromHours(1.0); + } if (theirSkill >= 70.1 && (theirSkill - 40.0) / 300.0 > Utility.RandomDouble()) + { return new LargeSmithBOD(); + } return SmallSmithBOD.CreateRandomFor(from); } @@ -123,7 +133,9 @@ namespace Server.Mobiles public override TimeSpan GetNextBulkOrder(Mobile from) { if (from is PlayerMobile mobile) + { return mobile.NextSmithBulkOrder; + } return TimeSpan.Zero; } @@ -131,7 +143,9 @@ namespace Server.Mobiles public override void OnSuccessfulBulkOrderReceive(Mobile from) { if (Core.SE && from is PlayerMobile mobile) + { mobile.NextSmithBulkOrder = TimeSpan.Zero; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Bowyer.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Bowyer.cs index 0d7dcc91c..13c4ecb27 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Bowyer.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Bowyer.cs @@ -39,7 +39,9 @@ namespace Server.Mobiles m_SBInfos.Add(new SBRangedWeapon()); if (IsTokunoVendor) + { m_SBInfos.Add(new SBSEBowyer()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Carpenter.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Carpenter.cs index 2ca799bef..8d187c8f2 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Carpenter.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Carpenter.cs @@ -29,7 +29,9 @@ namespace Server.Mobiles m_SBInfos.Add(new SBWoodenShields()); if (IsTokunoVendor) + { m_SBInfos.Add(new SBSECarpenter()); + } } public override void InitOutfit() diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Cook.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Cook.cs index a83de7b47..14f8a617b 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Cook.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Cook.cs @@ -27,7 +27,9 @@ namespace Server.Mobiles m_SBInfos.Add(new SBCook()); if (IsTokunoVendor) + { m_SBInfos.Add(new SBSECook()); + } } public override void InitOutfit() diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/CustomHairstylist.cs b/Projects/UOContent/Mobiles/Vendors/NPC/CustomHairstylist.cs index 710d57ea5..090266ad4 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/CustomHairstylist.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/CustomHairstylist.cs @@ -189,8 +189,12 @@ namespace Server.Mobiles var canAfford = 0; for (var i = 0; i < sellList.Length; ++i) + { if (balance >= sellList[i].Price && (!sellList[i].FacialHair || !isFemale)) + { ++canAfford; + } + } AddPage(0); @@ -201,15 +205,21 @@ namespace Server.Mobiles var index = 0; for (var i = 0; i < sellList.Length; ++i) + { if (balance >= sellList[i].Price && (!sellList[i].FacialHair || !isFemale)) { if (sellList[i].TitleString != null) + { AddHtml(140, 75 + index * 25, 300, 20, sellList[i].TitleString); + } else + { AddHtmlLocalized(140, 75 + index * 25, 300, 20, sellList[i].Title); + } AddButton(100, 75 + index++ * 25, 4005, 4007, 1 + i); } + } } public override void OnResponse(NetState sender, RelayInfo info) @@ -225,22 +235,35 @@ namespace Server.Mobiles var isFemale = m_From.Female || m_From.Body.IsFemale; if (buyInfo.FacialHair && isFemale) + { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1010639, m_From.NetState); + } else if (balance >= buyInfo.Price) + { try { var origArgs = buyInfo.GumpArgs; var args = new object[origArgs.Length]; for (var i = 0; i < args.Length; ++i) + { if (origArgs[i] == CustomHairstylist.Price) + { args[i] = m_SellList[index].Price; + } else if (origArgs[i] == CustomHairstylist.From) + { args[i] = m_From; + } else if (origArgs[i] == CustomHairstylist.Vendor) + { args[i] = m_Vendor; + } else + { args[i] = origArgs[i]; + } + } var g = ActivatorUtil.CreateInstance(buyInfo.GumpType, args) as Gump; @@ -250,8 +273,11 @@ namespace Server.Mobiles { // ignored } + } else + { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); + } } } } @@ -299,7 +325,9 @@ namespace Server.Mobiles Hues = new int[count]; for (var i = 0; i < count; ++i) + { Hues[i] = start + i; + } } public string Name { get; } @@ -378,6 +406,7 @@ namespace Server.Mobiles var offset = switches[0] / m_Entries.Length; if (index >= 0 && index < m_Entries.Length) + { if (offset >= 0 && offset < m_Entries[index].Hues.Length) { if (m_Hair && m_From.HairItemID > 0 || m_FacialHair && m_From.FacialHairItemID > 0) @@ -396,10 +425,14 @@ namespace Server.Mobiles var hue = m_Entries[index].Hues[offset]; if (m_Hair) + { m_From.HairHue = hue; + } if (m_FacialHair) + { m_From.FacialHairHue = hue; + } } else { @@ -411,6 +444,7 @@ namespace Server.Mobiles ); // You have no hair to dye and you cannot use this. } } + } } else { @@ -515,9 +549,13 @@ namespace Server.Mobiles ); // Cancel if (!facialHair) + { AddHtmlLocalized(50, 15, 350, 20, 1018353); //
New Hairstyle
+ } else + { AddHtmlLocalized(55, 15, 200, 20, 1018354); //
New Beard
+ } for (var i = 0; i < entries.Length; ++i) { @@ -550,7 +588,9 @@ namespace Server.Mobiles public override void OnResponse(NetState sender, RelayInfo info) { if (m_FacialHair && (m_From.Female || m_From.Body.IsFemale)) + { return; + } if (m_From.Race == Race.Elf) { @@ -578,14 +618,20 @@ namespace Server.Mobiles if (entry.ItemID == 0) { if (m_FacialHair ? facialHairID == 0 : hairID == 0) + { return; + } if (Banker.Withdraw(m_From, m_Price)) { if (m_FacialHair) + { m_From.FacialHairItemID = 0; + } else + { m_From.HairItemID = 0; + } } else { @@ -602,20 +648,28 @@ namespace Server.Mobiles if (m_FacialHair) { if (facialHairID > 0 && facialHairID == entry.ItemID) + { return; + } } else { if (hairID > 0 && hairID == entry.ItemID) + { return; + } } if (Banker.Withdraw(m_From, m_Price)) { if (m_FacialHair) + { m_From.FacialHairItemID = entry.ItemID; + } else + { m_From.HairItemID = entry.ItemID; + } } else { diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Glassblower.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Glassblower.cs index 9a8ad25df..4f88dc1ff 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Glassblower.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Glassblower.cs @@ -42,7 +42,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Body == 0x2F2) + { Body = 0x2F6; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs index 6fb290e92..23b68e00a 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs @@ -74,7 +74,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.InRange(Location, 2)) + { return true; + } return base.HandlesOnSpeech(from); } @@ -88,13 +90,21 @@ namespace Server.Mobiles if (e.HasKeyword(0x0004)) // *join* | *member* { if (pm.NpcGuild == NpcGuild) + { SayTo(pm, 501047); // Thou art already a member of our guild. + } else if (pm.NpcGuild != NpcGuild.None) + { SayTo(pm, 501046); // Thou must resign from thy other guild first. + } else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow) + { SayTo(pm, 501048); // You are too young to join my guild... + } else if (CheckCustomReqs(pm)) + { SayPriceTo(pm); + } e.Handled = true; } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BlacksmithGuildmaster.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BlacksmithGuildmaster.cs index 7b3e63e39..9c4e59811 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BlacksmithGuildmaster.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/BlacksmithGuildmaster.cs @@ -43,7 +43,9 @@ namespace Server.Mobiles } if (item == null) + { AddItem(new FullApron()); + } AddItem(new Bascinet()); AddItem(new SmithHammer()); diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/ThiefGuildmaster.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/ThiefGuildmaster.cs index 2ca32d518..f9712f7c2 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/ThiefGuildmaster.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/ThiefGuildmaster.cs @@ -32,9 +32,13 @@ namespace Server.Mobiles base.InitOutfit(); if (Utility.RandomBool()) + { AddItem(new Kryss()); + } else + { AddItem(new Dagger()); + } } public override bool CheckCustomReqs(PlayerMobile pm) @@ -68,7 +72,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.InRange(Location, 2)) + { return true; + } return base.HandlesOnSpeech(from); } @@ -80,9 +86,13 @@ namespace Server.Mobiles if (!e.Handled && from is PlayerMobile pm && pm.InRange(Location, 2) && e.HasKeyword(0x1F)) // *disguise* { if (pm.NpcGuild == NpcGuild.ThievesGuild) + { SayTo(pm, 501839); // That particular item costs 700 gold pieces. + } else + { SayTo(pm, 501838); // I don't know what you're talking about. + } e.Handled = true; } @@ -93,6 +103,7 @@ namespace Server.Mobiles public override bool OnGoldGiven(Mobile from, Gold dropped) { if (from is PlayerMobile pm && dropped.Amount == 700) + { if (pm.NpcGuild == NpcGuild.ThievesGuild) { pm.AddToBackpack(new DisguiseKit()); @@ -100,6 +111,7 @@ namespace Server.Mobiles dropped.Delete(); return true; } + } return base.OnGoldGiven(from, dropped); } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs index 8f8b5ae71..312ec5695 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles var entry = new RechargeEntry(from, this); if (WeaponEngravingTool.Find(from) == null) + { entry.Enabled = false; + } list.Add(entry); } @@ -63,16 +65,22 @@ namespace Server.Mobiles public override void OnClick() { if (!Core.ML || m_Vendor?.Deleted != false) + { return; + } var tool = WeaponEngravingTool.Find(m_From); if (tool?.UsesRemaining <= 0) { if (Banker.GetBalance(m_From) >= 100000) + { m_From.SendGump(new WeaponEngravingTool.ConfirmGump(tool, m_Vendor)); + } else + { m_Vendor.Say(1076167); // You need a 100,000 gold and a blue diamond to recharge the weapon engraver. + } } else { diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/GypsyAnimalTrainer.cs b/Projects/UOContent/Mobiles/Vendors/NPC/GypsyAnimalTrainer.cs index 712ba1243..03c154a79 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/GypsyAnimalTrainer.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/GypsyAnimalTrainer.cs @@ -6,9 +6,13 @@ namespace Server.Mobiles public GypsyAnimalTrainer() { if (Utility.RandomBool()) + { Title = "the gypsy animal trainer"; + } else + { Title = "the gypsy animal herder"; + } } public GypsyAnimalTrainer(Serial serial) : base(serial) @@ -26,32 +30,44 @@ namespace Server.Mobiles var item = FindItemOnLayer(Layer.Pants); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterTorso); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerTorso); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.Shirt); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/GypsyBanker.cs b/Projects/UOContent/Mobiles/Vendors/NPC/GypsyBanker.cs index ab491fc28..596f744fe 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/GypsyBanker.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/GypsyBanker.cs @@ -32,37 +32,51 @@ namespace Server.Mobiles var item = FindItemOnLayer(Layer.Pants); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.Shoes); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterTorso); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerTorso); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.Shirt); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/GypsyMaiden.cs b/Projects/UOContent/Mobiles/Vendors/NPC/GypsyMaiden.cs index aec77c170..b1de7055b 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/GypsyMaiden.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/GypsyMaiden.cs @@ -40,22 +40,30 @@ namespace Server.Mobiles ); if (Utility.RandomBool()) + { AddItem(new HalfApron(Utility.RandomBrightHue())); + } var item = FindItemOnLayer(Layer.Pants); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/InnKeeper.cs b/Projects/UOContent/Mobiles/Vendors/NPC/InnKeeper.cs index a982be220..44ead67cf 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/InnKeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/InnKeeper.cs @@ -24,7 +24,9 @@ namespace Server.Mobiles m_SBInfos.Add(new SBInnKeeper()); if (IsTokunoVendor) + { m_SBInfos.Add(new SBSEFood()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/IronWorker.cs b/Projects/UOContent/Mobiles/Vendors/NPC/IronWorker.cs index e3c069720..c2740ada0 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/IronWorker.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/IronWorker.cs @@ -74,32 +74,44 @@ namespace Server.Mobiles item = FindItemOnLayer(Layer.Pants); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerLegs); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.OuterTorso); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.InnerTorso); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } item = FindItemOnLayer(Layer.Shirt); if (item != null) + { item.Hue = Utility.RandomBrightHue(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Provisioner.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Provisioner.cs index 1a842e84e..458d1cc86 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Provisioner.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Provisioner.cs @@ -24,7 +24,9 @@ namespace Server.Mobiles m_SBInfos.Add(new SBProvisioner()); if (IsTokunoVendor) + { m_SBInfos.Add(new SBSEHats()); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs b/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs index 101448ca6..14afcc2a5 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/RealEstateBroker.cs @@ -25,7 +25,9 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { if (from.Alive && from.InRange(this, 3)) + { return true; + } return base.HandlesOnSpeech(from); } @@ -129,33 +131,61 @@ namespace Server.Mobiles if (deed is SmallBrickHouseDeed || deed is StonePlasterHouseDeed || deed is FieldStoneHouseDeed || deed is WoodHouseDeed || deed is WoodPlasterHouseDeed || deed is ThatchedRoofCottageDeed) + { price = 43800; + } else if (deed is BrickHouseDeed) + { price = 144500; + } else if (deed is TwoStoryWoodPlasterHouseDeed || deed is TwoStoryStonePlasterHouseDeed) + { price = 192400; + } else if (deed is TowerDeed) + { price = 433200; + } else if (deed is KeepDeed) + { price = 665200; + } else if (deed is CastleDeed) + { price = 1022800; + } else if (deed is LargePatioDeed) + { price = 152800; + } else if (deed is LargeMarbleDeed) + { price = 192800; + } else if (deed is SmallTowerDeed) + { price = 88500; + } else if (deed is LogCabinDeed) + { price = 97800; + } else if (deed is SandstonePatioDeed) + { price = 90900; + } else if (deed is VillaDeed) + { price = 136500; + } else if (deed is StoneWorkshopDeed) + { price = 60600; + } else if (deed is MarbleWorkshopDeed) + { price = 60300; + } return AOS.Scale(price, 80); // refunds 80% of the purchase price } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/StoneCrafter.cs b/Projects/UOContent/Mobiles/Vendors/NPC/StoneCrafter.cs index 48eb59dc2..f1e614e42 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/StoneCrafter.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/StoneCrafter.cs @@ -43,7 +43,9 @@ namespace Server.Mobiles var version = reader.ReadInt(); if (Title == "the stonecrafter") + { Title = "the stone crafter"; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs index f4780b269..fed1e8898 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs @@ -51,14 +51,22 @@ namespace Server.Mobiles var theirSkill = pm.Skills.Tailoring.Base; if (theirSkill >= 70.1) + { pm.NextTailorBulkOrder = TimeSpan.FromHours(6.0); + } else if (theirSkill >= 50.1) + { pm.NextTailorBulkOrder = TimeSpan.FromHours(2.0); + } else + { pm.NextTailorBulkOrder = TimeSpan.FromHours(1.0); + } if (theirSkill >= 70.1 && (theirSkill - 40.0) / 300.0 > Utility.RandomDouble()) + { return new LargeTailorBOD(); + } return SmallTailorBOD.CreateRandomFor(from); } @@ -73,7 +81,9 @@ namespace Server.Mobiles public override TimeSpan GetNextBulkOrder(Mobile from) { if (from is PlayerMobile mobile) + { return mobile.NextTailorBulkOrder; + } return TimeSpan.Zero; } @@ -81,7 +91,9 @@ namespace Server.Mobiles public override void OnSuccessfulBulkOrderReceive(Mobile from) { if (Core.SE && from is PlayerMobile mobile) + { mobile.NextTailorBulkOrder = TimeSpan.Zero; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs index 11f68ef3d..f67e7b6e7 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Vagabond.cs @@ -32,7 +32,9 @@ namespace Server.Mobiles AddItem(new LongPants(GetRandomHue())); if (Utility.RandomBool()) + { AddItem(new Cloak(Utility.RandomBrightHue())); + } AddItem( Utility.RandomBool() diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs index 12e2950a4..1f67f5c44 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs @@ -33,7 +33,9 @@ namespace Server.Mobiles m_SBInfos.Add(new SBWeaponSmith()); if (IsTokunoVendor) + { m_SBInfos.Add(new SBSEWeapons()); + } } public override int GetShoeHue() => 0; @@ -67,14 +69,22 @@ namespace Server.Mobiles var theirSkill = pm.Skills.Blacksmith.Base; if (theirSkill >= 70.1) + { pm.NextSmithBulkOrder = TimeSpan.FromHours(6.0); + } else if (theirSkill >= 50.1) + { pm.NextSmithBulkOrder = TimeSpan.FromHours(2.0); + } else + { pm.NextSmithBulkOrder = TimeSpan.FromHours(1.0); + } if (theirSkill >= 70.1 && (theirSkill - 40.0) / 300.0 > Utility.RandomDouble()) + { return new LargeSmithBOD(); + } return SmallSmithBOD.CreateRandomFor(from); } @@ -90,7 +100,9 @@ namespace Server.Mobiles public override TimeSpan GetNextBulkOrder(Mobile from) { if (from is PlayerMobile mobile) + { return mobile.NextSmithBulkOrder; + } return TimeSpan.Zero; } @@ -98,7 +110,9 @@ namespace Server.Mobiles public override void OnSuccessfulBulkOrderReceive(Mobile from) { if (Core.SE && from is PlayerMobile mobile) + { mobile.NextSmithBulkOrder = TimeSpan.Zero; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs index a0907ca9d..ed480751f 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs @@ -51,14 +51,22 @@ namespace Server.Mobiles var theirSkill = pm.Skills.Tailoring.Base; if (theirSkill >= 70.1) + { pm.NextTailorBulkOrder = TimeSpan.FromHours(6.0); + } else if (theirSkill >= 50.1) + { pm.NextTailorBulkOrder = TimeSpan.FromHours(2.0); + } else + { pm.NextTailorBulkOrder = TimeSpan.FromHours(1.0); + } if (theirSkill >= 70.1 && (theirSkill - 40.0) / 300.0 > Utility.RandomDouble()) + { return new LargeTailorBOD(); + } return SmallTailorBOD.CreateRandomFor(from); } @@ -73,7 +81,9 @@ namespace Server.Mobiles public override TimeSpan GetNextBulkOrder(Mobile from) { if (from is PlayerMobile mobile) + { return mobile.NextTailorBulkOrder; + } return TimeSpan.Zero; } @@ -81,7 +91,9 @@ namespace Server.Mobiles public override void OnSuccessfulBulkOrderReceive(Mobile from) { if (Core.SE && from is PlayerMobile mobile) + { mobile.NextTailorBulkOrder = TimeSpan.Zero; + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs b/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs index 354c38b78..8023ee883 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs @@ -28,7 +28,9 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (text.Length > 130) + { text = text.Substring(0, 130); + } m_Barkeeper.EndChangeRumor(from, m_RumorIndex, text); } @@ -53,7 +55,9 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (text.Length > 130) + { text = text.Substring(0, 130); + } m_Barkeeper.EndChangeKeyword(from, m_RumorIndex, text); } @@ -73,7 +77,9 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (text.Length > 130) + { text = text.Substring(0, 130); + } m_Barkeeper.EndChangeTip(from, text); } @@ -94,7 +100,9 @@ namespace Server.Mobiles public static BarkeeperRumor Deserialize(IGenericReader reader) { if (!reader.ReadBool()) + { return null; + } return new BarkeeperRumor(reader.ReadString(), reader.ReadString()); } @@ -199,9 +207,13 @@ namespace Server.Mobiles base.InitBody(); if (BodyValue == 0x340 || BodyValue == 0x402) + { Hue = 0; + } else + { Hue = 0x83F4; // hue is not random + } var pack = Backpack; @@ -233,12 +245,16 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) + { return false; + } var shoes = FindItemOnLayer(Layer.Shoes); if (shoes is Sandals) + { shoes.Hue = 0; + } return true; } @@ -277,14 +293,18 @@ namespace Server.Mobiles var keyword = rumor?.Keyword; if (keyword == null || (keyword = keyword.Trim()).Length == 0) + { continue; + } if (Insensitive.Equals(keyword, e.Speech)) { var message = rumor.Message; if (message == null || (message = message.Trim()).Length == 0) + { continue; + } PublicOverheadMessage(MessageType.Regular, 0x3B2, false, message); } @@ -295,7 +315,9 @@ namespace Server.Mobiles public override bool CheckGold(Mobile from, Item dropped) { if (!(dropped is Gold g)) + { return false; + } if (g.Amount > 50) { @@ -337,10 +359,14 @@ namespace Server.Mobiles public bool IsOwner(Mobile from) { if (from?.Deleted != false || Deleted) + { return false; + } if (from.AccessLevel > AccessLevel.GameMaster) + { return true; + } return Owner == from; } @@ -350,13 +376,17 @@ namespace Server.Mobiles base.GetContextMenuEntries(from, list); if (IsOwner(from) && from.InLOS(this)) - list.Add(new ManageBarkeeperEntry(from, this)); + { + list.Add(new ManageBarkeeperEntry(@from, this)); + } } public void BeginManagement(Mobile from) { if (!IsOwner(from)) + { return; + } from.SendGump(new BarkeeperGump(from, this)); } @@ -369,7 +399,9 @@ namespace Server.Mobiles public void BeginChangeRumor(Mobile from, int index) { if (index < 0 || index >= Rumors.Length) + { return; + } from.Prompt = new ChangeRumorMessagePrompt(this, index); PrivateOverheadMessage( @@ -384,12 +416,18 @@ namespace Server.Mobiles public void EndChangeRumor(Mobile from, int index, string text) { if (index < 0 || index >= Rumors.Length) + { return; + } if (Rumors[index] == null) + { Rumors[index] = new BarkeeperRumor(text, null); + } else + { Rumors[index].Message = text; + } from.Prompt = new ChangeRumorKeywordPrompt(this, index); PrivateOverheadMessage( @@ -404,12 +442,18 @@ namespace Server.Mobiles public void EndChangeKeyword(Mobile from, int index, string text) { if (index < 0 || index >= Rumors.Length) + { return; + } if (Rumors[index] == null) + { Rumors[index] = new BarkeeperRumor(null, text); + } else + { Rumors[index].Keyword = text; + } PrivateOverheadMessage(MessageType.Regular, 0x3B2, false, "I'll pass on the message.", from.NetState); } @@ -417,7 +461,9 @@ namespace Server.Mobiles public void RemoveRumor(Mobile from, int index) { if (index < 0 || index >= Rumors.Length) + { return; + } Rumors[index] = null; } @@ -498,7 +544,9 @@ namespace Server.Mobiles Title == "the chef") { if (m_SBInfos.Count == 0) + { m_SBInfos.Add(new SBPlayerBarkeeper()); + } } else { @@ -519,7 +567,9 @@ namespace Server.Mobiles writer.WriteEncodedInt(Rumors.Length); for (var i = 0; i < Rumors.Length; ++i) + { BarkeeperRumor.Serialize(writer, Rumors[i]); + } writer.Write(TipMessage); } @@ -545,7 +595,9 @@ namespace Server.Mobiles Rumors = new BarkeeperRumor[reader.ReadEncodedInt()]; for (var i = 0; i < Rumors.Length; ++i) + { Rumors[i] = BarkeeperRumor.Deserialize(reader); + } TipMessage = reader.ReadString(); @@ -554,7 +606,9 @@ namespace Server.Mobiles } if (version < 1) + { Timer.DelayCall(UpgradeFromVersion0); + } } private void UpgradeFromVersion0() @@ -647,7 +701,9 @@ namespace Server.Mobiles var pageCount = (entries.Length + 19) / 20; for (var i = 0; i < pageCount; ++i) + { RenderPage(entries, i); + } } private void RenderBackground() @@ -745,7 +801,9 @@ namespace Server.Mobiles --buttonID; if (buttonID >= 0 && buttonID < m_Entries.Length) + { m_Barkeeper.EndChangeTitle(m_From, m_Entries[buttonID].m_Title, m_Entries[buttonID].m_Vendor); + } } else { @@ -1009,12 +1067,16 @@ namespace Server.Mobiles public override void OnResponse(NetState state, RelayInfo info) { if (!m_Barkeeper.IsOwner(m_From)) + { return; + } var index = info.ButtonID - 1; if (index < 0) + { return; + } var type = index % 6; index /= 6; diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs index 956755bb3..c5e1dafcb 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs @@ -41,7 +41,9 @@ namespace Server.Mobiles get { if (Core.ML) + { return Price.ToString("N0", CultureInfo.GetCultureInfo("en-US")); + } return Price.ToString(); } @@ -55,7 +57,9 @@ namespace Server.Mobiles m_Description = value ?? ""; if (Valid) + { Item.InvalidateProperties(); + } } } @@ -89,12 +93,16 @@ namespace Server.Mobiles public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { if (!base.CheckHold(m, item, message, checkItems, plusItems, plusWeight)) + { return false; + } if (Ethic.IsImbued(item, true)) { if (message) + { m.SendMessage("Imbued items may not be sold here."); + } return false; } @@ -106,7 +114,9 @@ namespace Server.Mobiles if (house?.IsAosRules == true && !house.CheckAosStorage(1 + item.TotalItems + plusItems)) { if (message) + { m.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house. + } return false; } @@ -120,10 +130,14 @@ namespace Server.Mobiles public override bool CheckItemUse(Mobile from, Item item) { if (!base.CheckItemUse(from, item)) + { return false; + } if (item is Container || item is BulkOrderBook) + { return true; + } from.SendLocalizedMessage(500447); // That is not accessible. return false; @@ -139,12 +153,16 @@ namespace Server.Mobiles base.GetChildContextMenuEntries(from, list, item); if (!(RootParent is PlayerVendor pv) || pv.IsOwner(from)) + { return; + } var vi = pv.GetVendorItem(item); if (vi != null) + { list.Add(new BuyEntry(item)); + } } public override void GetChildNameProperties(ObjectPropertyList list, Item item) @@ -156,14 +174,22 @@ namespace Server.Mobiles var vi = pv?.GetVendorItem(item); if (vi == null) + { return; + } if (!vi.IsForSale) + { list.Add(1043307); // Price: Not for sale. + } else if (vi.IsForFree) + { list.Add(1043306); // Price: FREE! + } else + { list.Add(1043304, vi.FormattedPrice); // Price: ~1_COST~ + } } public override void GetChildProperties(ObjectPropertyList list, Item item) @@ -175,7 +201,9 @@ namespace Server.Mobiles var vi = pv?.GetVendorItem(item); if (vi?.Description != null && vi.Description.Length > 0) + { list.Add(1043305, vi.Description); //
Seller's Description:
"~1_DESC~" + } } public override void OnSingleClickContained(Mobile from, Item item) @@ -187,13 +215,22 @@ namespace Server.Mobiles if (vi != null) { if (!vi.IsForSale) - item.LabelTo(from, 1043307); // Price: Not for sale. + { + item.LabelTo(@from, 1043307); // Price: Not for sale. + } else if (vi.IsForFree) - item.LabelTo(from, 1043306); // Price: FREE! + { + item.LabelTo(@from, 1043306); // Price: FREE! + } else - item.LabelTo(from, 1043304, vi.FormattedPrice); // Price: ~1_COST~ + { + item.LabelTo(@from, 1043304, vi.FormattedPrice); // Price: ~1_COST~ + } - if (!string.IsNullOrEmpty(vi.Description)) item.LabelTo(from, "Description: {0}", vi.Description); + if (!string.IsNullOrEmpty(vi.Description)) + { + item.LabelTo(@from, "Description: {0}", vi.Description); + } } } @@ -225,7 +262,9 @@ namespace Server.Mobiles public override void OnClick() { if (m_Item.Deleted) + { return; + } PlayerVendor.TryToBuy(m_Item, Owner.From); } @@ -264,7 +303,9 @@ namespace Server.Mobiles CantWalk = true; if (!Core.AOS) + { NameHue = 0x35; + } InitStats(100, 100, 25); InitBody(); @@ -325,7 +366,10 @@ namespace Server.Mobiles { get { - if (BaseHouse.NewVendorSystem) return ChargePerRealWorldDay / 12; + if (BaseHouse.NewVendorSystem) + { + return ChargePerRealWorldDay / 12; + } var total = m_SellItems.Values.Aggregate( 0, @@ -414,14 +458,18 @@ namespace Server.Mobiles var price = reader.ReadInt(); if (price > 100000000) + { price = 100000000; + } var description = reader.ReadString(); var created = version < 1 ? DateTime.UtcNow : reader.ReadDateTime(); if (item != null) + { SetVendorItem(item, version < 1 && price <= 0 ? -1 : price, description, created); + } } break; @@ -452,7 +500,9 @@ namespace Server.Mobiles } if (version < 2 && RawStr == 75 && RawDex == 75 && RawInt == 75) + { InitStats(100, 100, 25); + } var delay = NextPayTime - DateTime.UtcNow; @@ -462,7 +512,9 @@ namespace Server.Mobiles Blessed = false; if (Core.AOS && NameHue == 0x35) + { NameHue = -1; + } } private void UpgradeFromVersion0(bool newVendorSystem) @@ -470,18 +522,28 @@ namespace Server.Mobiles var toRemove = new List(); foreach (var vi in m_SellItems.Values) + { if (!CanBeVendorItem(vi.Item)) + { toRemove.Add(vi.Item); + } else + { vi.Description = Utility.FixHtml(vi.Description); + } + } foreach (var item in toRemove) + { RemoveVendorItem(item); + } House = BaseHouse.FindHouseAt(this); if (newVendorSystem) + { ActivateNewVendorSystem(); + } } private void ActivateNewVendorSystem() @@ -489,7 +551,9 @@ namespace Server.Mobiles FixDresswear(); if (House?.IsOwner(Owner) == false) + { Destroy(false); + } } public void InitBody() @@ -498,7 +562,9 @@ namespace Server.Mobiles SpeechHue = 0x3B2; if (!Core.AOS) + { NameHue = 0x35; + } if (Female = Utility.RandomBool()) { @@ -532,9 +598,14 @@ namespace Server.Mobiles public virtual bool IsOwner(Mobile m) { if (m.AccessLevel >= AccessLevel.GameMaster) + { return true; + } - if (BaseHouse.NewVendorSystem && House != null) return House.IsOwner(m); + if (BaseHouse.NewVendorSystem && House != null) + { + return House.IsOwner(m); + } return m == Owner; } @@ -544,11 +615,17 @@ namespace Server.Mobiles var list = new List(); foreach (var item in Items) + { if (item.Movable && item != Backpack && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair) + { list.Add(item); + } + } if (Backpack != null) + { list.AddRange(Backpack.Items); + } return list; } @@ -558,7 +635,9 @@ namespace Server.Mobiles Return(); if (!BaseHouse.NewVendorSystem) + { FixDresswear(); + } /* Possible cases regarding item return: * @@ -584,16 +663,24 @@ namespace Server.Mobiles House.MovingCrate ??= new MovingCrate(House); if (HoldGold > 0) + { Banker.Deposit(House.MovingCrate, HoldGold); + } - foreach (var item in list) House.MovingCrate.DropItem(item); + foreach (var item in list) + { + House.MovingCrate.DropItem(item); + } } else // Move to vendor inventory { var inventory = new VendorInventory(House, Owner, Name, ShopName); inventory.Gold = HoldGold; - foreach (var item in list) inventory.AddItem(item); + foreach (var item in list) + { + inventory.AddItem(item); + } House.VendorInventories.Add(inventory); } @@ -603,9 +690,14 @@ namespace Server.Mobiles Container backpack = new Backpack(); if (HoldGold > 0) + { Banker.Deposit(backpack, HoldGold); + } - foreach (var item in list) backpack.DropItem(item); + foreach (var item in list) + { + backpack.DropItem(item); + } backpack.MoveToWorld(Location, Map); } @@ -651,7 +743,9 @@ namespace Server.Mobiles else if (item is BaseShoes) { if (item is Sandals) + { item.Hue = 0; + } item.Layer = Layer.Shoes; } @@ -675,7 +769,10 @@ namespace Server.Mobiles { base.GetProperties(list); - if (BaseHouse.NewVendorSystem) list.Add(1062449, ShopName); // Shop Name: ~1_NAME~ + if (BaseHouse.NewVendorSystem) + { + list.Add(1062449, ShopName); // Shop Name: ~1_NAME~ + } } public VendorItem GetVendorItem(Item item) @@ -708,7 +805,10 @@ namespace Server.Mobiles vi.Invalidate(); m_SellItems.Remove(item); - foreach (var subItem in item.Items) RemoveVendorItem(subItem); + foreach (var subItem in item.Items) + { + RemoveVendorItem(subItem); + } item.InvalidateProperties(); } @@ -719,14 +819,18 @@ namespace Server.Mobiles var parent = item.Parent as Item; if (parent == Backpack) + { return true; + } if (parent is Container) { var parentVI = GetVendorItem(parent); if (parentVI != null) + { return !parentVI.IsForSale; + } } return false; @@ -736,7 +840,10 @@ namespace Server.Mobiles { base.OnSubItemAdded(item); - if (GetVendorItem(item) == null && CanBeVendorItem(item)) SetVendorItem(item, 999, ""); + if (GetVendorItem(item) == null && CanBeVendorItem(item)) + { + SetVendorItem(item, 999, ""); + } } public override void OnSubItemRemoved(Item item) @@ -744,7 +851,9 @@ namespace Server.Mobiles base.OnSubItemRemoved(item); if (item.GetBounce() == null) + { RemoveVendorItem(item); + } } public override void OnSubItemBounceCleared(Item item) @@ -752,7 +861,9 @@ namespace Server.Mobiles base.OnSubItemBounceCleared(item); if (!CanBeVendorItem(item)) + { RemoveVendorItem(item); + } } public override void OnItemRemoved(Item item) @@ -760,8 +871,12 @@ namespace Server.Mobiles base.OnItemRemoved(item); if (item == Backpack) + { foreach (var subItem in item.Items) + { RemoveVendorItem(subItem); + } + } } public override bool OnDragDrop(Mobile from, Item item) @@ -815,7 +930,9 @@ namespace Server.Mobiles if (Backpack?.TryDropItem(from, item, false) == true) { if (newItem) - OnItemGiven(from, item); + { + OnItemGiven(@from, item); + } return true; } @@ -829,7 +946,9 @@ namespace Server.Mobiles if (IsOwner(from)) { if (GetVendorItem(item) == null) - Timer.DelayCall(OnItemGiven, from, item); + { + Timer.DelayCall(OnItemGiven, @from, item); + } return true; } @@ -843,7 +962,9 @@ namespace Server.Mobiles var vi = GetVendorItem(item); if (vi == null) + { return; + } var name = item.Name.IsNullOrDefault($"#{item.LabelNumber}"); @@ -858,13 +979,19 @@ namespace Server.Mobiles { if (item.IsChildOf(Backpack)) { - if (IsOwner(from)) return true; + if (IsOwner(from)) + { + return true; + } SayTo(from, 503223); // If you'd like to purchase an item, just ask. return false; } - if (BaseHouse.NewVendorSystem && IsOwner(from)) return true; + if (BaseHouse.NewVendorSystem && IsOwner(from)) + { + return true; + } return base.CheckNonlocalLift(from, item); } @@ -872,10 +999,14 @@ namespace Server.Mobiles public bool CanInteractWith(Mobile from, bool ownerOnly) { if (!from.CanSee(this) || !Utility.InUpdateRange(from, this) || !from.CheckAlive()) + { return false; + } if (ownerOnly) - return IsOwner(from); + { + return IsOwner(@from); + } if (House?.IsBanned(from) == true && !IsOwner(from)) { @@ -891,15 +1022,25 @@ namespace Server.Mobiles public override void OnDoubleClick(Mobile from) { if (IsOwner(from)) - SendOwnerGump(from); - else if (CanInteractWith(from, false)) OpenBackpack(from); + { + SendOwnerGump(@from); + } + else if (CanInteractWith(from, false)) + { + OpenBackpack(@from); + } } public override void DisplayPaperdollTo(Mobile m) { if (BaseHouse.NewVendorSystem) + { base.DisplayPaperdollTo(m); - else if (CanInteractWith(m, false)) OpenBackpack(m); + } + else if (CanInteractWith(m, false)) + { + OpenBackpack(m); + } } public void SendOwnerGump(Mobile to) @@ -933,7 +1074,9 @@ namespace Server.Mobiles public static void TryToBuy(Item item, Mobile from) { if (!(item.RootParent is PlayerVendor vendor) || !vendor.CanInteractWith(from, false)) + { return; + } if (vendor.IsOwner(from)) { @@ -980,7 +1123,9 @@ namespace Server.Mobiles public int GiveGold(Mobile to, int amount) { if (amount <= 0) + { return 0; + } if (amount > HoldGold) { @@ -992,25 +1137,35 @@ namespace Server.Mobiles HoldGold -= amountGiven; if (amountGiven > 0) + { to.SendLocalizedMessage( 1060397, amountGiven.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } if (amountGiven == 0) + { SayTo( to, 1070755 ); // Your bank box cannot hold the gold you are requesting. I will keep the gold until you can take it. + } else if (amount > amountGiven) + { SayTo( to, 1070756 ); // I can only give you part of the gold now, as your bank box is too full to hold the full amount. + } else if (HoldGold > 0) + { SayTo(to, 1042639); // Your gold has been transferred. + } else + { SayTo(to, 503234); // All the gold I have been carrying for you has been deposited into your bank account. + } return amountGiven; } @@ -1030,7 +1185,9 @@ namespace Server.Mobiles GiveGold(from, HoldGold); if (HoldGold > 0) + { return; + } } Destroy(true); @@ -1053,10 +1210,14 @@ namespace Server.Mobiles public bool CheckTeleport(Mobile to) { if (Deleted || !IsOwner(to) || House == null || Map == Map.Internal) + { return false; + } if (House.IsInside(to) || to.Map != House.Map || !House.InRange(to, 5)) + { return false; + } if (Placeholder == null) { @@ -1088,7 +1249,10 @@ namespace Server.Mobiles public override void GetContextMenuEntries(Mobile from, List list) { - if (from.Alive && Placeholder != null && IsOwner(from)) list.Add(new ReturnVendorEntry(this)); + if (from.Alive && Placeholder != null && IsOwner(from)) + { + list.Add(new ReturnVendorEntry(this)); + } base.GetContextMenuEntries(from, list); } @@ -1102,7 +1266,9 @@ namespace Server.Mobiles var from = e.Mobile; if (e.Handled || !from.Alive || from.GetDistanceToSqrt(this) > 3) + { return; + } if (e.HasKeyword(0x3C) || e.HasKeyword(0x171) && WasNamed(e.Speech)) // vendor buy, *buy* { @@ -1135,8 +1301,12 @@ namespace Server.Mobiles var mobiles = e.Mobile.GetMobilesInRange(2); foreach (var m in mobiles) + { if (m.CanSee(e.Mobile) && m.InLOS(e.Mobile)) - m.OpenBackpack(from); + { + m.OpenBackpack(@from); + } + } mobiles.Free(); } @@ -1199,7 +1369,9 @@ namespace Server.Mobiles var from = Owner.From; if (!m_Vendor.Deleted && m_Vendor.IsOwner(from) && from.CheckAlive()) + { m_Vendor.Return(); + } } } @@ -1217,7 +1389,10 @@ namespace Server.Mobiles public static TimeSpan GetInterval() { if (BaseHouse.NewVendorSystem) + { return TimeSpan.FromDays(1.0); + } + return TimeSpan.FromMinutes(Clock.MinutesPerUODay); } @@ -1271,7 +1446,9 @@ namespace Server.Mobiles protected override void OnTarget(Mobile from, object targeted) { if (targeted is Item item) - TryToBuy(item, from); + { + TryToBuy(item, @from); + } } } @@ -1289,24 +1466,34 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (!m_VI.Valid || !m_Vendor.CanInteractWith(from, true)) + { return; + } string firstWord; var sep = text.IndexOfAny(new[] { ' ', ',' }); if (sep >= 0) + { firstWord = text.Substring(0, sep); + } else + { firstWord = text; + } string description; if (int.TryParse(firstWord, out var price)) { if (sep >= 0) + { description = text.Substring(sep + 1).Trim(); + } else + { description = ""; + } } else { @@ -1320,7 +1507,9 @@ namespace Server.Mobiles public override void OnCancel(Mobile from) { if (!m_VI.Valid || !m_Vendor.CanInteractWith(from, true)) + { return; + } SetInfo(from, -1, ""); } @@ -1338,11 +1527,17 @@ namespace Server.Mobiles if (item is Container) { if (item is LockableContainer container && container.Locked) - m_Vendor.SayTo(from, 1043298); // Locked items may not be made not-for-sale. + { + m_Vendor.SayTo(@from, 1043298); // Locked items may not be made not-for-sale. + } else if (item.Items.Count > 0) - m_Vendor.SayTo(from, 1043299); // To be not for sale, all items in a container must be for sale. + { + m_Vendor.SayTo(@from, 1043299); // To be not for sale, all items in a container must be for sale. + } else + { setPrice = true; + } } else if (item is BaseBook || item is BulkOrderBook) { @@ -1368,9 +1563,13 @@ namespace Server.Mobiles } if (setPrice) + { m_Vendor.SetVendorItem(item, price, description); + } else + { m_VI.Description = description; + } } } @@ -1383,12 +1582,16 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (!m_Vendor.CanInteractWith(from, true)) + { return; + } text = text.Trim(); if (!int.TryParse(text, out var amount)) + { amount = 0; + } GiveGold(from, amount); } @@ -1396,7 +1599,9 @@ namespace Server.Mobiles public override void OnCancel(Mobile from) { if (!m_Vendor.CanInteractWith(from, true)) + { return; + } GiveGold(from, 0); } @@ -1404,9 +1609,13 @@ namespace Server.Mobiles private void GiveGold(Mobile to, int amount) { if (amount <= 0) + { m_Vendor.SayTo(to, "Very well. I will hold on to the money for now then."); + } else + { m_Vendor.GiveGold(to, amount); + } } } @@ -1419,7 +1628,9 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (!m_Vendor.CanInteractWith(from, true)) + { return; + } var name = text.Trim(); @@ -1446,7 +1657,9 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (!m_Vendor.CanInteractWith(from, true)) + { return; + } var name = text.Trim(); @@ -1490,7 +1703,9 @@ namespace Server.Mobiles base.GetProperties(list); if (Vendor != null) + { list.Add(1062498, Vendor.Name); // reserved for vendor ~1_NAME~ + } } public void RestartTimer() diff --git a/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs b/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs index 85504d06d..12ccbea5a 100644 --- a/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/RentedVendor.cs @@ -33,8 +33,12 @@ namespace Server.Mobiles get { for (var i = 0; i < Instances.Length; i++) + { if (Instances[i] == this) + { return i; + } + } return 0; } @@ -154,7 +158,9 @@ namespace Server.Mobiles else if (IsLandlord(from)) { if (RentalGold > 0) + { list.Add(new CollectRentEntry(this)); + } list.Add(new TerminateContractEntry(this)); list.Add(new ContractOptionsEntry(this)); @@ -190,9 +196,13 @@ namespace Server.Mobiles var durationID = reader.ReadEncodedInt(); if (durationID < VendorRentalDuration.Instances.Length) + { RentalDuration = VendorRentalDuration.Instances[durationID]; + } else + { RentalDuration = VendorRentalDuration.Instances[0]; + } RentalPrice = reader.ReadInt(); LandlordRenew = reader.ReadBool(); @@ -219,7 +229,9 @@ namespace Server.Mobiles var from = Owner.From; if (m_Vendor.Deleted || !from.CheckAlive()) + { return; + } if (m_Vendor.IsOwner(from)) { @@ -249,7 +261,9 @@ namespace Server.Mobiles var from = Owner.From; if (m_Vendor.Deleted || !from.CheckAlive() || !m_Vendor.IsLandlord(from)) + { return; + } if (m_Vendor.RentalGold > 0) { @@ -257,13 +271,17 @@ namespace Server.Mobiles m_Vendor.RentalGold -= depositedGold; if (depositedGold > 0) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + } if (m_Vendor.RentalGold > 0) - from.SendLocalizedMessage(500390); // Your bank box is full. + { + @from.SendLocalizedMessage(500390); // Your bank box is full. + } } } } @@ -279,7 +297,9 @@ namespace Server.Mobiles var from = Owner.From; if (m_Vendor.Deleted || !from.CheckAlive() || !m_Vendor.IsLandlord(from)) + { return; + } from.SendLocalizedMessage( 1062503 @@ -297,16 +317,22 @@ namespace Server.Mobiles public override void OnResponse(Mobile from, string text) { if (!m_Vendor.CanInteractWith(from, false) || !m_Vendor.IsLandlord(from)) + { return; + } text = text.Trim(); if (!int.TryParse(text, out var amount)) + { amount = -1; + } var owner = m_Vendor.Owner; if (owner == null) + { return; + } if (amount < 0) { diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBArchitect.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBArchitect.cs index b6d294473..339a90d33 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBArchitect.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBArchitect.cs @@ -15,7 +15,9 @@ namespace Server.Mobiles { Add(new GenericBuyInfo("1041280", typeof(InteriorDecorator), 10001, 20, 0xFC1, 0)); if (Core.AOS) + { Add(new GenericBuyInfo("1060651", typeof(HousePlacementTool), 627, 20, 0x14F6, 0)); + } } } @@ -26,7 +28,9 @@ namespace Server.Mobiles Add(typeof(InteriorDecorator), 5000); if (Core.AOS) + { Add(typeof(HousePlacementTool), 301); + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBanker.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBanker.cs index 723a66f85..271f1b7dd 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBanker.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBanker.cs @@ -17,7 +17,10 @@ namespace Server.Mobiles Add(new GenericBuyInfo("1041243", typeof(ContractOfEmployment), 1252, 20, 0x14F0, 0)); if (BaseHouse.NewVendorSystem) + { Add(new GenericBuyInfo("1062332", typeof(VendorRentalContract), 1252, 20, 0x14F0, 0x672)); + } + Add(new GenericBuyInfo("1047016", typeof(CommodityDeed), 5, 20, 0x14F0, 0x47)); } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBarkeeper.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBarkeeper.cs index df6a02df4..7cf023464 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBarkeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBBarkeeper.cs @@ -51,7 +51,9 @@ namespace Server.Mobiles Add(new GenericBuyInfo("1041243", typeof(ContractOfEmployment), 1252, 20, 0x14F0, 0)); Add(new GenericBuyInfo("a barkeep contract", typeof(BarkeepContract), 1252, 20, 0x14F0, 0)); if (BaseHouse.NewVendorSystem) + { Add(new GenericBuyInfo("1062332", typeof(VendorRentalContract), 1252, 20, 0x14F0, 0x672)); + } /*if (Map == Tokuno) { diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBHolyMage.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBHolyMage.cs index da9f7d9ec..44c56bb6c 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBHolyMage.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBHolyMage.cs @@ -44,9 +44,13 @@ namespace Server.Mobiles var itemID = 0x1F2E + i; if (i == 6) + { itemID = 0x1F2D; + } else if (i > 6) + { --itemID; + } Add(new GenericBuyInfo(types[i], 12 + i / 8 * 10, 20, itemID, 0)); } @@ -79,7 +83,9 @@ namespace Server.Mobiles var types = Loot.RegularScrollTypes; for (var i = 0; i < types.Length; ++i) + { Add(types[i], (i / 8 + 2) * 2); + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBInnKeeper.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBInnKeeper.cs index daa16a5ab..6f395221e 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBInnKeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBInnKeeper.cs @@ -64,7 +64,9 @@ namespace Server.Mobiles Add(new GenericBuyInfo("a barkeep contract", typeof(BarkeepContract), 1252, 20, 0x14F0, 0)); if (BaseHouse.NewVendorSystem) + { Add(new GenericBuyInfo("1062332", typeof(VendorRentalContract), 1252, 20, 0x14F0, 0x672)); + } } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMage.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMage.cs index ff57978c8..d21a79680 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMage.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMage.cs @@ -16,7 +16,9 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(Spellbook), 18, 10, 0xEFA, 0)); if (Core.AOS) + { Add(new GenericBuyInfo(typeof(NecromancerSpellbook), 115, 10, 0x2253, 0)); + } Add(new GenericBuyInfo(typeof(ScribesPen), 8, 10, 0xFBF, 0)); @@ -62,9 +64,13 @@ namespace Server.Mobiles var itemID = 0x1F2E + i; if (i == 6) + { itemID = 0x1F2D; + } else if (i > 6) + { --itemID; + } Add(new GenericBuyInfo(types[i], 12 + i / 8 * 10, 20, itemID, 0)); } @@ -100,7 +106,9 @@ namespace Server.Mobiles var types = Loot.RegularScrollTypes; for (var i = 0; i < types.Length; ++i) + { Add(types[i], (i / 8 + 2) * 2); + } if (Core.SE) { diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMapmaker.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMapmaker.cs index d342634b0..77544fb90 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMapmaker.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMapmaker.cs @@ -18,7 +18,9 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(BlankScroll), 12, 40, 0xEF3, 0)); for (var i = 0; i < PresetMapEntry.Table.Length; ++i) + { Add(new PresetMapBuyInfo(PresetMapEntry.Table[i], Utility.RandomMinMax(7, 10), 20)); + } } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMonk.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMonk.cs index 36679ceec..e6dbe71b8 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMonk.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBMonk.cs @@ -13,7 +13,10 @@ namespace Server.Mobiles { public InternalBuyInfo() { - if (Core.AOS) Add(new GenericBuyInfo(typeof(MonkRobe), 136, 20, 0x2687, 0x21E)); + if (Core.AOS) + { + Add(new GenericBuyInfo(typeof(MonkRobe), 136, 20, 0x2687, 0x21E)); + } } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBProvisioner.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBProvisioner.cs index 3fe85289b..6ee2af559 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBProvisioner.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBProvisioner.cs @@ -18,7 +18,9 @@ namespace Server.Mobiles public InternalBuyInfo() { if (Core.ML) + { Add(new GenericBuyInfo("1079931", typeof(SalvageBag), 1255, 20, 0xE76, Utility.RandomBlueHue())); + } Add(new GenericBuyInfo("1060834", typeof(PlantBowl), 2, 20, 0x15FD, 0)); @@ -87,7 +89,10 @@ namespace Server.Mobiles Add(new GenericBuyInfo("1016449", typeof(CheckerBoard), 2, 20, 0xFA6, 0)); Add(new GenericBuyInfo(typeof(Backgammon), 2, 20, 0xE1C, 0)); if (Core.AOS) + { Add(new GenericBuyInfo(typeof(MahjongGame), 6, 20, 0xFAA, 0)); + } + Add(new GenericBuyInfo(typeof(Dices), 2, 20, 0xFA7, 0)); if (Core.AOS) @@ -97,7 +102,9 @@ namespace Server.Mobiles } if (!Guild.NewGuildSystem) + { Add(new GenericBuyInfo("1041055", typeof(GuildDeed), 12450, 20, 0x14F0, 0)); + } } } @@ -162,7 +169,9 @@ namespace Server.Mobiles Add(typeof(SilverEarrings), 10); if (!Guild.NewGuildSystem) + { Add(typeof(GuildDeed), 6225); + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs index 9751934d1..f0a3d6e74 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs @@ -54,7 +54,9 @@ namespace Server.Mobiles Add(new GenericBuyInfo("a barkeep contract", typeof(BarkeepContract), 1252, 20, 0x14F0, 0)); if (BaseHouse.NewVendorSystem) + { Add(new GenericBuyInfo("1062332", typeof(VendorRentalContract), 1252, 20, 0x14F0, 0x672)); + } /*if (Map == Tokuno) { diff --git a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs index 0297dcc2a..c7c7dbfb8 100644 --- a/Projects/UOContent/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs +++ b/Projects/UOContent/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs @@ -50,9 +50,13 @@ namespace Server.Mobiles var itemID = 0x1F2E + i; if (i == 6) + { itemID = 0x1F2D; + } else if (i > 6) + { --itemID; + } Add(new GenericBuyInfo(types[i], 12 + i / 8 * 10, 20, itemID, 0)); } @@ -122,7 +126,9 @@ namespace Server.Mobiles var types = Loot.RegularScrollTypes; for (var i = 0; i < types.Length; ++i) + { Add(types[i], (i / 8 + 2) * 5); + } } } } diff --git a/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs b/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs index 8cbc37910..320264b15 100644 --- a/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs +++ b/Projects/UOContent/Mobiles/Vendors/VendorInventory.cs @@ -73,7 +73,10 @@ namespace Server.Mobiles public void Delete() { - foreach (var item in Items) item.Delete(); + foreach (var item in Items) + { + item.Delete(); + } Items.Clear(); Gold = 0; @@ -122,8 +125,12 @@ namespace Server.Mobiles } foreach (var item in m_Inventory.Items) + { if (!item.Deleted) + { house.DropToMovingCrate(item); + } + } m_Inventory.Gold = 0; m_Inventory.Items.Clear(); diff --git a/Projects/UOContent/Multis/BaseHouse.cs b/Projects/UOContent/Multis/BaseHouse.cs index 07b78c04c..1a66af03f 100644 --- a/Projects/UOContent/Multis/BaseHouse.cs +++ b/Projects/UOContent/Multis/BaseHouse.cs @@ -73,7 +73,9 @@ namespace Server.Multis if (owner != null) { if (!m_Table.TryGetValue(owner, out var list)) + { m_Table[owner] = list = new List(); + } list.Add(this); } @@ -105,30 +107,44 @@ namespace Server.Multis get { if (RestrictDecay || !DecayEnabled || DecayPeriod == TimeSpan.Zero) + { return DecayType.Ageless; + } if (m_Owner == null) + { return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh; + } if (!(m_Owner.Account is Account acct)) + { return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh; + } if (acct.AccessLevel >= AccessLevel.GameMaster) + { return DecayType.Ageless; + } for (var i = 0; i < acct.Length; ++i) { var mob = acct[i]; if (mob?.AccessLevel >= AccessLevel.GameMaster) + { return DecayType.Ageless; + } } if (!Core.AOS) + { return DecayType.ManualRefresh; + } if (acct.Inactive) + { return DecayType.Condemned; + } var allHouses = new List(); @@ -137,7 +153,9 @@ namespace Server.Multis var mob = acct[i]; if (mob != null) + { allHouses.AddRange(GetHouses(mob)); + } } BaseHouse newest = null; @@ -147,11 +165,15 @@ namespace Server.Multis var check = allHouses[i]; if (newest == null || IsNewer(check, newest)) + { newest = check; + } } if (this == newest) + { return DecayType.AutoRefresh; + } return DecayType.ManualRefresh; } @@ -177,7 +199,9 @@ namespace Server.Multis if (!CanDecay) { if (DynamicDecay.Enabled) + { ResetDynamicDecay(); + } LastRefreshed = DateTime.UtcNow; result = DecayLevel.Ageless; @@ -187,12 +211,18 @@ namespace Server.Multis var stage = m_CurrentStage; if (stage == DecayLevel.Ageless || DynamicDecay.Decays(stage) && NextDecayStage <= DateTime.UtcNow) + { SetDynamicDecay(++stage); + } if (stage == DecayLevel.Collapsed && (HasRentedVendors || VendorInventories.Count > 0)) + { result = DecayLevel.DemolitionPending; + } else + { result = stage; + } } else { @@ -204,7 +234,9 @@ namespace Server.Multis m_LastDecayLevel = result; if (Sign?.GettingProperties == false) + { Sign.InvalidateProperties(); + } } return result; @@ -225,8 +257,12 @@ namespace Server.Multis get { foreach (var vendor in PlayerVendors) + { if (!(vendor is RentedVendor)) + { return true; + } + } return false; } @@ -237,8 +273,12 @@ namespace Server.Multis get { foreach (var vendor in PlayerVendors) + { if (vendor is RentedVendor) + { return true; + } + } return false; } @@ -249,8 +289,12 @@ namespace Server.Multis get { foreach (var item in Addons) + { if (item is BaseAddonContainer) + { return true; + } + } return false; } @@ -272,7 +316,9 @@ namespace Server.Multis if (m_Owner != null) { if (!m_Table.TryGetValue(m_Owner, out var list)) + { m_Table[m_Owner] = list = new List(); + } list.Remove(this); m_Owner.Delta(MobileDelta.Noto); @@ -283,7 +329,9 @@ namespace Server.Multis if (m_Owner != null) { if (!m_Table.TryGetValue(m_Owner, out var list)) + { m_Table[m_Owner] = list = new List(); + } list.Add(this); m_Owner.Delta(MobileDelta.Noto); @@ -307,7 +355,9 @@ namespace Server.Multis m_Public = value; if (!m_Public) // Privatizing the house, change to brass sign + { ChangeSignType(0xBD2); + } Sign?.InvalidateProperties(); } @@ -323,7 +373,9 @@ namespace Server.Multis get { if (m_Region != null) + { return m_Region.GoLocation; + } var rel = m_RelativeBanLocation; return new Point3D(X + rel.X, Y + rel.Y, Z + rel.Z); @@ -340,7 +392,9 @@ namespace Server.Multis m_RelativeBanLocation = value; if (m_Region != null) + { m_Region.GoLocation = new Point3D(X + value.X, Y + value.Y, Z + value.Z); + } } } @@ -367,17 +421,26 @@ namespace Server.Multis count += GetLockdowns(); if (Secures != null) + { for (var i = 0; i < Secures.Count; ++i) { var info = Secures[i]; if (info.Item.Deleted) + { continue; + } + if (info.Item is StrongBox) + { count += 1; + } else + { count += 125; + } } + } return count; } @@ -390,15 +453,22 @@ namespace Server.Multis var count = 0; if (Secures != null) + { for (var i = 0; i < Secures.Count; i++) { var info = Secures[i]; if (info.Item.Deleted) + { continue; + } + if (!(info.Item is StrongBox)) + { count += 1; + } } + } return count; } @@ -446,7 +516,9 @@ namespace Server.Multis public static void Decay_OnTick() { for (var i = 0; i < AllHouses.Count; ++i) + { AllHouses[i].CheckDecay(); + } } public bool IsNewer(BaseHouse check, BaseHouse house) @@ -463,17 +535,34 @@ namespace Server.Multis var percent = (int)(timeAfterRefresh.Ticks * 1000 / DecayPeriod.Ticks); if (percent >= 1000) // 100.0% + { return HasRentedVendors || VendorInventories.Count > 0 ? DecayLevel.DemolitionPending : DecayLevel.Collapsed; + } + if (percent >= 950) // 95.0% - 99.9% + { return DecayLevel.IDOC; + } + if (percent >= 750) // 75.0% - 94.9% + { return DecayLevel.Greatly; + } + if (percent >= 500) // 50.0% - 74.9% + { return DecayLevel.Fairly; + } + if (percent >= 250) // 25.0% - 49.9% + { return DecayLevel.Somewhat; + } + if (percent >= 005) // 00.5% - 24.9% + { return DecayLevel.Slightly; + } return DecayLevel.LikeNew; } @@ -481,14 +570,18 @@ namespace Server.Multis public virtual bool RefreshDecay() { if (DecayType == DecayType.Condemned) + { return false; + } var oldLevel = DecayLevel; LastRefreshed = DateTime.UtcNow; if (DynamicDecay.Enabled) + { ResetDynamicDecay(); + } Sign?.InvalidateProperties(); @@ -509,19 +602,27 @@ namespace Server.Multis public virtual void KillVendors() { foreach (var vendor in PlayerVendors.ToList()) + { vendor.Destroy(true); + } foreach (var barkeeper in PlayerBarkeepers.ToList()) + { barkeeper.Delete(); + } } public virtual void Decay_Sandbox() { if (Deleted) + { return; + } if (Core.ML) + { new TempNoHousingRegion(this, null); + } KillVendors(); Delete(); @@ -534,7 +635,9 @@ namespace Server.Multis var hpe = GetAosEntry(); if (hpe == null) + { return 0; + } return (int)(hpe.Storage * BonusStorageScalar); } @@ -544,7 +647,9 @@ namespace Server.Multis var hpe = GetAosEntry(); if (hpe == null) + { return 0; + } return (int)(hpe.Lockdowns * BonusStorageScalar); } @@ -576,17 +681,27 @@ namespace Server.Multis fromLockdowns += GetLockdowns(); if (!NewVendorSystem) + { foreach (var vendor in PlayerVendors) + { if (vendor.Backpack != null) + { fromVendors += vendor.Backpack.TotalItems; + } + } + } if (MovingCrate != null) { fromMovingCrate += MovingCrate.TotalItems; foreach (var item in MovingCrate.Items) + { if (item is PackingBox) + { fromMovingCrate--; + } + } } return fromSecures + fromVendors + fromLockdowns + fromMovingCrate; @@ -606,7 +721,9 @@ namespace Server.Multis var hpe = GetAosEntry(); if (hpe == null) + { return 0; + } return (int)(hpe.Vendors * BonusStorageScalar); } @@ -626,6 +743,7 @@ namespace Server.Multis var eable = map.GetObjectsInRange(location, 0); foreach (var entity in eable) + { if (Math.Abs(location.Z - entity.Z) <= 16) { if (entity is PlayerVendor || entity is PlayerBarkeeper || entity is PlayerVendorPlaceholder) @@ -640,6 +758,7 @@ namespace Server.Multis break; } } + } eable.Free(); } @@ -663,6 +782,7 @@ namespace Server.Multis } foreach (var item in LockDowns) + { if (!item.Deleted) { item.IsLockedDown = false; @@ -670,12 +790,16 @@ namespace Server.Multis item.Movable = true; if (item.Parent == null) + { DropToMovingCrate(item); + } } + } LockDowns.Clear(); foreach (Item item in VendorRentalContracts) + { if (!item.Deleted) { item.IsLockedDown = false; @@ -683,8 +807,11 @@ namespace Server.Multis item.Movable = true; if (item.Parent == null) + { DropToMovingCrate(item); + } } + } VendorRentalContracts.Clear(); @@ -695,20 +822,25 @@ namespace Server.Multis if (!item.Deleted) { if (item is StrongBox box) + { item = box.ConvertToStandardContainer(); + } item.IsLockedDown = false; item.IsSecure = false; item.Movable = true; if (item.Parent == null) + { DropToMovingCrate(item); + } } } Secures.Clear(); foreach (var addon in Addons) + { if (!addon.Deleted) { Item deed = null; @@ -731,7 +863,9 @@ namespace Server.Multis var c = ba.Components[i]; if (c.Hue != 0) + { hue = c.Hue; + } } } } @@ -751,7 +885,9 @@ namespace Server.Multis addon.Delete(); if (retainDeedHue) + { deed.Hue = hue; + } DropToMovingCrate(deed); } @@ -760,6 +896,7 @@ namespace Server.Multis DropToMovingCrate(addon); } } + } Addons.Clear(); @@ -784,7 +921,9 @@ namespace Server.Multis MovingCrate?.Hide(); if (m_Trash != null && m_Trash.Map != Map.Internal) + { list.Add(m_Trash); + } list.AddRange(LockDowns.Where(item => item.Parent == null && item.Map != Map.Internal)); list.AddRange(VendorRentalContracts.Where(item => item.Parent == null && item.Map != Map.Internal)); @@ -796,7 +935,9 @@ namespace Server.Multis mobile.Return(); if (mobile.Map != Map.Internal) + { list.Add(mobile); + } } list.AddRange(PlayerBarkeepers.Where(mobile => mobile.Map != Map.Internal)); @@ -814,9 +955,13 @@ namespace Server.Multis RelocatedEntities.Add(relocEntity); if (entity is Item item) + { item.Internalize(); + } else if (entity is Mobile mobile) + { mobile.Internalize(); + } } } @@ -878,7 +1023,9 @@ namespace Server.Multis var relocateItem = item; if (item is StrongBox box) + { relocateItem = box.ConvertToStandardContainer(); + } if (addon != null) { @@ -896,7 +1043,9 @@ namespace Server.Multis var c = ba.Components[i]; if (c.Hue != 0) + { hue = c.Hue; + } } } @@ -914,7 +1063,9 @@ namespace Server.Multis } if (retainDeedHue) + { deed.Hue = hue; + } } relocateItem = deed; @@ -922,27 +1073,42 @@ namespace Server.Multis } if (relocateItem != null) + { DropToMovingCrate(relocateItem); + } } } if (m_Trash == item) + { m_Trash = null; + } LockDowns.Remove(item); if (item is VendorRentalContract contract) + { VendorRentalContracts.Remove(contract); + } + Addons.Remove(item); for (var i = Secures.Count - 1; i >= 0; i--) + { if (Secures[i].Item == item) + { Secures.RemoveAt(i); + } + } } else if (entity is Mobile mobile && !mobile.Deleted) { if (Map.CanFit(location, 16, false, false)) + { mobile.MoveToWorld(location, Map); + } else + { InternalizedVendors.Add(mobile); + } } } @@ -959,7 +1125,9 @@ namespace Server.Multis public List GetItems() { if (Map == null || Map == Map.Internal) + { return new List(); + } var start = new Point2D(X + Components.Min.X, Y + Components.Min.Y); var end = new Point2D(X + Components.Max.X + 1, Y + Components.Max.Y + 1); @@ -976,13 +1144,19 @@ namespace Server.Multis public List GetMobiles() { if (Map == null || Map == Map.Internal) + { return new List(); + } var list = new List(); foreach (var mobile in Region.GetMobiles()) + { if (IsInside(mobile)) + { list.Add(mobile); + } + } return list; } @@ -1013,10 +1187,14 @@ namespace Server.Multis v += GetLockdowns(); if (Secures != null) + { v += Secures.Count; + } if (!NewVendorSystem) + { v += PlayerVendors.Count * 10; + } return v; } @@ -1036,14 +1214,20 @@ namespace Server.Multis var list = new List(); if (m != null) + { if (m_Table.TryGetValue(m, out var exists)) + { for (var i = 0; i < exists.Count; ++i) { var house = exists[i]; if (house?.Deleted == false && house.Owner == m) + { list.Add(house); + } } + } + } return list; } @@ -1056,12 +1240,16 @@ namespace Server.Multis var house = FindHouseAt(cont); if (house?.IsAosRules != true) + { return true; + } if (house.HasSecureItem(cont) && !house.CheckAosStorage(1 + item.TotalItems + plusItems)) { if (message) + { m.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house. + } return false; } @@ -1072,12 +1260,16 @@ namespace Server.Multis public static bool CheckAccessible(Mobile m, Item item) { if (m.AccessLevel >= AccessLevel.GameMaster) + { return true; // Staff can access anything + } var house = FindHouseAt(item); if (house == null) + { return true; + } var res = house.CheckSecureAccess(m, item); @@ -1089,7 +1281,9 @@ namespace Server.Multis } if (house.HasLockedDownItem(item)) + { return house.IsCoOwner(m) && item is Container; + } return true; } @@ -1097,7 +1291,9 @@ namespace Server.Multis public static BaseHouse FindHouseAt(Mobile m) { if (m?.Deleted != false) + { return null; + } return FindHouseAt(m.Location, m.Map, 16); } @@ -1108,13 +1304,19 @@ namespace Server.Multis public static BaseHouse FindHouseAt(Point3D loc, Map map, int height) { if (map == null || map == Map.Internal) + { return null; + } var sector = map.GetSector(loc); for (var i = 0; i < sector.Multis.Count; ++i) + { if (sector.Multis[i] is BaseHouse house && house.IsInside(loc, height)) + { return house; + } + } return null; } @@ -1136,37 +1338,84 @@ namespace Server.Multis } if (!HasLockedDownItem(item)) + { return true; + } + if (from.AccessLevel >= AccessLevel.GameMaster) + { return true; + } + if (item is Runebook) + { return true; + } + if (item is ISecurable securable) - return HasSecureAccess(from, securable.Level); + { + return HasSecureAccess(@from, securable.Level); + } + if (item is Container) - return IsCoOwner(from); + { + return IsCoOwner(@from); + } + if (item.Stackable) + { return true; + } + if (item is BaseLight) - return IsFriend(from); + { + return IsFriend(@from); + } + if (item is PotionKeg) - return IsFriend(from); + { + return IsFriend(@from); + } + if (item is Dices) + { return true; + } + if (item is RecallRune) + { return true; + } + if (item is TreasureMap) + { return true; + } + if (item is Clock) + { return true; + } + if (item is BaseInstrument) + { return true; + } + if (item is Dyes) + { return true; + } + if (item is VendorRentalContract) + { return true; + } + if (item is RewardBrazier) + { return true; + } return false; } @@ -1174,7 +1423,9 @@ namespace Server.Multis public virtual bool IsInside(Point3D p, int height) { if (Deleted) + { return false; + } var mcl = Components; @@ -1182,10 +1433,14 @@ namespace Server.Multis var y = p.Y - (Y + mcl.Min.Y); if (x < 0 || x >= mcl.Width || y < 0 || y >= mcl.Height) + { return false; + } if (this is HouseFoundation && y < mcl.Height - 1 && p.Z >= Z) + { return true; + } var tiles = mcl.Tiles[x][y]; @@ -1197,16 +1452,22 @@ namespace Server.Multis // Slanted roofs do not count; they overhang blocking south and east sides of the multi if ((data.Flags & TileFlag.Roof) != 0) + { continue; + } // Signs and signposts are not considered part of the multi if (id >= 0xB95 && id <= 0xC0E || id >= 0xC43 && id <= 0xC44) + { continue; + } var tileZ = tile.Z + Z; if (p.Z == tileZ || p.Z + height > tileZ) + { return true; + } } return false; @@ -1215,14 +1476,18 @@ namespace Server.Multis public SecureAccessResult CheckSecureAccess(Mobile m, Item item) { if (Secures == null || !(item is Container)) + { return SecureAccessResult.Insecure; + } for (var i = 0; i < Secures.Count; ++i) { var info = Secures[i]; if (info.Item == item) + { return HasSecureAccess(m, info.Level) ? SecureAccessResult.Accessible : SecureAccessResult.Inaccessible; + } } return SecureAccessResult.Insecure; @@ -1231,28 +1496,44 @@ namespace Server.Multis public override void OnMapChange() { if (LockDowns == null) + { return; + } UpdateRegion(); if (Sign?.Deleted == false) + { Sign.Map = Map; + } if (Doors != null) + { foreach (var item in Doors) + { item.Map = Map; + } + } foreach (var entity in GetHouseEntities()) + { if (entity is Item item) + { item.Map = Map; + } else if (entity is Mobile mobile) + { mobile.Map = Map; + } + } } public virtual void ChangeSignType(int itemID) { if (Sign != null) + { Sign.ItemID = itemID; + } } public virtual void UpdateRegion() @@ -1273,30 +1554,44 @@ namespace Server.Multis public override void OnLocationChange(Point3D oldLocation) { if (LockDowns == null) + { return; + } var x = Location.X - oldLocation.X; var y = Location.Y - oldLocation.Y; var z = Location.Z - oldLocation.Z; if (Sign?.Deleted == false) + { Sign.Location = new Point3D(Sign.X + x, Sign.Y + y, Sign.Z + z); + } UpdateRegion(); if (Doors != null) + { foreach (var item in Doors) + { if (!item.Deleted) + { item.Location = new Point3D(item.X + x, item.Y + y, item.Z + z); + } + } + } foreach (var entity in GetHouseEntities()) { var newLocation = new Point3D(entity.X + x, entity.Y + y, entity.Z + z); if (entity is Item item) + { item.Location = newLocation; + } else if (entity is Mobile mobile) + { mobile.Location = newLocation; + } } } @@ -1562,7 +1857,10 @@ namespace Server.Multis if (door != null) { - if (from != null) door.KeyValue = CreateKeys(from); + if (from != null) + { + door.KeyValue = CreateKeys(@from); + } AddDoor(door, xOffset, yOffset, zOffset); } @@ -1597,7 +1895,9 @@ namespace Server.Multis var box = m.BankBox; if (!box.TryDropItem(m, bankKey, false)) + { bankKey.Delete(); + } m.AddToBackpack(packKey); } @@ -1624,7 +1924,10 @@ namespace Server.Multis public BaseDoor MakeDoor(bool wood, DoorFacing facing) { if (wood) + { return new DarkWoodHouseDoor(facing); + } + return new MetalHouseDoor(facing); } @@ -1637,7 +1940,9 @@ namespace Server.Multis public void AddTrashBarrel(Mobile from) { if (!IsActive) + { return; + } for (var i = 0; Doors != null && i < Doors.Count; ++i) { @@ -1645,14 +1950,18 @@ namespace Server.Multis var p = door.Location; if (door.Open) + { p = new Point3D(p.X - door.Offset.X, p.Y - door.Offset.Y, p.Z - door.Offset.Z); + } if (from.Z + 16 >= p.Z && p.Z + 16 >= from.Z) - if (from.InRange(p, 1)) + { + if (@from.InRange(p, 1)) { - from.SendLocalizedMessage(502120); // You cannot place a trash barrel near a door or near steps. + @from.SendLocalizedMessage(502120); // You cannot place a trash barrel near a door or near steps. return; } + } } if (m_Trash?.Deleted != false) @@ -1681,12 +1990,18 @@ namespace Server.Multis private void SetLockdown(Item i, bool locked, bool checkContains = false) { if (LockDowns == null) + { return; + } if (i is BaseAddonContainer) + { i.Movable = false; + } else + { i.Movable = !locked; + } i.IsLockedDown = locked; @@ -1695,27 +2010,40 @@ namespace Server.Multis if (i is VendorRentalContract contract) { if (!VendorRentalContracts.Contains(contract)) + { VendorRentalContracts.Add(contract); + } } else { if (!checkContains || !LockDowns.Contains(i)) + { LockDowns.Add(i); + } } } else { if (i is VendorRentalContract contract) + { VendorRentalContracts.Remove(contract); + } + LockDowns.Remove(i); } if (!locked) + { i.SetLastMoved(); + } if (i is Container && (!locked || !(i is BaseBoard || i is Aquarium || i is FishBowl))) + { foreach (var c in i.Items) + { SetLockdown(c, locked, checkContains); + } + } } public bool LockDown(Mobile m, Item item) => LockDown(m, item, true); @@ -1723,7 +2051,9 @@ namespace Server.Multis public bool LockDown(Mobile m, Item item, bool checkIsInside) { if (!IsCoOwner(m) || !IsActive) + { return false; + } if (item is BaseAddonContainer || item.Movable && !HasSecureItem(item)) { @@ -1788,24 +2118,40 @@ namespace Server.Multis var p = sign?.GetWorldLocation() ?? Point3D.Zero; if (from.Map != Map || to.Map != Map) + { isValid = false; + } else if (sign == null) + { isValid = false; + } else if (from.Map != sign.Map || to.Map != sign.Map) + { isValid = false; + } else if (IsInside(from)) + { isValid = false; + } else if (IsInside(to)) + { isValid = false; + } else if (!from.InRange(p, 2)) + { isValid = false; + } else if (!to.InRange(p, 2)) + { isValid = false; + } if (!isValid) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1062067 ); // In order to transfer the house, you and the recipient must both be outside the building and within two paces of the house sign. + } return isValid; } @@ -1813,7 +2159,9 @@ namespace Server.Multis public void BeginConfirmTransfer(Mobile from, Mobile to) { if (Deleted || !from.CheckAlive() || !IsOwner(from)) + { return; + } if (NewVendorSystem && HasPersonalVendors) { @@ -1877,7 +2225,9 @@ namespace Server.Multis private void ConfirmTransfer_Callback(Mobile to, bool ok, Mobile from) { if (!ok || Deleted || !from.CheckAlive() || !IsOwner(from)) + { return; + } if (CheckTransferPosition(from, to)) { @@ -1889,7 +2239,9 @@ namespace Server.Multis public void EndConfirmTransfer(Mobile from, Mobile to) { if (Deleted || !from.CheckAlive() || !IsOwner(from)) + { return; + } if (NewVendorSystem && HasPersonalVendors) { @@ -1954,7 +2306,9 @@ namespace Server.Multis public void Release(Mobile m, Item item) { if (!IsCoOwner(m) || !IsActive) + { return; + } if (HasLockedDownItem(item)) { @@ -1977,7 +2331,9 @@ namespace Server.Multis public void AddSecure(Mobile m, Item item) { if (Secures == null || !IsOwner(m) || !IsActive) + { return; + } if (!IsInside(item)) { @@ -1996,8 +2352,12 @@ namespace Server.Multis SecureInfo info = null; for (var i = 0; info == null && i < Secures.Count; ++i) + { if (Secures[i].Item == item) + { info = Secures[i]; + } + } if (info != null) { @@ -2047,7 +2407,9 @@ namespace Server.Multis { if (m?.Player != true || m.AccessLevel >= AccessLevel.GameMaster || !IsAosRules || m_Owner != null && m_Owner.AccessLevel >= AccessLevel.GameMaster) + { return false; + } for (var i = 0; i < m.Aggressed.Count; ++i) { @@ -2057,7 +2419,9 @@ namespace Server.Multis DateTime.UtcNow - info.LastCombatTime < HouseRegion.CombatHeatDelay && (!(m.Guild is Guild attackerGuild) || !(info.Defender.Guild is Guild defenderGuild) || defenderGuild != attackerGuild && !defenderGuild.IsEnemy(attackerGuild))) + { return true; + } } return false; @@ -2066,10 +2430,14 @@ namespace Server.Multis public bool HasSecureAccess(Mobile m, SecureLevel level) { if (m.AccessLevel >= AccessLevel.GameMaster) + { return true; + } if (IsCombatRestricted(m)) + { return false; + } return level switch { @@ -2085,7 +2453,9 @@ namespace Server.Multis public void ReleaseSecure(Mobile m, Item item) { if (Secures == null || !IsOwner(m) || item is StrongBox || !IsActive) + { return; + } for (var i = 0; i < Secures.Count; ++i) { @@ -2097,9 +2467,14 @@ namespace Server.Multis item.IsSecure = false; if (item is BaseAddonContainer) + { item.Movable = false; + } else + { item.Movable = true; + } + item.SetLastMoved(); item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501656); // [no longer secure] Secures.RemoveAt(i); @@ -2113,7 +2488,9 @@ namespace Server.Multis public void AddStrongBox(Mobile from) { if (!IsCoOwner(from) || !IsActive) + { return; + } if (from == Owner) { @@ -2144,14 +2521,18 @@ namespace Server.Multis var p = door.Location; if (door.Open) + { p = new Point3D(p.X - door.Offset.X, p.Y - door.Offset.Y, p.Z - door.Offset.Z); + } if (from.Z + 16 >= p.Z && p.Z + 16 >= from.Z) - if (from.InRange(p, 1)) + { + if (@from.InRange(p, 1)) { - from.SendLocalizedMessage(502113); // You cannot place a strongbox near a door or near steps. + @from.SendLocalizedMessage(502113); // You cannot place a strongbox near a door or near steps. return; } + } } var sb = new StrongBox(from, this) { Movable = false, IsLockedDown = false, IsSecure = true }; @@ -2162,7 +2543,9 @@ namespace Server.Multis public void Kick(Mobile from, Mobile targ) { if (!IsFriend(from) || Friends == null) + { return; + } if (targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel) { @@ -2199,7 +2582,9 @@ namespace Server.Multis public void RemoveAccess(Mobile from, Mobile targ) { if (!IsFriend(from) || Access == null) + { return; + } if (Access.Contains(targ)) { @@ -2218,7 +2603,9 @@ namespace Server.Multis public void RemoveBan(Mobile from, Mobile targ) { if (!IsCoOwner(from) || Bans == null) + { return; + } if (Bans.Contains(targ)) { @@ -2231,7 +2618,9 @@ namespace Server.Multis public void Ban(Mobile from, Mobile targ) { if (!IsFriend(from) || Bans == null) + { return; + } if (targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel) { @@ -2281,7 +2670,9 @@ namespace Server.Multis public void GrantAccess(Mobile from, Mobile targ) { if (!IsFriend(from) || Access == null) + { return; + } if (HasAccess(targ)) { @@ -2306,7 +2697,9 @@ namespace Server.Multis public void AddCoOwner(Mobile from, Mobile targ) { if (!IsOwner(from) || CoOwners == null || Friends == null) + { return; + } if (IsOwner(targ)) { @@ -2348,7 +2741,9 @@ namespace Server.Multis public void RemoveCoOwner(Mobile from, Mobile targ) { if (!IsOwner(from) || CoOwners == null) + { return; + } if (CoOwners.Contains(targ)) { @@ -2378,7 +2773,9 @@ namespace Server.Multis public void AddFriend(Mobile from, Mobile targ) { if (!IsCoOwner(from) || Friends == null || CoOwners == null) + { return; + } if (IsOwner(targ)) { @@ -2416,7 +2813,9 @@ namespace Server.Multis public void RemoveFriend(Mobile from, Mobile targ) { if (!IsCoOwner(from) || Friends == null) + { return; + } if (Friends.Contains(targ)) { @@ -2456,9 +2855,13 @@ namespace Server.Multis writer.Write(relEntity.RelativeLocation); if (relEntity.Entity.Deleted) + { writer.Write(Serial.MinusOne); + } else + { writer.Write(relEntity.Entity.Serial); + } } writer.WriteEncodedInt(VendorInventories.Count); @@ -2485,7 +2888,9 @@ namespace Server.Multis writer.Write(Secures.Count); for (var i = 0; i < Secures.Count; ++i) + { Secures[i].Serialize(writer); + } writer.Write(m_Public); @@ -2529,7 +2934,9 @@ namespace Server.Multis if (child.Decays && !child.IsLockedDown && !child.IsSecure && child.LastMoved + child.DecayTime <= DateTime.UtcNow) + { Timer.DelayCall(child.Delete); + } } } } @@ -2576,7 +2983,9 @@ namespace Server.Multis var entity = World.FindEntity(reader.ReadUInt()); if (entity != null) + { RelocatedEntities.Add(new RelocatedEntity(entity, relLocation)); + } } var inventoryCount = reader.ReadEncodedInt(); @@ -2648,13 +3057,18 @@ namespace Server.Multis case 1: { if (version < 13) + { reader.ReadPoint3D(); // house ban location + } + goto case 0; } case 0: { if (version < 14) + { m_RelativeBanLocation = BaseBanLocation; + } if (version < 12) { @@ -2663,13 +3077,19 @@ namespace Server.Multis } if (version < 4) + { Addons = new List(); + } if (version < 7) + { Access = new List(); + } if (version < 8) + { Price = DefaultPrice; + } m_Owner = reader.ReadMobile(); @@ -2678,7 +3098,9 @@ namespace Server.Multis count = reader.ReadInt(); for (var i = 0; i < count; i++) + { reader.ReadRect2D(); + } } UpdateRegion(); @@ -2694,10 +3116,14 @@ namespace Server.Multis LockDowns = reader.ReadStrongItemList(); for (var i = 0; i < LockDowns.Count; ++i) + { LockDowns[i].IsLockedDown = true; + } for (var i = 0; i < VendorRentalContracts.Count; ++i) + { VendorRentalContracts[i].IsLockedDown = true; + } if (version < 3) { @@ -2705,23 +3131,29 @@ namespace Server.Multis Secures = new List(items.Count); for (var i = 0; i < items.Count; ++i) + { if (items[i] is Container c) { c.IsSecure = true; Secures.Add(new SecureInfo(c, SecureLevel.CoOwners)); } + } } MaxLockDowns = reader.ReadInt(); MaxSecures = reader.ReadInt(); if ((Map == null || Map == Map.Internal) && Location == Point3D.Zero) + { Delete(); + } if (m_Owner != null) { if (!m_Table.TryGetValue(m_Owner, out var list)) + { m_Table[m_Owner] = list = new List(); + } list.Add(this); } @@ -2731,19 +3163,28 @@ namespace Server.Multis } if (version <= 1) + { ChangeSignType(0xBD2); // private house, plain brass sign + } - if (version < 10) Timer.DelayCall(FixLockdowns_Sandbox); + if (version < 10) + { + Timer.DelayCall(FixLockdowns_Sandbox); + } if (version < 11) + { LastRefreshed = DateTime.UtcNow + TimeSpan.FromHours(24 * Utility.RandomDouble()); + } if (DynamicDecay.Enabled && !loadedDynamicDecay) { var old = GetOldDecayLevel(); if (old == DecayLevel.DemolitionPending) + { old = DecayLevel.Collapsed; + } SetDynamicDecay(old); } @@ -2751,10 +3192,14 @@ namespace Server.Multis if (!CheckDecay()) { if (RelocatedEntities.Count > 0) + { Timer.DelayCall(RestoreRelocatedEntities); + } if (m_Owner == null && Friends.Count == 0 && CoOwners.Count == 0) + { Timer.DelayCall(TimeSpan.FromSeconds(10.0), Delete); + } } } @@ -2763,10 +3208,14 @@ namespace Server.Multis var conts = LockDowns?.Where(item => item is Container).ToList(); if (conts == null) + { return; + } foreach (var cont in conts) + { SetLockdown(cont, true, true); + } } public static void HandleDeletion(Mobile mob) @@ -2774,24 +3223,36 @@ namespace Server.Multis var houses = GetHouses(mob); if (houses.Count == 0) + { return; + } var acct = mob.Account as Account; Mobile trans = null; if (acct != null) + { for (var i = 0; i < acct.Length; ++i) + { if (acct[i] != null && acct[i] != mob) + { trans = acct[i]; + } + } + } for (var i = 0; i < houses.Count; ++i) { var house = houses[i]; if (trans == null && house.CoOwners.Count == 0) + { Timer.DelayCall(house.Delete); + } else + { house.Owner = trans; + } } } @@ -2800,6 +3261,7 @@ namespace Server.Multis var count = 0; if (LockDowns != null) + { for (var i = 0; i < LockDowns.Count; ++i) { if (LockDowns[i] != null) @@ -2807,11 +3269,14 @@ namespace Server.Multis var item = LockDowns[i]; if (!(item is Container)) + { count += item.TotalItems; + } } count++; } + } return count; } @@ -2832,7 +3297,9 @@ namespace Server.Multis if (m_Owner != null) { if (!m_Table.TryGetValue(m_Owner, out var list)) + { m_Table[m_Owner] = list = new List(); + } list.Remove(this); } @@ -2941,14 +3408,19 @@ namespace Server.Multis var c = ba.Components[j]; if (c.Hue != 0) + { hue = c.Hue; + } } } if (deed != null) { if (retainDeedHue) + { deed.Hue = hue; + } + deed.MoveToWorld(item.Location, item.Map); } } @@ -2961,7 +3433,9 @@ namespace Server.Multis } foreach (var inventory in VendorInventories.ToList()) + { inventory.Delete(); + } MovingCrate?.Delete(); @@ -2976,11 +3450,17 @@ namespace Server.Multis public static bool HasAccountHouse(Mobile m) { if (!(m.Account is Account a)) + { return false; + } for (var i = 0; i < a.Length; ++i) + { if (a[i] != null && HasHouse(a[i])) + { return true; + } + } return false; } @@ -3002,7 +3482,9 @@ namespace Server.Multis uint keyValue = 0; for (var i = 0; keyValue == 0 && i < Doors.Count; ++i) + { keyValue = Doors[i].KeyValue; + } Key.RemoveKeys(m, keyValue); } @@ -3013,19 +3495,25 @@ namespace Server.Multis var keyValue = CreateKeys(m); if (Doors != null) + { for (var i = 0; i < Doors.Count; ++i) + { Doors[i].KeyValue = keyValue; + } + } } public void RemoveLocks() { if (Doors != null) + { for (var i = 0; i < Doors.Count; ++i) { var door = Doors[i]; door.KeyValue = 0; door.Locked = false; } + } } public virtual HouseDeed GetDeed() => null; @@ -3035,7 +3523,9 @@ namespace Server.Multis public bool IsBanned(Mobile m) { if (m == null || m == Owner || m.AccessLevel > AccessLevel.Player || Bans == null) + { return false; + } var theirAccount = m.Account as Account; @@ -3044,10 +3534,14 @@ namespace Server.Multis var c = Bans[i]; if (c == m) + { return true; + } if (c.Account is Account bannedAccount && bannedAccount == theirAccount) + { return true; + } } return false; @@ -3056,19 +3550,29 @@ namespace Server.Multis public bool HasAccess(Mobile m) { if (m == null) + { return false; + } if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access?.Contains(m) == true) + { return true; + } if (!(m is BaseCreature bc)) + { return false; + } if (bc.NoHouseRestrictions) + { return true; + } if (!(bc.Controlled || bc.Summoned)) + { return false; + } m = bc.ControlMaster ?? bc.SummonMaster; @@ -3082,11 +3586,17 @@ namespace Server.Multis public bool HasSecureItem(Item item) { if (item == null) + { return false; + } for (var i = 0; i < Secures?.Count; ++i) + { if (Secures[i].Item == item) + { return true; + } + } return false; } @@ -3096,7 +3606,9 @@ namespace Server.Multis var map = Map; if (map == null) + { return null; + } var mcl = Components; var eable = @@ -3118,9 +3630,13 @@ namespace Server.Multis m_CurrentStage = level; if (DynamicDecay.Decays(level)) + { NextDecayStage = DateTime.UtcNow + DynamicDecay.GetRandomDuration(level); + } else + { NextDecayStage = DateTime.MinValue; + } } private class TransferItem : Item @@ -3189,13 +3705,20 @@ namespace Server.Multis public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { if (!base.AllowSecureTrade(from, to, newOwner, accepted)) + { return false; + } + if (!accepted) + { return true; + } if (Deleted || m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive()) + { return false; + } if (HasAccountHouse(to)) { @@ -3209,15 +3732,21 @@ namespace Server.Multis public override void OnSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { if (Deleted) + { return; + } Delete(); if (m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive()) + { return; + } if (!accepted) + { return; + } from.SendLocalizedMessage(501338); // You have transferred ownership of the house. @@ -3260,11 +3789,17 @@ namespace Server.Multis protected override void OnTick() { if (m_Map == null) + { return; + } for (var x = m_StartX; x <= m_EndX; ++x) + { for (var y = m_StartY; y <= m_EndY; ++y) + { m_Map.FixColumn(x, y); + } + } } } } @@ -3365,7 +3900,9 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from)) + { return; + } if (targeted is Item item) { @@ -3374,7 +3911,9 @@ namespace Server.Multis if (item is AddonContainerComponent component) { if (component.Addon != null) - m_House.Release(from, component.Addon); + { + m_House.Release(@from, component.Addon); + } } else { @@ -3402,7 +3941,9 @@ namespace Server.Multis if (item is AddonContainerComponent component) { if (component.Addon != null) - m_House.LockDown(from, component.Addon); + { + m_House.LockDown(@from, component.Addon); + } } else { @@ -3442,7 +3983,9 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from)) + { return; + } if (targeted is Item item) { @@ -3451,7 +3994,9 @@ namespace Server.Multis if (item is AddonContainerComponent component) { if (component.Addon != null) - m_House.ReleaseSecure(from, component.Addon); + { + m_House.ReleaseSecure(@from, component.Addon); + } } else { @@ -3474,7 +4019,9 @@ namespace Server.Multis if (item is AddonContainerComponent component) { if (component.Addon != null) - m_House.AddSecure(from, component.Addon); + { + m_House.AddSecure(@from, component.Addon); + } } else { @@ -3504,12 +4051,18 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from)) + { return; + } if (targeted is Mobile mobile) - m_House.Kick(from, mobile); + { + m_House.Kick(@from, mobile); + } else - from.SendLocalizedMessage(501347); // You cannot eject that from the house! + { + @from.SendLocalizedMessage(501347); // You cannot eject that from the house! + } } } @@ -3529,14 +4082,20 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from)) + { return; + } if (targeted is Mobile mobile) { if (m_Banning) - m_House.Ban(from, mobile); + { + m_House.Ban(@from, mobile); + } else - m_House.RemoveBan(from, mobile); + { + m_House.RemoveBan(@from, mobile); + } } else { @@ -3559,12 +4118,18 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from)) + { return; + } if (targeted is Mobile mobile) - m_House.GrantAccess(from, mobile); + { + m_House.GrantAccess(@from, mobile); + } else - from.SendLocalizedMessage(1060712); // That is not a player. + { + @from.SendLocalizedMessage(1060712); // That is not a player. + } } } @@ -3584,14 +4149,20 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsOwner(from)) + { return; + } if (targeted is Mobile mobile) { if (m_Add) - m_House.AddCoOwner(from, mobile); + { + m_House.AddCoOwner(@from, mobile); + } else - m_House.RemoveCoOwner(from, mobile); + { + m_House.RemoveCoOwner(@from, mobile); + } } else { @@ -3616,14 +4187,20 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from)) + { return; + } if (targeted is Mobile mobile) { if (m_Add) - m_House.AddFriend(from, mobile); + { + m_House.AddFriend(@from, mobile); + } else - m_House.RemoveFriend(from, mobile); + { + m_House.RemoveFriend(@from, mobile); + } } else { @@ -3646,9 +4223,13 @@ namespace Server.Multis protected override void OnTarget(Mobile from, object targeted) { if (targeted is Mobile mobile) - m_House.BeginConfirmTransfer(from, mobile); + { + m_House.BeginConfirmTransfer(@from, mobile); + } else - from.SendLocalizedMessage(501384); // Only a player can own a house! + { + @from.SendLocalizedMessage(501384); // Only a player can own a house! + } } } @@ -3668,7 +4249,9 @@ namespace Server.Multis var house = BaseHouse.FindHouseAt(item); if (house?.IsOwner(from) != true || !house.IsAosRules) + { return null; + } ISecurable sec = null; @@ -3677,13 +4260,19 @@ namespace Server.Multis var isOwned = item is BaseDoor door && house.Doors.Contains(door); if (!isOwned) + { isOwned = house is HouseFoundation foundation && foundation.IsFixture(item); + } if (!isOwned) + { isOwned = house.HasLockedDownItem(item); + } if (isOwned) + { sec = securable; + } } else { @@ -3694,7 +4283,9 @@ namespace Server.Multis var si = list[i]; if (si.Item == item) + { sec = si; + } } } @@ -3706,7 +4297,9 @@ namespace Server.Multis var sec = GetSecurable(from, item); if (sec != null) + { list.Add(new SetSecureLevelEntry(item, sec)); + } } public override void OnClick() diff --git a/Projects/UOContent/Multis/Boats/BaseBoat.cs b/Projects/UOContent/Multis/Boats/BaseBoat.cs index 9757ad686..6614c88b9 100644 --- a/Projects/UOContent/Multis/Boats/BaseBoat.cs +++ b/Projects/UOContent/Multis/Boats/BaseBoat.cs @@ -170,19 +170,29 @@ namespace Server.Multis var start = TimeOfDecay - BoatDecayDelay; if (DateTime.UtcNow - start < TimeSpan.FromHours(1.0)) + { return 1043010; // This structure is like new. + } if (DateTime.UtcNow - start < TimeSpan.FromDays(2.0)) + { return 1043011; // This structure is slightly worn. + } if (DateTime.UtcNow - start < TimeSpan.FromDays(3.0)) + { return 1043012; // This structure is somewhat worn. + } if (DateTime.UtcNow - start < TimeSpan.FromDays(4.0)) + { return 1043013; // This structure is fairly worn. + } if (DateTime.UtcNow - start < TimeSpan.FromDays(5.0)) + { return 1043014; // This structure is greatly worn. + } return 1043015; // This structure is in danger of collapsing. } @@ -233,8 +243,12 @@ namespace Server.Multis var sector = map.GetSector(loc); for (var i = 0; i < sector.Multis.Count; i++) + { if (sector.Multis[i] is BaseBoat boat && boat.Contains(loc.X, loc.Y)) + { return boat; + } + } return null; } @@ -335,18 +349,28 @@ namespace Server.Multis case 0: { if (version < 3) + { NextNavPoint = -1; + } if (version < 2) { if (ItemID == NorthID) + { m_Facing = Direction.North; + } else if (ItemID == SouthID) + { m_Facing = Direction.South; + } else if (ItemID == EastID) + { m_Facing = Direction.East; + } else if (ItemID == WestID) + { m_Facing = Direction.West; + } } Owner = reader.ReadMobile(); @@ -358,7 +382,9 @@ namespace Server.Multis m_ShipName = reader.ReadString(); if (version < 1) + { Refresh(); + } break; } @@ -372,10 +398,14 @@ namespace Server.Multis uint keyValue = 0; if (PPlank != null) + { keyValue = PPlank.KeyValue; + } if (keyValue == 0 && SPlank != null) + { keyValue = SPlank.KeyValue; + } Key.RemoveKeys(m, keyValue); } @@ -396,14 +426,22 @@ namespace Server.Multis var box = m.BankBox; if (!box.TryDropItem(m, bankKey, false)) + { bankKey.Delete(); + } else + { m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502484); // A ship's key is now in my safety deposit box. + } if (m.AddToBackpack(packKey)) + { m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502485); // A ship's key is now in my backpack. + } else + { m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502483); // A ship's key is now at my feet. + } return value; } @@ -428,35 +466,51 @@ namespace Server.Multis public override void OnLocationChange(Point3D old) { if (TillerMan != null) + { TillerMan.Location = new Point3D( X + (TillerMan.X - old.X), Y + (TillerMan.Y - old.Y), Z + (TillerMan.Z - old.Z) ); + } if (Hold != null) + { Hold.Location = new Point3D(X + (Hold.X - old.X), Y + (Hold.Y - old.Y), Z + (Hold.Z - old.Z)); + } if (PPlank != null) + { PPlank.Location = new Point3D(X + (PPlank.X - old.X), Y + (PPlank.Y - old.Y), Z + (PPlank.Z - old.Z)); + } if (SPlank != null) + { SPlank.Location = new Point3D(X + (SPlank.X - old.X), Y + (SPlank.Y - old.Y), Z + (SPlank.Z - old.Z)); + } } public override void OnMapChange() { if (TillerMan != null) + { TillerMan.Map = Map; + } if (Hold != null) + { Hold.Map = Map; + } if (PPlank != null) + { PPlank.Map = Map; + } if (SPlank != null) + { SPlank.Map = Map; + } } public bool CanCommand(Mobile m) => true; @@ -480,7 +534,9 @@ namespace Server.Multis public bool CheckDecay() { if (m_Decaying) + { return true; + } if (!IsMoving && DateTime.UtcNow >= m_DecayTime) { @@ -497,12 +553,16 @@ namespace Server.Multis public bool LowerAnchor(bool message) { if (CheckDecay()) + { return false; + } if (Anchored) { if (message) + { TillerMan?.Say(501445); // Ar, the anchor was already dropped sir. + } return false; } @@ -512,7 +572,9 @@ namespace Server.Multis Anchored = true; if (message) + { TillerMan?.Say(501444); // Ar, anchor dropped sir. + } return true; } @@ -520,12 +582,16 @@ namespace Server.Multis public bool RaiseAnchor(bool message) { if (CheckDecay()) + { return false; + } if (!Anchored) { if (message) + { TillerMan?.Say(501447); // Ar, the anchor has not been dropped sir. + } return false; } @@ -533,7 +599,9 @@ namespace Server.Multis Anchored = false; if (message) + { TillerMan?.Say(501446); // Ar, anchor raised sir. + } return true; } @@ -541,7 +609,9 @@ namespace Server.Multis public bool StartMove(Direction dir, bool fast) { if (CheckDecay()) + { return false; + } var drift = dir != Forward && dir != ForwardLeft && dir != ForwardRight; var interval = fast ? drift ? FastDriftInterval : FastInterval : @@ -563,7 +633,9 @@ namespace Server.Multis public bool OneMove(Direction dir) { if (CheckDecay()) + { return false; + } var drift = dir != Forward; var interval = drift ? FastDriftInterval : FastInterval; @@ -582,7 +654,9 @@ namespace Server.Multis public void BeginRename(Mobile from) { if (CheckDecay()) + { return; + } if (from.AccessLevel < AccessLevel.GameMaster && from != Owner) { @@ -604,7 +678,9 @@ namespace Server.Multis public void EndRename(Mobile from, string newName) { if (Deleted || CheckDecay()) + { return; + } if (from.AccessLevel < AccessLevel.GameMaster && from != Owner) { @@ -626,31 +702,45 @@ namespace Server.Multis public DryDockResult CheckDryDock(Mobile from) { if (CheckDecay()) + { return DryDockResult.Decaying; + } if (!from.Alive) + { return DryDockResult.Dead; + } var pack = from.Backpack; if ((SPlank == null || !Key.ContainsKey(pack, SPlank.KeyValue)) && (PPlank == null || !Key.ContainsKey(pack, PPlank.KeyValue))) + { return DryDockResult.NoKey; + } if (!Anchored) + { return DryDockResult.NotAnchored; + } if (Hold != null && Hold.Items.Count > 0) + { return DryDockResult.Hold; + } var map = Map; if (map == null || map == Map.Internal) + { return DryDockResult.Items; + } var ents = GetMovingEntities(); if (ents.Count >= 1) + { return ents[0] is Mobile ? DryDockResult.Mobiles : DryDockResult.Items; + } return DryDockResult.Valid; } @@ -658,53 +748,87 @@ namespace Server.Multis public void BeginDryDock(Mobile from) { if (CheckDecay()) + { return; + } var result = CheckDryDock(from); if (result == DryDockResult.Dead) - from.SendLocalizedMessage(502493); // You appear to be dead. + { + @from.SendLocalizedMessage(502493); // You appear to be dead. + } else if (result == DryDockResult.NoKey) - from.SendLocalizedMessage(502494); // You must have a key to the ship to dock the boat. + { + @from.SendLocalizedMessage(502494); // You must have a key to the ship to dock the boat. + } else if (result == DryDockResult.NotAnchored) - from.SendLocalizedMessage(1010570); // You must lower the anchor to dock the boat. + { + @from.SendLocalizedMessage(1010570); // You must lower the anchor to dock the boat. + } else if (result == DryDockResult.Mobiles) - from.SendLocalizedMessage(502495); // You cannot dock the ship with beings on board! + { + @from.SendLocalizedMessage(502495); // You cannot dock the ship with beings on board! + } else if (result == DryDockResult.Items) - from.SendLocalizedMessage(502496); // You cannot dock the ship with a cluttered deck. + { + @from.SendLocalizedMessage(502496); // You cannot dock the ship with a cluttered deck. + } else if (result == DryDockResult.Hold) - from.SendLocalizedMessage(502497); // Make sure your hold is empty, and try again! + { + @from.SendLocalizedMessage(502497); // Make sure your hold is empty, and try again! + } else if (result == DryDockResult.Valid) - from.SendGump(new ConfirmDryDockGump(from, this)); + { + @from.SendGump(new ConfirmDryDockGump(@from, this)); + } } public void EndDryDock(Mobile from) { if (Deleted || CheckDecay()) + { return; + } var result = CheckDryDock(from); if (result == DryDockResult.Dead) - from.SendLocalizedMessage(502493); // You appear to be dead. + { + @from.SendLocalizedMessage(502493); // You appear to be dead. + } else if (result == DryDockResult.NoKey) - from.SendLocalizedMessage(502494); // You must have a key to the ship to dock the boat. + { + @from.SendLocalizedMessage(502494); // You must have a key to the ship to dock the boat. + } else if (result == DryDockResult.NotAnchored) - from.SendLocalizedMessage(1010570); // You must lower the anchor to dock the boat. + { + @from.SendLocalizedMessage(1010570); // You must lower the anchor to dock the boat. + } else if (result == DryDockResult.Mobiles) - from.SendLocalizedMessage(502495); // You cannot dock the ship with beings on board! + { + @from.SendLocalizedMessage(502495); // You cannot dock the ship with beings on board! + } else if (result == DryDockResult.Items) - from.SendLocalizedMessage(502496); // You cannot dock the ship with a cluttered deck. + { + @from.SendLocalizedMessage(502496); // You cannot dock the ship with a cluttered deck. + } else if (result == DryDockResult.Hold) - from.SendLocalizedMessage(502497); // Make sure your hold is empty, and try again! + { + @from.SendLocalizedMessage(502497); // Make sure your hold is empty, and try again! + } if (result != DryDockResult.Valid) + { return; + } var boat = DockedBoat; if (boat == null) + { return; + } RemoveKeys(from); @@ -715,7 +839,9 @@ namespace Server.Multis public void SetName(SpeechEventArgs e) { if (CheckDecay()) + { return; + } if (e.Mobile.AccessLevel < AccessLevel.GameMaster && e.Mobile != Owner) { @@ -732,16 +858,22 @@ namespace Server.Multis } if (e.Speech.Length > 8) + { Rename(e.Speech.Substring(8).Trim().IsNullOrDefault(null)); + } } public void Rename(string newName) { if (CheckDecay()) + { return; + } if (newName?.Length > 40) + { newName = newName.Substring(0, 40); + } if (m_ShipName == newName) { @@ -753,15 +885,21 @@ namespace Server.Multis ShipName = newName; if (TillerMan != null && m_ShipName != null) + { TillerMan.Say(1042885, m_ShipName); // This ship is now called the ~1_NEW_SHIP_NAME~. + } else + { TillerMan?.Say(502534); // This ship now has no name. + } } public void RemoveName(Mobile m) { if (CheckDecay()) + { return; + } if (m.AccessLevel < AccessLevel.GameMaster && m != Owner) { @@ -792,32 +930,46 @@ namespace Server.Multis public void GiveName(Mobile m) { if (TillerMan == null || CheckDecay()) + { return; + } if (m_ShipName == null) + { TillerMan.Say(502526); // Ar, this ship has no name. + } else + { TillerMan.Say(1042881, m_ShipName); // This is the ~1_BOAT_NAME~. + } } public void GiveNavPoint() { if (TillerMan == null || CheckDecay()) + { return; + } if (NextNavPoint < 0) + { TillerMan.Say(1042882); // I have no current nav point. + } else + { TillerMan.Say( 1042883, (NextNavPoint + 1).ToString() ); // My current destination navpoint is nav ~1_NAV_POINT_NUM~. + } } public void AssociateMap(MapItem map) { if (CheckDecay()) + { return; + } if (map is BlankMap) { @@ -844,31 +996,40 @@ namespace Server.Multis var start = -1; for (var i = 0; i < navPoint.Length; i++) + { if (char.IsDigit(navPoint[i])) { start = i; break; } + } if (start != -1) { var sNumber = navPoint.Substring(start); if (!int.TryParse(sNumber, out number)) + { number = -1; + } if (number != -1) { number--; - if (MapItem == null || number < 0 || number >= MapItem.Pins.Count) number = -1; + if (MapItem == null || number < 0 || number >= MapItem.Pins.Count) + { + number = -1; + } } } if (number == -1) { if (message) + { TillerMan?.Say(1042551); // I don't see that navpoint, sir. + } return false; } @@ -880,12 +1041,16 @@ namespace Server.Multis public bool StartCourse(bool single, bool message) { if (CheckDecay()) + { return false; + } if (Anchored) { if (message) + { TillerMan?.Say(501419); // Ar, the anchor is down sir! + } return false; } @@ -893,7 +1058,9 @@ namespace Server.Multis if (MapItem?.Deleted != false) { if (message) + { TillerMan?.Say(502513); // I have seen no map, sir. + } return false; } @@ -901,7 +1068,9 @@ namespace Server.Multis if (Map != MapItem.Map || !Contains(MapItem.GetWorldLocation())) { if (message) + { TillerMan?.Say(502514); // The map is too far away from me, sir. + } return false; } @@ -909,7 +1078,9 @@ namespace Server.Multis if (Map != Map.Trammel && Map != Map.Felucca || NextNavPoint < 0 || NextNavPoint >= MapItem.Pins.Count) { if (message) + { TillerMan?.Say(1042551); // I don't see that navpoint, sir. + } return false; } @@ -923,7 +1094,9 @@ namespace Server.Multis m_MoveTimer.Start(); if (message) + { TillerMan?.Say(501429); // Aye aye sir. + } return true; } @@ -931,11 +1104,14 @@ namespace Server.Multis public override void OnSpeech(SpeechEventArgs e) { if (CheckDecay()) + { return; + } var from = e.Mobile; if (CanCommand(from) && Contains(from)) + { for (var i = 0; i < e.Keywords.Length; ++i) { var keyword = e.Keywords[i]; @@ -1072,17 +1248,22 @@ namespace Server.Multis break; } } + } } public bool StartTurn(int offset, bool message) { if (CheckDecay()) + { return false; + } if (Anchored) { if (message) + { TillerMan.Say(501419); // Ar, the anchor is down sir! + } return false; } @@ -1099,7 +1280,9 @@ namespace Server.Multis m_TurnTimer.Start(); if (message) + { TillerMan?.Say(501429); // Aye aye sir. + } return true; } @@ -1113,19 +1296,29 @@ namespace Server.Multis } if (CheckDecay()) + { return false; + } if (Anchored) { if (message) + { TillerMan.Say(501419); // Ar, the anchor is down sir! + } return false; } - if (SetFacing((Direction)(((int)m_Facing + offset) & 0x7))) return true; + if (SetFacing((Direction)(((int)m_Facing + offset) & 0x7))) + { + return true; + } + if (message) + { TillerMan.Say(501423); // Ar, can't turn sir. + } return false; } @@ -1133,12 +1326,16 @@ namespace Server.Multis public bool StartMove(Direction dir, int speed, int clientSpeed, TimeSpan interval, bool single, bool message) { if (CheckDecay()) + { return false; + } if (Anchored) { if (message) + { TillerMan?.Say(501419); // Ar, the anchor is down sir! + } return false; } @@ -1159,12 +1356,16 @@ namespace Server.Multis public bool StopMove(bool message) { if (CheckDecay()) + { return false; + } if (m_MoveTimer == null) { if (message) + { TillerMan?.Say(501443); // Er, the ship is not moving sir. + } return false; } @@ -1176,7 +1377,9 @@ namespace Server.Multis m_MoveTimer = null; if (message) + { TillerMan?.Say(501429); // Aye aye sir. + } return true; } @@ -1184,18 +1387,23 @@ namespace Server.Multis public bool CanFit(Point3D p, Map map, int itemID) { if (map == null || map == Map.Internal || Deleted || CheckDecay()) + { return false; + } var newComponents = MultiData.GetComponents(itemID); for (var x = 0; x < newComponents.Width; ++x) + { for (var y = 0; y < newComponents.Height; ++y) { var tx = p.X + newComponents.Min.X + x; var ty = p.Y + newComponents.Min.Y + y; if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty)) + { continue; + } var landTile = map.Tiles.GetLandTile(tx, ty); var tiles = map.Tiles.GetStaticTiles(tx, ty, true); @@ -1218,14 +1426,21 @@ namespace Server.Multis var isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2; if (tile.Z == p.Z && isWater) + { hasWater = true; + } else if (tile.Z >= p.Z && !isWater) + { return false; + } } if (!hasWater) + { return false; + } } + } var eable = map.GetItemsInBounds( new Rectangle2D( @@ -1240,7 +1455,9 @@ namespace Server.Multis item => { if (item is BaseMulti || item.ItemID > TileData.MaxItemValue || item.Z < p.Z || !item.Visible) + { return true; + } var x = item.X - p.X + newComponents.Min.X; var y = item.Y - p.Y + newComponents.Min.Y; @@ -1281,8 +1498,12 @@ namespace Server.Multis var wrap = GetWrapFor(map); for (var i = 0; i < wrap.Length; ++i) + { if (wrap[i].Contains(p)) + { return true; + } + } return false; } @@ -1303,9 +1524,13 @@ namespace Server.Multis // Compute the maximum distance we can travel without going too far away if (iDir % 2 == 0) // North, East, South and West + { maxSpeed = Math.Abs(adx - ady); + } else // Right, Down, Left and Up + { maxSpeed = Math.Min(adx, ady); + } return (Direction)((iDir - (int)Facing) & 0x7); } @@ -1324,21 +1549,27 @@ namespace Server.Multis else if (MapItem?.Deleted != false) { if (message) + { TillerMan?.Say(502513); // I have seen no map, sir. + } return false; } else if (Map != MapItem.Map || !Contains(MapItem.GetWorldLocation())) { if (message) + { TillerMan?.Say(502514); // The map is too far away from me, sir. + } return false; } else if (Map != Map.Trammel && Map != Map.Felucca || NextNavPoint < 0 || NextNavPoint >= MapItem.Pins.Count) { if (message) + { TillerMan?.Say(1042551); // I don't see that navpoint, sir. + } return false; } @@ -1353,10 +1584,12 @@ namespace Server.Multis if (maxSpeed == 0) { if (message && Order == BoatOrder.Single) + { TillerMan?.Say( 1042874, (NextNavPoint + 1).ToString() ); // We have arrived at nav point ~1_POINT_NUM~ , sir. + } if (NextNavPoint + 1 < MapItem.Pins.Count) { @@ -1365,10 +1598,12 @@ namespace Server.Multis if (Order == BoatOrder.Course) { if (message) + { TillerMan?.Say( 1042875, (NextNavPoint + 1).ToString() ); // Heading to nav point ~1_POINT_NUM~, sir. + } return true; } @@ -1379,15 +1614,22 @@ namespace Server.Multis NextNavPoint = -1; if (message && Order == BoatOrder.Course) + { TillerMan?.Say(502515); // The course is completed, sir. + } return false; } if (dir == Left || dir == BackwardLeft || dir == Backward) + { return Turn(-2, true); + } + if (dir == Right || dir == BackwardRight) + { return Turn(2, true); + } speed = Math.Min(Speed, maxSpeed); clientSpeed = 0x4; @@ -1401,12 +1643,16 @@ namespace Server.Multis var map = Map; if (map == null || Deleted || CheckDecay()) + { return false; + } if (Anchored) { if (message) + { TillerMan?.Say(501419); // Ar, the anchor is down sir! + } return false; } @@ -1416,12 +1662,15 @@ namespace Server.Multis Movement.Movement.Offset(d, ref rx, ref ry); for (var i = 1; i <= speed; ++i) + { if (!CanFit(new Point3D(X + i * rx, Y + i * ry, Z), Map, ItemID)) { if (i == 1) { if (message) + { TillerMan?.Say(501424); // Ar, we've stopped sir. + } return false; } @@ -1429,6 +1678,7 @@ namespace Server.Multis speed = i - 1; break; } + } var xOffset = speed * rx; var yOffset = speed * ry; @@ -1445,23 +1695,35 @@ namespace Server.Multis if (rect.Contains(new Point2D(X, Y)) && !rect.Contains(new Point2D(newX, newY))) { if (newX < rect.X) + { newX = rect.X + rect.Width - 1; + } else if (newX >= rect.X + rect.Width) + { newX = rect.X; + } if (newY < rect.Y) + { newY = rect.Y + rect.Height - 1; + } else if (newY >= rect.Y + rect.Height) + { newY = rect.Y; + } for (var j = 1; j <= speed; ++j) + { if (!CanFit(new Point3D(newX + j * rx, newY + j * ry, Z), Map, ItemID)) { if (message) + { TillerMan?.Say(501424); // Ar, we've stopped sir. + } return false; } + } xOffset = newX - X; yOffset = newY - Y; @@ -1487,31 +1749,43 @@ namespace Server.Multis var m = ns.Mobile; if (ns.HighSeas && m.CanSee(this) && m.InRange(Location, GetUpdateRange(m))) + { ns.Send(new MoveBoatHS(m, this, d, clientSpeed, toMove, xOffset, yOffset)); + } } foreach (var e in toMove) + { if (e is Item item) { item.NoMoveHS = true; if (!(item is TillerMan || item is Hold || item is Plank)) + { item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z); + } } else if (e is Mobile m) { m.NoMoveHS = true; m.Location = new Point3D(m.X + xOffset, m.Y + yOffset, m.Z); } + } NoMoveHS = true; Location = new Point3D(X + xOffset, Y + yOffset, Z); foreach (var e in toMove) + { if (e is Item item) + { item.NoMoveHS = false; + } else if (e is Mobile mobile) + { mobile.NoMoveHS = false; + } + } NoMoveHS = false; } @@ -1522,7 +1796,9 @@ namespace Server.Multis private static void SafeAdd(Item item, List toMove) { if (item != null) + { toMove.Add(item); + } } public void Teleport(int xOffset, int yOffset, int zOffset) @@ -1534,8 +1810,13 @@ namespace Server.Multis var e = toMove[i]; if (e is Item item) + { item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z + zOffset); - else if (e is Mobile m) m.Location = new Point3D(m.X + xOffset, m.Y + yOffset, m.Z + zOffset); + } + else if (e is Mobile m) + { + m.Location = new Point3D(m.X + xOffset, m.Y + yOffset, m.Z + zOffset); + } } Location = new Point3D(X + xOffset, Y + yOffset, Z + zOffset); @@ -1548,24 +1829,32 @@ namespace Server.Multis var map = Map; if (map == null || map == Map.Internal) + { return list; + } var mcl = Components; foreach (var o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height))) { if (o == this || o is TillerMan || o is Hold || o is Plank) + { continue; + } if (o is Item item) { if (Contains(item) && item.Visible && item.Z >= Z) + { list.Add(item); + } } else if (o is Mobile m) { if (Contains(m)) + { list.Add(m); + } } } @@ -1575,27 +1864,49 @@ namespace Server.Multis public bool SetFacing(Direction facing) { if (Parent != null || Map == null) + { return false; + } if (CheckDecay()) + { return false; + } if (Map != Map.Internal) + { switch (facing) { case Direction.North: - if (!CanFit(Location, Map, NorthID)) return false; + if (!CanFit(Location, Map, NorthID)) + { + return false; + } + break; case Direction.East: - if (!CanFit(Location, Map, EastID)) return false; + if (!CanFit(Location, Map, EastID)) + { + return false; + } + break; case Direction.South: - if (!CanFit(Location, Map, SouthID)) return false; + if (!CanFit(Location, Map, SouthID)) + { + return false; + } + break; case Direction.West: - if (!CanFit(Location, Map, WestID)) return false; + if (!CanFit(Location, Map, WestID)) + { + return false; + } + break; } + } var old = m_Facing; @@ -1618,14 +1929,18 @@ namespace Server.Multis Movement.Movement.Offset(facing, ref xOffset, ref yOffset); if (TillerMan != null) + { TillerMan.Location = new Point3D( X + xOffset * TillerManDistance + (facing == Direction.North ? 1 : 0), Y + yOffset * TillerManDistance, TillerMan.Z ); + } if (Hold != null) + { Hold.Location = new Point3D(X + xOffset * HoldDistance, Y + yOffset * HoldDistance, Hold.Z); + } var count = (m_Facing - old) & 0x7; count /= 2; @@ -1660,7 +1975,9 @@ namespace Server.Multis public static void UpdateAllComponents() { for (var i = Boats.Count - 1; i >= 0; --i) + { Boats[i].UpdateComponents(); + } } public static void Initialize() @@ -1720,7 +2037,9 @@ namespace Server.Multis protected override void OnTick() { if (!m_Boat.Deleted) + { m_Boat.Turn(m_Offset, true); + } } } @@ -1737,7 +2056,9 @@ namespace Server.Multis protected override void OnTick() { if (!m_Boat.DoMovement(true)) + { m_Boat.StopMove(false); + } } } @@ -1793,7 +2114,9 @@ namespace Server.Multis foreach (var ent in ents) { if (!beholder.CanSee(ent)) + { continue; + } Stream.Write(ent.Serial); Stream.Write((short)(ent.X + xOffset)); @@ -1830,7 +2153,9 @@ namespace Server.Multis foreach (var ent in ents) { if (!beholder.CanSee(ent)) + { continue; + } // Embedded WorldItemHS packets Stream.Write((byte)0xF3); diff --git a/Projects/UOContent/Multis/Boats/BaseBoatDeed.cs b/Projects/UOContent/Multis/Boats/BaseBoatDeed.cs index 1ae18162f..327e79baa 100644 --- a/Projects/UOContent/Multis/Boats/BaseBoatDeed.cs +++ b/Projects/UOContent/Multis/Boats/BaseBoatDeed.cs @@ -12,7 +12,9 @@ namespace Server.Multis Weight = 1.0; if (!Core.AOS) + { LootType = LootType.Newbied; + } MultiID = id; Offset = offset; @@ -58,7 +60,9 @@ namespace Server.Multis } if (Weight == 0.0) + { Weight = 1.0; + } } public override void OnDoubleClick(Mobile from) @@ -74,9 +78,13 @@ namespace Server.Multis else { if (Core.SE) - from.SendLocalizedMessage(502482); // Where do you wish to place the ship? + { + @from.SendLocalizedMessage(502482); // Where do you wish to place the ship? + } else - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502482); // Where do you wish to place the ship? + { + @from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502482); // Where do you wish to place the ship? + } from.Target = new InternalTarget(this); } @@ -84,7 +92,10 @@ namespace Server.Multis public void OnPlacement(Mobile from, Point3D p) { - if (Deleted) return; + if (Deleted) + { + return; + } if (!IsChildOf(from.Backpack)) { @@ -95,7 +106,9 @@ namespace Server.Multis var map = from.Map; if (map == null) + { return; + } if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas)) { @@ -116,7 +129,9 @@ namespace Server.Multis var boat = Boat; if (boat == null) + { return; + } p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z); @@ -130,10 +145,14 @@ namespace Server.Multis var keyValue = boat.CreateKeys(from); if (boat.PPlank != null) + { boat.PPlank.KeyValue = keyValue; + } if (boat.SPlank != null) + { boat.SPlank.KeyValue = keyValue; + } boat.MoveToWorld(p, map); } @@ -156,18 +175,26 @@ namespace Server.Multis if (o is IPoint3D ip) { if (ip is Item item) + { ip = item.GetWorldTop(); + } var p = new Point3D(ip); var region = Region.Find(p, from.Map); if (region.IsPartOf()) - from.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon. + { + @from.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon. + } else if (region.IsPartOf() || region.IsPartOf()) - from.SendLocalizedMessage(1042549); // A boat may not be placed in this area. + { + @from.SendLocalizedMessage(1042549); // A boat may not be placed in this area. + } else - m_Deed.OnPlacement(from, p); + { + m_Deed.OnPlacement(@from, p); + } } } } diff --git a/Projects/UOContent/Multis/Boats/BaseDockedBoat.cs b/Projects/UOContent/Multis/Boats/BaseDockedBoat.cs index 03dfdb2f5..3b006298b 100644 --- a/Projects/UOContent/Multis/Boats/BaseDockedBoat.cs +++ b/Projects/UOContent/Multis/Boats/BaseDockedBoat.cs @@ -69,17 +69,23 @@ namespace Server.Multis m_ShipName = reader.ReadString(); if (version == 0) + { reader.ReadUInt(); + } break; } } if (LootType == LootType.Newbied) + { LootType = LootType.Blessed; + } if (Weight == 0.0) + { Weight = 1.0; + } } public override void OnDoubleClick(Mobile from) @@ -99,22 +105,33 @@ namespace Server.Multis public override void AddNameProperty(ObjectPropertyList list) { if (m_ShipName != null) + { list.Add(m_ShipName); + } else + { base.AddNameProperty(list); + } } public override void OnSingleClick(Mobile from) { if (m_ShipName != null) - LabelTo(from, m_ShipName); + { + LabelTo(@from, m_ShipName); + } else - base.OnSingleClick(from); + { + base.OnSingleClick(@from); + } } public void OnPlacement(Mobile from, Point3D p) { - if (Deleted) return; + if (Deleted) + { + return; + } if (!IsChildOf(from.Backpack)) { @@ -125,12 +142,16 @@ namespace Server.Multis var map = from.Map; if (map == null) + { return; + } var boat = Boat; if (boat == null) + { return; + } p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z); @@ -146,10 +167,14 @@ namespace Server.Multis var keyValue = boat.CreateKeys(from); if (boat.PPlank != null) + { boat.PPlank.KeyValue = keyValue; + } if (boat.SPlank != null) + { boat.SPlank.KeyValue = keyValue; + } boat.MoveToWorld(p, map); } @@ -172,18 +197,26 @@ namespace Server.Multis if (o is IPoint3D ip) { if (ip is Item item) + { ip = item.GetWorldTop(); + } var p = new Point3D(ip); var region = Region.Find(p, from.Map); if (region.IsPartOf()) - from.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon. + { + @from.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon. + } else if (region.IsPartOf() || region.IsPartOf()) - from.SendLocalizedMessage(1042549); // A boat may not be placed in this area. + { + @from.SendLocalizedMessage(1042549); // A boat may not be placed in this area. + } else - m_Model.OnPlacement(from, p); + { + m_Model.OnPlacement(@from, p); + } } } } diff --git a/Projects/UOContent/Multis/Boats/ConfirmDryDockGump.cs b/Projects/UOContent/Multis/Boats/ConfirmDryDockGump.cs index 5c8dc29f0..0d4d8d532 100644 --- a/Projects/UOContent/Multis/Boats/ConfirmDryDockGump.cs +++ b/Projects/UOContent/Multis/Boats/ConfirmDryDockGump.cs @@ -32,7 +32,9 @@ namespace Server.Multis public override void OnResponse(NetState state, RelayInfo info) { if (info.ButtonID == 2) + { m_Boat.EndDryDock(m_From); + } } } } diff --git a/Projects/UOContent/Multis/Boats/Hold.cs b/Projects/UOContent/Multis/Boats/Hold.cs index f69f39ebb..56ffd1594 100644 --- a/Projects/UOContent/Multis/Boats/Hold.cs +++ b/Projects/UOContent/Multis/Boats/Hold.cs @@ -34,7 +34,9 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item item) { if (m_Boat?.Contains(from) != true || m_Boat.IsMoving) + { return false; + } return base.OnDragDrop(from, item); } @@ -42,7 +44,9 @@ namespace Server.Items public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { if (m_Boat?.Contains(from) != true || m_Boat.IsMoving) + { return false; + } return base.OnDragDropInto(from, item, p); } @@ -50,7 +54,9 @@ namespace Server.Items public override bool CheckItemUse(Mobile from, Item item) { if (item != this && (m_Boat?.Contains(from) != true || m_Boat.IsMoving)) + { return false; + } return base.CheckItemUse(from, item); } @@ -58,7 +64,9 @@ namespace Server.Items public override bool CheckLift(Mobile from, Item item, ref LRReason reject) { if (m_Boat?.Contains(from) != true || m_Boat.IsMoving) + { return false; + } return base.CheckLift(from, item, ref reject); } @@ -71,11 +79,17 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (m_Boat?.Contains(from) != true) + { m_Boat.TillerMan?.Say(502490); // You must be on the ship to open the hold. + } else if (m_Boat.IsMoving) + { m_Boat.TillerMan?.Say(502491); // I can not open the hold while the ship is moving. + } else - base.OnDoubleClick(from); + { + base.OnDoubleClick(@from); + } } public override void Serialize(IGenericWriter writer) @@ -100,7 +114,9 @@ namespace Server.Items m_Boat = reader.ReadItem() as BaseBoat; if (m_Boat == null || Parent != null) + { Delete(); + } Movable = false; diff --git a/Projects/UOContent/Multis/Boats/Plank.cs b/Projects/UOContent/Multis/Boats/Plank.cs index 215db71c3..01af7c5cf 100644 --- a/Projects/UOContent/Multis/Boats/Plank.cs +++ b/Projects/UOContent/Multis/Boats/Plank.cs @@ -77,7 +77,9 @@ namespace Server.Items KeyValue = reader.ReadUInt(); if (Boat == null) + { Delete(); + } break; } @@ -93,6 +95,7 @@ namespace Server.Items public void SetFacing(Direction dir) { if (IsOpen) + { ItemID = dir switch { Direction.North => Starboard ? 0x3ED4 : 0x3ED5, @@ -101,7 +104,9 @@ namespace Server.Items Direction.West => Starboard ? 0x3E89 : 0x3E84, _ => ItemID }; + } else + { ItemID = dir switch { Direction.North => Starboard ? 0x3EB2 : 0x3EB1, @@ -110,12 +115,15 @@ namespace Server.Items Direction.West => Starboard ? 0x3E8A : 0x3E85, _ => ItemID }; + } } public void Open() { if (IsOpen || Deleted) + { return; + } m_CloseTimer?.Stop(); @@ -139,26 +147,40 @@ namespace Server.Items if (IsOpen) { if (from is BaseFactionGuard) + { return false; + } if ((from.Direction & Direction.Running) != 0 || Boat?.Contains(from) == false) + { return true; + } var map = Map; if (map == null) + { return false; + } int rx = 0, ry = 0; if (ItemID == 0x3ED4) + { rx = 1; + } else if (ItemID == 0x3ED5) + { rx = -1; + } else if (ItemID == 0x3E84) + { ry = 1; + } else if (ItemID == 0x3E89) + { ry = -1; + } for (var i = 1; i <= 6; ++i) { @@ -174,7 +196,9 @@ namespace Server.Items !Region.Find(new Point3D(x, y, z), map).IsPartOf()) { if (i == 1 && j >= -2 && j <= 2) + { return true; + } from.Location = new Point3D(x, y, z); return false; @@ -187,7 +211,9 @@ namespace Server.Items !Region.Find(new Point3D(x, y, z), map).IsPartOf()) { if (i == 1) + { return true; + } from.Location = new Point3D(x, y, z); return false; @@ -205,7 +231,9 @@ namespace Server.Items public void Close() { if (!IsOpen || !CanClose() || Deleted) + { return; + } m_CloseTimer?.Stop(); @@ -231,16 +259,22 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (Boat == null) + { return; + } if (from.InRange(GetWorldLocation(), 8)) { if (Boat.Contains(from)) { if (IsOpen) + { Close(); + } else + { Open(); + } } else { diff --git a/Projects/UOContent/Multis/Boats/Strandedness.cs b/Projects/UOContent/Multis/Boats/Strandedness.cs index 039b999a2..f6046f70d 100644 --- a/Projects/UOContent/Multis/Boats/Strandedness.cs +++ b/Projects/UOContent/Multis/Boats/Strandedness.cs @@ -93,7 +93,9 @@ namespace Server.Misc var map = from.Map; if (map == null) + { return false; + } var surface = map.GetTopSurface(from.Location); @@ -118,22 +120,34 @@ namespace Server.Misc public static void EventSink_Login(Mobile from) { if (!IsStranded(from)) + { return; + } var map = from.Map; Point2D[] list; if (map == Map.Felucca) + { list = m_Felucca; + } else if (map == Map.Trammel) + { list = m_Trammel; + } else if (map == Map.Ilshenar) + { list = m_Ilshenar; + } else if (map == Map.Tokuno) + { list = m_Tokuno; + } else + { return; + } var p = Point2D.Zero; var pdist = double.MaxValue; @@ -157,20 +171,28 @@ namespace Server.Misc canFit = map.CanSpawnMobile(x, y, z); for (var i = 1; !canFit && i <= 40; i += 2) + { for (var xo = -1; !canFit && xo <= 1; ++xo) + { for (var yo = -1; !canFit && yo <= 1; ++yo) { if (xo == 0 && yo == 0) + { continue; + } x = p.X + xo * i; y = p.Y + yo * i; z = map.GetAverageZ(x, y); canFit = map.CanSpawnMobile(x, y, z); } + } + } if (canFit) - from.Location = new Point3D(x, y, z); + { + @from.Location = new Point3D(x, y, z); + } } } } diff --git a/Projects/UOContent/Multis/Boats/TillerMan.cs b/Projects/UOContent/Multis/Boats/TillerMan.cs index 50dad2627..4b6664826 100644 --- a/Projects/UOContent/Multis/Boats/TillerMan.cs +++ b/Projects/UOContent/Multis/Boats/TillerMan.cs @@ -49,31 +49,45 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { if (m_Boat?.ShipName != null) + { list.Add(1042884, m_Boat.ShipName); // the tiller man of the ~1_SHIP_NAME~ + } else + { base.AddNameProperty(list); + } } public override void OnSingleClick(Mobile from) { if (m_Boat?.ShipName != null) - LabelTo(from, 1042884, m_Boat.ShipName); // the tiller man of the ~1_SHIP_NAME~ + { + LabelTo(@from, 1042884, m_Boat.ShipName); // the tiller man of the ~1_SHIP_NAME~ + } else - base.OnSingleClick(from); + { + base.OnSingleClick(@from); + } } public override void OnDoubleClick(Mobile from) { if (m_Boat?.Contains(from) == true) - m_Boat.BeginRename(from); + { + m_Boat.BeginRename(@from); + } else - m_Boat?.BeginDryDock(from); + { + m_Boat?.BeginDryDock(@from); + } } public override bool OnDragDrop(Mobile from, Item dropped) { if (dropped is MapItem item && m_Boat?.CanCommand(from) == true && m_Boat.Contains(from)) + { m_Boat.AssociateMap(item); + } return false; } @@ -105,7 +119,9 @@ namespace Server.Items m_Boat = reader.ReadItem() as BaseBoat; if (m_Boat == null) + { Delete(); + } break; } diff --git a/Projects/UOContent/Multis/Camps/BaseCamp.cs b/Projects/UOContent/Multis/Camps/BaseCamp.cs index d72843959..4e71a6e74 100644 --- a/Projects/UOContent/Multis/Camps/BaseCamp.cs +++ b/Projects/UOContent/Multis/Camps/BaseCamp.cs @@ -44,7 +44,9 @@ namespace Server.Multis public void CheckAddComponents() { if (Deleted) + { return; + } AddComponents(); } @@ -56,12 +58,16 @@ namespace Server.Multis public virtual void RefreshDecay(bool setDecayTime) { if (Deleted) + { return; + } m_DecayTimer?.Stop(); if (setDecayTime) + { m_DecayTime = DateTime.UtcNow + DecayDelay; + } m_DecayTimer = Timer.DelayCall(DecayDelay, Delete); } @@ -88,7 +94,9 @@ namespace Server.Multis } if (m is BaseVendor) + { m.Direction = Direction.South; + } m.MoveToWorld(loc, Map); } @@ -109,9 +117,13 @@ namespace Server.Multis var inNewRange = Utility.InRange(m.Location, Location, EventRange); if (inNewRange && !inOldRange) + { OnEnter(m); + } else if (inOldRange && !inNewRange) + { OnExit(m); + } } public override void OnAfterDelete() @@ -119,16 +131,22 @@ namespace Server.Multis base.OnAfterDelete(); for (var i = 0; i < m_Items.Count; ++i) + { m_Items[i].Delete(); + } for (var i = 0; i < m_Mobiles.Count; ++i) { var bc = (BaseCreature)m_Mobiles[i]; if (bc.IsPrisoner == false) + { m_Mobiles[i].Delete(); + } else if (m_Mobiles[i].CantWalk) + { m_Mobiles[i].Delete(); + } } m_Items.Clear(); @@ -191,7 +209,9 @@ namespace Server.Multis var version = reader.ReadInt(); if (Weight == 8.0) + { Weight = 1.0; + } } } } diff --git a/Projects/UOContent/Multis/Camps/BrigandCamp.cs b/Projects/UOContent/Multis/Camps/BrigandCamp.cs index 7c4cc9f2f..a01b9df80 100644 --- a/Projects/UOContent/Multis/Camps/BrigandCamp.cs +++ b/Projects/UOContent/Multis/Camps/BrigandCamp.cs @@ -50,7 +50,10 @@ namespace Server.Multis AddCampChests(); - for (var i = 0; i < 4; i++) AddMobile(Brigands, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + for (var i = 0; i < 4; i++) + { + AddMobile(Brigands, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + } BaseCreature bc = Utility.Random(2) switch { @@ -147,7 +150,9 @@ namespace Server.Multis public override void AddItem(Item item, int xOffset, int yOffset, int zOffset) { if (item != null) + { item.Movable = false; + } base.AddItem(item, xOffset, yOffset, zOffset); } diff --git a/Projects/UOContent/Multis/Camps/LizardmenCamp.cs b/Projects/UOContent/Multis/Camps/LizardmenCamp.cs index d9a9bb5a5..a615512a8 100644 --- a/Projects/UOContent/Multis/Camps/LizardmenCamp.cs +++ b/Projects/UOContent/Multis/Camps/LizardmenCamp.cs @@ -53,7 +53,10 @@ namespace Server.Multis AddCampChests(); - for (var i = 0; i < 4; i++) AddMobile(Lizardmen, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + for (var i = 0; i < 4; i++) + { + AddMobile(Lizardmen, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + } m_Prisoner = Utility.Random(2) switch { @@ -111,6 +114,7 @@ namespace Server.Multis crates.LiftOverride = true; if (Utility.RandomDouble() < 0.8) + { switch (Utility.Random(4)) { case 0: @@ -126,6 +130,7 @@ namespace Server.Multis crates.DropItem(new LesserPoisonPotion()); break; } + } AddItem(crates, -2, 2, 0); } @@ -159,7 +164,9 @@ namespace Server.Multis public override void AddItem(Item item, int xOffset, int yOffset, int zOffset) { if (item != null) + { item.Movable = false; + } base.AddItem(item, xOffset, yOffset, zOffset); } diff --git a/Projects/UOContent/Multis/Camps/OrcCamp.cs b/Projects/UOContent/Multis/Camps/OrcCamp.cs index 42e39ad98..83f6e84b9 100644 --- a/Projects/UOContent/Multis/Camps/OrcCamp.cs +++ b/Projects/UOContent/Multis/Camps/OrcCamp.cs @@ -53,7 +53,11 @@ namespace Server.Multis AddCampChests(); - for (var i = 0; i < 3; i++) AddMobile(Orcs, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + for (var i = 0; i < 3; i++) + { + AddMobile(Orcs, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + } + AddMobile(new OrcCaptain(), 2, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); m_Prisoner = Utility.Random(2) switch @@ -112,6 +116,7 @@ namespace Server.Multis crates.LiftOverride = true; if (Utility.RandomDouble() < 0.8) + { switch (Utility.Random(4)) { case 0: @@ -127,6 +132,7 @@ namespace Server.Multis crates.DropItem(new LesserPoisonPotion()); break; } + } AddItem(crates, 2, -2, 0); } @@ -160,7 +166,9 @@ namespace Server.Multis public override void AddItem(Item item, int xOffset, int yOffset, int zOffset) { if (item != null) + { item.Movable = false; + } base.AddItem(item, xOffset, yOffset, zOffset); } diff --git a/Projects/UOContent/Multis/Camps/RatCamp.cs b/Projects/UOContent/Multis/Camps/RatCamp.cs index 43ace4b5b..90d27b3f7 100644 --- a/Projects/UOContent/Multis/Camps/RatCamp.cs +++ b/Projects/UOContent/Multis/Camps/RatCamp.cs @@ -53,7 +53,10 @@ namespace Server.Multis AddCampChests(); - for (var i = 0; i < 4; i++) AddMobile(Ratmen, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + for (var i = 0; i < 4; i++) + { + AddMobile(Ratmen, 6, Utility.RandomMinMax(-7, 7), Utility.RandomMinMax(-7, 7), 0); + } m_Prisoner = Utility.Random(2) switch { @@ -111,6 +114,7 @@ namespace Server.Multis crates.LiftOverride = true; if (Utility.RandomDouble() < 0.8) + { switch (Utility.Random(4)) { case 0: @@ -126,6 +130,7 @@ namespace Server.Multis crates.DropItem(new LesserPoisonPotion()); break; } + } AddItem(crates, 2, 2, 0); } @@ -159,7 +164,9 @@ namespace Server.Multis public override void AddItem(Item item, int xOffset, int yOffset, int zOffset) { if (item != null) + { item.Movable = false; + } base.AddItem(item, xOffset, yOffset, zOffset); } diff --git a/Projects/UOContent/Multis/ComponentVerification.cs b/Projects/UOContent/Multis/ComponentVerification.cs index 4418a7a66..7d4bd9c91 100644 --- a/Projects/UOContent/Multis/ComponentVerification.cs +++ b/Projects/UOContent/Multis/ComponentVerification.cs @@ -140,7 +140,9 @@ namespace Server.Multis var table = new int[length]; for (var i = 0; i < table.Length; ++i) + { table[i] = -1; + } return table; } @@ -162,7 +164,9 @@ namespace Server.Multis var tileCIDs = new int[tileColumns.Length]; for (var i = 0; i < tileColumns.Length; ++i) + { tileCIDs[i] = ss.GetColumnID(tileColumns[i]); + } var featureCID = ss.GetColumnID("FeatureMask"); @@ -177,7 +181,9 @@ namespace Server.Multis var itemID = record.GetInt32(tileCIDs[j]); if (itemID <= 0 || itemID >= table.Length) + { continue; + } table[itemID] = fid; } @@ -198,7 +204,9 @@ namespace Server.Multis m_Columns = new ColumnInfo[types.Length]; for (var i = 0; i < m_Columns.Length; ++i) + { m_Columns[i] = new ColumnInfo(i, types[i], names[i]); + } var records = new List(); @@ -238,8 +246,12 @@ namespace Server.Multis public int GetColumnID(string name) { for (var i = 0; i < m_Columns.Length; ++i) + { if (m_Columns[i].m_Name == name) + { return i; + } + } return -1; } @@ -249,8 +261,12 @@ namespace Server.Multis string line; while ((line = ip.ReadLine()) != null) + { if (line.Length > 0) + { return line.Split('\t'); + } + } return null; } diff --git a/Projects/UOContent/Multis/Deeds.cs b/Projects/UOContent/Multis/Deeds.cs index c4386310c..4c54f4087 100644 --- a/Projects/UOContent/Multis/Deeds.cs +++ b/Projects/UOContent/Multis/Deeds.cs @@ -14,26 +14,38 @@ namespace Server.Multis.Deeds if (o is IPoint3D ip) { if (ip is Item item) + { ip = item.GetWorldTop(); + } var p = new Point3D(ip); var reg = Region.Find(new Point3D(p), from.Map); if (from.AccessLevel >= AccessLevel.GameMaster || reg.AllowHousing(from, p)) - m_Deed.OnPlacement(from, p); + { + m_Deed.OnPlacement(@from, p); + } else if (reg.IsPartOf()) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 501270 ); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + } else if (reg.IsPartOf() || reg.IsPartOf()) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1043287 ); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + } else if (reg.IsPartOf()) - from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. + { + @from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. + } else - from.SendLocalizedMessage(501265); // Housing can not be created in this area. + { + @from.SendLocalizedMessage(501265); // Housing can not be created in this area. + } } } } @@ -95,7 +107,9 @@ namespace Server.Multis.Deeds } if (Weight == 0.0) + { Weight = 1.0; + } } public override void OnDoubleClick(Mobile from) @@ -124,7 +138,9 @@ namespace Server.Multis.Deeds public void OnPlacement(Mobile from, Point3D p) { if (Deleted) + { return; + } if (!IsChildOf(from.Backpack)) { @@ -152,9 +168,13 @@ namespace Server.Multis.Deeds object o = toMove[i]; if (o is Mobile mobile) + { mobile.Location = house.BanLocation; + } else if (o is Item item) + { item.Location = house.BanLocation; + } } break; diff --git a/Projects/UOContent/Multis/DynamicDecay.cs b/Projects/UOContent/Multis/DynamicDecay.cs index 2992d64fa..aae3f8e86 100644 --- a/Projects/UOContent/Multis/DynamicDecay.cs +++ b/Projects/UOContent/Multis/DynamicDecay.cs @@ -31,7 +31,9 @@ namespace Server.Multis public static TimeSpan GetRandomDuration(DecayLevel level) { if (!m_Stages.TryGetValue(level, out var info)) + { return TimeSpan.Zero; + } var min = info.MinDuration.Ticks; var max = info.MaxDuration.Ticks; diff --git a/Projects/UOContent/Multis/HousePlacement.cs b/Projects/UOContent/Multis/HousePlacement.cs index c7a3bdcb3..54312c65d 100644 --- a/Projects/UOContent/Multis/HousePlacement.cs +++ b/Projects/UOContent/Multis/HousePlacement.cs @@ -44,25 +44,37 @@ namespace Server.Multis var map = from.Map; if (map == null || map == Map.Internal) + { return HousePlacementResult.BadLand; // A house cannot go here + } if (from.AccessLevel >= AccessLevel.GameMaster) + { return HousePlacementResult.Valid; // Staff can place anywhere + } if (map == Map.Ilshenar || SpellHelper.IsFeluccaT2A(map, center)) + { return HousePlacementResult.BadRegion; // No houses in Ilshenar/T2A + } if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E)) + { return HousePlacementResult.InvalidCastleKeep; + } if (Region.Find(center, map).IsPartOf()) + { return HousePlacementResult.BadRegion; + } // This holds data describing the internal structure of the house var mcl = MultiData.GetComponents(multiID); if (multiID >= 0x13EC && multiID < 0x1D00) + { HouseFoundation.AddStairsTo(ref mcl); // this is a AOS house, add the stairs + } // Location of the nortwest-most corner of the house var start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z); @@ -84,6 +96,7 @@ namespace Server.Multis */ for (var x = 0; x < mcl.Width; ++x) + { for (var y = 0; y < mcl.Height; ++y) { var tileX = start.X + x; @@ -92,22 +105,30 @@ namespace Server.Multis var addTiles = mcl.Tiles[x][y]; if (addTiles.Length == 0) + { continue; // There are no tiles here, continue checking somewhere else + } var testPoint = new Point3D(tileX, tileY, center.Z); var reg = Region.Find(testPoint, map); - if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc + if (!reg.AllowHousing(@from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc { if (reg.IsPartOf()) + { return HousePlacementResult.BadRegionTemp; + } if (reg.IsPartOf() || reg.IsPartOf()) + { return HousePlacementResult.BadRegionHidden; + } if (reg.IsPartOf()) + { return HousePlacementResult.BadRegionRaffle; + } return HousePlacementResult.BadRegion; } @@ -126,7 +147,9 @@ namespace Server.Multis var item = sector.Items[i]; if (item.Visible && item.X == tileX && item.Y == tileY) + { items.Add(item); + } } mobiles.Clear(); @@ -136,7 +159,9 @@ namespace Server.Multis var m = sector.Mobiles[i]; if (m.X == tileX && m.Y == tileY) + { mobiles.Add(m); + } } int landStartZ = 0, landAvgZ = 0, landTopZ = 0; @@ -150,7 +175,9 @@ namespace Server.Multis var addTile = addTiles[i]; if (addTile.ID == 0x1) // Nodraw + { continue; + } var addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags; @@ -158,21 +185,29 @@ namespace Server.Multis var hasSurface = false; if (isFoundation) + { hasFoundation = true; + } var addTileZ = center.Z + addTile.Z; var addTileTop = addTileZ + addTile.Height; if ((addTileFlags & TileFlag.Surface) != 0) + { addTileTop += 16; + } if (addTileTop > landStartZ && landAvgZ > addTileZ) + { return HousePlacementResult.BadLand; // Broke rule #2 + } if (isFoundation && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0 && landAvgZ == center.Z) + { hasSurface = true; + } for (var j = 0; j < oldTiles.Length; ++j) { @@ -181,7 +216,10 @@ namespace Server.Multis if ((id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0) && addTileTop > oldTile.Z && oldTile.Z + id.CalcHeight > addTileZ) + { return HousePlacementResult.BadStatic; // Broke rule #2 + } + /*else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z) hasSurface = true;*/ } @@ -194,9 +232,13 @@ namespace Server.Multis if (addTileTop > item.Z && item.Z + id.CalcHeight > addTileZ) { if (item.Movable) + { toMove.Add(item); + } else if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0) + { return HousePlacementResult.BadItem; // Broke rule #2 + } } /*else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z) @@ -206,37 +248,52 @@ namespace Server.Multis } if (isFoundation && !hasSurface) + { return HousePlacementResult.NoSurface; // Broke rule #4 + } for (var j = 0; j < mobiles.Count; ++j) { var m = mobiles[j]; if (addTileTop > m.Z && m.Z + 16 > addTileZ) + { toMove.Add(m); + } } } for (var i = 0; i < m_RoadIDs.Length; i += 2) + { if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) + { return HousePlacementResult.BadLand; // Broke rule #5 + } + } if (hasFoundation) { for (var xOffset = -1; xOffset <= 1; ++xOffset) + { for (var yOffset = -YardSize; yOffset <= YardSize; ++yOffset) { var yardPoint = new Point2D(tileX + xOffset, tileY + yOffset); if (!yard.Contains(yardPoint)) + { yard.Add(yardPoint); + } } + } for (var xOffset = -1; xOffset <= 1; ++xOffset) + { for (var yOffset = -1; yOffset <= 1; ++yOffset) { if (xOffset == 0 && yOffset == 0) + { continue; + } // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8) @@ -254,20 +311,28 @@ namespace Server.Multis if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface) + { shouldBreak = true; + } } if (shouldBreak) + { continue; + } } var borderPoint = new Point2D(tileX + xOffset, tileY + yOffset); if (!borders.Contains(borderPoint)) + { borders.Add(borderPoint); + } } + } } } + } for (var i = 0; i < borders.Count; ++i) { @@ -277,11 +342,17 @@ namespace Server.Multis var landID = landTile.ID & TileData.MaxLandValue; if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0) + { return HousePlacementResult.BadLand; + } for (var j = 0; j < m_RoadIDs.Length; j += 2) + { if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) + { return HousePlacementResult.BadLand; // Broke rule #5 + } + } var tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true); @@ -292,7 +363,9 @@ namespace Server.Multis if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0 && tile.Z + id.CalcHeight > center.Z + 2) + { return HousePlacementResult.BadStatic; // Broke rule #1 + } } var sector = map.GetSector(borderPoint.X, borderPoint.Y); @@ -303,13 +376,17 @@ namespace Server.Multis var item = sectorItems[j]; if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable) + { continue; + } var id = item.ItemData; if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0 && item.Z + id.CalcHeight > center.Z + 2) + { return HousePlacementResult.BadItem; // Broke rule #1 + } } } @@ -325,18 +402,29 @@ namespace Server.Multis _sectors.Add(sector); for (var j = 0; j < sector.Multis?.Count; j++) + { if (sector.Multis[j] is BaseHouse) { var _house = (BaseHouse)sector.Multis[j]; - if (!_houses.Contains(_house)) _houses.Add(_house); + if (!_houses.Contains(_house)) + { + _houses.Add(_house); + } } + } } } for (var i = 0; i < yard.Count; ++i) + { foreach (var b in _houses) + { if (b.Contains(yard[i])) + { return HousePlacementResult.BadStatic; // Broke rule #3 + } + } + } /*Point2D yardPoint = yard[i]; IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y ); diff --git a/Projects/UOContent/Multis/HousePlacementTool.cs b/Projects/UOContent/Multis/HousePlacementTool.cs index 78b826611..6408128db 100644 --- a/Projects/UOContent/Multis/HousePlacementTool.cs +++ b/Projects/UOContent/Multis/HousePlacementTool.cs @@ -29,9 +29,13 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) - from.SendGump(new HousePlacementCategoryGump(from)); + { + @from.SendGump(new HousePlacementCategoryGump(@from)); + } else - from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + { + @from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. + } } public override void Serialize(IGenericWriter writer) @@ -48,7 +52,9 @@ namespace Server.Items var version = reader.ReadInt(); if (Weight == 0.0) + { Weight = 3.0; + } } } @@ -90,7 +96,9 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (!m_From.CheckAlive() || m_From.Backpack?.FindItemByType() == null) + { return; + } switch (info.ButtonID) { @@ -198,16 +206,22 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { if (!m_From.CheckAlive() || m_From.Backpack?.FindItemByType() == null) + { return; + } var index = info.ButtonID - 1; if (index >= 0 && index < m_Entries.Length) { if (m_From.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(m_From)) + { m_From.SendLocalizedMessage(501271); // You already own a house, you may not place another! + } else + { m_From.Target = new NewHousePlacementTarget(m_Entries, m_Entries[index]); + } } else { @@ -237,41 +251,59 @@ namespace Server.Items protected override void OnTarget(Mobile from, object o) { if (!from.CheckAlive() || from.Backpack?.FindItemByType() == null) + { return; + } if (o is IPoint3D ip) { if (ip is Item item) + { ip = item.GetWorldTop(); + } var p = new Point3D(ip); var reg = Region.Find(new Point3D(p), from.Map); if (from.AccessLevel >= AccessLevel.GameMaster || reg.AllowHousing(from, p)) - m_Placed = m_Entry.OnPlacement(from, p); + { + m_Placed = m_Entry.OnPlacement(@from, p); + } else if (reg.IsPartOf()) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 501270 ); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + } else if (reg.IsPartOf() || reg.IsPartOf()) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1043287 ); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + } else if (reg.IsPartOf()) - from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. + { + @from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. + } else - from.SendLocalizedMessage(501265); // Housing can not be created in this area. + { + @from.SendLocalizedMessage(501265); // Housing can not be created in this area. + } } } protected override void OnTargetFinish(Mobile from) { if (!from.CheckAlive() || from.Backpack?.FindItemByType() == null) + { return; + } if (!m_Placed) - from.SendGump(new HousePlacementListGump(from, m_Entries)); + { + @from.SendGump(new HousePlacementListGump(@from, m_Entries)); + } } } @@ -1927,11 +1959,17 @@ namespace Server.Items object[] args; if (Type == typeof(HouseFoundation)) - args = new object[] { from, MultiID, m_Storage, m_Lockdowns }; + { + args = new object[] { @from, MultiID, m_Storage, m_Lockdowns }; + } else if (Type == typeof(SmallOldHouse) || Type == typeof(SmallShop) || Type == typeof(TwoStoryHouse)) - args = new object[] { from, MultiID }; + { + args = new object[] { @from, MultiID }; + } else - args = new object[] { from }; + { + args = new object[] { @from }; + } return ActivatorUtil.CreateInstance(Type, args) as BaseHouse; } @@ -1946,7 +1984,9 @@ namespace Server.Items public void PlacementWarning_Callback(Mobile from, bool okay, PreviewHouse prevHouse) { if (!from.CheckAlive() || from.Backpack?.FindItemByType() == null) + { return; + } if (!okay) { @@ -1984,7 +2024,9 @@ namespace Server.Items var house = ConstructHouse(from); if (house == null) + { return; + } house.Price = Cost; @@ -2022,9 +2064,13 @@ namespace Server.Items object o = toMove[i]; if (o is Mobile mobile) + { mobile.Location = house.BanLocation; + } else if (o is Item item) + { item.Location = house.BanLocation; + } } } @@ -2071,7 +2117,9 @@ namespace Server.Items public bool OnPlacement(Mobile from, Point3D p) { if (!from.CheckAlive() || from.Backpack?.FindItemByType() == null) + { return false; + } var center = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z); var res = HousePlacement.Check(from, MultiID, center, out var toMove); @@ -2112,9 +2160,13 @@ namespace Server.Items object o = toMove[i]; if (o is Mobile mobile) + { mobile.Location = banLoc; + } else if (o is Item item) + { item.Location = banLoc; + } } prev.MoveToWorld(center, from.Map); @@ -2193,13 +2245,19 @@ namespace Server.Items m_Table.TryGetValue(house.GetType(), out var obj); if (obj is HousePlacementEntry entry) + { return entry; + } if (obj is List list) + { return list.FirstOrDefault(e => e.MultiID == house.ItemID); + } if (obj is Dictionary table) + { return table[house.ItemID]; + } return null; } @@ -2227,7 +2285,9 @@ namespace Server.Items var table = new Dictionary(); foreach (var t in list) + { table[t.MultiID] = t; + } table[e.MultiID] = e; diff --git a/Projects/UOContent/Multis/HouseSign.cs b/Projects/UOContent/Multis/HouseSign.cs index c45e66a96..90e991ad8 100644 --- a/Projects/UOContent/Multis/HouseSign.cs +++ b/Projects/UOContent/Multis/HouseSign.cs @@ -27,7 +27,9 @@ namespace Server.Multis set { if (Owner != null) + { Owner.RestrictDecay = value; + } } } @@ -45,7 +47,9 @@ namespace Server.Multis base.OnAfterDelete(); if (Owner?.Deleted == false) + { Owner.Delete(); + } } public override void AddNameProperty(ObjectPropertyList list) @@ -75,7 +79,9 @@ namespace Server.Multis else if (level != DecayLevel.Ageless) { if (level == DecayLevel.Collapsed) + { level = DecayLevel.IDOC; + } list.Add(1062028, $"#{1043009 + (int)level}"); // Condition: This structure is ... } @@ -110,16 +116,24 @@ namespace Server.Multis if (Owner.IsFriend(m) && m.AccessLevel < AccessLevel.GameMaster) { if (Core.ML && Owner.IsOwner(m) || !Core.ML) + { Owner.RefreshDecay(); + } if (!Core.AOS) + { m.SendLocalizedMessage(501293); // Welcome back to the house, friend! + } } if (Owner.IsAosRules) + { m.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Information, m, Owner)); + } else + { m.SendGump(new HouseGump(m, Owner)); + } } } @@ -142,7 +156,9 @@ namespace Server.Multis public override void OnDoubleClick(Mobile m) { if (Owner == null) + { return; + } if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending) @@ -150,9 +166,11 @@ namespace Server.Multis var canClaim = Owner?.CoOwners.Count > 0 && Owner.IsCoOwner(m) || Owner.IsFriend(m); if (canClaim && !BaseHouse.HasAccountHouse(m)) + { m.SendGump( new WarningGump(501036, 32512, 1049719, 32512, 420, 280, okay => ClaimGump_Callback(m, okay)) ); + } } ShowSign(m); @@ -163,13 +181,19 @@ namespace Server.Multis base.GetContextMenuEntries(from, list); if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true) + { return; + } if (Owner.AreThereAvailableVendorsFor(from)) + { list.Add(new VendorsEntry(this)); + } if (Owner.VendorInventories.Count > 0) + { list.Add(new ReclaimVendorInventoryEntry(this)); + } } public override void Serialize(IGenericWriter writer) @@ -200,7 +224,9 @@ namespace Server.Multis } if (Name == "a house sign") + { Name = null; + } } private class VendorsEntry : ContextMenuEntry @@ -214,14 +240,20 @@ namespace Server.Multis var from = Owner.From; if (!from.CheckAlive() || m_Sign.Deleted || m_Sign.Owner?.AreThereAvailableVendorsFor(from) != true) + { return; + } if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5)) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1062429 ); // You must be within five paces of the house sign to use this option. + } else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Vendors, from, m_Sign.Owner)); + { + @from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Vendors, @from, m_Sign.Owner)); + } } } @@ -237,7 +269,9 @@ namespace Server.Multis if (m_Sign.Deleted || m_Sign.Owner == null || m_Sign.Owner.VendorInventories.Count == 0 || !from.CheckAlive()) + { return; + } if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5)) { diff --git a/Projects/UOContent/Multis/HouseTeleporter.cs b/Projects/UOContent/Multis/HouseTeleporter.cs index 48790dd12..89ef29988 100644 --- a/Projects/UOContent/Multis/HouseTeleporter.cs +++ b/Projects/UOContent/Multis/HouseTeleporter.cs @@ -43,7 +43,9 @@ namespace Server.Items if (CheckAccess(m)) { if (!m.Hidden || m.AccessLevel == AccessLevel.Player) + { new EffectTimer(Location, Map, 2023, 0x1F0, TimeSpan.FromSeconds(0.4)).Start(); + } new DelayTimer(this, m).Start(); } @@ -91,7 +93,9 @@ namespace Server.Items Target = reader.ReadItem(); if (version < 1) + { Level = SecureLevel.Anyone; + } break; } @@ -125,7 +129,9 @@ namespace Server.Items ); if (m_SoundID != -1) + { Effects.PlaySound(m_Location, m_Map, m_SoundID); + } } } @@ -145,12 +151,16 @@ namespace Server.Items var target = m_Teleporter.Target; if (target?.Deleted != false) + { return; + } var m = m_Mobile; if (m.Location != m_Teleporter.Location || m.Map != m_Teleporter.Map) + { return; + } var p = target.GetWorldTop(); var map = target.Map; @@ -160,7 +170,9 @@ namespace Server.Items m.MoveToWorld(p, map); if (m.Hidden && m.AccessLevel != AccessLevel.Player) + { return; + } Effects.PlaySound(target.Location, target.Map, 0x1FE); diff --git a/Projects/UOContent/Multis/Houses.cs b/Projects/UOContent/Multis/Houses.cs index 7a2e43bf0..de60e623a 100644 --- a/Projects/UOContent/Multis/Houses.cs +++ b/Projects/UOContent/Multis/Houses.cs @@ -539,7 +539,9 @@ namespace Server.Multis door.KeyValue = keyValue; if (door is BaseHouseDoor houseDoor) + { houseDoor.Facing = DoorFacing.EastCCW; + } AddDoor(door, -2, 0, id == 0xA2 ? 24 : 27); diff --git a/Projects/UOContent/Multis/MovingCrate.cs b/Projects/UOContent/Multis/MovingCrate.cs index e88fc0b81..c2e71139a 100644 --- a/Projects/UOContent/Multis/MovingCrate.cs +++ b/Projects/UOContent/Multis/MovingCrate.cs @@ -50,6 +50,7 @@ namespace Server.Multis { // 1. Try to stack the item foreach (var item in Items) + { if (item is PackingBox) { var subItems = item.Items; @@ -59,12 +60,16 @@ namespace Server.Multis var subItem = subItems[i]; if (!(subItem is Container) && subItem.StackWith(null, dropped, false)) + { return; + } } } + } // 2. Try to drop the item into an existing container foreach (var item in Items) + { if (item is PackingBox packingBox) { Container box = packingBox; @@ -76,6 +81,7 @@ namespace Server.Multis return; } } + } // 3. Drop the item into a new container Container subContainer = new PackingBox(); @@ -98,25 +104,37 @@ namespace Server.Multis var positions = new bool[Rows, Columns]; foreach (var item in Items) + { if (item is PackingBox) { var i = (item.Y - Bounds.Y) / VerticalSpacing; if (i < 0) + { i = 0; + } else if (i >= Rows) + { i = Rows - 1; + } var j = (item.X - Bounds.X) / HorizontalSpacing; if (j < 0) + { j = 0; + } else if (j >= Columns) + { j = Columns - 1; + } positions[i, j] = true; } + } for (var i = 0; i < Rows; i++) + { for (var j = 0; j < Columns; j++) + { if (!positions[i, j]) { var x = Bounds.X + j * HorizontalSpacing; @@ -124,6 +142,8 @@ namespace Server.Multis return new Point3D(x, y, 0); } + } + } return Point3D.Zero; } @@ -150,7 +170,9 @@ namespace Server.Multis base.OnItemRemoved(item); if (TotalItems == 0) + { Delete(); + } } public void RestartTimer() @@ -177,16 +199,26 @@ namespace Server.Multis var toRemove = new List(); foreach (var item in Items) + { if (item is PackingBox && item.Items.Count == 0) + { toRemove.Add(item); + } + } foreach (var item in toRemove) + { item.Delete(); + } if (TotalItems == 0) + { Delete(); + } else + { Internalize(); + } } public override void OnAfterDelete() @@ -194,7 +226,9 @@ namespace Server.Multis base.OnAfterDelete(); if (House?.MovingCrate == this) + { House.MovingCrate = null; + } m_InternalizeTimer?.Stop(); } @@ -227,7 +261,9 @@ namespace Server.Multis } if (version == 0) + { MaxItems = -1; // reset to default + } } public class InternalizeTimer : Timer @@ -276,7 +312,9 @@ namespace Server.Multis base.OnItemRemoved(item); if (item.GetBounce() == null && TotalItems == 0) + { Delete(); + } } public override void OnItemBounceCleared(Item item) @@ -284,7 +322,9 @@ namespace Server.Multis base.OnItemBounceCleared(item); if (TotalItems == 0) + { Delete(); + } } public override void Serialize(IGenericWriter writer) @@ -301,7 +341,9 @@ namespace Server.Multis var version = reader.ReadEncodedInt(); if (version == 0) + { MaxItems = -1; // reset to default + } } } } diff --git a/Projects/UOContent/Multis/PreviewHouse.cs b/Projects/UOContent/Multis/PreviewHouse.cs index f6408e5fb..75db2c831 100644 --- a/Projects/UOContent/Multis/PreviewHouse.cs +++ b/Projects/UOContent/Multis/PreviewHouse.cs @@ -42,7 +42,9 @@ namespace Server.Multis base.OnLocationChange(oldLocation); if (m_Components == null) + { return; + } var xOffset = X - oldLocation.X; var yOffset = Y - oldLocation.Y; @@ -61,7 +63,9 @@ namespace Server.Multis base.OnMapChange(); if (m_Components == null) + { return; + } for (var i = 0; i < m_Components.Count; ++i) { @@ -76,7 +80,9 @@ namespace Server.Multis base.OnDelete(); if (m_Components == null) + { return; + } for (var i = 0; i < m_Components.Count; ++i) { diff --git a/Projects/UOContent/Regions/BaseRegion.cs b/Projects/UOContent/Regions/BaseRegion.cs index c65e23996..1eb0fb01e 100644 --- a/Projects/UOContent/Regions/BaseRegion.cs +++ b/Projects/UOContent/Regions/BaseRegion.cs @@ -32,7 +32,9 @@ namespace Server.Regions public BaseRegion(DynamicJson json, JsonSerializerOptions options) : base(json, options) { if (json.data.TryGetValue("rune", out var runeName)) + { RuneName = runeName.GetString(); + } NoLogoutDelay = json.data.TryGetValue("logoutDelay", out var logoutDelay) && !logoutDelay.GetBoolean(); } @@ -66,7 +68,9 @@ namespace Server.Regions var br = region as BaseRegion; if (br?.RuneName != null) + { return br.RuneName; + } region = region.Parent; } @@ -82,7 +86,9 @@ namespace Server.Regions public override void OnEnter(Mobile m) { if (m is PlayerMobile mobile && mobile.Young && !YoungProtected) + { mobile.SendGump(new YoungDungeonWarning()); + } } public override bool AcceptsSpawnsFrom(Region region) => @@ -92,7 +98,9 @@ namespace Server.Regions public void InitRectangles() { if (Rectangles != null) + { return; + } // Test if area rectangles are overlapping, and in that case break them into smaller non overlapping rectangles for (var i = 0; i < Area.Length; i++) @@ -118,26 +126,34 @@ namespace Server.Regions var ez = rect.End.X; if (l1 < l2) + { m_RectBuffer2.Add(new Rectangle3D(new Point3D(l1, t1, sz), new Point3D(l2, b1, ez))); + } if (r1 > r2) + { m_RectBuffer2.Add(new Rectangle3D(new Point3D(r2, t1, sz), new Point3D(r1, b1, ez))); + } if (t1 < t2) + { m_RectBuffer2.Add( new Rectangle3D( new Point3D(Math.Max(l1, l2), t1, sz), new Point3D(Math.Min(r1, r2), t2, ez) ) ); + } if (b1 > b2) + { m_RectBuffer2.Add( new Rectangle3D( new Point3D(Math.Max(l1, l2), b2, sz), new Point3D(Math.Min(r1, r2), b1, ez) ) ); + } } } } diff --git a/Projects/UOContent/Regions/DungeonRegion.cs b/Projects/UOContent/Regions/DungeonRegion.cs index 7d2d0974d..657ae4ef1 100644 --- a/Projects/UOContent/Regions/DungeonRegion.cs +++ b/Projects/UOContent/Regions/DungeonRegion.cs @@ -8,10 +8,14 @@ namespace Server.Regions public DungeonRegion(DynamicJson json, JsonSerializerOptions options) : base(json, options) { if (json.GetProperty("map", options, out Map map)) + { EntranceMap = map; + } if (json.GetProperty("entrance", options, out Point3D entrance)) + { EntranceLocation = entrance; + } } public override bool YoungProtected => false; diff --git a/Projects/UOContent/Regions/GuardedRegion.cs b/Projects/UOContent/Regions/GuardedRegion.cs index 413f991bd..1dd744e62 100644 --- a/Projects/UOContent/Regions/GuardedRegion.cs +++ b/Projects/UOContent/Regions/GuardedRegion.cs @@ -54,7 +54,10 @@ namespace Server.Regions get { if (Map == Map.Ilshenar || Map == Map.Malas) + { return typeof(ArcherGuard); + } + return typeof(WarriorGuard); } } @@ -76,11 +79,17 @@ namespace Server.Regions var reg = from.Region.GetRegion(); if (reg == null) - from.SendMessage("You are not in a guardable region."); + { + @from.SendMessage("You are not in a guardable region."); + } else if (reg.Disabled) - from.SendMessage("The guards in this region have been disabled."); + { + @from.SendMessage("The guards in this region have been disabled."); + } else - from.SendMessage("This region is actively guarded."); + { + @from.SendMessage("This region is actively guarded."); + } } [Usage("SetGuarded ")] @@ -188,10 +197,14 @@ namespace Server.Regions public override void OnEnter(Mobile m) { if (IsDisabled()) + { return; + } if (!AllowReds && m.Kills >= 5) + { CheckGuardCandidate(m); + } } public override void OnExit(Mobile m) @@ -203,10 +216,14 @@ namespace Server.Regions base.OnSpeech(args); if (IsDisabled()) + { return; + } if (args.Mobile.Alive && args.HasKeyword(0x0007)) // *guards* + { CallGuards(args.Mobile.Location); + } } public override void OnAggressed(Mobile aggressor, Mobile aggressed, bool criminal) @@ -214,7 +231,9 @@ namespace Server.Regions base.OnAggressed(aggressor, aggressed, criminal); if (!IsDisabled() && aggressor != aggressed && criminal) + { CheckGuardCandidate(aggressor); + } } public override void OnGotBeneficialAction(Mobile helper, Mobile helped) @@ -222,12 +241,16 @@ namespace Server.Regions base.OnGotBeneficialAction(helper, helped); if (IsDisabled()) + { return; + } var noto = Notoriety.Compute(helper, helped); if (helper != helped && (noto == Notoriety.Criminal || noto == Notoriety.Murderer)) + { CheckGuardCandidate(helper); + } } public override void OnCriminalAction(Mobile m, bool message) @@ -235,13 +258,17 @@ namespace Server.Regions base.OnCriminalAction(m, message); if (!IsDisabled()) + { CheckGuardCandidate(m); + } } public void CheckGuardCandidate(Mobile m) { if (IsDisabled() || !IsGuardCandidate(m)) + { return; + } if (!m_GuardCandidates.TryGetValue(m, out var timer)) { @@ -254,12 +281,15 @@ namespace Server.Regions var map = m.Map; if (map == null) + { return; + } Mobile fakeCall = null; var prio = 0.0; foreach (var v in m.GetMobilesInRange(8)) + { if (!v.Player && v != m && !IsGuardCandidate(v) && ((v as BaseCreature)?.IsHumanInTown() ?? v.Body.IsHuman && v.Region.IsPartOf(this))) { @@ -271,6 +301,7 @@ namespace Server.Regions prio = dist; } } + } if (fakeCall != null) { @@ -303,11 +334,14 @@ namespace Server.Regions public void CallGuards(Point3D p) { if (IsDisabled()) + { return; + } var eable = Map.GetMobilesInRange(p, 14); foreach (var m in eable) + { if (IsGuardCandidate(m) && (!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this) || m_GuardCandidates.ContainsKey(m))) { @@ -320,6 +354,7 @@ namespace Server.Regions m.SendLocalizedMessage(502276); // Guards can no longer be called on you. break; } + } eable.Free(); } @@ -345,7 +380,9 @@ namespace Server.Regions protected override void OnTick() { if (m_Table.Remove(m_Mobile)) + { m_Mobile.SendLocalizedMessage(502276); // Guards can no longer be called on you. + } } } } diff --git a/Projects/UOContent/Regions/HouseRegion.cs b/Projects/UOContent/Regions/HouseRegion.cs index ebaef4350..0f0c6c6ec 100644 --- a/Projects/UOContent/Regions/HouseRegion.cs +++ b/Projects/UOContent/Regions/HouseRegion.cs @@ -36,7 +36,9 @@ namespace Server.Regions var house = BaseHouse.FindHouseAt(m); if (house?.Public == false && !house.IsFriend(m)) + { m.Location = house.BanLocation; + } } public override bool AllowHousing(Mobile from, Point3D p) => false; @@ -62,9 +64,13 @@ namespace Server.Regions public override bool SendInaccessibleMessage(Item item, Mobile from) { if (item is Container) - item.SendLocalizedMessageTo(from, 501647); // That is secure. + { + item.SendLocalizedMessageTo(@from, 501647); // That is secure. + } else - item.SendLocalizedMessageTo(from, 1061637); // You are not allowed to access this. + { + item.SendLocalizedMessageTo(@from, 1061637); // You are not allowed to access this. + } return true; } @@ -75,7 +81,9 @@ namespace Server.Regions public override void OnLocationChanged(Mobile m, Point3D oldLocation) { if (m_Recursion) + { return; + } base.OnLocationChanged(m, oldLocation); @@ -91,14 +99,18 @@ namespace Server.Regions m.Location = House.BanLocation; if (!Core.SE) + { m.SendLocalizedMessage(501284); // You may not enter. + } } else if (House.IsAosRules && !House.Public && !House.HasAccess(m) && House.IsInside(m)) { m.Location = House.BanLocation; if (!Core.SE) + { m.SendLocalizedMessage(501284); // You may not enter. + } } else if (House.IsCombatRestricted(m) && House.IsInside(m) && !House.IsInside(oldLocation, 16)) { @@ -115,7 +127,9 @@ namespace Server.Regions if (House.InternalizedVendors.Count > 0 && House.IsInside(m) && !House.IsInside(oldLocation, 16) && House.IsOwner(m) && m.Alive && !m.HasGump()) + { m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); + } m_Recursion = false; } @@ -123,26 +137,38 @@ namespace Server.Regions public override bool OnMoveInto(Mobile from, Direction d, Point3D newLocation, Point3D oldLocation) { if (!base.OnMoveInto(from, d, newLocation, oldLocation)) + { return false; + } var bc = from as BaseCreature; if (bc?.NoHouseRestrictions != true) { if (bc?.Controlled == false) // Untamed creatures cannot enter public houses + { return false; + } if (bc?.IsHouseSummonable == true && !(BaseCreature.Summoning || House.IsInside(oldLocation, 16))) + { return false; + } + if (bc?.Controlled == false && House.IsAosRules && !House.Public) + { return false; + } + if ((House.Public || !House.IsAosRules) && House.IsBanned(from) && House.IsInside(newLocation, 16)) { from.Location = House.BanLocation; if (!Core.SE) - from.SendLocalizedMessage(501284); // You may not enter. + { + @from.SendLocalizedMessage(501284); // You may not enter. + } return false; } @@ -150,7 +176,9 @@ namespace Server.Regions if (House.IsAosRules && !House.Public && !House.HasAccess(from) && House.IsInside(newLocation, 16)) { if (!Core.SE) - from.SendLocalizedMessage(501284); // You may not enter. + { + @from.SendLocalizedMessage(501284); // You may not enter. + } return false; } @@ -163,13 +191,17 @@ namespace Server.Regions if (House is HouseFoundation foundation && foundation.Customizer != null && foundation.Customizer != from && House.IsInside(newLocation, 16)) + { return false; + } } if (House.InternalizedVendors.Count > 0 && House.IsInside(from) && !House.IsInside(oldLocation, 16) && House.IsOwner(from) && from.Alive && !from.HasGump()) - from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); + { + @from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); + } return true; } @@ -195,10 +227,14 @@ namespace Server.Regions var isFriend = isCoOwner || House.IsFriend(from); if (!isFriend) + { return; + } if (!from.Alive) + { return; + } if (Core.ML && Insensitive.Equals(e.Speech, "I wish to resize my house")) { @@ -223,7 +259,10 @@ namespace Server.Regions } if (!House.IsInside(from) || !House.IsActive) + { return; + } + if (e.HasKeyword(0x33)) // remove thyself { from.SendLocalizedMessage(501326); // Target the individual to eject from this house. @@ -294,18 +333,28 @@ namespace Server.Regions else if (e.HasKeyword(0x27)) // I wish to place a strongbox { if (isOwner) - from.SendLocalizedMessage(502109); // Owners do not get a strongbox of their own. + { + @from.SendLocalizedMessage(502109); // Owners do not get a strongbox of their own. + } else if (isCoOwner) - House.AddStrongBox(from); + { + House.AddStrongBox(@from); + } else - from.SendLocalizedMessage(1010587); // You are not a co-owner of this house. + { + @from.SendLocalizedMessage(1010587); // You are not a co-owner of this house. + } } else if (e.HasKeyword(0x28)) // trash barrel { if (isCoOwner) - House.AddTrashBarrel(from); + { + House.AddTrashBarrel(@from); + } else - from.SendLocalizedMessage(1010587); // You are not a co-owner of this house. + { + @from.SendLocalizedMessage(1010587); // You are not a co-owner of this house. + } } } @@ -316,7 +365,9 @@ namespace Server.Regions var res = House.CheckSecureAccess(from, c); if (res == SecureAccessResult.Accessible) + { return true; + } if (res == SecureAccessResult.Inaccessible) { @@ -333,9 +384,13 @@ namespace Server.Regions if (o is Item item) { if (House.HasLockedDownItem(item)) - item.LabelTo(from, 501643); // [locked down] + { + item.LabelTo(@from, 501643); // [locked down] + } else if (House.HasSecureItem(item)) - item.LabelTo(from, 501644); // [locked down & secure] + { + item.LabelTo(@from, 501644); // [locked down & secure] + } } return base.OnSingleClick(from, o); diff --git a/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs b/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs index 9c3996f1f..72187b4af 100644 --- a/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs +++ b/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs @@ -22,20 +22,26 @@ namespace Server.Regions var ns = m.NetState; if (ns != null && !TransformationSpellHelper.UnderTransformation(m, typeof(AnimalForm)) && m.AccessLevel == AccessLevel.Player) + { ns.Send(SpeedControl.WalkSpeed); + } } public override void OnExit(Mobile m) { var ns = m.NetState; if (ns != null && !TransformationSpellHelper.UnderTransformation(m, typeof(AnimalForm))) + { ns.Send(SpeedControl.Disable); + } } private static void Desert_OnLogin(Mobile m) { if (m.Region.IsPartOf() && m.AccessLevel == AccessLevel.Player) + { m.NetState.Send(SpeedControl.WalkSpeed); + } } } } diff --git a/Projects/UOContent/Skills/Anatomy.cs b/Projects/UOContent/Skills/Anatomy.cs index 0981a6eab..80f6d7ec7 100644 --- a/Projects/UOContent/Skills/Anatomy.cs +++ b/Projects/UOContent/Skills/Anatomy.cs @@ -68,14 +68,32 @@ namespace Server.SkillHandlers var dexMod = dex / 10; var stmMod = stm / 10; - if (strMod < 0) strMod = 0; - else if (strMod > 10) strMod = 10; + if (strMod < 0) + { + strMod = 0; + } + else if (strMod > 10) + { + strMod = 10; + } - if (dexMod < 0) dexMod = 0; - else if (dexMod > 10) dexMod = 10; + if (dexMod < 0) + { + dexMod = 0; + } + else if (dexMod > 10) + { + dexMod = 10; + } - if (stmMod > 10) stmMod = 10; - else if (stmMod < 0) stmMod = 0; + if (stmMod > 10) + { + stmMod = 10; + } + else if (stmMod < 0) + { + stmMod = 0; + } if (from.CheckTargetSkill(SkillName.Anatomy, targ, 0, 100)) { @@ -87,12 +105,14 @@ namespace Server.SkillHandlers ); // That looks [strong] and [dexterous]. if (from.Skills.Anatomy.Base >= 65.0) + { targ.PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1038303 + stmMod, - from.NetState + @from.NetState ); // That being is at [10,20,...] percent endurance. + } } else { diff --git a/Projects/UOContent/Skills/AnimalLore.cs b/Projects/UOContent/Skills/AnimalLore.cs index 6b07423c8..740caedfd 100644 --- a/Projects/UOContent/Skills/AnimalLore.cs +++ b/Projects/UOContent/Skills/AnimalLore.cs @@ -135,7 +135,9 @@ namespace Server.SkillHandlers { var bd = BaseInstrument.GetBaseDifficulty(c); if (c.Uncalmable) + { bd = 0; + } AddHtmlLocalized(153, 276, 160, 18, 1070793, LabelColor); // Barding Difficulty AddHtml(320, y, 35, 18, FormatDouble(bd)); @@ -277,15 +279,25 @@ namespace Server.SkillHandlers var foodPref = 3000340; if ((c.FavoriteFood & FoodType.FruitsAndVegies) != 0) + { foodPref = 1049565; // Fruits and Vegetables + } else if ((c.FavoriteFood & FoodType.GrainsAndHay) != 0) + { foodPref = 1049566; // Grains and Hay + } else if ((c.FavoriteFood & FoodType.Fish) != 0) + { foodPref = 1049568; // Fish + } else if ((c.FavoriteFood & FoodType.Meat) != 0) + { foodPref = 1049564; // Meat + } else if ((c.FavoriteFood & FoodType.Eggs) != 0) + { foodPref = 1044477; // Eggs + } AddHtmlLocalized(153, 168, 160, 18, foodPref, LabelColor); @@ -295,21 +307,37 @@ namespace Server.SkillHandlers var packInstinct = 3000340; if ((c.PackInstinct & PackInstinct.Canine) != 0) + { packInstinct = 1049570; // Canine + } else if ((c.PackInstinct & PackInstinct.Ostard) != 0) + { packInstinct = 1049571; // Ostard + } else if ((c.PackInstinct & PackInstinct.Feline) != 0) + { packInstinct = 1049572; // Feline + } else if ((c.PackInstinct & PackInstinct.Arachnid) != 0) + { packInstinct = 1049573; // Arachnid + } else if ((c.PackInstinct & PackInstinct.Daemon) != 0) + { packInstinct = 1049574; // Daemon + } else if ((c.PackInstinct & PackInstinct.Bear) != 0) + { packInstinct = 1049575; // Bear + } else if ((c.PackInstinct & PackInstinct.Equine) != 0) + { packInstinct = 1049576; // Equine + } else if ((c.PackInstinct & PackInstinct.Bull) != 0) + { packInstinct = 1049577; // Bull + } AddHtmlLocalized(153, 204, 160, 18, packInstinct, LabelColor); @@ -337,7 +365,9 @@ namespace Server.SkillHandlers var skill = c.Skills[name]; if (skill.Base < 10.0) + { return "
---
"; + } return $"
{skill.Value:F1}
"; } @@ -345,7 +375,9 @@ namespace Server.SkillHandlers private static string FormatAttributes(int cur, int max) { if (max == 0) + { return "
---
"; + } return $"
{cur}/{max}
"; } @@ -353,7 +385,9 @@ namespace Server.SkillHandlers private static string FormatStat(int val) { if (val == 0) + { return "
---
"; + } return $"
{val}
"; } @@ -361,7 +395,9 @@ namespace Server.SkillHandlers private static string FormatDouble(double val) { if (val == 0) + { return "
---
"; + } return $"
{val:F1}
"; } @@ -369,7 +405,9 @@ namespace Server.SkillHandlers private static string FormatElement(int val) { if (val <= 0) + { return "
---
"; + } return $"
{val}%
"; } @@ -377,7 +415,9 @@ namespace Server.SkillHandlers private static string FormatDamage(int min, int max) { if (min <= 0 || max <= 0) + { return "
---
"; + } return $"
{min}-{max}
"; } diff --git a/Projects/UOContent/Skills/AnimalTaming.cs b/Projects/UOContent/Skills/AnimalTaming.cs index 95b7ff377..a8eba8f4b 100644 --- a/Projects/UOContent/Skills/AnimalTaming.cs +++ b/Projects/UOContent/Skills/AnimalTaming.cs @@ -29,7 +29,9 @@ namespace Server.SkillHandlers m.RevealingAction(); if (!DisableMessage) + { m.SendLocalizedMessage(502789); // Tame which animal? + } return TimeSpan.FromHours(6.0); } @@ -46,13 +48,19 @@ namespace Server.SkillHandlers public static void ScaleStats(BaseCreature bc, double scalar) { if (bc.RawStr > 0) + { bc.RawStr = (int)Math.Max(1, bc.RawStr * scalar); + } if (bc.RawDex > 0) + { bc.RawDex = (int)Math.Max(1, bc.RawDex * scalar); + } if (bc.RawInt > 0) + { bc.RawInt = (int)Math.Max(1, bc.RawInt * scalar); + } if (bc.HitsMaxSeed > 0) { @@ -80,7 +88,10 @@ namespace Server.SkillHandlers bc.Skills[i].Cap = Math.Max(100.0, bc.Skills[i].Cap * capScalar); - if (bc.Skills[i].Base > bc.Skills[i].Cap) bc.Skills[i].Cap = bc.Skills[i].Base; + if (bc.Skills[i].Base > bc.Skills[i].Cap) + { + bc.Skills[i].Cap = bc.Skills[i].Base; + } } } @@ -95,7 +106,9 @@ namespace Server.SkillHandlers protected override void OnTargetFinish(Mobile from) { if (m_SetSkillTime) - from.NextSkillTime = Core.TickCount; + { + @from.NextSkillTime = Core.TickCount; + } } protected override void OnTarget(Mobile from, object targeted) @@ -250,9 +263,13 @@ namespace Server.SkillHandlers creature.Direction = creature.GetDirectionTo(from); if (creature.BardPacified && Utility.RandomDouble() > .24) + { Timer.DelayCall(TimeSpan.FromSeconds(2.0), Pacify, creature); + } else + { creature.BardEndTime = DateTime.UtcNow; + } creature.BardPacified = false; @@ -261,7 +278,9 @@ namespace Server.SkillHandlers if (from is PlayerMobile pm && !(pm.HonorActive || TransformationSpellHelper.UnderTransformation(pm, typeof(EtherealVoyageSpell)))) + { creature.Combatant = pm; + } } else { @@ -427,10 +446,14 @@ namespace Server.SkillHandlers } if (!alreadyOwned) // Passively check animal lore for gain + { m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0); + } if (m_Creature.Paralyzed) + { m_Paralyzed = true; + } } else { @@ -439,15 +462,21 @@ namespace Server.SkillHandlers m_BeingTamed.Remove(m_Creature); if (m_Creature.Paralyzed) + { m_Paralyzed = true; + } if (!alreadyOwned) // Passively check animal lore for gain + { m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0); + } var minSkill = m_Creature.MinTameSkill + m_Creature.Owners.Count * 6.0; if (minSkill > -24.9 && CheckMastery(m_Tamer, m_Creature)) + { minSkill = -24.9; // 50% at 0.0? + } minSkill += 24.9; @@ -476,7 +505,9 @@ namespace Server.SkillHandlers } if (m_Creature.StatLossAfterTame) + { ScaleStats(m_Creature, 0.50); + } } if (alreadyOwned) diff --git a/Projects/UOContent/Skills/ArmsLore.cs b/Projects/UOContent/Skills/ArmsLore.cs index 13b9fb583..80d069530 100644 --- a/Projects/UOContent/Skills/ArmsLore.cs +++ b/Projects/UOContent/Skills/ArmsLore.cs @@ -44,25 +44,41 @@ namespace Server.SkillHandlers var hand = weap.Layer == Layer.OneHanded ? 0 : 1; if (damage < 3) + { damage = 0; + } else + { damage = (int)Math.Ceiling(Math.Min(damage, 30) / 5.0); + } var type = weap.Type; if (type == WeaponType.Ranged) - from.SendLocalizedMessage(1038224 + damage * 9); + { + @from.SendLocalizedMessage(1038224 + damage * 9); + } else if (type == WeaponType.Piercing) - from.SendLocalizedMessage(1038218 + hand + damage * 9); + { + @from.SendLocalizedMessage(1038218 + hand + damage * 9); + } else if (type == WeaponType.Slashing) - from.SendLocalizedMessage(1038220 + hand + damage * 9); + { + @from.SendLocalizedMessage(1038220 + hand + damage * 9); + } else if (type == WeaponType.Bashing) - from.SendLocalizedMessage(1038222 + hand + damage * 9); + { + @from.SendLocalizedMessage(1038222 + hand + damage * 9); + } else - from.SendLocalizedMessage(1038216 + hand + damage * 9); + { + @from.SendLocalizedMessage(1038216 + hand + damage * 9); + } if (weap.Poison != null && weap.PoisonCharges > 0) - from.SendLocalizedMessage(1038284); // It appears to have poison smeared on it. + { + @from.SendLocalizedMessage(1038284); // It appears to have poison smeared on it. + } } else { @@ -94,9 +110,13 @@ namespace Server.SkillHandlers var perc = 4 * pet.BardingHP / pet.BardingMaxHP; if (perc < 0) + { perc = 0; + } else if (perc > 4) + { perc = 4; + } pet.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1053021 - perc, from.NetState); } diff --git a/Projects/UOContent/Skills/Begging.cs b/Projects/UOContent/Skills/Begging.cs index eb63b2af3..3e3e9f577 100644 --- a/Projects/UOContent/Skills/Begging.cs +++ b/Projects/UOContent/Skills/Begging.cs @@ -36,7 +36,9 @@ namespace Server.SkillHandlers protected override void OnTargetFinish(Mobile from) { if (m_SetSkillTime) - from.NextSkillTime = Core.TickCount; + { + @from.NextSkillTime = Core.TickCount; + } } protected override void OnTarget(Mobile from, object targeted) @@ -58,9 +60,13 @@ namespace Server.SkillHandlers else if (!from.InRange(targ, 2)) { if (!targ.Female) + { number = 500401; // You are too far away to beg from him. + } else + { number = 500402; // You are too far away to beg from her. + } } else if (!Core.ML && from.Mounted ) // If we're on a mount, who would give us money? TODO: guessed it's removed since ML @@ -86,7 +92,9 @@ namespace Server.SkillHandlers } if (number != -1) - from.SendLocalizedMessage(number); + { + @from.SendLocalizedMessage(number); + } } private class InternalTimer : Timer @@ -125,12 +133,18 @@ namespace Server.SkillHandlers var max = 10 + m_From.Fame / 2500; if (max > 14) + { max = 14; + } else if (max < 10) + { max = 10; + } if (toConsume > max) + { toConsume = max; + } if (toConsume > 0) { @@ -154,7 +168,9 @@ namespace Server.SkillHandlers var toLose = m_From.Karma + 3000; if (toLose > 40) + { toLose = 40; + } Titles.AwardKarma(m_From, -toLose, true); } diff --git a/Projects/UOContent/Skills/DetectHidden.cs b/Projects/UOContent/Skills/DetectHidden.cs index 2227f295c..2782e0a6e 100644 --- a/Projects/UOContent/Skills/DetectHidden.cs +++ b/Projects/UOContent/Skills/DetectHidden.cs @@ -33,32 +33,45 @@ namespace Server.SkillHandlers Point3D p; if (targ is Mobile mobile) + { p = mobile.Location; + } else if (targ is Item item) + { p = item.Location; + } else if (targ is IPoint3D d) + { p = new Point3D(d); + } else + { p = src.Location; + } var srcSkill = src.Skills.DetectHidden.Value; var range = (int)(srcSkill / 10.0); if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0)) + { range /= 2; + } var house = BaseHouse.FindHouseAt(p, src.Map, 16); var inHouse = house?.IsFriend(src) == true; if (inHouse) + { range = 22; + } if (range > 0) { var inRange = src.Map.GetMobilesInRange(p, range); foreach (var trg in inRange) + { if (trg.Hidden && src != trg) { var ss = srcSkill + Utility.Random(21) - 10; @@ -67,13 +80,16 @@ namespace Server.SkillHandlers if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || inHouse && house.IsInside(trg))) { if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y)) + { continue; + } trg.RevealingAction(); trg.SendLocalizedMessage(500814); // You have been revealed! foundAnyone = true; } } + } inRange.Free(); @@ -82,6 +98,7 @@ namespace Server.SkillHandlers var itemsInRange = src.Map.GetItemsInRange(p, range); foreach (var trap in itemsInRange) + { if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0)) { src.SendLocalizedMessage( @@ -95,12 +112,16 @@ namespace Server.SkillHandlers foundAnyone = true; } + } itemsInRange.Free(); } } - if (!foundAnyone) src.SendLocalizedMessage(500817); // You can see nothing hidden there. + if (!foundAnyone) + { + src.SendLocalizedMessage(500817); // You can see nothing hidden there. + } } } } diff --git a/Projects/UOContent/Skills/Discordance.cs b/Projects/UOContent/Skills/Discordance.cs index cf4cb2735..a91cf6f75 100644 --- a/Projects/UOContent/Skills/Discordance.cs +++ b/Projects/UOContent/Skills/Discordance.cs @@ -35,7 +35,9 @@ namespace Server.SkillHandlers public static bool GetEffect(Mobile targ, ref int effect) { if (!m_Table.TryGetValue(targ, out var info)) + { return false; + } effect = info.m_Effect; return true; @@ -59,7 +61,9 @@ namespace Server.SkillHandlers var maxRange = BaseInstrument.GetBardRange(from, SkillName.Discordance); if (from.Map != targ.Map || range > maxRange) + { ends = true; + } } if (ends && info.m_Ending && info.m_EndTime < DateTime.UtcNow) @@ -115,11 +119,17 @@ namespace Server.SkillHandlers var mod = m_Mods[i]; if (mod is ResistanceMod resistanceMod) + { m_Creature.AddResistanceMod(resistanceMod); + } else if (mod is StatMod statMod) + { m_Creature.AddStatMod(statMod); + } else if (mod is SkillMod skillMod) + { m_Creature.AddSkillMod(skillMod); + } } } @@ -130,11 +140,17 @@ namespace Server.SkillHandlers var mod = m_Mods[i]; if (mod is ResistanceMod resistanceMod) + { m_Creature.RemoveResistanceMod(resistanceMod); + } else if (mod is StatMod statMod) + { m_Creature.RemoveStatMod(statMod.Name); + } else if (mod is SkillMod skillMod) + { m_Creature.RemoveSkillMod(skillMod); + } } } } @@ -179,7 +195,9 @@ namespace Server.SkillHandlers var music = from.Skills.Musicianship.Value; if (music > 100.0) + { diff -= (music - 100.0) * 0.5; + } if (!BaseInstrument.CheckMusicianship(from)) { @@ -202,12 +220,18 @@ namespace Server.SkillHandlers var discord = from.Skills.Discordance.Value; if (discord > 100.0) + { effect = -20 + (int)((discord - 100.0) / -2.5); + } else + { effect = (int)(discord / -5.0); + } if (Core.SE && BaseInstrument.GetBaseDifficulty(targ) >= 160.0) + { effect /= 2; + } scalar = effect * 0.01; @@ -218,8 +242,12 @@ namespace Server.SkillHandlers mods.Add(new ResistanceMod(ResistanceType.Energy, effect)); for (var i = 0; i < targ.Skills.Length; ++i) + { if (targ.Skills[i].Value > 0) + { mods.Add(new DefaultSkillMod((SkillName)i, true, targ.Skills[i].Value * scalar)); + } + } } else { @@ -252,8 +280,12 @@ namespace Server.SkillHandlers ); for (var i = 0; i < targ.Skills.Length; ++i) + { if (targ.Skills[i].Value > 0) + { mods.Add(new DefaultSkillMod((SkillName)i, true, targ.Skills[i].Value * scalar)); + } + } } var info = new DiscordanceInfo(from, targ, Math.Abs(effect), mods); diff --git a/Projects/UOContent/Skills/EvalInt.cs b/Projects/UOContent/Skills/EvalInt.cs index 2f80ce09a..c22004450 100644 --- a/Projects/UOContent/Skills/EvalInt.cs +++ b/Projects/UOContent/Skills/EvalInt.cs @@ -65,9 +65,13 @@ namespace Server.SkillHandlers int body; if (targ.Body.IsHuman) + { body = targ.Female ? 11 : 0; + } else + { body = 22; + } if (from.CheckTargetSkill(SkillName.EvalInt, targ, 0.0, 120.0)) { @@ -79,12 +83,14 @@ namespace Server.SkillHandlers ); // He/She/It looks [slighly less intelligent than a rock.] [Of Average intellect] [etc...] if (from.Skills.EvalInt.Base >= 76.0) + { targ.PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1038202 + mnMod, - from.NetState + @from.NetState ); // That being is at [10,20,...] percent mental strength. + } } else { diff --git a/Projects/UOContent/Skills/ForensicEval.cs b/Projects/UOContent/Skills/ForensicEval.cs index 0a26ac3e1..877b85ace 100644 --- a/Projects/UOContent/Skills/ForensicEval.cs +++ b/Projects/UOContent/Skills/ForensicEval.cs @@ -36,9 +36,13 @@ namespace Server.SkillHandlers if (from.CheckTargetSkill(SkillName.Forensics, target, 40.0, 100.0)) { if (target is PlayerMobile pm && pm.NpcGuild == NpcGuild.ThievesGuild) - from.SendLocalizedMessage(501004); // That individual is a thief! + { + @from.SendLocalizedMessage(501004); // That individual is a thief! + } else - from.SendLocalizedMessage(501003); // You notice nothing unusual. + { + @from.SendLocalizedMessage(501003); // You notice nothing unusual. + } } else { @@ -50,18 +54,24 @@ namespace Server.SkillHandlers if (from.CheckTargetSkill(SkillName.Forensics, c, 0.0, 100.0)) { if (c.m_Forensicist != null) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1042750, c.m_Forensicist ); // The forensicist ~1_NAME~ has already discovered that: + } else - c.m_Forensicist = from.Name; + { + c.m_Forensicist = @from.Name; + } if (((Body)c.Amount).IsHuman) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1042751, c.Killer == null ? "no one" : c.Killer.Name ); // This person was killed by ~1_KILLER_NAME~ + } if (c.Looters.Count > 0) { @@ -69,7 +79,10 @@ namespace Server.SkillHandlers for (var i = 0; i < c.Looters.Count; i++) { if (i > 0) + { sb.Append(", "); + } + sb.Append(c.Looters[i].Name); } @@ -91,9 +104,13 @@ namespace Server.SkillHandlers else if (target is ILockpickable p) { if (p.Picker != null) - from.SendLocalizedMessage(1042749, p.Picker.Name); // This lock was opened by ~1_PICKER_NAME~ + { + @from.SendLocalizedMessage(1042749, p.Picker.Name); // This lock was opened by ~1_PICKER_NAME~ + } else - from.SendLocalizedMessage(501003); // You notice nothing unusual. + { + @from.SendLocalizedMessage(501003); // You notice nothing unusual. + } } } } diff --git a/Projects/UOContent/Skills/Hiding.cs b/Projects/UOContent/Skills/Hiding.cs index c0531a436..778e18ffd 100644 --- a/Projects/UOContent/Skills/Hiding.cs +++ b/Projects/UOContent/Skills/Hiding.cs @@ -23,7 +23,10 @@ namespace Server.SkillHandlers return TimeSpan.FromSeconds(1.0); } - if (Core.ML && m.Target != null) Target.Cancel(m); + if (Core.ML && m.Target != null) + { + Target.Cancel(m); + } var bonus = 0.0; @@ -41,7 +44,9 @@ namespace Server.SkillHandlers BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16); if (house != null) + { bonus = 50.0; + } } // int range = 18 - (int)(m.Skills.Hiding.Value / 10); @@ -57,8 +62,12 @@ namespace Server.SkillHandlers if (ok) { if (!CombatOverride) + { if (m.GetMobilesInRange(range).Any(check => check.InLOS(m) && check.Combatant == m)) + { badCombat = true; + } + } ok = !badCombat && m.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus); } diff --git a/Projects/UOContent/Skills/Inscribe.cs b/Projects/UOContent/Skills/Inscribe.cs index 9f940d0fe..e1423478d 100644 --- a/Projects/UOContent/Skills/Inscribe.cs +++ b/Projects/UOContent/Skills/Inscribe.cs @@ -62,7 +62,9 @@ namespace Server.SkillHandlers pageDst.Lines = new string[length]; for (var j = 0; j < length; j++) + { pageDst.Lines[j] = pageSrc.Lines[j]; + } } } @@ -99,9 +101,11 @@ namespace Server.SkillHandlers protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { if (cancelType == TargetCancelType.Timeout) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 501619 ); // You have waited too long to make your inscribe selection, your inscription attempt has timed out. + } } } @@ -114,7 +118,9 @@ namespace Server.SkillHandlers protected override void OnTarget(Mobile from, object targeted) { if (m_BookSrc.Deleted) + { return; + } if (!(targeted is BaseBook bookDst)) { @@ -155,9 +161,11 @@ namespace Server.SkillHandlers protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { if (cancelType == TargetCancelType.Timeout) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 501619 ); // You have waited too long to make your inscribe selection, your inscription attempt has timed out. + } } protected override void OnTargetFinish(Mobile from) diff --git a/Projects/UOContent/Skills/ItemIdentification.cs b/Projects/UOContent/Skills/ItemIdentification.cs index 6e87b8ad7..be8cbd13a 100644 --- a/Projects/UOContent/Skills/ItemIdentification.cs +++ b/Projects/UOContent/Skills/ItemIdentification.cs @@ -31,12 +31,18 @@ namespace Server.Items if (from.CheckTargetSkill(SkillName.ItemID, item, 0, 100)) { if (item is BaseWeapon weapon) + { weapon.Identified = true; + } else if (item is BaseArmor armor) + { armor.Identified = true; + } if (!Core.AOS) - item.OnSingleClick(from); + { + item.OnSingleClick(@from); + } } else { diff --git a/Projects/UOContent/Skills/Meditation.cs b/Projects/UOContent/Skills/Meditation.cs index 45249db7f..123b63d63 100644 --- a/Projects/UOContent/Skills/Meditation.cs +++ b/Projects/UOContent/Skills/Meditation.cs @@ -14,16 +14,24 @@ namespace Server.SkillHandlers public static bool CheckOkayHolding(Item item) { if (item == null) + { return true; + } if (item is Spellbook || item is Runebook) + { return true; + } if (Core.AOS && item is BaseWeapon weapon && weapon.Attributes.SpellChanneling != 0) + { return true; + } if (Core.AOS && item is BaseArmor armor && armor.Attributes.SpellChanneling != 0) + { return true; + } return false; } @@ -66,10 +74,14 @@ namespace Server.SkillHandlers if (Core.AOS && m.Player) { if (!CheckOkayHolding(oneHanded)) + { m.AddToBackpack(oneHanded); + } if (!CheckOkayHolding(twoHanded)) + { m.AddToBackpack(twoHanded); + } } else if (!CheckOkayHolding(oneHanded) || !CheckOkayHolding(twoHanded)) { @@ -90,7 +102,9 @@ namespace Server.SkillHandlers BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.ActiveMeditation, 1075657)); if (m.Player || m.Body.IsHuman) + { m.PlaySound(0xF9); + } } else { diff --git a/Projects/UOContent/Skills/Peacemaking.cs b/Projects/UOContent/Skills/Peacemaking.cs index 9f9b1ce9d..37b79f821 100644 --- a/Projects/UOContent/Skills/Peacemaking.cs +++ b/Projects/UOContent/Skills/Peacemaking.cs @@ -45,7 +45,9 @@ namespace Server.SkillHandlers protected override void OnTargetFinish(Mobile from) { if (m_SetSkillTime) - from.NextSkillTime = Core.TickCount; + { + @from.NextSkillTime = Core.TickCount; + } } protected override void OnTarget(Mobile from, object targeted) @@ -110,7 +112,9 @@ namespace Server.SkillHandlers var bc = m as BaseCreature; if (bc?.Uncalmable == true || bc?.AreaPeaceImmune == true || m == from || !from.CanBeHarmful(m, false)) + { continue; + } calmed = true; @@ -121,15 +125,21 @@ namespace Server.SkillHandlers m.Warmode = false; if (bc?.BardPacified == false) - bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0)); + { + bc.Pacify(@from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0)); + } } if (!calmed) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1049648 ); // You play hypnotic music, but there is nothing in range for you to calm. + } else - from.SendLocalizedMessage(500615); // You play your hypnotic music, stopping the battle. + { + @from.SendLocalizedMessage(500615); // You play your hypnotic music, stopping the battle. + } } } } @@ -166,7 +176,9 @@ namespace Server.SkillHandlers var music = from.Skills.Musicianship.Value; if (music > 100.0) + { diff -= (music - 100.0) * 0.5; + } if (!from.CheckTargetSkill(SkillName.Peacemaking, targ, diff - 25.0, diff + 25.0)) { @@ -190,9 +202,13 @@ namespace Server.SkillHandlers var seconds = 100 - diff / 1.5; if (seconds > 120) + { seconds = 120; + } else if (seconds < 10) + { seconds = 10; + } bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(seconds)); } diff --git a/Projects/UOContent/Skills/Poisoning.cs b/Projects/UOContent/Skills/Poisoning.cs index 9dd8b7197..2be70dcd4 100644 --- a/Projects/UOContent/Skills/Poisoning.cs +++ b/Projects/UOContent/Skills/Poisoning.cs @@ -50,7 +50,9 @@ namespace Server.SkillHandlers protected override void OnTarget(Mobile from, object targeted) { if (m_Potion.Deleted) + { return; + } var startTimer = false; @@ -61,10 +63,14 @@ namespace Server.SkillHandlers else if (targeted is BaseWeapon weapon) { if (Core.AOS) + { startTimer = weapon.PrimaryAbility == WeaponAbility.InfectiousStrike || weapon.SecondaryAbility == WeaponAbility.InfectiousStrike; + } else if (weapon.Layer == Layer.OneHanded) + { startTimer = weapon.Type == WeaponType.Slashing || weapon.Type == WeaponType.Piercing; + } } if (startTimer) @@ -82,13 +88,17 @@ namespace Server.SkillHandlers else // Target can't be poisoned { if (Core.AOS) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1060204 ); // You cannot poison that! You can only poison infectious weapons, food or drink. + } else - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 502145 ); // You cannot poison that! You can only poison bladed or piercing weapons, food or drink. + } } } @@ -157,13 +167,17 @@ namespace Server.SkillHandlers if (m_Target is BaseWeapon weapon) { if (weapon.Type == WeaponType.Slashing) + { m_From.SendLocalizedMessage( 1010516 ); // You fail to apply a sufficient dose of poison on the blade + } else + { m_From.SendLocalizedMessage( 1010518 ); // You fail to apply a sufficient dose of poison + } } else { diff --git a/Projects/UOContent/Skills/Provocation.cs b/Projects/UOContent/Skills/Provocation.cs index a60ed28ab..7078aef11 100644 --- a/Projects/UOContent/Skills/Provocation.cs +++ b/Projects/UOContent/Skills/Provocation.cs @@ -129,7 +129,9 @@ namespace Server.SkillHandlers var music = from.Skills.Musicianship.Value; if (music > 100.0) + { diff -= (music - 100.0) * 0.5; + } if (from.CanBeHarmful(m_Creature, true) && from.CanBeHarmful(creature, true)) { diff --git a/Projects/UOContent/Skills/RemoveTrap.cs b/Projects/UOContent/Skills/RemoveTrap.cs index 69855e67f..39d22524a 100644 --- a/Projects/UOContent/Skills/RemoveTrap.cs +++ b/Projects/UOContent/Skills/RemoveTrap.cs @@ -109,13 +109,15 @@ namespace Server.SkillHandlers var silver = faction.AwardSilver(from, trap.SilverFromDisarm); if (silver > 0) - from.SendLocalizedMessage( + { + @from.SendLocalizedMessage( 1008113, true, silver.ToString( "N0" ) ); // You have been granted faction silver for removing the enemy trap : + } } trap.Delete(); @@ -126,7 +128,9 @@ namespace Server.SkillHandlers } if (!isOwner) - kit.ConsumeCharge(from); + { + kit.ConsumeCharge(@from); + } } } else diff --git a/Projects/UOContent/Skills/Snooping.cs b/Projects/UOContent/Skills/Snooping.cs index fceecf898..8bafc926c 100644 --- a/Projects/UOContent/Skills/Snooping.cs +++ b/Projects/UOContent/Skills/Snooping.cs @@ -17,15 +17,21 @@ namespace Server.SkillHandlers var map = from.Map; if (to.Player) - return from.CanBeHarmful(to, false, true); // normal restrictions + { + return @from.CanBeHarmful(to, false, true); // normal restrictions + } if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) + { return true; // felucca you can snoop anybody + } var reg = to.Region.GetRegion(); if (reg?.IsDisabled() != true) + { return true; // not in town? we can snoop any npc + } return !to.Body.IsHuman || to is BaseCreature cret && (cret.AlwaysAttackable || cret.AlwaysMurderer); } @@ -37,7 +43,9 @@ namespace Server.SkillHandlers var root = cont.RootParent as Mobile; if (root?.Alive == false) + { return; + } if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player) { @@ -63,20 +71,28 @@ namespace Server.SkillHandlers var eable = map.GetClientsInRange(from.Location, 8); foreach (var ns in eable) - if (ns.Mobile != from) + { + if (ns.Mobile != @from) + { ns.Mobile.SendMessage(message); + } + } eable.Free(); } } if (from.AccessLevel == AccessLevel.Player) - Titles.AwardKarma(from, -4, true); + { + Titles.AwardKarma(@from, -4, true); + } if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0)) { if (cont is TrappableContainer container && container.ExecuteTrap(from)) + { return; + } cont.DisplayTo(from); } @@ -85,7 +101,9 @@ namespace Server.SkillHandlers from.SendLocalizedMessage(500210); // You failed to peek into the container. if (from.Skills.Hiding.Value / 2 < Utility.Random(100)) - from.RevealingAction(); + { + @from.RevealingAction(); + } } } else diff --git a/Projects/UOContent/Skills/SpiritSpeak.cs b/Projects/UOContent/Skills/SpiritSpeak.cs index 73953f8fc..80af6a159 100644 --- a/Projects/UOContent/Skills/SpiritSpeak.cs +++ b/Projects/UOContent/Skills/SpiritSpeak.cs @@ -22,7 +22,9 @@ namespace Server.SkillHandlers spell.Cast(); if (spell.IsCasting) + { return TimeSpan.FromSeconds(5.0); + } return TimeSpan.Zero; } @@ -37,7 +39,9 @@ namespace Server.SkillHandlers var secs = m.Skills.SpiritSpeak.Base / 50; secs *= 90; if (secs < 15) + { secs = 15; + } t.Delay = TimeSpan.FromSeconds(secs); // 15seconds to 3 minutes t.Start(); @@ -95,7 +99,9 @@ namespace Server.SkillHandlers public override void OnCasterHurt() { if (IsCasting) + { Disturb(DisturbType.Hurt, false, true); + } } public override bool ConsumeReagents() => true; @@ -112,7 +118,9 @@ namespace Server.SkillHandlers public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) { if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest) + { return false; + } return true; } @@ -170,7 +178,9 @@ namespace Server.SkillHandlers Caster.SendLocalizedMessage(number); if (min > max) + { min = max; + } Caster.Hits += Utility.RandomMinMax(min, max); diff --git a/Projects/UOContent/Skills/Stealing.cs b/Projects/UOContent/Skills/Stealing.cs index 8fdaf7318..d4e6e7fed 100644 --- a/Projects/UOContent/Skills/Stealing.cs +++ b/Projects/UOContent/Skills/Stealing.cs @@ -29,10 +29,14 @@ namespace Server.SkillHandlers public static bool IsEmptyHanded(Mobile from) { if (from.FindItemOnLayer(Layer.OneHanded) != null) + { return false; + } if (from.FindItemOnLayer(Layer.TwoHanded) != null) + { return false; + } return true; } @@ -77,7 +81,9 @@ namespace Server.SkillHandlers StealableArtifactsSpawner.StealableInstance si = null; if (toSteal.Parent == null || !toSteal.Movable) + { si = StealableArtifactsSpawner.GetStealableInstance(toSteal); + } if (!IsEmptyHanded(m_Thief)) { @@ -178,7 +184,9 @@ namespace Server.SkillHandlers else { if (sig.IsBeingCorrupted) + { sig.GraceStart = DateTime.UtcNow; // begin grace period + } m_Thief.SendLocalizedMessage(1010586); // YOU STOLE THE SIGIL!!! (woah, calm down now) @@ -275,7 +283,9 @@ namespace Server.SkillHandlers pileWeight - 22.5, pileWeight + 27.5 )) + { stolen = toSteal; + } } else { @@ -288,7 +298,9 @@ namespace Server.SkillHandlers pileWeight - 22.5, pileWeight + 27.5 )) + { stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount) ?? toSteal; + } } } else @@ -297,7 +309,9 @@ namespace Server.SkillHandlers iw *= 10; if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5)) + { stolen = toSteal; + } } if (stolen != null) @@ -357,7 +371,9 @@ namespace Server.SkillHandlers from.AddToBackpack(stolen); if (!(stolen is Container || stolen.Stackable)) + { StolenItem.Add(stolen, m_Thief, mobRoot); + } } var corpse = root as Corpse; @@ -371,13 +387,19 @@ namespace Server.SkillHandlers else if (mobRoot != null) { if (!IsInGuild(mobRoot) && IsInnocentTo(m_Thief, mobRoot)) + { m_Thief.CriminalAction(false); + } var message = $"You notice {m_Thief.Name} trying to steal from {mobRoot.Name}."; foreach (var ns in m_Thief.GetClientsInRange(8)) + { if (ns.Mobile != m_Thief) + { ns.Mobile.SendMessage(message); + } + } } } else if (corpse?.IsCriminalAction(m_Thief) == true) @@ -439,11 +461,13 @@ namespace Server.SkillHandlers Clean(); foreach (var si in m_Queue) + { if (si.Stolen == item && !si.IsExpired) { victim = si.Victim; return true; } + } return false; } @@ -453,15 +477,21 @@ namespace Server.SkillHandlers Clean(); foreach (var si in m_Queue) + { if (si.Stolen.RootParent == corpse && si.Victim != null && !si.IsExpired) { if (si.Victim.AddToBackpack(si.Stolen)) + { si.Victim.SendLocalizedMessage(1010464); // the item that was stolen is returned to you. + } else + { si.Victim.SendLocalizedMessage(1010463); // the item that was stolen from you falls to the ground. + } si.Expires = DateTime.UtcNow; // such a hack } + } } public static void Clean() @@ -471,9 +501,13 @@ namespace Server.SkillHandlers var si = m_Queue.Peek(); if (si.IsExpired) + { m_Queue.Dequeue(); + } else + { break; + } } } } diff --git a/Projects/UOContent/Skills/Stealth.cs b/Projects/UOContent/Skills/Stealth.cs index 1dfd846d3..799322494 100644 --- a/Projects/UOContent/Skills/Stealth.cs +++ b/Projects/UOContent/Skills/Stealth.cs @@ -36,23 +36,31 @@ namespace Server.SkillHandlers public static int GetArmorRating(Mobile m) { if (!Core.AOS) + { return (int)m.ArmorRating; + } var ar = 0; for (var i = 0; i < m.Items.Count; i++) { if (!(m.Items[i] is BaseArmor armor)) + { continue; + } var materialType = (int)armor.MaterialType; var bodyPosition = (int)armor.BodyPosition; if (materialType >= ArmorTable.GetLength(0) || bodyPosition >= ArmorTable.GetLength(1)) + { continue; + } if (armor.ArmorAttributes.MageArmor == 0) + { ar += ArmorTable[materialType, bodyPosition]; + } } return ar; @@ -92,7 +100,9 @@ namespace Server.SkillHandlers m.AllowedStealthSteps = Math.Max((int)(m.Skills.Stealth.Value / (Core.AOS ? 5.0 : 10.0)), 1); if (m is PlayerMobile pm) + { pm.IsStealthing = true; + } m.SendLocalizedMessage(502730); // You begin to move quietly. diff --git a/Projects/UOContent/Skills/TasteID.cs b/Projects/UOContent/Skills/TasteID.cs index 5d15dc16e..dbbf8f416 100644 --- a/Projects/UOContent/Skills/TasteID.cs +++ b/Projects/UOContent/Skills/TasteID.cs @@ -37,9 +37,13 @@ namespace Server.SkillHandlers if (from.CheckTargetSkill(SkillName.TasteID, food, 0, 100)) { if (food.Poison != null) - food.SendLocalizedMessageTo(from, 1038284); // It appears to have poison smeared on it. + { + food.SendLocalizedMessageTo(@from, 1038284); // It appears to have poison smeared on it. + } else - food.SendLocalizedMessageTo(from, 1010600); // You detect nothing unusual about this substance. + { + food.SendLocalizedMessageTo(@from, 1010600); // You detect nothing unusual about this substance. + } } else { diff --git a/Projects/UOContent/SpecialSystems/Engines/GiftGiving.cs b/Projects/UOContent/SpecialSystems/Engines/GiftGiving.cs index 98f9e8a12..6c5f1a81f 100644 --- a/Projects/UOContent/SpecialSystems/Engines/GiftGiving.cs +++ b/Projects/UOContent/SpecialSystems/Engines/GiftGiving.cs @@ -27,7 +27,9 @@ namespace Server.Misc private static void EventSink_Login(Mobile m) { if (!(m.Account is Account acct)) + { return; + } var now = DateTime.UtcNow; @@ -36,13 +38,19 @@ namespace Server.Misc var giver = m_Givers[i]; if (now < giver.Start || now >= giver.Finish) + { continue; // not in the correct time frame + } if (acct.Created > giver.Start - giver.MinimumAge) + { continue; // newly created account + } if (acct.LastLogin >= giver.Start) + { continue; // already got one + } giver.DelayGiveGift(TimeSpan.FromSeconds(5.0), m); } @@ -67,7 +75,9 @@ namespace Server.Misc public virtual GiftResult GiveGift(Mobile mob, Item item) { if (mob.PlaceInBackpack(item) && !WeightOverloading.IsOverloaded(mob)) + { return GiftResult.Backpack; + } mob.BankBox.DropItem(item); return GiftResult.BankBox; diff --git a/Projects/UOContent/SpecialSystems/Engines/TestCenter.cs b/Projects/UOContent/SpecialSystems/Engines/TestCenter.cs index c853d6a77..26cf7696c 100644 --- a/Projects/UOContent/SpecialSystems/Engines/TestCenter.cs +++ b/Projects/UOContent/SpecialSystems/Engines/TestCenter.cs @@ -19,13 +19,17 @@ namespace Server.Misc { // Register our speech handler if (Enabled) + { EventSink.Speech += EventSink_Speech; + } } private static void EventSink_Speech(SpeechEventArgs args) { if (args.Handled) + { return; + } if (Insensitive.StartsWith(args.Speech, "set")) { @@ -34,24 +38,34 @@ namespace Server.Misc var split = args.Speech.Split(' '); if (split.Length == 3) + { try { var name = split[1]; var value = Convert.ToDouble(split[2]); if (Insensitive.Equals(name, "str")) - ChangeStrength(from, (int)value); + { + ChangeStrength(@from, (int)value); + } else if (Insensitive.Equals(name, "dex")) - ChangeDexterity(from, (int)value); + { + ChangeDexterity(@from, (int)value); + } else if (Insensitive.Equals(name, "int")) - ChangeIntelligence(from, (int)value); + { + ChangeIntelligence(@from, (int)value); + } else - ChangeSkill(from, name, value); + { + ChangeSkill(@from, name, value); + } } catch { // ignored } + } } else if (Insensitive.Equals(args.Speech, "help")) { @@ -149,9 +163,13 @@ namespace Server.Misc var oldFixedPoint = skill.BaseFixedPoint; if (skill.Owner.Total - oldFixedPoint + newFixedPoint > skill.Owner.Cap) - from.SendMessage("You can not exceed the skill cap. Try setting another skill lower first."); + { + @from.SendMessage("You can not exceed the skill cap. Try setting another skill lower first."); + } else + { skill.BaseFixedPoint = newFixedPoint; + } } } else @@ -198,7 +216,9 @@ namespace Server.Misc var sb = new StringBuilder(); if (strings.Length > 0) + { sb.Append(strings[0]); + } for (var i = 1; i < strings.Length; ++i) { @@ -228,6 +248,7 @@ namespace Server.Misc } if (sb.Length > 0) + { sender.Send( new AsciiMessage( Server.Serial.MinusOne, @@ -239,6 +260,7 @@ namespace Server.Misc sb.ToString() ) ); + } break; } diff --git a/Projects/UOContent/SpecialSystems/Items/Stones/AlchemyStone.cs b/Projects/UOContent/SpecialSystems/Items/Stones/AlchemyStone.cs index 6976eff11..5e6286613 100644 --- a/Projects/UOContent/SpecialSystems/Items/Stones/AlchemyStone.cs +++ b/Projects/UOContent/SpecialSystems/Items/Stones/AlchemyStone.cs @@ -20,7 +20,9 @@ namespace Server.Items var alcBag = new AlchemyBag(); if (!from.AddToBackpack(alcBag)) + { alcBag.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/SpecialSystems/Items/Stones/IngotStone.cs b/Projects/UOContent/SpecialSystems/Items/Stones/IngotStone.cs index 2ac1b509b..53c9a5813 100644 --- a/Projects/UOContent/SpecialSystems/Items/Stones/IngotStone.cs +++ b/Projects/UOContent/SpecialSystems/Items/Stones/IngotStone.cs @@ -20,7 +20,9 @@ namespace Server.Items var ingotBag = new BagOfingots(); if (!from.AddToBackpack(ingotBag)) + { ingotBag.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/SpecialSystems/Items/Stones/RegStone.cs b/Projects/UOContent/SpecialSystems/Items/Stones/RegStone.cs index ea7a06ee1..1c5b327b5 100644 --- a/Projects/UOContent/SpecialSystems/Items/Stones/RegStone.cs +++ b/Projects/UOContent/SpecialSystems/Items/Stones/RegStone.cs @@ -20,7 +20,9 @@ namespace Server.Items var regBag = new BagOfReagents(); if (!from.AddToBackpack(regBag)) + { regBag.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/SpecialSystems/Items/Stones/ScribeStone.cs b/Projects/UOContent/SpecialSystems/Items/Stones/ScribeStone.cs index 3ae0ba49b..a42b4ae9d 100644 --- a/Projects/UOContent/SpecialSystems/Items/Stones/ScribeStone.cs +++ b/Projects/UOContent/SpecialSystems/Items/Stones/ScribeStone.cs @@ -20,7 +20,9 @@ namespace Server.Items var scribeBag = new ScribeBag(); if (!from.AddToBackpack(scribeBag)) + { scribeBag.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/SpecialSystems/Items/Stones/SmithStone.cs b/Projects/UOContent/SpecialSystems/Items/Stones/SmithStone.cs index bfc294963..c9f698001 100644 --- a/Projects/UOContent/SpecialSystems/Items/Stones/SmithStone.cs +++ b/Projects/UOContent/SpecialSystems/Items/Stones/SmithStone.cs @@ -20,7 +20,9 @@ namespace Server.Items var SmithBag = new SmithBag(); if (!from.AddToBackpack(SmithBag)) + { SmithBag.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/SpecialSystems/Items/Stones/TailorStone.cs b/Projects/UOContent/SpecialSystems/Items/Stones/TailorStone.cs index e166b18a5..2094795c0 100644 --- a/Projects/UOContent/SpecialSystems/Items/Stones/TailorStone.cs +++ b/Projects/UOContent/SpecialSystems/Items/Stones/TailorStone.cs @@ -20,7 +20,9 @@ namespace Server.Items var tailorBag = new TailorBag(); if (!from.AddToBackpack(tailorBag)) + { tailorBag.Delete(); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Spells/Base/MagerySpell.cs b/Projects/UOContent/Spells/Base/MagerySpell.cs index 147e1521f..d496cf100 100644 --- a/Projects/UOContent/Spells/Base/MagerySpell.cs +++ b/Projects/UOContent/Spells/Base/MagerySpell.cs @@ -26,7 +26,9 @@ namespace Server.Spells var circle = (int)Circle; if (Scroll != null) + { circle -= 2; + } var avg = ChanceLength * circle; @@ -42,7 +44,9 @@ namespace Server.Spells maxSkill += (1 + (int)Circle / 6) * 25; if (m.Skills.MagicResist.Value < maxSkill) + { m.CheckSkill(SkillName.MagicResist, 0.0, m.Skills.MagicResist.Cap); + } return m.Skills.MagicResist.Value; } @@ -54,16 +58,22 @@ namespace Server.Spells n /= 100.0; if (n <= 0.0) + { return false; + } if (n >= 1.0) + { return true; + } var maxSkill = (1 + (int)Circle) * 10; maxSkill += (1 + (int)Circle / 6) * 25; if (target.Skills.MagicResist.Value < maxSkill) + { target.CheckSkill(SkillName.MagicResist, 0.0, target.Skills.MagicResist.Cap); + } return n >= Utility.RandomDouble(); } diff --git a/Projects/UOContent/Spells/Base/SpellInfo.cs b/Projects/UOContent/Spells/Base/SpellInfo.cs index 4f8b8c341..2a364dce0 100644 --- a/Projects/UOContent/Spells/Base/SpellInfo.cs +++ b/Projects/UOContent/Spells/Base/SpellInfo.cs @@ -85,7 +85,9 @@ namespace Server.Spells Amounts = new int[regs.Length]; for (var i = 0; i < regs.Length; ++i) + { Amounts[i] = 1; + } } public int Action { get; set; } diff --git a/Projects/UOContent/Spells/Base/SpellRegistry.cs b/Projects/UOContent/Spells/Base/SpellRegistry.cs index 2352db892..95ed5dbb5 100644 --- a/Projects/UOContent/Spells/Base/SpellRegistry.cs +++ b/Projects/UOContent/Spells/Base/SpellRegistry.cs @@ -49,8 +49,12 @@ namespace Server.Spells m_Count = 0; for (var i = 0; i < m_Types.Length; ++i) + { if (m_Types[i] != null) + { ++m_Count; + } + } } return m_Count; @@ -68,10 +72,14 @@ namespace Server.Spells public static void Register(int spellID, Type type) { if (spellID < 0 || spellID >= m_Types.Length) + { return; + } if (m_Types[spellID] == null) + { ++m_Count; + } m_Types[spellID] = type; @@ -91,19 +99,25 @@ namespace Server.Spells } if (spm != null) + { SpecialMoves.Add(spellID, spm); + } } } public static SpecialMove GetSpecialMove(int spellID) { if (spellID < 0 || spellID >= m_Types.Length) + { return null; + } var t = m_Types[spellID]; if (t == null || !t.IsSubclassOf(typeof(SpecialMove))) + { return null; + } SpecialMoves.TryGetValue(spellID, out var move); return move; @@ -112,7 +126,9 @@ namespace Server.Spells public static Spell NewSpell(int spellID, Mobile caster, Item scroll) { if (spellID < 0 || spellID >= m_Types.Length) + { return null; + } var t = m_Types[spellID]; diff --git a/Projects/UOContent/Spells/Bushido/CounterAttack.cs b/Projects/UOContent/Spells/Bushido/CounterAttack.cs index 9652c64de..06bcd092b 100644 --- a/Projects/UOContent/Spells/Bushido/CounterAttack.cs +++ b/Projects/UOContent/Spells/Bushido/CounterAttack.cs @@ -27,16 +27,24 @@ namespace Server.Spells.Bushido public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield) + { return true; + } if (Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon) + { return true; + } if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseWeapon) + { return true; + } Caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability! return false; diff --git a/Projects/UOContent/Spells/Bushido/Evasion.cs b/Projects/UOContent/Spells/Bushido/Evasion.cs index 9de5596ef..24bc2c0b8 100644 --- a/Projects/UOContent/Spells/Bushido/Evasion.cs +++ b/Projects/UOContent/Spells/Bushido/Evasion.cs @@ -30,32 +30,46 @@ namespace Server.Spells.Bushido public static bool VerifyCast(Mobile caster, bool messages) { if (caster == null) // Sanity + { return false; + } if (!(caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + { weap = caster.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; + } if (weap != null) { if (Core.ML && caster.Skills[weap.Skill].Base < 50) { if (messages) + { caster.SendLocalizedMessage( 1076206 ); // Your skill with your equipped weapon must be 50 or higher to use Evasion. + } + return false; } } else if (!(caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) { if (messages) + { caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability! + } + return false; } if (!caster.CanBeginAction()) { - if (messages) caster.SendLocalizedMessage(501789); // You must wait before trying again. + if (messages) + { + caster.SendLocalizedMessage(501789); // You must wait before trying again. + } + return false; } @@ -65,15 +79,23 @@ namespace Server.Spells.Bushido public static bool CheckSpellEvasion(Mobile defender) { if (!(defender.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + { weap = defender.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; + } if (Core.ML) { - if (defender.Spell?.IsCasting == true) return false; + if (defender.Spell?.IsCasting == true) + { + return false; + } if (weap != null) { - if (defender.Skills[weap.Skill].Base < 50) return false; + if (defender.Skills[weap.Skill].Base < 50) + { + return false; + } } else if (!(defender.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) { @@ -130,16 +152,22 @@ namespace Server.Spells.Bushido */ if (!Core.ML) + { return TimeSpan.FromSeconds(8.0); + } double seconds = 3; if (m.Skills.Bushido.Value > 60) + { seconds += (m.Skills.Bushido.Value - 60) / 20; + } if (m.Skills.Anatomy.Value >= 100.0 && m.Skills.Tactics.Value >= 100.0 && m.Skills.Bushido.Value > 100.0 ) // Bushido being HIGHER than 100 for bonus is intended + { seconds++; + } return TimeSpan.FromSeconds((int)seconds); } @@ -156,16 +184,22 @@ namespace Server.Spells.Bushido */ if (!Core.ML) + { return 1.5; + } double bonus = 0; if (m.Skills.Bushido.Value >= 60) + { bonus += (m.Skills.Bushido.Value - 60) * .004 + 0.16; + } if (m.Skills.Anatomy.Value >= 100 && m.Skills.Tactics.Value >= 100 && m.Skills.Bushido.Value > 100 ) // Bushido being HIGHER than 100 for bonus is intended + { bonus += 0.10; + } return 1.0 + bonus; } diff --git a/Projects/UOContent/Spells/Bushido/MomentumStrike.cs b/Projects/UOContent/Spells/Bushido/MomentumStrike.cs index 2ece6c6ef..8dc9042a0 100644 --- a/Projects/UOContent/Spells/Bushido/MomentumStrike.cs +++ b/Projects/UOContent/Spells/Bushido/MomentumStrike.cs @@ -13,7 +13,9 @@ namespace Server.Spells.Bushido public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, false)) + { return; + } ClearCurrentMove(attacker); @@ -31,14 +33,18 @@ namespace Server.Spells.Bushido } if (!CheckMana(attacker, true)) + { return; + } var target = targets.RandomElement(); var damageBonus = attacker.Skills.Bushido.Value / 100.0; if (!defender.Alive) + { damageBonus *= 1.5; + } attacker.SendLocalizedMessage(1063171); // You transfer the momentum of your weapon into another enemy! target.SendLocalizedMessage(1063172); // You were hit by the momentum of a Samurai's weapon! diff --git a/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs b/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs index 856ac7382..6d72a6e41 100644 --- a/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs +++ b/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs @@ -33,7 +33,9 @@ namespace Server.Spells.Bushido var mana = ScaleMana(RequiredMana); if (!base.CheckCast()) + { return false; + } if (!CheckExpansion(Caster)) { @@ -86,7 +88,9 @@ namespace Server.Spells.Bushido } if (!base.CheckFizzle()) + { return false; + } Caster.Mana -= mana; @@ -104,18 +108,26 @@ namespace Server.Spells.Bushido public virtual void OnCastSuccessful(Mobile caster) { if (Evasion.IsEvading(caster)) + { Evasion.EndEvasion(caster); + } if (Confidence.IsConfident(caster)) + { Confidence.EndConfidence(caster); + } if (CounterAttack.IsCountering(caster)) + { CounterAttack.StopCountering(caster); + } var spellID = SpellRegistry.GetRegistryNumber(this); if (spellID > 0) + { caster.Send(new ToggleSpecialAbility(spellID + 1, true)); + } } public static void OnEffectEnd(Mobile caster, Type type) @@ -123,7 +135,9 @@ namespace Server.Spells.Bushido var spellID = SpellRegistry.GetRegistryNumber(type); if (spellID > 0) + { caster.Send(new ToggleSpecialAbility(spellID + 1, false)); + } } } } diff --git a/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs b/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs index 6b35de5fe..57be69bef 100644 --- a/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs +++ b/Projects/UOContent/Spells/Chivalry/CleanseByFire.cs @@ -27,7 +27,9 @@ namespace Server.Spells.Chivalry public void Target(Mobile m) { if (m == null) + { return; + } if (!m.Poisoned) { @@ -54,7 +56,9 @@ namespace Server.Spells.Chivalry if (m.CurePoison(Caster)) { if (Caster != m) + { Caster.SendLocalizedMessage(1010058); // You have cured the target of all poisons! + } m.SendLocalizedMessage(1010059); // You have been cured of all poisons. } diff --git a/Projects/UOContent/Spells/Chivalry/CloseWounds.cs b/Projects/UOContent/Spells/Chivalry/CloseWounds.cs index d270eec61..a7f2497c2 100644 --- a/Projects/UOContent/Spells/Chivalry/CloseWounds.cs +++ b/Projects/UOContent/Spells/Chivalry/CloseWounds.cs @@ -30,7 +30,9 @@ namespace Server.Spells.Chivalry public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.InRange(m, 2)) { @@ -64,7 +66,9 @@ namespace Server.Spells.Chivalry var toHeal = Math.Clamp(ComputePowerValue(6) + Utility.RandomMinMax(0, 2), 7, 39); if (m.Hits + toHeal > m.HitsMax) + { toHeal = m.HitsMax - m.Hits; + } SpellHelper.Heal(toHeal, m, Caster, false); diff --git a/Projects/UOContent/Spells/Chivalry/DispelEvil.cs b/Projects/UOContent/Spells/Chivalry/DispelEvil.cs index 5d52aba2f..0f3d8f1a4 100644 --- a/Projects/UOContent/Spells/Chivalry/DispelEvil.cs +++ b/Projects/UOContent/Spells/Chivalry/DispelEvil.cs @@ -82,7 +82,10 @@ namespace Server.Spells.Chivalry var fleeChance = (100 - Math.Sqrt(m.Fame / 2.0)) * chiv * dispelSkill; fleeChance /= 1000000; - if (fleeChance > Utility.RandomDouble()) bc.BeginFlee(TimeSpan.FromSeconds(30.0)); + if (fleeChance > Utility.RandomDouble()) + { + bc.BeginFlee(TimeSpan.FromSeconds(30.0)); + } } } diff --git a/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs b/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs index 9e3cb9f5a..cae387370 100644 --- a/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs +++ b/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs @@ -36,10 +36,14 @@ namespace Server.Spells.Chivalry foreach (var m in Caster.GetMobilesInRange(3)) // TODO: Validate range { if (m is BaseCreature creature && creature.IsAnimatedDead) + { continue; + } if (Caster != m && m.InLOS(Caster) && Caster.CanBeBeneficial(m, false, true) && !(m is Golem)) + { targets.Add(m); + } } Caster.PlaySound(0x244); @@ -86,7 +90,9 @@ namespace Server.Spells.Chivalry Caster.DoBeneficial(m); if (Caster != m) + { Caster.SendLocalizedMessage(1010058); // You have cured the target of all poisons! + } m.SendLocalizedMessage(1010059); // You have been cured of all poisons. sendEffect = true; @@ -132,13 +138,19 @@ namespace Server.Spells.Chivalry } if (EvilOmenSpell.TryEndEffect(m)) + { sendEffect = true; + } if (StrangleSpell.RemoveCurse(m)) + { sendEffect = true; + } if (CorpseSkinSpell.RemoveCurse(m)) + { sendEffect = true; + } // TODO: Should this remove blood oath? Pain spike? diff --git a/Projects/UOContent/Spells/Chivalry/PaladinSpell.cs b/Projects/UOContent/Spells/Chivalry/PaladinSpell.cs index 294f83998..b65ded8e2 100644 --- a/Projects/UOContent/Spells/Chivalry/PaladinSpell.cs +++ b/Projects/UOContent/Spells/Chivalry/PaladinSpell.cs @@ -28,7 +28,9 @@ namespace Server.Spells.Chivalry var mana = ScaleMana(RequiredMana); if (!base.CheckCast()) + { return false; + } if (Caster.TithingPoints < RequiredTithing) { @@ -57,7 +59,9 @@ namespace Server.Spells.Chivalry var requiredTithing = RequiredTithing; if (AosAttributes.GetValue(Caster, AosAttribute.LowerRegCost) > Utility.Random(100)) + { requiredTithing = 0; + } var mana = ScaleMana(RequiredMana); @@ -83,7 +87,9 @@ namespace Server.Spells.Chivalry Caster.TithingPoints -= requiredTithing; if (!base.CheckFizzle()) + { return false; + } Caster.Mana -= mana; @@ -111,7 +117,9 @@ namespace Server.Spells.Chivalry base.OnDisturb(type, message); if (message) + { Caster.PlaySound(0x1D6); + } } public override void OnBeginCast() @@ -139,7 +147,9 @@ namespace Server.Spells.Chivalry public static int ComputePowerValue(Mobile from, int div) { if (from == null) + { return 0; + } var v = (int)Math.Sqrt(from.Karma + 20000 + from.Skills.Chivalry.Fixed * 10); diff --git a/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs b/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs index 623ba2fc7..5d2e3c63e 100644 --- a/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs +++ b/Projects/UOContent/Spells/Chivalry/RemoveCurse.cs @@ -30,7 +30,9 @@ namespace Server.Spells.Chivalry public void Target(Mobile m) { if (m == null) + { return; + } if (CheckBSequence(m)) { @@ -45,13 +47,21 @@ namespace Server.Spells.Chivalry int chance; if (Caster.Karma < -5000) + { chance = 0; + } else if (Caster.Karma < 0) + { chance = (int)Math.Sqrt(20000 + Caster.Karma) - 122; + } else if (Caster.Karma < 5625) + { chance = (int)Math.Sqrt(Caster.Karma) + 25; + } else + { chance = 100; + } if (chance > Utility.Random(100)) { @@ -80,15 +90,21 @@ namespace Server.Spells.Chivalry var mod = m.GetStatMod("[Magic] Str Offset"); if (mod?.Offset < 0) + { m.RemoveStatMod("[Magic] Str Offset"); + } mod = m.GetStatMod("[Magic] Dex Offset"); if (mod?.Offset < 0) + { m.RemoveStatMod("[Magic] Dex Offset"); + } mod = m.GetStatMod("[Magic] Int Offset"); if (mod?.Offset < 0) + { m.RemoveStatMod("[Magic] Int Offset"); + } m.Paralyzed = false; @@ -97,7 +113,11 @@ namespace Server.Spells.Chivalry CorpseSkinSpell.RemoveCurse(m); CurseSpell.RemoveEffect(m); MortalStrike.EndWound(m); - if (Core.ML) BloodOathSpell.RemoveCurse(m); + if (Core.ML) + { + BloodOathSpell.RemoveCurse(m); + } + MindRotSpell.ClearMindRotScalar(m); BuffInfo.RemoveBuff(m, BuffIcon.Clumsy); diff --git a/Projects/UOContent/Spells/Chivalry/SacredJourney.cs b/Projects/UOContent/Spells/Chivalry/SacredJourney.cs index 0b06aaacc..df669a534 100644 --- a/Projects/UOContent/Spells/Chivalry/SacredJourney.cs +++ b/Projects/UOContent/Spells/Chivalry/SacredJourney.cs @@ -88,7 +88,9 @@ namespace Server.Spells.Chivalry BaseCreature.TeleportPets(Caster, loc, map, true); if (m_Book != null) + { --m_Book.CurCharges; + } Effects.SendLocationParticles( EffectItem.Create(Caster.Location, Caster.Map, EffectItem.DefaultDuration), @@ -109,15 +111,21 @@ namespace Server.Spells.Chivalry public override void OnCast() { if (m_Entry == null) + { Caster.Target = new RecallSpellTarget(this); + } else + { Effect(m_Entry.Location, m_Entry.Map, true); + } } public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Sigil.ExistsOn(Caster)) { diff --git a/Projects/UOContent/Spells/Eighth/AirElemental.cs b/Projects/UOContent/Spells/Eighth/AirElemental.cs index d4a459283..398e20f8c 100644 --- a/Projects/UOContent/Spells/Eighth/AirElemental.cs +++ b/Projects/UOContent/Spells/Eighth/AirElemental.cs @@ -25,7 +25,9 @@ namespace Server.Spells.Eighth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 2 > Caster.FollowersMax) { @@ -43,9 +45,13 @@ namespace Server.Spells.Eighth var duration = TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5.0); if (Core.AOS) + { SpellHelper.Summon(new SummonedAirElemental(), Caster, 0x217, duration, false, false); + } else + { SpellHelper.Summon(new AirElemental(), Caster, 0x217, duration, false, false); + } } FinishSequence(); diff --git a/Projects/UOContent/Spells/Eighth/EarthElemental.cs b/Projects/UOContent/Spells/Eighth/EarthElemental.cs index 9f1ddef9d..94faf7f70 100644 --- a/Projects/UOContent/Spells/Eighth/EarthElemental.cs +++ b/Projects/UOContent/Spells/Eighth/EarthElemental.cs @@ -25,7 +25,9 @@ namespace Server.Spells.Eighth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 2 > Caster.FollowersMax) { @@ -43,9 +45,13 @@ namespace Server.Spells.Eighth var duration = TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5.0); if (Core.AOS) + { SpellHelper.Summon(new SummonedEarthElemental(), Caster, 0x217, duration, false, false); + } else + { SpellHelper.Summon(new EarthElemental(), Caster, 0x217, duration, false, false); + } } FinishSequence(); diff --git a/Projects/UOContent/Spells/Eighth/Earthquake.cs b/Projects/UOContent/Spells/Eighth/Earthquake.cs index 6ca41b687..c4dceef0e 100644 --- a/Projects/UOContent/Spells/Eighth/Earthquake.cs +++ b/Projects/UOContent/Spells/Eighth/Earthquake.cs @@ -52,7 +52,9 @@ namespace Server.Spells.Eighth damage = m.Hits / 2; if (!m.Player) + { damage = Math.Clamp(damage, 15, 100); + } damage += Utility.RandomMinMax(0, 15); } @@ -61,9 +63,13 @@ namespace Server.Spells.Eighth damage = m.Hits * 6 / 10; if (!m.Player && damage < 10) + { damage = 10; + } else if (damage > 75) + { damage = 75; + } } Caster.DoHarmful(m); diff --git a/Projects/UOContent/Spells/Eighth/EnergyVortex.cs b/Projects/UOContent/Spells/Eighth/EnergyVortex.cs index a47c02204..b723b61b0 100644 --- a/Projects/UOContent/Spells/Eighth/EnergyVortex.cs +++ b/Projects/UOContent/Spells/Eighth/EnergyVortex.cs @@ -38,9 +38,13 @@ namespace Server.Spells.Eighth TimeSpan duration; if (Core.AOS) + { duration = TimeSpan.FromSeconds(90.0); + } else + { duration = TimeSpan.FromSeconds(Utility.Random(80, 40)); + } BaseCreature.Summon(new EnergyVortex(), false, Caster, new Point3D(p), 0x212, duration); } @@ -51,7 +55,9 @@ namespace Server.Spells.Eighth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + (Core.SE ? 2 : 1) > Caster.FollowersMax) { diff --git a/Projects/UOContent/Spells/Eighth/FireElemental.cs b/Projects/UOContent/Spells/Eighth/FireElemental.cs index a99636c3e..d48989085 100644 --- a/Projects/UOContent/Spells/Eighth/FireElemental.cs +++ b/Projects/UOContent/Spells/Eighth/FireElemental.cs @@ -26,7 +26,9 @@ namespace Server.Spells.Eighth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 4 > Caster.FollowersMax) { @@ -44,9 +46,13 @@ namespace Server.Spells.Eighth var duration = TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5); if (Core.AOS) + { SpellHelper.Summon(new SummonedFireElemental(), Caster, 0x217, duration, false, false); + } else + { SpellHelper.Summon(new FireElemental(), Caster, 0x217, duration, false, false); + } } FinishSequence(); diff --git a/Projects/UOContent/Spells/Eighth/Resurrection.cs b/Projects/UOContent/Spells/Eighth/Resurrection.cs index e09a2c3c0..426820f56 100644 --- a/Projects/UOContent/Spells/Eighth/Resurrection.cs +++ b/Projects/UOContent/Spells/Eighth/Resurrection.cs @@ -25,7 +25,9 @@ namespace Server.Spells.Eighth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Eighth/SummonDaemon.cs b/Projects/UOContent/Spells/Eighth/SummonDaemon.cs index def7c3044..8b77f1d17 100644 --- a/Projects/UOContent/Spells/Eighth/SummonDaemon.cs +++ b/Projects/UOContent/Spells/Eighth/SummonDaemon.cs @@ -26,7 +26,9 @@ namespace Server.Spells.Eighth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + (Core.SE ? 4 : 5) > Caster.FollowersMax) { diff --git a/Projects/UOContent/Spells/Eighth/WaterElemental.cs b/Projects/UOContent/Spells/Eighth/WaterElemental.cs index bcd6b9bb6..c79f11445 100644 --- a/Projects/UOContent/Spells/Eighth/WaterElemental.cs +++ b/Projects/UOContent/Spells/Eighth/WaterElemental.cs @@ -25,7 +25,9 @@ namespace Server.Spells.Eighth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 3 > Caster.FollowersMax) { @@ -43,9 +45,13 @@ namespace Server.Spells.Eighth var duration = TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5); if (Core.AOS) + { SpellHelper.Summon(new SummonedWaterElemental(), Caster, 0x217, duration, false, false); + } else + { SpellHelper.Summon(new WaterElemental(), Caster, 0x217, duration, false, false); + } } FinishSequence(); diff --git a/Projects/UOContent/Spells/Fifth/BladeSpirits.cs b/Projects/UOContent/Spells/Fifth/BladeSpirits.cs index dfd8a729a..d7a5526fd 100644 --- a/Projects/UOContent/Spells/Fifth/BladeSpirits.cs +++ b/Projects/UOContent/Spells/Fifth/BladeSpirits.cs @@ -37,9 +37,13 @@ namespace Server.Spells.Fifth TimeSpan duration; if (Core.AOS) + { duration = TimeSpan.FromSeconds(120); + } else + { duration = TimeSpan.FromSeconds(Utility.Random(80, 40)); + } BaseCreature.Summon(new BladeSpirits(), false, Caster, new Point3D(p), 0x212, duration); } @@ -50,7 +54,9 @@ namespace Server.Spells.Fifth public override TimeSpan GetCastDelay() { if (Core.AOS) + { return TimeSpan.FromTicks(base.GetCastDelay().Ticks * (Core.SE ? 3 : 5)); + } return base.GetCastDelay() + TimeSpan.FromSeconds(6.0); } @@ -58,7 +64,9 @@ namespace Server.Spells.Fifth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + (Core.SE ? 2 : 1) > Caster.FollowersMax) { diff --git a/Projects/UOContent/Spells/Fifth/Incognito.cs b/Projects/UOContent/Spells/Fifth/Incognito.cs index b16c3b769..d638c4171 100644 --- a/Projects/UOContent/Spells/Fifth/Incognito.cs +++ b/Projects/UOContent/Spells/Fifth/Incognito.cs @@ -101,7 +101,9 @@ namespace Server.Spells.Fifth var timeVal = 6 * Caster.Skills.Magery.Fixed / 50 + 1; if (timeVal > 144) + { timeVal = 144; + } var length = TimeSpan.FromSeconds(timeVal); @@ -124,7 +126,9 @@ namespace Server.Spells.Fifth public static void StopTimer(Mobile m) { if (!m_Timers.TryGetValue(m, out var t)) + { return; + } t.Stop(); m_Timers.Remove(m); @@ -153,7 +157,9 @@ namespace Server.Spells.Fifth protected override void OnTick() { if (m_Owner.CanBeginAction()) + { return; + } (m_Owner as PlayerMobile)?.SetHairMods(-1, -1); diff --git a/Projects/UOContent/Spells/Fifth/MindBlast.cs b/Projects/UOContent/Spells/Fifth/MindBlast.cs index 073de939c..c149cb11e 100644 --- a/Projects/UOContent/Spells/Fifth/MindBlast.cs +++ b/Projects/UOContent/Spells/Fifth/MindBlast.cs @@ -19,7 +19,9 @@ namespace Server.Spells.Fifth public MindBlastSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { if (Core.AOS) + { m_Info.LeftHandEffect = m_Info.RightHandEffect = 9002; + } } public override SpellCircle Circle => SpellCircle.Fifth; @@ -29,7 +31,9 @@ namespace Server.Spells.Fifth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -70,22 +74,34 @@ namespace Server.Spells.Fifth int highestStat = target.Str, lowestStat = target.Str; if (target.Dex > highestStat) + { highestStat = target.Dex; + } if (target.Dex < lowestStat) + { lowestStat = target.Dex; + } if (target.Int > highestStat) + { highestStat = target.Int; + } if (target.Int < lowestStat) + { lowestStat = target.Int; + } if (highestStat > 150) + { highestStat = 150; + } if (lowestStat > 150) + { lowestStat = 150; + } var damage = Math.Min(GetDamageScalar(m) * (highestStat - lowestStat) / 2, 45); // Many users prefer 3 or 4 diff --git a/Projects/UOContent/Spells/Fifth/Paralyze.cs b/Projects/UOContent/Spells/Fifth/Paralyze.cs index 286cb65d0..9b4bccc67 100644 --- a/Projects/UOContent/Spells/Fifth/Paralyze.cs +++ b/Projects/UOContent/Spells/Fifth/Paralyze.cs @@ -26,7 +26,9 @@ namespace Server.Spells.Fifth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -50,10 +52,14 @@ namespace Server.Spells.Fifth var secs = (int)(GetDamageSkill(Caster) / 10 - GetResistSkill(m) / 10); if (!Core.SE) + { secs += 2; + } if (!m.Player) + { secs *= 3; + } duration = Math.Max(secs, 0); } @@ -64,7 +70,9 @@ namespace Server.Spells.Fifth duration = 7.0 + Caster.Skills.Magery.Value * 0.2; if (CheckResisted(m)) + { duration *= 0.75; + } } if (m is PlagueBeastLord lord) diff --git a/Projects/UOContent/Spells/Fifth/PoisonField.cs b/Projects/UOContent/Spells/Fifth/PoisonField.cs index e62c7cd66..0abbd4c55 100644 --- a/Projects/UOContent/Spells/Fifth/PoisonField.cs +++ b/Projects/UOContent/Spells/Fifth/PoisonField.cs @@ -46,13 +46,21 @@ namespace Server.Spells.Fifth bool eastToWest; if (rx >= 0 && ry >= 0) + { eastToWest = false; + } else if (rx >= 0) + { eastToWest = true; + } else if (ry >= 0) + { eastToWest = true; + } else + { eastToWest = false; + } Effects.PlaySound(p, Caster.Map, 0x20B); @@ -153,7 +161,9 @@ namespace Server.Spells.Fifth public void ApplyPoisonTo(Mobile m) { if (m_Caster == null) + { return; + } Poison p; @@ -162,13 +172,21 @@ namespace Server.Spells.Fifth var total = (m_Caster.Skills.Magery.Fixed + m_Caster.Skills.Poisoning.Fixed) / 2; if (total >= 1000) + { p = Poison.Deadly; + } else if (total > 850) + { p = Poison.Greater; + } else if (total > 650) + { p = Poison.Regular; + } else + { p = Poison.Lesser; + } } else { @@ -176,8 +194,12 @@ namespace Server.Spells.Fifth } if (m.ApplyPoison(m_Caster, p) == ApplyPoisonResult.Poisoned) + { if (SpellHelper.CanRevealCaster(m)) + { m_Caster.RevealingAction(); + } + } (m as BaseCreature)?.OnHarmfulSpell(m_Caster); } @@ -218,14 +240,20 @@ namespace Server.Spells.Fifth protected override void OnTick() { if (m_Item.Deleted) + { return; + } if (!m_Item.Visible) { if (m_InLOS && m_CanFit) + { m_Item.Visible = true; + } else + { m_Item.Delete(); + } if (!m_Item.Deleted) { @@ -262,9 +290,13 @@ namespace Server.Spells.Fifth ); foreach (var m in eable) + { if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != caster) && SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false)) + { m_Queue.Enqueue(m); + } + } eable.Free(); diff --git a/Projects/UOContent/Spells/Fifth/SummonCreature.cs b/Projects/UOContent/Spells/Fifth/SummonCreature.cs index 6ee542462..83c21bc50 100644 --- a/Projects/UOContent/Spells/Fifth/SummonCreature.cs +++ b/Projects/UOContent/Spells/Fifth/SummonCreature.cs @@ -49,7 +49,9 @@ namespace Server.Spells.Fifth public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 2 > Caster.FollowersMax) { @@ -63,6 +65,7 @@ namespace Server.Spells.Fifth public override void OnCast() { if (CheckSequence()) + { try { var creature = (BaseCreature)ActivatorUtil.CreateInstance(m_Types.RandomElement()); @@ -72,9 +75,13 @@ namespace Server.Spells.Fifth TimeSpan duration; if (Core.AOS) + { duration = TimeSpan.FromSeconds(2 * Caster.Skills.Magery.Fixed / 5.0); + } else + { duration = TimeSpan.FromSeconds(4.0 * Caster.Skills.Magery.Value); + } SpellHelper.Summon(creature, Caster, 0x215, duration, false, false); } @@ -82,6 +89,7 @@ namespace Server.Spells.Fifth { // ignored } + } FinishSequence(); } @@ -89,7 +97,9 @@ namespace Server.Spells.Fifth public override TimeSpan GetCastDelay() { if (Core.AOS) + { return TimeSpan.FromTicks(base.GetCastDelay().Ticks * 5); + } return base.GetCastDelay() + TimeSpan.FromSeconds(6.0); } diff --git a/Projects/UOContent/Spells/First/Clumsy.cs b/Projects/UOContent/Spells/First/Clumsy.cs index a8ebc2fdf..78d0aff6f 100644 --- a/Projects/UOContent/Spells/First/Clumsy.cs +++ b/Projects/UOContent/Spells/First/Clumsy.cs @@ -22,7 +22,9 @@ namespace Server.Spells.First public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/First/Feeblemind.cs b/Projects/UOContent/Spells/First/Feeblemind.cs index 21e60a1c6..f3a94b418 100644 --- a/Projects/UOContent/Spells/First/Feeblemind.cs +++ b/Projects/UOContent/Spells/First/Feeblemind.cs @@ -22,7 +22,9 @@ namespace Server.Spells.First public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/First/Heal.cs b/Projects/UOContent/Spells/First/Heal.cs index fb89a1076..23e0d7156 100644 --- a/Projects/UOContent/Spells/First/Heal.cs +++ b/Projects/UOContent/Spells/First/Heal.cs @@ -27,7 +27,9 @@ namespace Server.Spells.First public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -61,7 +63,9 @@ namespace Server.Spells.First toHeal += Utility.RandomMinMax(1, 4); if (Core.SE && Caster != m) + { toHeal = (int)(toHeal * 1.5); + } } else { diff --git a/Projects/UOContent/Spells/First/MagicArrow.cs b/Projects/UOContent/Spells/First/MagicArrow.cs index 098796386..474cc56a6 100644 --- a/Projects/UOContent/Spells/First/MagicArrow.cs +++ b/Projects/UOContent/Spells/First/MagicArrow.cs @@ -25,7 +25,9 @@ namespace Server.Spells.First public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/First/Weaken.cs b/Projects/UOContent/Spells/First/Weaken.cs index a298b9211..6eb850bb2 100644 --- a/Projects/UOContent/Spells/First/Weaken.cs +++ b/Projects/UOContent/Spells/First/Weaken.cs @@ -22,7 +22,9 @@ namespace Server.Spells.First public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Fourth/ArchCure.cs b/Projects/UOContent/Spells/Fourth/ArchCure.cs index ac00f82e3..98d7b5e07 100644 --- a/Projects/UOContent/Spells/Fourth/ArchCure.cs +++ b/Projects/UOContent/Spells/Fourth/ArchCure.cs @@ -50,7 +50,9 @@ namespace Server.Spells.Fourth // You can target any living mobile directly, beneficial checks apply if (directTarget != null && Caster.CanBeBeneficial(directTarget, false)) + { targets.Add(directTarget); + } var eable = map.GetMobilesInRange(new Point3D(p), 2); targets.AddRange(eable.Where(m => m != directTarget).Where(m => AreaCanTarget(m, feluccaRules))); @@ -80,7 +82,9 @@ namespace Server.Spells.Fourth chanceToCure -= 1; if (chanceToCure > Utility.Random(100) && m.CurePoison(Caster)) + { ++cured; + } } m.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); @@ -88,7 +92,9 @@ namespace Server.Spells.Fourth } if (cured > 0) + { Caster.SendLocalizedMessage(1010058); // You have cured the target of all poisons! + } } } @@ -108,18 +114,26 @@ namespace Server.Spells.Fourth */ if (!Caster.CanBeBeneficial(target, false)) + { return false; + } if (Core.AOS && target != Caster) { if (IsAggressor(target) || IsAggressed(target)) + { return false; + } if ((!IsInnocentTo(Caster, target) || !IsInnocentTo(target, Caster)) && !IsAllyTo(Caster, target)) + { return false; + } if (feluccaRules && !(target is PlayerMobile)) + { return false; + } } return true; @@ -128,8 +142,12 @@ namespace Server.Spells.Fourth private bool IsAggressor(Mobile m) { foreach (var info in Caster.Aggressors) + { if (m == info.Attacker && !info.Expired) + { return true; + } + } return false; } @@ -137,8 +155,12 @@ namespace Server.Spells.Fourth private bool IsAggressed(Mobile m) { foreach (var info in Caster.Aggressed) + { if (m == info.Defender && !info.Expired) + { return true; + } + } return false; } diff --git a/Projects/UOContent/Spells/Fourth/ArchProtection.cs b/Projects/UOContent/Spells/Fourth/ArchProtection.cs index 8ad3b3dfb..9040cc025 100644 --- a/Projects/UOContent/Spells/Fourth/ArchProtection.cs +++ b/Projects/UOContent/Spells/Fourth/ArchProtection.cs @@ -41,7 +41,9 @@ namespace Server.Spells.Fourth SpellHelper.GetSurfaceTop(ref p); if (!Core.AOS) + { Effects.PlaySound(p, Caster.Map, 0x299); + } if (Caster.Map == null) { @@ -57,17 +59,20 @@ namespace Server.Spells.Fourth var party = Party.Get(Caster); foreach (var m in targets) + { if (m == Caster || party?.Contains(m) == true) { Caster.DoBeneficial(m); ProtectionSpell.Toggle(Caster, m); } + } } else { var val = (int)(Caster.Skills.Magery.Value / 10.0 + 1); foreach (var m in targets) + { if (m.BeginAction()) { Caster.DoBeneficial(m); @@ -79,6 +84,7 @@ namespace Server.Spells.Fourth m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist); m.PlaySound(0x1F7); } + } } } @@ -112,7 +118,10 @@ namespace Server.Spells.Fourth { var time = caster.Skills.Magery.Value * 1.2; if (time > 144) + { time = 144; + } + Delay = TimeSpan.FromSeconds(time); Priority = TimerPriority.OneSecond; diff --git a/Projects/UOContent/Spells/Fourth/Curse.cs b/Projects/UOContent/Spells/Fourth/Curse.cs index a2a6b3026..840f757b2 100644 --- a/Projects/UOContent/Spells/Fourth/Curse.cs +++ b/Projects/UOContent/Spells/Fourth/Curse.cs @@ -26,7 +26,9 @@ namespace Server.Spells.Fourth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Fourth/FireField.cs b/Projects/UOContent/Spells/Fourth/FireField.cs index e99cf9658..3959e2f24 100644 --- a/Projects/UOContent/Spells/Fourth/FireField.cs +++ b/Projects/UOContent/Spells/Fourth/FireField.cs @@ -46,13 +46,21 @@ namespace Server.Spells.Fourth bool eastToWest; if (rx >= 0 && ry >= 0) + { eastToWest = false; + } else if (rx >= 0) + { eastToWest = true; + } else if (ry >= 0) + { eastToWest = true; + } else + { eastToWest = false; + } Effects.PlaySound(p, Caster.Map, 0x20C); @@ -61,9 +69,13 @@ namespace Server.Spells.Fourth TimeSpan duration; if (Core.AOS) + { duration = TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5.0) / 4.0); + } else + { duration = TimeSpan.FromSeconds(4.0 + Caster.Skills.Magery.Value * 0.5); + } for (var i = -2; i <= 2; ++i) { @@ -167,7 +179,9 @@ namespace Server.Spells.Fourth } if (version < 2) + { m_Damage = 2; + } } public override bool OnMoveOver(Mobile m) @@ -176,7 +190,9 @@ namespace Server.Spells.Fourth SpellHelper.ValidIndirectTarget(m_Caster, m) && m_Caster.CanBeHarmful(m, false)) { if (SpellHelper.CanRevealCaster(m)) + { m_Caster.RevealingAction(); + } m_Caster.DoHarmful(m); @@ -220,14 +236,20 @@ namespace Server.Spells.Fourth protected override void OnTick() { if (m_Item.Deleted) + { return; + } if (!m_Item.Visible) { if (m_InLOS && m_CanFit) + { m_Item.Visible = true; + } else + { m_Item.Delete(); + } if (!m_Item.Deleted) { @@ -252,19 +274,27 @@ namespace Server.Spells.Fourth var caster = m_Item.m_Caster; if (map == null || caster == null) + { return; + } foreach (var m in m_Item.GetMobilesInRange(0)) + { if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != caster) && SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false)) + { m_Queue.Enqueue(m); + } + } while (m_Queue.Count > 0) { var m = (Mobile)m_Queue.Dequeue(); if (SpellHelper.CanRevealCaster(m)) + { caster.RevealingAction(); + } caster.DoHarmful(m); diff --git a/Projects/UOContent/Spells/Fourth/GreaterHeal.cs b/Projects/UOContent/Spells/Fourth/GreaterHeal.cs index 8131c5908..edabfde61 100644 --- a/Projects/UOContent/Spells/Fourth/GreaterHeal.cs +++ b/Projects/UOContent/Spells/Fourth/GreaterHeal.cs @@ -28,7 +28,9 @@ namespace Server.Spells.Fourth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Fourth/Lightning.cs b/Projects/UOContent/Spells/Fourth/Lightning.cs index 64d329d4b..dcbccb065 100644 --- a/Projects/UOContent/Spells/Fourth/Lightning.cs +++ b/Projects/UOContent/Spells/Fourth/Lightning.cs @@ -24,7 +24,9 @@ namespace Server.Spells.Fourth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Fourth/ManaDrain.cs b/Projects/UOContent/Spells/Fourth/ManaDrain.cs index 1e42ce598..d8cb4cec5 100644 --- a/Projects/UOContent/Spells/Fourth/ManaDrain.cs +++ b/Projects/UOContent/Spells/Fourth/ManaDrain.cs @@ -27,7 +27,9 @@ namespace Server.Spells.Fourth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -48,7 +50,9 @@ namespace Server.Spells.Fourth var toDrain = Math.Clamp(40 + (int)(GetDamageSkill(Caster) - GetResistSkill(m)), 0, m.Mana); if (m_Table.Contains(m)) + { toDrain = 0; + } m.FixedParticles(0x3789, 10, 25, 5032, EffectLayer.Head); m.PlaySound(0x1F8); @@ -64,11 +68,17 @@ namespace Server.Spells.Fourth else { if (CheckResisted(m)) + { m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + } else if (m.Mana >= 100) + { m.Mana -= Utility.Random(1, 100); + } else + { m.Mana -= Utility.Random(1, m.Mana); + } m.FixedParticles(0x374A, 10, 15, 5032, EffectLayer.Head); m.PlaySound(0x1F8); diff --git a/Projects/UOContent/Spells/Fourth/Recall.cs b/Projects/UOContent/Spells/Fourth/Recall.cs index 5c2c51cd2..a43dabc3d 100644 --- a/Projects/UOContent/Spells/Fourth/Recall.cs +++ b/Projects/UOContent/Spells/Fourth/Recall.cs @@ -87,7 +87,9 @@ namespace Server.Spells.Fourth BaseCreature.TeleportPets(Caster, loc, map, true); if (m_Book != null) + { --m_Book.CurCharges; + } Caster.PlaySound(0x1FC); Caster.MoveToWorld(loc, map); @@ -100,19 +102,29 @@ namespace Server.Spells.Fourth public override void GetCastSkills(out double min, out double max) { if (TransformationSpellHelper.UnderTransformation(Caster, typeof(WraithFormSpell))) + { min = max = 0; + } else if (Core.SE && m_Book != null) // recall using Runebook charge + { min = max = 0; + } else + { base.GetCastSkills(out min, out max); + } } public override void OnCast() { if (m_Entry == null) + { Caster.Target = new RecallSpellTarget(this); + } else + { Effect(m_Entry.Location, m_Entry.Map, true); + } } public override bool CheckCast() diff --git a/Projects/UOContent/Spells/Gargoyle/SpellDefinitions/FlySpell.cs b/Projects/UOContent/Spells/Gargoyle/SpellDefinitions/FlySpell.cs index 1184fdde0..953945cca 100644 --- a/Projects/UOContent/Spells/Gargoyle/SpellDefinitions/FlySpell.cs +++ b/Projects/UOContent/Spells/Gargoyle/SpellDefinitions/FlySpell.cs @@ -48,7 +48,9 @@ namespace Server.Spells public override void OnDisturb(DisturbType type, bool message) { if (message && !m_Stop) + { Caster.SendLocalizedMessage(1113192); // You have been disrupted while attempting to fly! + } } public override void OnCast() diff --git a/Projects/UOContent/Spells/Initializer.cs b/Projects/UOContent/Spells/Initializer.cs index b7f6e90e4..8acce3250 100644 --- a/Projects/UOContent/Spells/Initializer.cs +++ b/Projects/UOContent/Spells/Initializer.cs @@ -121,7 +121,9 @@ namespace Server.Spells Register(115, typeof(WraithFormSpell)); if (Core.SE) + { Register(116, typeof(ExorcismSpell)); + } // Paladin abilities Register(200, typeof(CleanseByFireSpell)); diff --git a/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs b/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs index 6eabf3114..bcbffdc65 100644 --- a/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/EagleStrikeSpell.cs @@ -29,7 +29,9 @@ namespace Server.Spells.Mysticism public void Target(Mobile m) { if (m == null) + { return; + } if (CheckHSequence(m)) { @@ -58,7 +60,9 @@ namespace Server.Spells.Mysticism private void Damage(Mobile to) { if (to == null) + { return; + } double damage = GetNewAosDamage(19, 1, 5, to); diff --git a/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs b/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs index 6eac00a67..b0689c689 100644 --- a/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/HailStormSpell.cs @@ -39,7 +39,9 @@ namespace Server.Spells.Mysticism SpellHelper.Turn(Caster, p); if (p is Item item) + { p = item.GetWorldLocation(); + } var targets = new List(); @@ -54,17 +56,23 @@ namespace Server.Spells.Mysticism foreach (var m in map.GetMobilesInRange(new Point3D(p), 2)) { if (m == Caster) + { continue; + } if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && Caster.CanSee(m)) { if (!Caster.InLOS(m)) + { continue; + } targets.Add(m); if (m.Player) + { pvp = true; + } } } } diff --git a/Projects/UOContent/Spells/Mysticism/MysticSpell.cs b/Projects/UOContent/Spells/Mysticism/MysticSpell.cs index 2ec16128e..11eebfdca 100644 --- a/Projects/UOContent/Spells/Mysticism/MysticSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/MysticSpell.cs @@ -38,7 +38,9 @@ namespace Server.Spells.Mysticism public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } var mana = ScaleMana(RequiredMana); diff --git a/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs b/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs index 0865007d7..fc7197e06 100644 --- a/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/NetherCycloneSpell.cs @@ -42,7 +42,9 @@ namespace Server.Spells.Mysticism SpellHelper.Turn(Caster, p); if (p is Item item) + { p = item.GetWorldLocation(); + } var targets = new List(); @@ -57,17 +59,23 @@ namespace Server.Spells.Mysticism foreach (var m in map.GetMobilesInRange(new Point3D(p), 2)) { if (m == Caster) + { continue; + } if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && Caster.CanSee(m)) { if (!Caster.InLOS(m)) + { continue; + } targets.Add(m); if (m.Player) + { pvp = true; + } } } } diff --git a/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs b/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs index b8fa67baa..947a20acb 100644 --- a/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs +++ b/Projects/UOContent/Spells/Mysticism/SpellPlagueSpell.cs @@ -88,13 +88,17 @@ namespace Server.Spells.Mysticism public static void RemoveEffect(Mobile m) { if (m_Table.TryGetValue(m, out var context)) + { context.EndPlague(false); + } } public static void CheckPlague(Mobile m) { if (m_Table.TryGetValue(m, out var context)) + { context.OnDamage(); + } } private static void OnPlayerDeath(Mobile m) @@ -128,9 +132,13 @@ namespace Server.Spells.Mysticism public void SetNext(SpellPlagueContext context) { if (m_Next == null) + { m_Next = context; + } else + { m_Next.SetNext(context); + } } public void Start() @@ -153,7 +161,9 @@ namespace Server.Spells.Mysticism var resist = m_Target.Skills.MagicResist.Value; if (resist >= 70) + { exploChance -= (int)((resist - 70.0) * 3.0 / 10.0); + } if (exploChance > Utility.Random(100)) { @@ -167,7 +177,9 @@ namespace Server.Spells.Mysticism SpellHelper.Damage(m_Owner, m_Target, damage, 0, 0, 0, 0, 0, 100); if (m_Explosions >= 3) + { EndPlague(); + } } } } @@ -206,7 +218,9 @@ namespace Server.Spells.Mysticism protected override void OnTarget(Mobile from, object o) { if (o is Mobile mobile) + { m_Owner.Target(mobile); + } } protected override void OnTargetFinish(Mobile from) diff --git a/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs b/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs index 9cc11283e..e080d53f9 100644 --- a/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs +++ b/Projects/UOContent/Spells/Necromancy/CorpseSkin.cs @@ -29,7 +29,9 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { if (m == null) + { return; + } if (CheckHSequence(m)) { @@ -48,9 +50,13 @@ namespace Server.Spells.Necromancy */ if (m_Table.TryGetValue(m, out var timer)) + { timer.DoExpire(); + } else + { m.SendLocalizedMessage(1061689); // Your skin turns dry and corpselike. + } m.Spell?.OnCasterHurt(); @@ -79,7 +85,9 @@ namespace Server.Spells.Necromancy m_Table[m] = timer; for (var i = 0; i < mods.Length; ++i) + { m.AddResistanceMod(mods[i]); + } HarmfulSpell(m); } @@ -95,7 +103,9 @@ namespace Server.Spells.Necromancy public static bool RemoveCurse(Mobile m) { if (!m_Table.TryGetValue(m, out var t)) + { return false; + } m.SendLocalizedMessage(1061688); // Your skin returns to normal. t?.DoExpire(); @@ -116,7 +126,9 @@ namespace Server.Spells.Necromancy public void DoExpire() { for (var i = 0; i < m_Mods.Length; ++i) + { m_Mobile.RemoveResistanceMod(m_Mods[i]); + } Stop(); BuffInfo.RemoveBuff(m_Mobile, BuffIcon.CorpseSkin); diff --git a/Projects/UOContent/Spells/Necromancy/Exorcism.cs b/Projects/UOContent/Spells/Necromancy/Exorcism.cs index 73f44df97..c43b65c8e 100644 --- a/Projects/UOContent/Spells/Necromancy/Exorcism.cs +++ b/Projects/UOContent/Spells/Necromancy/Exorcism.cs @@ -99,7 +99,9 @@ namespace Server.Spells.Necromancy foreach (var m in targets) // Surprisingly, no sparkle type effects + { m.Location = GetNearestShrine(m); + } } } @@ -109,7 +111,9 @@ namespace Server.Spells.Necromancy private bool IsValidTarget(Mobile m) { if (!m.Player || m.Alive) + { return false; + } var c = m.Corpse as Corpse; var map = m.Map; @@ -117,16 +121,22 @@ namespace Server.Spells.Necromancy if (c?.Deleted == false && map != null && c.Map == map) { if (SpellHelper.IsAnyT2A(map, c.Location) && SpellHelper.IsAnyT2A(map, m.Location)) + { return false; // Same Map, both in T2A, ie, same 'sub server'. + } if (m.Region.IsPartOf() == Region.Find(c.Location, map).IsPartOf()) + { return false; // Same Map, both in Dungeon region OR They're both NOT in a dungeon region. + } // Just an approximation cause RunUO doesn't divide up the world the same way OSI does ;p } if (Party.Get(m)?.Contains(Caster) == true) + { return false; + } if (m.Guild != null && Caster.Guild != null) { @@ -134,7 +144,9 @@ namespace Server.Spells.Necromancy var cGuild = Caster.Guild as Guild; if (mGuild?.IsAlly(cGuild) == true || mGuild == cGuild) + { return false; + } } var f = Faction.Find(m); @@ -149,15 +161,25 @@ namespace Server.Spells.Necromancy Point3D[] locList; if (map == Map.Felucca || map == Map.Trammel) + { locList = m_BritanniaLocs; + } else if (map == Map.Ilshenar) + { locList = m_IllshLocs; + } else if (map == Map.Tokuno) + { locList = m_TokunoLocs; + } else if (map == Map.Malas) + { locList = m_MalasLocs; + } else + { locList = Array.Empty(); + } var closest = Point3D.Zero; var minDist = double.MaxValue; diff --git a/Projects/UOContent/Spells/Necromancy/NecromancerSpell.cs b/Projects/UOContent/Spells/Necromancy/NecromancerSpell.cs index bf400fd63..a23f9c29e 100644 --- a/Projects/UOContent/Spells/Necromancy/NecromancerSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/NecromancerSpell.cs @@ -31,7 +31,9 @@ namespace Server.Spells.Necromancy if (Core.ML ) // Pub 36: "Added a new property called Increased Karma Loss which grants higher karma loss for casting necromancy spells." + { karma += AOS.Scale(karma, AosAttributes.GetValue(Caster, AosAttribute.IncreasedKarmaLoss)); + } return karma; } diff --git a/Projects/UOContent/Spells/Necromancy/PainSpike.cs b/Projects/UOContent/Spells/Necromancy/PainSpike.cs index af667b8bc..3aeaac3b7 100644 --- a/Projects/UOContent/Spells/Necromancy/PainSpike.cs +++ b/Projects/UOContent/Spells/Necromancy/PainSpike.cs @@ -32,7 +32,9 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { if (m == null) + { return; + } if (CheckHSequence(m)) { @@ -104,7 +106,9 @@ namespace Server.Spells.Necromancy m_Table.Remove(m_Mobile); if (m_Mobile.Alive && !m_Mobile.IsDeadBondedPet) + { m_Mobile.Hits += m_ToRestore; + } BuffInfo.RemoveBuff(m_Mobile, BuffIcon.PainSpike); } diff --git a/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs b/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs index d99515f53..f24284a4a 100644 --- a/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs +++ b/Projects/UOContent/Spells/Necromancy/PoisonStrike.cs @@ -32,7 +32,9 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { if (m == null) + { return; + } if (CheckHSequence(m)) { @@ -65,7 +67,10 @@ namespace Server.Spells.Necromancy var pvmDamage = damage * (1 + sdiBonus); if (Core.ML && sdiBonus > 0.15) + { sdiBonus = 0.15; + } + var pvpDamage = damage * (1 + sdiBonus); var map = m.Map; @@ -75,7 +80,9 @@ namespace Server.Spells.Necromancy var targets = new List(); if (Caster.CanBeHarmful(m, false)) + { targets.Add(m); + } targets.AddRange( m.GetMobilesInRange(2) @@ -91,11 +98,17 @@ namespace Server.Spells.Necromancy int num; if (targ.InRange(m.Location, 0)) + { num = 1; + } else if (targ.InRange(m.Location, 1)) + { num = 2; + } else + { num = 3; + } Caster.DoHarmful(targ); SpellHelper.Damage( diff --git a/Projects/UOContent/Spells/Necromancy/SummonFamiliar.cs b/Projects/UOContent/Spells/Necromancy/SummonFamiliar.cs index 89c6c4333..7d71522e3 100644 --- a/Projects/UOContent/Spells/Necromancy/SummonFamiliar.cs +++ b/Projects/UOContent/Spells/Necromancy/SummonFamiliar.cs @@ -42,7 +42,9 @@ namespace Server.Spells.Necromancy public override bool CheckCast() { if (!(Table.TryGetValue(Caster, out var check) && check?.Deleted == false)) + { return base.CheckCast(); + } Caster.SendLocalizedMessage(1061605); // You already have a familiar. return false; @@ -126,8 +128,11 @@ namespace Server.Spells.Necromancy AddButton(27, 53 + i * 21, 9702, 9703, i + 1); if (name is int intName) + { AddHtmlLocalized(50, 51 + i * 21, 150, 20, intName, enabled ? EnabledColor16 : DisabledColor16); + } else if (name is string strName) + { AddHtml( 50, 51 + i * 21, @@ -135,6 +140,7 @@ namespace Server.Spells.Necromancy 20, $"{strName}" ); + } } } diff --git a/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs b/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs index f30318446..39b940e92 100644 --- a/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs +++ b/Projects/UOContent/Spells/Necromancy/VengefulSpirit.cs @@ -28,7 +28,9 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { if (m == null) + { return; + } if (Caster == m) { @@ -56,7 +58,9 @@ namespace Server.Spells.Necromancy 0x81, TimeSpan.FromSeconds(duration.TotalSeconds + 2.0) )) + { rev.FixedParticles(0x373A, 1, 15, 9909, EffectLayer.Waist); + } } FinishSequence(); @@ -70,7 +74,9 @@ namespace Server.Spells.Necromancy public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 3 > Caster.FollowersMax) { diff --git a/Projects/UOContent/Spells/Necromancy/Wither.cs b/Projects/UOContent/Spells/Necromancy/Wither.cs index 82dafcf62..4860c31ae 100644 --- a/Projects/UOContent/Spells/Necromancy/Wither.cs +++ b/Projects/UOContent/Spells/Necromancy/Wither.cs @@ -48,6 +48,7 @@ namespace Server.Spells.Necromancy var isMonster = cbc?.Controlled == false && !cbc.Summoned; foreach (var m in Caster.GetMobilesInRange(Core.ML ? 4 : 5)) + { if (Caster != m && Caster.InLOS(m) && (isMonster || SpellHelper.ValidIndirectTarget(Caster, m)) && Caster.CanBeHarmful(m, false)) { @@ -56,7 +57,9 @@ namespace Server.Spells.Necromancy if (m is BaseCreature bc) { if (!bc.Controlled && !bc.Summoned && bc.Team == cbc.Team) + { continue; + } } else if (!m.Player) { @@ -66,6 +69,7 @@ namespace Server.Spells.Necromancy targets.Add(m); } + } Effects.PlaySound(Caster.Location, map, 0x1FB); Effects.PlaySound(Caster.Location, map, 0x10B); @@ -96,7 +100,9 @@ namespace Server.Spells.Necromancy // PvP spell damage increase cap of 15% from an item�s magic property in Publish 33(SE) if (Core.SE && m.Player && Caster.Player && sdiBonus > 15) + { sdiBonus = 15; + } damage *= 100 + sdiBonus; damage /= 100; diff --git a/Projects/UOContent/Spells/Necromancy/WraithForm.cs b/Projects/UOContent/Spells/Necromancy/WraithForm.cs index f88bf1739..2978bf2c1 100644 --- a/Projects/UOContent/Spells/Necromancy/WraithForm.cs +++ b/Projects/UOContent/Spells/Necromancy/WraithForm.cs @@ -35,7 +35,9 @@ namespace Server.Spells.Necromancy public override void DoEffect(Mobile m) { if (m is PlayerMobile mobile) + { mobile.IgnoreMobiles = true; + } m.PlaySound(0x17F); m.FixedParticles(0x374A, 1, 15, 9902, 1108, 4, EffectLayer.Waist); @@ -44,7 +46,9 @@ namespace Server.Spells.Necromancy public override void RemoveEffect(Mobile m) { if (m is PlayerMobile mobile && mobile.AccessLevel == AccessLevel.Player) + { mobile.IgnoreMobiles = false; + } } } } diff --git a/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs b/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs index 253b6fc0d..a34ca1c0d 100644 --- a/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs +++ b/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs @@ -71,7 +71,9 @@ namespace Server.Spells.Ninjitsu public static void OnLogin(Mobile m) { if (GetContext(m)?.SpeedBoost == true) + { m.Send(SpeedControl.MountSpeed); + } } public override bool CheckCast() @@ -187,7 +189,9 @@ namespace Server.Spells.Ninjitsu public static MorphResult Morph(Mobile m, int entryID) { if (entryID < 0 || entryID >= Entries.Length) + { return MorphResult.Fail; + } var entry = Entries[entryID]; @@ -217,13 +221,17 @@ namespace Server.Spells.Ninjitsu var chance = (ninjitsu - entry.ReqSkill) / 37.5; if (chance < Utility.RandomDouble()) + { return MorphResult.Fail; + } } m.CheckSkill(SkillName.Ninjitsu, 0.0, 37.5); if (!BaseFormTalisman.EntryEnabled(m, entry.Type)) + { return MorphResult.Success; // Still consumes mana, just no effect + } BaseMount.Dismount(m); @@ -234,7 +242,9 @@ namespace Server.Spells.Ninjitsu m.HueMod = hueMod; if (entry.SpeedBoost) + { m.Send(SpeedControl.MountSpeed); + } SkillMod mod = null; @@ -265,7 +275,9 @@ namespace Server.Spells.Ninjitsu m_Table[m] = context; if (context.Type == typeof(BakeKitsune) || context.Type == typeof(GreyWolf)) + { m.CheckStatTimers(); + } } public static void RemoveContext(Mobile m, bool resetGraphics) @@ -273,7 +285,9 @@ namespace Server.Spells.Ninjitsu var context = GetContext(m); if (context != null) + { RemoveContext(m, context, resetGraphics); + } } public static void RemoveContext(Mobile m, AnimalFormContext context, bool resetGraphics) @@ -281,17 +295,23 @@ namespace Server.Spells.Ninjitsu m_Table.Remove(m); if (context.SpeedBoost) + { m.Send(SpeedControl.Disable); + } var mod = context.Mod; if (mod != null) + { m.RemoveSkillMod(mod); + } mod = context.StealingMod; if (mod != null) + { m.RemoveSkillMod(mod); + } if (resetGraphics) { @@ -422,7 +442,9 @@ namespace Server.Spells.Ninjitsu } if (!enabled) + { continue; + } var x = pos % 2 == 0 ? 14 : 264; var y = pos / 2 * 64 + 44; @@ -454,7 +476,9 @@ namespace Server.Spells.Ninjitsu var entryID = info.ButtonID - 1; if (entryID < 0 || entryID >= AnimalForm.Entries.Length) + { return; + } var mana = m_Spell.ScaleMana(m_Spell.RequiredMana); var entry = AnimalForm.Entries[entryID]; diff --git a/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs b/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs index d9aae3f1b..95bf55a9c 100644 --- a/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs +++ b/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs @@ -21,12 +21,16 @@ namespace Server.Spells.Ninjitsu Item handOne = from.FindItemOnLayer(Layer.OneHanded) as BaseWeapon; if (handOne != null && !(handOne is BaseRanged)) - return base.Validate(from); + { + return base.Validate(@from); + } Item handTwo = from.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; if (handTwo != null && !(handTwo is BaseRanged)) - return base.Validate(from); + { + return base.Validate(@from); + } from.SendLocalizedMessage(1063097); // You must be wielding a melee weapon without a shield to use this ability. return false; diff --git a/Projects/UOContent/Spells/Ninjitsu/KiAttack.cs b/Projects/UOContent/Spells/Ninjitsu/KiAttack.cs index 20fa9e9d4..1c073c140 100644 --- a/Projects/UOContent/Spells/Ninjitsu/KiAttack.cs +++ b/Projects/UOContent/Spells/Ninjitsu/KiAttack.cs @@ -17,7 +17,9 @@ namespace Server.Spells.Ninjitsu public override void OnUse(Mobile from) { if (!Validate(from)) + { return; + } var info = new KiAttackInfo(from); info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2.0), EndKiAttack, info); @@ -45,7 +47,9 @@ namespace Server.Spells.Ninjitsu public override double GetDamageScalar(Mobile attacker, Mobile defender) { if (attacker.Hidden) + { return 1.0; + } /* * Pub40 changed pvp damage max to 55% @@ -57,7 +61,9 @@ namespace Server.Spells.Ninjitsu public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) + { return; + } if (GetBonus(attacker) == 0.0) { @@ -90,7 +96,9 @@ namespace Server.Spells.Ninjitsu public static double GetBonus(Mobile from) { if (!m_Table.TryGetValue(from, out var info)) + { return 0; + } var xDelta = info.m_Location.X - from.X; var yDelta = info.m_Location.Y - from.Y; @@ -98,7 +106,9 @@ namespace Server.Spells.Ninjitsu var bonus = Math.Sqrt(xDelta * xDelta + yDelta * yDelta); if (bonus > 20.0) + { bonus = 20.0; + } return bonus; } diff --git a/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs b/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs index 5bdf51329..868c9467f 100644 --- a/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs +++ b/Projects/UOContent/Spells/Ninjitsu/MirrorImage.cs @@ -35,7 +35,9 @@ namespace Server.Spells.Ninjitsu public static void AddClone(Mobile m) { if (m == null) + { return; + } m_CloneCount[m] = 1 + (m_CloneCount.TryGetValue(m, out var count) ? count : 0); } @@ -43,12 +45,18 @@ namespace Server.Spells.Ninjitsu public static void RemoveClone(Mobile m) { if (m == null || !m_CloneCount.TryGetValue(m, out var count)) + { return; + } if (count <= 1) + { m_CloneCount.Remove(m); + } else + { m_CloneCount[m]--; + } } public override bool CheckCast() @@ -147,7 +155,10 @@ namespace Server.Mobiles Skills[i].Cap = caster.Skills[i].Cap; } - for (var i = 0; i < caster.Items.Count; i++) AddItem(CloneItem(caster.Items[i])); + for (var i = 0; i < caster.Items.Count; i++) + { + AddItem(CloneItem(caster.Items[i])); + } Warmode = true; diff --git a/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs b/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs index fc62b9d6c..93430a678 100644 --- a/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs +++ b/Projects/UOContent/Spells/Ninjitsu/NinjaSpell.cs @@ -32,7 +32,9 @@ namespace Server.Spells.Ninjitsu var mana = ScaleMana(RequiredMana); if (!base.CheckCast()) + { return false; + } if (!CheckExpansion(Caster)) { @@ -85,7 +87,9 @@ namespace Server.Spells.Ninjitsu } if (!base.CheckFizzle()) + { return false; + } Caster.Mana -= mana; diff --git a/Projects/UOContent/Spells/Ninjitsu/SurpriseAttack.cs b/Projects/UOContent/Spells/Ninjitsu/SurpriseAttack.cs index 83c993028..e49c8f227 100644 --- a/Projects/UOContent/Spells/Ninjitsu/SurpriseAttack.cs +++ b/Projects/UOContent/Spells/Ninjitsu/SurpriseAttack.cs @@ -82,7 +82,9 @@ namespace Server.Spells.Ninjitsu public static bool GetMalus(Mobile target, ref int malus) { if (!m_Table.TryGetValue(target, out var info)) + { return false; + } malus = info.m_Malus; return true; diff --git a/Projects/UOContent/Spells/Second/Agility.cs b/Projects/UOContent/Spells/Second/Agility.cs index 406f17e30..bdd1fb2b3 100644 --- a/Projects/UOContent/Spells/Second/Agility.cs +++ b/Projects/UOContent/Spells/Second/Agility.cs @@ -23,7 +23,9 @@ namespace Server.Spells.Second public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Second/Cunning.cs b/Projects/UOContent/Spells/Second/Cunning.cs index a33c2f6cc..4348d982f 100644 --- a/Projects/UOContent/Spells/Second/Cunning.cs +++ b/Projects/UOContent/Spells/Second/Cunning.cs @@ -23,7 +23,9 @@ namespace Server.Spells.Second public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Second/Cure.cs b/Projects/UOContent/Spells/Second/Cure.cs index ab8d8bc2b..b53ff1db3 100644 --- a/Projects/UOContent/Spells/Second/Cure.cs +++ b/Projects/UOContent/Spells/Second/Cure.cs @@ -23,7 +23,9 @@ namespace Server.Spells.Second public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -46,7 +48,9 @@ namespace Server.Spells.Second if (m.CurePoison(Caster)) { if (Caster != m) + { Caster.SendLocalizedMessage(1010058); // You have cured the target of all poisons! + } m.SendLocalizedMessage(1010059); // You have been cured of all poisons. } diff --git a/Projects/UOContent/Spells/Second/Harm.cs b/Projects/UOContent/Spells/Second/Harm.cs index 18eb0d71b..f529f82d1 100644 --- a/Projects/UOContent/Spells/Second/Harm.cs +++ b/Projects/UOContent/Spells/Second/Harm.cs @@ -24,7 +24,9 @@ namespace Server.Spells.Second public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -57,9 +59,13 @@ namespace Server.Spells.Second } if (!m.InRange(Caster, 2)) + { damage *= 0.25; // 1/4 damage at > 2 tile range + } else if (!m.InRange(Caster, 1)) + { damage *= 0.50; // 1/2 damage at 2 tile range + } if (Core.AOS) { diff --git a/Projects/UOContent/Spells/Second/Strength.cs b/Projects/UOContent/Spells/Second/Strength.cs index 7fc214868..5800db5ba 100644 --- a/Projects/UOContent/Spells/Second/Strength.cs +++ b/Projects/UOContent/Spells/Second/Strength.cs @@ -23,7 +23,9 @@ namespace Server.Spells.Second public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Seventh/ChainLightning.cs b/Projects/UOContent/Spells/Seventh/ChainLightning.cs index c02489e32..bca360c4e 100644 --- a/Projects/UOContent/Spells/Seventh/ChainLightning.cs +++ b/Projects/UOContent/Spells/Seventh/ChainLightning.cs @@ -37,7 +37,9 @@ namespace Server.Spells.Seventh SpellHelper.Turn(Caster, p); if (p is Item item) + { p = item.GetWorldLocation(); + } var targets = new List(); @@ -56,10 +58,14 @@ namespace Server.Spells.Seventh if (Core.AOS && (m == Caster || !Caster.InLOS(m)) || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false)) + { return false; + } if (m.Player) + { playerVsPlayer = true; + } return true; } @@ -79,9 +85,13 @@ namespace Server.Spells.Seventh if (targets.Count > 0) { if (Core.AOS && targets.Count > 2) + { damage = damage * 2 / targets.Count; + } else if (!Core.AOS) + { damage /= targets.Count; + } for (var i = 0; i < targets.Count; ++i) { diff --git a/Projects/UOContent/Spells/Seventh/EnergyField.cs b/Projects/UOContent/Spells/Seventh/EnergyField.cs index b8d125766..0ac5220a2 100644 --- a/Projects/UOContent/Spells/Seventh/EnergyField.cs +++ b/Projects/UOContent/Spells/Seventh/EnergyField.cs @@ -46,25 +46,37 @@ namespace Server.Spells.Seventh bool eastToWest; if (rx >= 0 && ry >= 0) + { eastToWest = false; + } else if (rx >= 0) + { eastToWest = true; + } else if (ry >= 0) + { eastToWest = true; + } else + { eastToWest = false; + } Effects.PlaySound(p, Caster.Map, 0x20B); TimeSpan duration; if (Core.AOS) + { duration = TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5) / 7.0); + } else + { duration = TimeSpan.FromSeconds( Caster.Skills.Magery.Value * 0.28 + 2.0 ); // (28% of magery) + 2.0 seconds + } var itemID = eastToWest ? 0x3946 : 0x3956; @@ -74,7 +86,9 @@ namespace Server.Spells.Seventh var canFit = SpellHelper.AdjustField(ref loc, Caster.Map, 12, false); if (!canFit) + { continue; + } Item item = new InternalItem(loc, Caster.Map, duration, itemID, Caster); item.ProcessDelta(); @@ -114,12 +128,18 @@ namespace Server.Spells.Seventh m_Caster = caster; if (caster.InLOS(this)) + { Visible = true; + } else + { Delete(); + } if (Deleted) + { return; + } m_Timer = new InternalTimer(this, duration); m_Timer.Start(); @@ -150,7 +170,9 @@ namespace Server.Spells.Seventh public override bool OnMoveOver(Mobile m) { if (!(m is PlayerMobile)) + { return base.OnMoveOver(m); + } var noto = Notoriety.Compute(m_Caster, m); return noto != Notoriety.Enemy && noto != Notoriety.Ally && base.OnMoveOver(m); diff --git a/Projects/UOContent/Spells/Seventh/FlameStrike.cs b/Projects/UOContent/Spells/Seventh/FlameStrike.cs index 11fc91a4f..65d765c7a 100644 --- a/Projects/UOContent/Spells/Seventh/FlameStrike.cs +++ b/Projects/UOContent/Spells/Seventh/FlameStrike.cs @@ -24,7 +24,9 @@ namespace Server.Spells.Seventh public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Seventh/GateTravel.cs b/Projects/UOContent/Spells/Seventh/GateTravel.cs index fae1de72f..3b8438934 100644 --- a/Projects/UOContent/Spells/Seventh/GateTravel.cs +++ b/Projects/UOContent/Spells/Seventh/GateTravel.cs @@ -92,9 +92,13 @@ namespace Server.Spells.Seventh public override void OnCast() { if (m_Entry == null) + { Caster.Target = new RecallSpellTarget(this, false); + } else + { Effect(m_Entry.Location, m_Entry.Map, true); + } } public override bool CheckCast() @@ -137,7 +141,9 @@ namespace Server.Spells.Seventh Map = map; if (ShowFeluccaWarning && map == Map.Felucca) + { ItemID = 0xDDA; + } Dispellable = true; diff --git a/Projects/UOContent/Spells/Seventh/ManaVampire.cs b/Projects/UOContent/Spells/Seventh/ManaVampire.cs index cc3354bf8..08856460a 100644 --- a/Projects/UOContent/Spells/Seventh/ManaVampire.cs +++ b/Projects/UOContent/Spells/Seventh/ManaVampire.cs @@ -25,7 +25,9 @@ namespace Server.Spells.Seventh public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -48,14 +50,20 @@ namespace Server.Spells.Seventh toDrain = (int)(GetDamageSkill(Caster) - GetResistSkill(m)); if (!m.Player) + { toDrain /= 2; + } } else { if (CheckResisted(m)) + { m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + } else + { toDrain = m.Mana; + } } m.Mana -= Math.Clamp(toDrain, 0, Math.Min(m.Mana, Caster.ManaMax - Caster.Mana)); diff --git a/Projects/UOContent/Spells/Seventh/MassDispel.cs b/Projects/UOContent/Spells/Seventh/MassDispel.cs index be02b6aea..532d4d656 100644 --- a/Projects/UOContent/Spells/Seventh/MassDispel.cs +++ b/Projects/UOContent/Spells/Seventh/MassDispel.cs @@ -44,7 +44,9 @@ namespace Server.Spells.Seventh foreach (var bc in eable) { if (!(bc.IsDispellable && Caster.CanBeHarmful(bc, false))) + { continue; + } var dispelChance = (50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100; diff --git a/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs b/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs index d818e3e5a..81e9831ad 100644 --- a/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs +++ b/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs @@ -37,7 +37,9 @@ namespace Server.Spells.Seventh SpellHelper.Turn(Caster, p); if (p is Item item) + { p = item.GetWorldLocation(); + } List targets; @@ -55,10 +57,14 @@ namespace Server.Spells.Seventh if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) || Core.AOS && !Caster.InLOS(m)) + { return false; + } if (m.Player) + { playerVsPlayer = true; + } return true; } @@ -83,9 +89,13 @@ namespace Server.Spells.Seventh Effects.PlaySound(p, Caster.Map, 0x160); if (Core.AOS && targets.Count > 2) + { damage = damage * 2 / targets.Count; + } else if (!Core.AOS) + { damage /= targets.Count; + } for (var i = 0; i < targets.Count; ++i) { diff --git a/Projects/UOContent/Spells/Seventh/Polymorph.cs b/Projects/UOContent/Spells/Seventh/Polymorph.cs index 5a9f2b9f5..20eb00424 100644 --- a/Projects/UOContent/Spells/Seventh/Polymorph.cs +++ b/Projects/UOContent/Spells/Seventh/Polymorph.cs @@ -62,9 +62,14 @@ namespace Server.Spells.Seventh if (!Caster.CanBeginAction()) { if (Core.ML) + { EndPolymorph(Caster); + } else + { Caster.SendLocalizedMessage(1005559); // This spell is already in effect. + } + return false; } @@ -93,9 +98,13 @@ namespace Server.Spells.Seventh else if (!Caster.CanBeginAction()) { if (Core.ML) + { EndPolymorph(Caster); + } else + { Caster.SendLocalizedMessage(1005559); // This spell is already in effect. + } } else if (TransformationSpellHelper.UnderTransformation(Caster)) { @@ -124,15 +133,21 @@ namespace Server.Spells.Seventh var mt = Caster.Mount; if (mt != null) + { mt.Rider = null; + } } Caster.BodyMod = m_NewBody; if (m_NewBody == 400 || m_NewBody == 401) + { Caster.HueMod = Caster.Race.RandomSkinHue(); + } else + { Caster.HueMod = 0; + } BaseArmor.ValidateMobile(Caster); BaseClothing.ValidateMobile(Caster); @@ -161,7 +176,9 @@ namespace Server.Spells.Seventh public static void StopTimer(Mobile m) { if (!m_Timers.TryGetValue(m, out var timer)) + { return; + } timer?.Stop(); m_Timers.Remove(m); @@ -170,7 +187,9 @@ namespace Server.Spells.Seventh private static void EndPolymorph(Mobile m) { if (m.CanBeginAction()) + { return; + } m.BodyMod = 0; m.HueMod = -1; @@ -191,7 +210,9 @@ namespace Server.Spells.Seventh var val = (int)owner.Skills.Magery.Value; if (val > 120) + { val = 120; + } Delay = TimeSpan.FromSeconds(val); Priority = TimerPriority.OneSecond; diff --git a/Projects/UOContent/Spells/Sixth/Dispel.cs b/Projects/UOContent/Spells/Sixth/Dispel.cs index 1ec56b4fb..1cc8e12e7 100644 --- a/Projects/UOContent/Spells/Sixth/Dispel.cs +++ b/Projects/UOContent/Spells/Sixth/Dispel.cs @@ -25,7 +25,9 @@ namespace Server.Spells.Sixth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Sixth/EnergyBolt.cs b/Projects/UOContent/Spells/Sixth/EnergyBolt.cs index 23e46a664..e2e74c421 100644 --- a/Projects/UOContent/Spells/Sixth/EnergyBolt.cs +++ b/Projects/UOContent/Spells/Sixth/EnergyBolt.cs @@ -24,7 +24,9 @@ namespace Server.Spells.Sixth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Sixth/Explosion.cs b/Projects/UOContent/Spells/Sixth/Explosion.cs index d05eaf809..ff6999039 100644 --- a/Projects/UOContent/Spells/Sixth/Explosion.cs +++ b/Projects/UOContent/Spells/Sixth/Explosion.cs @@ -28,7 +28,9 @@ namespace Server.Spells.Sixth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Sixth/Invisibility.cs b/Projects/UOContent/Spells/Sixth/Invisibility.cs index 2c1f7ea88..21322a1b6 100644 --- a/Projects/UOContent/Spells/Sixth/Invisibility.cs +++ b/Projects/UOContent/Spells/Sixth/Invisibility.cs @@ -29,7 +29,9 @@ namespace Server.Spells.Sixth public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Sixth/MassCurse.cs b/Projects/UOContent/Spells/Sixth/MassCurse.cs index d9c553f21..31f7e7e98 100644 --- a/Projects/UOContent/Spells/Sixth/MassCurse.cs +++ b/Projects/UOContent/Spells/Sixth/MassCurse.cs @@ -44,7 +44,9 @@ namespace Server.Spells.Sixth { if (Core.AOS && (m == Caster || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanSee(m) || !Caster.CanBeHarmful(m, false))) + { continue; + } Caster.DoHarmful(m); diff --git a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs index 11089f365..20de8418d 100644 --- a/Projects/UOContent/Spells/Sixth/ParalyzeField.cs +++ b/Projects/UOContent/Spells/Sixth/ParalyzeField.cs @@ -45,13 +45,21 @@ namespace Server.Spells.Sixth bool eastToWest; if (rx >= 0 && ry >= 0) + { eastToWest = false; + } else if (rx >= 0) + { eastToWest = true; + } else if (ry >= 0) + { eastToWest = true; + } else + { eastToWest = false; + } Effects.PlaySound(p, Caster.Map, 0x20B); @@ -64,7 +72,9 @@ namespace Server.Spells.Sixth var loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z); if (!SpellHelper.AdjustField(ref loc, Caster.Map, 12, false)) + { continue; + } Item item = new InternalItem(Caster, itemID, loc, Caster.Map, duration); item.ProcessDelta(); @@ -103,12 +113,18 @@ namespace Server.Spells.Sixth MoveToWorld(loc, map); if (caster.InLOS(this)) + { Visible = true; + } else + { Delete(); + } if (Deleted) + { return; + } m_Caster = caster; @@ -168,7 +184,9 @@ namespace Server.Spells.Sixth SpellHelper.ValidIndirectTarget(m_Caster, m) && m_Caster.CanBeHarmful(m, false)) { if (SpellHelper.CanRevealCaster(m)) + { m_Caster.RevealingAction(); + } m_Caster.DoHarmful(m); @@ -182,7 +200,9 @@ namespace Server.Spells.Sixth ); if (!m.Player) + { duration *= 3.0; + } } else { diff --git a/Projects/UOContent/Spells/Sixth/Reveal.cs b/Projects/UOContent/Spells/Sixth/Reveal.cs index 91c3ea3ca..2d00c52de 100644 --- a/Projects/UOContent/Spells/Sixth/Reveal.cs +++ b/Projects/UOContent/Spells/Sixth/Reveal.cs @@ -45,7 +45,9 @@ namespace Server.Spells.Sixth (m.X != p.X || m.Y != p.Y || !m.Hidden || m.AccessLevel != AccessLevel.Player && Caster.AccessLevel <= m.AccessLevel || !CheckDifficulty(Caster, m))) + { continue; + } m.RevealingAction(); @@ -70,7 +72,9 @@ namespace Server.Spells.Sixth { // Reveal always reveals vs. invisibility spell if (!Core.AOS || InvisibilitySpell.HasTimer(m)) + { return true; + } var magery = from.Skills.Magery.Fixed; var detectHidden = from.Skills.DetectHidden.Fixed; @@ -81,9 +85,13 @@ namespace Server.Spells.Sixth int chance; if (divisor > 0) + { chance = 50 * (magery + detectHidden) / divisor; + } else + { chance = 100; + } return chance > Utility.Random(100); } diff --git a/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs b/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs index 441b7074b..b2f12f671 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs @@ -63,7 +63,9 @@ namespace Server.Spells.Spellweaving ); // The Sanctuary is a special, single location place for (var i = 0; i < Arcanists.Count; i++) + { GiveArcaneFocus(Arcanists[i], duration, strengthBonus); + } } FinishSequence(); @@ -77,7 +79,9 @@ namespace Server.Spells.Spellweaving var lt = map.Tiles.GetLandTile(location.X, location.Y); // Land Tiles if (IsValidTile(lt.ID) && lt.Z == location.Z) + { return true; + } var tiles = map.Tiles.GetStaticTiles(location.X, location.Y); // Static Tiles @@ -89,9 +93,14 @@ namespace Server.Spells.Spellweaving var tand = t.ID; if (t.Z + id.CalcHeight != location.Z) + { continue; + } + if (IsValidTile(tand)) + { return true; + } } var eable = map.GetItemsInRange(location, 0); @@ -131,7 +140,9 @@ namespace Server.Spells.Spellweaving private void GiveArcaneFocus(Mobile to, TimeSpan duration, int strengthBonus) { if (to == null) // Sanity + { return; + } var focus = FindArcaneFocus(to); diff --git a/Projects/UOContent/Spells/Spellweaving/ArcaneForm.cs b/Projects/UOContent/Spells/Spellweaving/ArcaneForm.cs index fbaadb7a6..91e817c15 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcaneForm.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcaneForm.cs @@ -32,7 +32,9 @@ namespace Server.Spells.Spellweaving public override bool CheckCast() { if (!TransformationSpellHelper.CheckCast(Caster, this)) + { return false; + } return base.CheckCast(); } diff --git a/Projects/UOContent/Spells/Spellweaving/ArcaneSummon.cs b/Projects/UOContent/Spells/Spellweaving/ArcaneSummon.cs index a355f5751..7d12aeafc 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcaneSummon.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcaneSummon.cs @@ -16,7 +16,9 @@ namespace Server.Spells.Spellweaving public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 1 > Caster.FollowersMax) { diff --git a/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs b/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs index 55e3426a8..919abb461 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs @@ -39,7 +39,9 @@ namespace Server.Spells.Spellweaving public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } var caster = Caster; @@ -111,7 +113,9 @@ namespace Server.Spells.Spellweaving base.OnDisturb(type, message); if (message) + { Caster.PlaySound(0x1D6); + } } public override void OnBeginCast() @@ -134,10 +138,14 @@ namespace Server.Spells.Spellweaving 100; // TODO: According to the guide this is it.. but.. is it correct per OSI? if (percent <= 0) + { return false; + } if (percent >= 1.0) + { return true; + } return percent >= Utility.RandomDouble(); } diff --git a/Projects/UOContent/Spells/Spellweaving/AttuneWeapon.cs b/Projects/UOContent/Spells/Spellweaving/AttuneWeapon.cs index 35af05a5e..93f4f30bc 100644 --- a/Projects/UOContent/Spells/Spellweaving/AttuneWeapon.cs +++ b/Projects/UOContent/Spells/Spellweaving/AttuneWeapon.cs @@ -32,7 +32,9 @@ namespace Server.Spells.Spellweaving } if (Caster.CanBeginAction()) + { return base.CheckCast(); + } Caster.SendLocalizedMessage(1075124); // You must wait before casting that spell again. return false; @@ -72,7 +74,9 @@ namespace Server.Spells.Spellweaving public static void TryAbsorb(Mobile defender, ref int damage) { if (damage == 0 || !IsAbsorbing(defender) || defender.MeleeDamageAbsorb <= 0) + { return; + } var absorbed = Math.Min(damage, defender.MeleeDamageAbsorb); @@ -85,7 +89,9 @@ namespace Server.Spells.Spellweaving ); // ~1_damage~ point(s) of damage have been absorbed. A total of ~2_remaining~ point(s) of shielding remain. if (defender.MeleeDamageAbsorb <= 0) + { StopAbsorbing(defender, true); + } } public static bool IsAbsorbing(Mobile m) => m_Table.ContainsKey(m); @@ -93,7 +99,9 @@ namespace Server.Spells.Spellweaving public static void StopAbsorbing(Mobile m, bool message) { if (m_Table.TryGetValue(m, out var t)) + { t.DoExpire(message); + } } private class ExpireTimer : Timer diff --git a/Projects/UOContent/Spells/Spellweaving/EssenceOfWind.cs b/Projects/UOContent/Spells/Spellweaving/EssenceOfWind.cs index 858929ee4..aa390cfb7 100644 --- a/Projects/UOContent/Spells/Spellweaving/EssenceOfWind.cs +++ b/Projects/UOContent/Spells/Spellweaving/EssenceOfWind.cs @@ -40,14 +40,18 @@ namespace Server.Spells.Spellweaving { if (Caster == m || !Caster.InLOS(m) || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false)) + { continue; + } Caster.DoHarmful(m); SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0); if (CheckResisted(m)) + { continue; + } m_Table[m] = new EssenceOfWindInfo(m, fcMalus, ssiMalus, duration); @@ -78,7 +82,9 @@ namespace Server.Spells.Spellweaving public static void StopDebuffing(Mobile m, bool message) { if (m_Table.TryGetValue(m, out var info)) + { info.Timer.DoExpire(message); + } } private class EssenceOfWindInfo diff --git a/Projects/UOContent/Spells/Spellweaving/EtherealVoyage.cs b/Projects/UOContent/Spells/Spellweaving/EtherealVoyage.cs index bd339c034..d43acee2e 100644 --- a/Projects/UOContent/Spells/Spellweaving/EtherealVoyage.cs +++ b/Projects/UOContent/Spells/Spellweaving/EtherealVoyage.cs @@ -31,19 +31,29 @@ namespace Server.Spells.Spellweaving public static void RemoveTransformationOnAggressiveAction(AggressiveActionEventArgs e) { if (TransformationSpellHelper.UnderTransformation(e.Aggressor, typeof(EtherealVoyageSpell))) + { TransformationSpellHelper.RemoveContext(e.Aggressor, true); + } } public override bool CheckCast() { if (TransformationSpellHelper.UnderTransformation(Caster, typeof(EtherealVoyageSpell))) + { Caster.SendLocalizedMessage(501775); // This spell is already in effect. + } else if (!Caster.CanBeginAction()) + { Caster.SendLocalizedMessage(1075124); // You must wait before casting that spell again. + } else if (Caster.Combatant != null) + { Caster.SendLocalizedMessage(1072586); // You cannot cast Ethereal Voyage while you are in combat. + } else + { return base.CheckCast(); + } return false; } diff --git a/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs b/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs index c91b26763..8ffac26ae 100644 --- a/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs +++ b/Projects/UOContent/Spells/Spellweaving/GiftOfLife.cs @@ -94,13 +94,17 @@ namespace Server.Spells.Spellweaving public static void HandleDeath(Mobile m) { if (m_Table.ContainsKey(m)) + { Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(2, 4)), HandleDeath_OnCallback, m); + } } private static void HandleDeath_OnCallback(Mobile m) { if (!m_Table.TryGetValue(m, out var timer)) + { return; + } var hitsScalar = timer.Spell.HitsScalar; @@ -143,7 +147,9 @@ namespace Server.Spells.Spellweaving public static void OnLogin(Mobile m) { if (m?.Alive != false || m_Table[m] == null) + { return; + } HandleDeath_OnCallback(m); } diff --git a/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs b/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs index 854604e7a..eb5ec0e6a 100644 --- a/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs +++ b/Projects/UOContent/Spells/Spellweaving/Items/TransientItem.cs @@ -34,7 +34,9 @@ namespace Server.Items public override void HandleInvalidTransfer(Mobile from) { if (InvalidTransferMessage != null) - TextDefinition.SendMessageTo(from, InvalidTransferMessage); + { + TextDefinition.SendMessageTo(@from, InvalidTransferMessage); + } Delete(); } @@ -66,9 +68,13 @@ namespace Server.Items public virtual void CheckExpiry() { if (CreationTime + LifeSpan < DateTime.UtcNow) + { Expire(RootParent as Mobile); + } else + { InvalidateProperties(); + } } public override void GetProperties(ObjectPropertyList list) diff --git a/Projects/UOContent/Spells/Spellweaving/Mobiles/NatureFury.cs b/Projects/UOContent/Spells/Spellweaving/Mobiles/NatureFury.cs index 63dfc37d7..10a783758 100644 --- a/Projects/UOContent/Spells/Spellweaving/Mobiles/NatureFury.cs +++ b/Projects/UOContent/Spells/Spellweaving/Mobiles/NatureFury.cs @@ -65,7 +65,9 @@ namespace Server.Mobiles PlaySound(0x1BC); if (Alive && !Deleted) + { Timer.DelayCall(TimeSpan.FromSeconds(7.0), DoEffects); + } } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Spells/Spellweaving/NatureFury.cs b/Projects/UOContent/Spells/Spellweaving/NatureFury.cs index 93af2d754..748280cb6 100644 --- a/Projects/UOContent/Spells/Spellweaving/NatureFury.cs +++ b/Projects/UOContent/Spells/Spellweaving/NatureFury.cs @@ -30,10 +30,14 @@ namespace Server.Spells.Spellweaving var map = Caster.Map; if (map == null) + { return; + } if (Region.Find(p, map).GetRegion()?.House?.IsFriend(Caster) == false) + { return; + } if (!map.CanSpawnMobile(p.X, p.Y, p.Z)) { @@ -55,7 +59,9 @@ namespace Server.Spells.Spellweaving public override bool CheckCast() { if (!base.CheckCast()) + { return false; + } if (Caster.Followers + 1 > Caster.FollowersMax) { diff --git a/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs b/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs index 0320216ea..b7b70e973 100644 --- a/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs +++ b/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs @@ -37,7 +37,9 @@ namespace Server.Spells.Spellweaving var context = TransformationSpellHelper.GetContext(m); if (context?.Type == typeof(ReaperFormSpell)) + { m.Send(SpeedControl.WalkSpeed); + } } public override void DoEffect(Mobile m) diff --git a/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs b/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs index 0f32f5bf9..ebe4e7336 100644 --- a/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs +++ b/Projects/UOContent/Spells/Spellweaving/WordOfDeath.cs @@ -19,7 +19,9 @@ namespace Server.Spells.Spellweaving public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -65,7 +67,10 @@ namespace Server.Spells.Spellweaving damage = Utility.RandomMinMax(minDamage, maxDamage); var damageBonus = AosAttributes.GetValue(Caster, AosAttribute.SpellDamage); if (m.Player && damageBonus > 15) + { damageBonus = 15; + } + damage *= damageBonus + 100; damage /= 100; } diff --git a/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs b/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs index 11753e2d5..0c81b27db 100644 --- a/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs +++ b/Projects/UOContent/Spells/Targeting/RecallSpellTarget.cs @@ -22,36 +22,48 @@ namespace Server.Spells if (o is RecallRune rune) { if (rune.Marked) + { m_Spell.Effect(rune.Target, rune.TargetMap, true); + } else - from.SendLocalizedMessage(501805); // That rune is not yet marked. + { + @from.SendLocalizedMessage(501805); // That rune is not yet marked. + } } else if (o is Runebook runebook) { var e = runebook.Default; if (e != null) + { m_Spell.Effect(e.Location, e.Map, true); + } else - from.SendLocalizedMessage(502354); // Target is not marked. + { + @from.SendLocalizedMessage(502354); // Target is not marked. + } } else if (m_ToBoat && o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat) { if (!boat.Deleted && boat.CheckKey(key.KeyValue)) + { m_Spell.Effect(boat.GetMarkedLocation(), boat.Map, false); + } else - from.Send( + { + @from.Send( new MessageLocalized( - from.Serial, - from.Body, + @from.Serial, + @from.Body, MessageType.Regular, 0x3B2, 3, 502357, - from.Name, + @from.Name, "" ) ); // I can not recall from that object. + } } else if (o is HouseRaffleDeed deed && deed.ValidLocation()) { diff --git a/Projects/UOContent/Spells/Targeting/SpellTargetItem.cs b/Projects/UOContent/Spells/Targeting/SpellTargetItem.cs index 498d10a57..0130beda4 100644 --- a/Projects/UOContent/Spells/Targeting/SpellTargetItem.cs +++ b/Projects/UOContent/Spells/Targeting/SpellTargetItem.cs @@ -19,7 +19,9 @@ namespace Server.Spells protected override void OnTarget(Mobile from, object o) { if (o is Item item) + { m_Spell.Target(item); + } } protected override void OnTargetFinish(Mobile from) diff --git a/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs b/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs index f28b43998..6a04be55a 100644 --- a/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs +++ b/Projects/UOContent/Spells/Targeting/SpellTargetPoint3D.cs @@ -26,13 +26,17 @@ namespace Server.Spells protected override void OnTarget(Mobile from, object o) { if (o is IPoint3D p) + { m_Spell.Target(p); + } } protected override void OnTargetOutOfLOS(Mobile from, object o) { if (!m_CheckLOS) + { return; + } from.SendLocalizedMessage(501943); // Target cannot be seen. Try again. from.Target = new SpellTargetPoint3D(m_Spell); diff --git a/Projects/UOContent/Spells/Third/Bless.cs b/Projects/UOContent/Spells/Third/Bless.cs index b30f1df80..90323054f 100644 --- a/Projects/UOContent/Spells/Third/Bless.cs +++ b/Projects/UOContent/Spells/Third/Bless.cs @@ -23,7 +23,9 @@ namespace Server.Spells.Third public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Third/Fireball.cs b/Projects/UOContent/Spells/Third/Fireball.cs index 6870fd0a8..0df5e4bc0 100644 --- a/Projects/UOContent/Spells/Third/Fireball.cs +++ b/Projects/UOContent/Spells/Third/Fireball.cs @@ -23,7 +23,9 @@ namespace Server.Spells.Third public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { diff --git a/Projects/UOContent/Spells/Third/Poison.cs b/Projects/UOContent/Spells/Third/Poison.cs index f97ecda41..bcc4e9f0d 100644 --- a/Projects/UOContent/Spells/Third/Poison.cs +++ b/Projects/UOContent/Spells/Third/Poison.cs @@ -22,7 +22,9 @@ namespace Server.Spells.Third public void Target(Mobile m) { if (m == null) + { return; + } if (!Caster.CanSee(m)) { @@ -53,13 +55,21 @@ namespace Server.Spells.Third var total = (Caster.Skills.Magery.Fixed + Caster.Skills.Poisoning.Fixed) / 2; if (total >= 1000) + { level = 3; + } else if (total > 850) + { level = 2; + } else if (total > 650) + { level = 1; + } else + { level = 0; + } } else { @@ -76,7 +86,9 @@ namespace Server.Spells.Third { if (pm.DuelContext?.Started != true || pm.DuelContext.Finished || pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning")) + { total += pm.Skills.Poisoning.Value; + } } else { @@ -86,16 +98,26 @@ namespace Server.Spells.Third var dist = Caster.GetDistanceToSqrt(m); if (dist >= 3.0) + { total -= (dist - 3.0) * 10.0; + } if (total >= 200.0 && Utility.Random(10) < 1) + { level = 3; + } else if (total > (Core.AOS ? 170.1 : 170.0)) + { level = 2; + } else if (total > (Core.AOS ? 130.1 : 130.0)) + { level = 1; + } else + { level = 0; + } } m.ApplyPoison(Caster, Poison.GetPoison(level)); diff --git a/Projects/UOContent/Spells/Third/Teleport.cs b/Projects/UOContent/Spells/Third/Teleport.cs index fae747ae6..527ef7f86 100644 --- a/Projects/UOContent/Spells/Third/Teleport.cs +++ b/Projects/UOContent/Spells/Third/Teleport.cs @@ -98,9 +98,13 @@ namespace Server.Spells.Third var eable = m.GetItemsInRange(0); foreach (var item in eable) + { if (item is ParalyzeFieldSpell.InternalItem || item is PoisonFieldSpell.InternalItem || item is FireFieldSpell.FireFieldItem) + { item.OnMoveOver(m); + } + } eable.Free(); } diff --git a/Projects/UOContent/Spells/Third/Unlock.cs b/Projects/UOContent/Spells/Third/Unlock.cs index 2950b0868..91e4a27a6 100644 --- a/Projects/UOContent/Spells/Third/Unlock.cs +++ b/Projects/UOContent/Spells/Third/Unlock.cs @@ -74,7 +74,9 @@ namespace Server.Spells.Third cont.Locked = false; if (cont.LockLevel == -255) + { cont.LockLevel = cont.RequiredSkill - 10; + } } else { diff --git a/Projects/UOContent/Spells/Third/WallOfStone.cs b/Projects/UOContent/Spells/Third/WallOfStone.cs index 9095c4b56..ecbe773c1 100644 --- a/Projects/UOContent/Spells/Third/WallOfStone.cs +++ b/Projects/UOContent/Spells/Third/WallOfStone.cs @@ -43,13 +43,21 @@ namespace Server.Spells.Third bool eastToWest; if (rx >= 0 && ry >= 0) + { eastToWest = false; + } else if (rx >= 0) + { eastToWest = true; + } else if (ry >= 0) + { eastToWest = true; + } else + { eastToWest = false; + } Effects.PlaySound(p, Caster.Map, 0x1F6); @@ -61,7 +69,9 @@ namespace Server.Spells.Third // Effects.SendLocationParticles( EffectItem.Create( loc, Caster.Map, EffectItem.DefaultDuration ), 0x376A, 9, 10, 5025 ); if (!canFit) + { continue; + } Item item = new InternalItem(loc, Caster.Map, Caster); @@ -96,12 +106,18 @@ namespace Server.Spells.Third m_Caster = caster; if (caster.InLOS(this)) + { Visible = true; + } else + { Delete(); + } if (Deleted) + { return; + } m_Timer = new InternalTimer(this, TimeSpan.FromSeconds(10.0)); m_Timer.Start(); @@ -161,7 +177,9 @@ namespace Server.Spells.Third { var noto = Notoriety.Compute(m_Caster, m); if (noto == Notoriety.Enemy || noto == Notoriety.Ally) + { return false; + } } return base.OnMoveOver(m); diff --git a/Projects/UOContent/Spells/UnsummonTimer.cs b/Projects/UOContent/Spells/UnsummonTimer.cs index f270eb08e..d038e1620 100644 --- a/Projects/UOContent/Spells/UnsummonTimer.cs +++ b/Projects/UOContent/Spells/UnsummonTimer.cs @@ -18,7 +18,9 @@ namespace Server.Spells protected override void OnTick() { if (!m_Creature.Deleted) + { m_Creature.Delete(); + } } } } diff --git a/Projects/UOContent/Targets/BladedItemTarget.cs b/Projects/UOContent/Targets/BladedItemTarget.cs index d72485019..1f277b62c 100644 --- a/Projects/UOContent/Targets/BladedItemTarget.cs +++ b/Projects/UOContent/Targets/BladedItemTarget.cs @@ -15,15 +15,21 @@ namespace Server.Targets protected override void OnTargetOutOfRange(Mobile from, object targeted) { if (targeted is UnholyBone bone && from.InRange(bone, 12)) - bone.Carve(from, m_Item); + { + bone.Carve(@from, m_Item); + } else - base.OnTargetOutOfRange(from, targeted); + { + base.OnTargetOutOfRange(@from, targeted); + } } protected override void OnTarget(Mobile from, object targeted) { if (m_Item.Deleted) + { return; + } if (targeted is ICarvable carvable) { @@ -32,9 +38,13 @@ namespace Server.Targets else if (targeted is SwampDragon pet && pet.HasBarding) { if (!pet.Controlled || pet.ControlMaster != from) - from.SendLocalizedMessage(1053022); // You cannot remove barding from a swamp dragon you do not own. + { + @from.SendLocalizedMessage(1053022); // You cannot remove barding from a swamp dragon you do not own. + } else + { pet.HasBarding = false; + } } else { @@ -77,7 +87,9 @@ namespace Server.Targets var bank = def.GetBank(map, loc.X, loc.Y); if (bank == null) + { return; + } if (bank.Current < 5) { diff --git a/Projects/UOContent/Targets/MoveTarget.cs b/Projects/UOContent/Targets/MoveTarget.cs index 5d53bef34..3de2bcc13 100644 --- a/Projects/UOContent/Targets/MoveTarget.cs +++ b/Projects/UOContent/Targets/MoveTarget.cs @@ -21,7 +21,9 @@ namespace Server.Targets } if (p is Item pItem) + { p = pItem.GetWorldTop(); + } CommandLogging.WriteLine( from, @@ -35,12 +37,16 @@ namespace Server.Targets if (m_Object is Item item) { if (!item.Deleted) - item.MoveToWorld(new Point3D(p), from.Map); + { + item.MoveToWorld(new Point3D(p), @from.Map); + } } else if (m_Object is Mobile m) { if (!m.Deleted) - m.MoveToWorld(new Point3D(p), from.Map); + { + m.MoveToWorld(new Point3D(p), @from.Map); + } } } } diff --git a/Projects/UOContent/Targets/PickMoveTarget.cs b/Projects/UOContent/Targets/PickMoveTarget.cs index 424f2bacc..310c7e83a 100644 --- a/Projects/UOContent/Targets/PickMoveTarget.cs +++ b/Projects/UOContent/Targets/PickMoveTarget.cs @@ -18,7 +18,9 @@ namespace Server.Targets } if (o is Item || o is Mobile) - from.Target = new MoveTarget(o); + { + @from.Target = new MoveTarget(o); + } } } }