diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..03397e46f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +[*] +charset=utf-8 +end_of_line=crlf +trim_trailing_whitespace=true +insert_final_newline=true +indent_style=space +indent_size=2 + diff --git a/GOALS.md b/GOALS.md index 2b08b1089..19ff4152e 100644 --- a/GOALS.md +++ b/GOALS.md @@ -44,7 +44,7 @@ - [ ] Naked corpses (container display issue) - [X] Rounding errors with new bank system - [ ] Replace `double` with `int` for skills to fix rounding errors and optimize code -- [ ] Replace specific checks for `Item`/`Mobile` by extended `IEntity` and mainstreaming the `NEWPARENT` code +- [X] Replace specific checks for `Item`/`Mobile` by extended `IEntity` and mainstreaming the `NEWPARENT` code - [ ] TryDropItem dropping items until it fails when it should be all-or-nothing - [ ] Consuming items are deleted directly in several places instead of using `Item.Consume()` - [ ] Content displaying for newer clients is not working properly in several situations diff --git a/README.md b/README.md index b93354911..ec71f975e 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,33 @@ -ModernUO -===== - -### Goals -- See [Goals](./GOALS.md) - -### Requirements -- .NET Framework 4.7 or Mono 5.10+ -- zlib (Linux only) -- [DotNetCompilerPlatform](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform) v2.0+ (Windows Only) - -### Building using Visual Studio (Recommended) -- Build `Server` project - - Building with Visual Studio for Windows will install `DotNetCompilerPlatform` automatically. - -### Building for Windows (Without Visual Studio) -`C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc /optimize /unsafe /t:exe /out:RunUO.exe /win32icon:Server\runuo.ico /d:NEWTIMERS /d:NEWPARENT /recurse:Server\\*.cs` -- DotNetCompilerPlatform must be installed with the `csc.exe` file in the `roslyn` folder at the root of the repository. - -### Building for Mac/Linux (Without Visual Studio) -`mcs -optimize+ -unsafe -t:exe -out:RunUO.exe -win32icon:Server/runuo.ico -nowarn:219,414 -d:NEWTIMERS -d:NEWPARENT -d:MONO -reference:System.Drawing -recurse:Server/*.cs` - -### Running on Mac/Linux (MONO) -`mono RunUO.exe` - -### Troubleshooting / FAQ - -#### Scripts fail to compile on Windows -This is usually caused nuget packages not being installed. Install the required packages and rebuild the Server project. -Note: The required nuget packages can be set to automatically restore on build with this [setting](https://docs.microsoft.com/en-us/nuget/consume-packages/media/restore-01-autorestoreoptions.png) +ModernUO +===== + +### Contacts +[Join Discord Channel](https://discord.gg/VdyCpjQ) + +### Goals +- See [Goals](./GOALS.md) + +### Requirements +- .NET Framework 4.7 or Mono 5.10+ +- zlib (Linux only) +- [DotNetCompilerPlatform](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform) v2.0+ (Windows Only) + +### Building using Visual Studio (Recommended) +- Build `Server` project + - Building with Visual Studio for Windows will install `DotNetCompilerPlatform` automatically. + +### Building for Windows (Without Visual Studio) +`C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc /optimize /unsafe /t:exe /out:RunUO.exe /win32icon:Server\runuo.ico /d:NEWTIMERS /recurse:Server\\*.cs` +- DotNetCompilerPlatform must be installed with the `csc.exe` file in the `roslyn` folder at the root of the repository. + +### Building for Mac/Linux (Without Visual Studio) +`mcs -optimize+ -unsafe -t:exe -out:RunUO.exe -win32icon:Server/runuo.ico -nowarn:219,414 -d:NEWTIMERS -d:MONO -recurse:"Server/*".cs` + +### Running on Mac/Linux (MONO) +`mono RunUO.exe` + +### Troubleshooting / FAQ + +#### Scripts fail to compile on Windows +This is usually caused nuget packages not being installed. Install the required packages and rebuild the Server project. +Note: The required nuget packages can be set to automatically restore on build with this [setting](https://docs.microsoft.com/en-us/nuget/consume-packages/media/restore-01-autorestoreoptions.png) diff --git a/RUNUO_MIGRATIONS.md b/RUNUO_MIGRATIONS.md new file mode 100644 index 000000000..4459fab64 --- /dev/null +++ b/RUNUO_MIGRATIONS.md @@ -0,0 +1,71 @@ +### Migrating from RunUO 2.0 +There are several considerations before migration from RunUO 2.0 to ModernUO. +Many of these issues can be fixed by writing scripts that do world file fixes. +Others will require careful code review to fix compile/runtime issues. + +#### Deserialization Issues +* All BODs will fail to deserialize due to the introduction of BaseBOD +* Serial is now a `uint` which could break certain scripts expecting negative numbers or fixed encoding. + +#### Constructor Inheritence Issues +* Items that inherit `Food` will pass the wrong arguments to their parent constructor. +* Items that inherit spells or scrolls will pass the wrong arguments to their parent constructors. + +#### Code Changes (Possible Compile Errors) +* The following functions no longer take a Type as their argument and now utilize generics: + * CanBeginAction, BeginAction and EndAction + * FindRegion and IsPartOf + * FindGump, HasGump, and CloseGump +* Timers use lambda functions instead of callback objects with generic `object state` argument. +* Various functions such as `OnAdded` which previously took `object parent` now take `IEntity` +* Functions that utilized non-generic structures (ArrayList, etc) have been changed to use generics. + + +### Future Migration Concerns + +#### Account System +* Accounts from the XML format will need to be migrated to the new database. +* IP Logs from the Accounts XML will need to be offloaded to a new database. + +#### Deserialization +* All layered/stackable items will need to be migrated/fixed since the new hierarchy will look like this: + * Item -> LayeredItem -> Armor/Weapon/etc + * Item -> StackableItem -> Food/etc +* All resources including but not limited to the following will need to be migrated: + * Gold, Silver, Platinum + * Arrow, Bolt, Feature, Shaft + * BaseOre, BaseIngot, BaseScale and all children + * BigFish, Fish, MagicFish + * Granite, Sand + * BaseReagent and all children + * BoltOfCloth, Bone, Cloth, Cotton, Flax, BaseHides, BaseLeather, UncutCloth, Wool, YarnAndThreads and all children + * ML Resources (Check Scripts/Items/Resources/MiscMLResources.cs on RunUO 2.0) + * Log and Board + * Bottle + * Solen Items (e.g. ZoogiFungus) + * Other commodity types I can't remember +* Spawners will need to be migrated since the old Spawner has been replaced and deserialization is not guaranteed. + +#### Timers +* Scripts that rely on Timers, TimerPriority, etc will need to be fixed to work with the format. + +#### Skills +* Scripts that use or do math against `double` type Skill values will need to be fixed. + +#### Fastwalk +* Other fastwalk/speedhack detection systems will need to be deleted or fixed. + +#### Reports +* These will be removed. + +#### RemoteAdmin +* This will also be removed. Discussion about a replacement as a plug-in is encouraged. + +#### MyRunUO +* This will be removed. Discussion about a replacement using an external database is encouraged. + +#### EventLog +* This will be changed to be cross platform compatible. What form it will take is still up for discussion. + +#### Packets (Maybe) +* Packets will be changed to be stateless functions that do not require instantiation. diff --git a/RunUO.vshost.exe.config b/RunUO.vshost.exe.config deleted file mode 100644 index 5106eb6a4..000000000 --- a/RunUO.vshost.exe.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Scripts/Accounting/Account.cs b/Scripts/Accounting/Account.cs index 042081ad7..1f23a2d22 100644 --- a/Scripts/Accounting/Account.cs +++ b/Scripts/Accounting/Account.cs @@ -11,7 +11,7 @@ using Server.Network; namespace Server.Accounting { - public class Account : IAccount, IComparable, IComparable + public class Account : IAccount, IComparable { public static readonly TimeSpan YoungDuration = TimeSpan.FromHours( 40.0 ); @@ -72,20 +72,14 @@ namespace Server.Accounting /// /// List of account comments. Type of contained objects is AccountComment. /// - public List Comments - { - get { if ( m_Comments == null ) m_Comments = new List(); return m_Comments; } - } + public List Comments => m_Comments ?? (m_Comments = new List()); - /// + /// /// List of account tags. Type of contained objects is AccountTag. /// - public List Tags - { - get { if ( m_Tags == null ) m_Tags = new List(); return m_Tags; } - } + public List Tags => m_Tags ?? (m_Tags = new List()); - /// + /// /// Account username. Case insensitive validation. /// public string Username { get; set; } @@ -136,10 +130,7 @@ namespace Server.Accounting if ( !isBanned ) return false; - DateTime banTime; - TimeSpan banDuration; - - if ( GetBanTags( out banTime, out banDuration ) ) + if ( GetBanTags( out DateTime banTime, out TimeSpan banDuration ) ) { if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= ( banTime + banDuration ) ) { @@ -164,11 +155,8 @@ namespace Server.Accounting { SetFlag( 1, !value ); - if ( m_YoungTimer != null ) - { - m_YoungTimer.Stop(); - m_YoungTimer = null; - } + m_YoungTimer?.Stop(); + m_YoungTimer = null; } } @@ -704,9 +692,7 @@ namespace Server.Accounting { if ( count < list.Length ) { - IPAddress address; - - if ( IPAddress.TryParse( Utility.GetText( ip, null ), out address ) ) + if ( IPAddress.TryParse( Utility.GetText( ip, null ), out IPAddress address ) ) { list[count] = Utility.Intern( address ); count++; @@ -848,7 +834,7 @@ namespace Server.Accounting { Mobile m = this[i]; - if ( m != null && m.AccessLevel >= level ) + if ( m?.AccessLevel >= level ) hasAccess = true; } } @@ -991,7 +977,7 @@ namespace Server.Accounting { Mobile m = m_Mobiles[i]; - if ( m != null && !m.Deleted ) + if (m?.Deleted == false) { xml.WriteStartElement( "char" ); xml.WriteAttributeString( "index", i.ToString() ); @@ -1002,7 +988,7 @@ namespace Server.Accounting xml.WriteEndElement(); - if ( m_Comments != null && m_Comments.Count > 0 ) + if (m_Comments?.Count > 0) { xml.WriteStartElement( "comments" ); @@ -1012,7 +998,7 @@ namespace Server.Accounting xml.WriteEndElement(); } - if ( m_Tags != null && m_Tags.Count > 0 ) + if (m_Tags?.Count > 0) { xml.WriteStartElement( "tags" ); @@ -1103,7 +1089,7 @@ namespace Server.Accounting { Mobile m = m_Mobiles[index]; - if ( m != null && m.Deleted ) + if (m?.Deleted == true) { m.Account = null; m_Mobiles[index] = m = null; @@ -1135,28 +1121,14 @@ namespace Server.Accounting } public int CompareTo( Account other ) - { - if ( other == null ) - return 1; - - return Username.CompareTo( other.Username ); - } + { + return other == null ? 1 : Username.CompareTo( other.Username ); + } public int CompareTo( IAccount other ) - { - if ( other == null ) - return 1; - - return Username.CompareTo( other.Username ); - } - - public int CompareTo( object obj ) - { - if ( obj is Account account ) - return CompareTo( account ); - - throw new ArgumentException(); - } + { + return other == null ? 1 : Username.CompareTo( other.Username ); + } #region Gold Account /// diff --git a/Scripts/Accounting/Firewall.cs b/Scripts/Accounting/Firewall.cs index 572728c02..d07fc7e6f 100644 --- a/Scripts/Accounting/Firewall.cs +++ b/Scripts/Accounting/Firewall.cs @@ -303,4 +303,4 @@ namespace Server #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Add.cs b/Scripts/Commands/Add.cs index 29af1f94c..55bc82d0f 100644 --- a/Scripts/Commands/Add.cs +++ b/Scripts/Commands/Add.cs @@ -190,19 +190,17 @@ namespace Server.Commands if (!IsConstructible(ctor, from.AccessLevel)) continue; - + int totalParams = 0; // Handle optional constructors - ParameterInfo[] paramList = ctor.GetParameters().Select(param => - { - if (param.DefaultValue is DBNull) + ParameterInfo[] paramList = ctor.GetParameters(); + for (int j = 0; j < paramList.Length; j++) + if (!paramList[j].HasDefaultValue) totalParams += 1; - return param; - }).ToArray(); - if (args.Length == totalParams) + if (args.Length >= totalParams && args.Length <= paramList.Length) { object[] paramValues = ParseValues(paramList, args); @@ -223,25 +221,23 @@ namespace Server.Commands { object[] values = new object[paramList.Length]; - for (int i = 0, a = 0; i < paramList.Length; ++i) + for (int i = 0, a = 0; i < paramList.Length; i++) { ParameterInfo param = paramList[i]; - if (param.DefaultValue is DBNull) - { - object value = ParseValue(param.ParameterType, args[a++], param.DefaultValue); - if (value == null) - return null; + object value = ParseValue(param.ParameterType, a < args.Length ? args[a++] : null); + if (value != null) values[i] = value; - } - else + else if (param.HasDefaultValue) values[i] = Type.Missing; + else + return null; } return values; } - public static object ParseValue(Type type, string value, object defaultValue) + public static object ParseValue(Type type, string value) { try { @@ -250,7 +246,7 @@ namespace Server.Commands if (IsParsable(type)) return ParseParsable(type, value); object obj = value; - if (value != null && value.StartsWith("0x")) + if (value?.StartsWith("0x") == true) { if (IsSignedNumeric(type)) obj = Convert.ToInt64(value.Substring(2), 16); @@ -262,7 +258,7 @@ namespace Server.Commands if (obj == null && !type.IsValueType) return null; - + return Convert.ChangeType(obj, type); } catch @@ -455,7 +451,7 @@ namespace Server.Commands private static void Internal_OnCommand(CommandEventArgs e, bool outline) { Mobile from = e.Mobile; - + if (e.Length >= 1) BoundingBoxPicker.Begin(from, (map, start, end) => TileBox_Callback(from, map, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline))); @@ -511,7 +507,7 @@ namespace Server.Commands private static void InternalZ_OnCommand(CommandEventArgs e, bool outline) { Mobile from = e.Mobile; - + if (e.Length >= 2) { string[] subArgs = new string[e.Length - 1]; @@ -532,7 +528,7 @@ namespace Server.Commands private static void InternalAvg_OnCommand(CommandEventArgs e, bool outline) { Mobile from = e.Mobile; - + if (e.Length >= 1) BoundingBoxPicker.Begin(from, (map, start, end) => TileBox_Callback(from, map, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline))); @@ -630,10 +626,7 @@ namespace Server.Commands { object[] attrs = ctor.GetCustomAttributes(m_ConstructibleType, false); - if (attrs.Length == 0) - return false; - - return accessLevel >= ((ConstructibleAttribute)attrs[0]).AccessLevel; + return attrs.Length != 0 && accessLevel >= ((ConstructibleAttribute)attrs[0]).AccessLevel; } public static bool IsEnum(Type type) @@ -701,4 +694,4 @@ namespace Server.Commands } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Batch.cs b/Scripts/Commands/Batch.cs index 0238ca21b..89e703c5e 100644 --- a/Scripts/Commands/Batch.cs +++ b/Scripts/Commands/Batch.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Reflection; using Server.Commands.Generic; @@ -308,7 +307,7 @@ namespace Server.Commands for (int i = m_Batch.BatchCommands.Count - 1; i >= 0; --i) { - BatchCommand sc = (BatchCommand)m_Batch.BatchCommands[i]; + BatchCommand sc = m_Batch.BatchCommands[i]; entry = info.GetTextEntry(1 + i * 2); diff --git a/Scripts/Commands/Decorate.cs b/Scripts/Commands/Decorate.cs index 8faf09bdd..003d7345d 100644 --- a/Scripts/Commands/Decorate.cs +++ b/Scripts/Commands/Decorate.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using Server.Engines.Quests.Haven; using Server.Engines.Quests.Necro; using Server.Items; @@ -429,7 +430,7 @@ namespace Server.Commands int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) - sp.AddEntry(m_Params[i].Substring(++indexOf), 100, 1); + sp.AddEntry(m_Params[i].Substring(++indexOf)); } else if (m_Params[i].StartsWith("MinDelay")) { @@ -901,12 +902,11 @@ namespace Server.Commands { eable = map.GetItemsInRange(new Point3D(x, y, z), 0); - foreach (Item item in eable) - if (item.Z == z && item.ItemID == itemID) - { - eable.Free(); - return true; - } + if (eable.Any(item => item.Z == z && item.ItemID == itemID)) + { + eable.Free(); + return true; + } } eable.Free(); @@ -989,7 +989,7 @@ namespace Server.Commands { List list = new List(); DecorationList v; - + while ((v = Read(ip)) != null) list.Add(v); @@ -1066,11 +1066,9 @@ namespace Server.Commands { public DecorationEntry(string line) { - string x, y, z; - - Pop(out x, ref line); - Pop(out y, ref line); - Pop(out z, ref line); + Pop(out string x, ref line); + Pop(out string y, ref line); + Pop(out string z, ref line); Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z)); Extra = line; @@ -1096,4 +1094,4 @@ namespace Server.Commands } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/DecorateMag.cs b/Scripts/Commands/DecorateMag.cs index 893be8414..229654383 100644 --- a/Scripts/Commands/DecorateMag.cs +++ b/Scripts/Commands/DecorateMag.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq; using Server.Engines.Quests.Haven; using Server.Engines.Quests.Necro; using Server.Items; @@ -427,7 +428,7 @@ namespace Server.Commands int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) - sp.AddEntry(m_Params[i].Substring(++indexOf), 100, 1); + sp.AddEntry(m_Params[i].Substring(++indexOf)); } else if (m_Params[i].StartsWith("MinDelay")) { @@ -899,12 +900,11 @@ namespace Server.Commands { eable = map.GetItemsInRange(new Point3D(x, y, z), 0); - foreach (Item item in eable) - if (item.Z == z && item.ItemID == itemID) - { - eable.Free(); - return true; - } + if (eable.Any(item => item.Z == z && item.ItemID == itemID)) + { + eable.Free(); + return true; + } } eable.Free(); @@ -1064,11 +1064,9 @@ namespace Server.Commands { public DecorationEntryMag(string line) { - string x, y, z; - - Pop(out x, ref line); - Pop(out y, ref line); - Pop(out z, ref line); + Pop(out string x, ref line); + Pop(out string y, ref line); + Pop(out string z, ref line); Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z)); Extra = line; @@ -1094,4 +1092,4 @@ namespace Server.Commands } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Docs.cs b/Scripts/Commands/Docs.cs index 464e0687f..47e60a2dd 100644 --- a/Scripts/Commands/Docs.cs +++ b/Scripts/Commands/Docs.cs @@ -229,11 +229,9 @@ namespace Server.Commands StringBuilder nameBuilder = new StringBuilder(rootType); StringBuilder fnamBuilder = new StringBuilder("docs/types/" + SanitizeType(rootType)); StringBuilder linkBuilder; - if (DontLink(type)) //if ( DontLink( rootType ) ) - linkBuilder = new StringBuilder("" + rootType + ""); - else - linkBuilder = - new StringBuilder("" + rootType + ""); + linkBuilder = DontLink(type) ? + new StringBuilder("" + rootType + "") : + new StringBuilder("" + rootType + ""); nameBuilder.Append("<"); fnamBuilder.Append("-"); @@ -272,10 +270,7 @@ namespace Server.Commands } } - if (name == null) - typeName = type.Name; - else - typeName = name; + typeName = name ?? type.Name; if (fnam == null) fileName = "docs/types/" + SanitizeType(type.Name) + ".html"; else fileName = fnam + ".html"; @@ -300,7 +295,8 @@ namespace Server.Commands { bool anonymousType = name.Contains("<"); StringBuilder sb = new StringBuilder(name); - for (int i = 0; i < ReplaceChars.Length; ++i) sb.Replace(ReplaceChars[i], '-'); + for (int i = 0; i < ReplaceChars.Length; ++i) + sb.Replace(ReplaceChars[i], '-'); if (anonymousType) return "(Anonymous-Type)" + sb; return sb.ToString(); @@ -396,7 +392,8 @@ namespace Server.Commands v = 1; } - if (v == 0) v = GetNameFrom(aCtor, aProp, aMethod).CompareTo(GetNameFrom(bCtor, bProp, bMethod)); + 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); @@ -418,7 +415,7 @@ namespace Server.Commands MethodInfo getMethod = prop.GetGetMethod(); MethodInfo setMethod = prop.GetGetMethod(); - return getMethod != null && getMethod.IsStatic || setMethod != null && setMethod.IsStatic; + return getMethod?.IsStatic == true || setMethod?.IsStatic == true; } return false; @@ -426,13 +423,7 @@ namespace Server.Commands private string GetNameFrom(ConstructorInfo ctor, PropertyInfo prop, MethodInfo method) { - if (ctor != null) - return ctor.DeclaringType?.Name ?? ""; - if (prop != null) - return prop.Name; - if (method != null) - return method.Name; - return ""; + return ctor?.DeclaringType?.Name ?? prop?.Name ?? method?.Name ?? ""; } } @@ -440,14 +431,8 @@ namespace Server.Commands { public int Compare(TypeInfo x, TypeInfo y) { - if (x == null && y == null) - return 0; - if (x == null) - return -1; - if (y == null) - return 1; - - return x.TypeName.CompareTo(y.TypeName); + return x == null && y == null ? 0 : x == null ? -1 : y == null ? 1 : + x.TypeName.CompareTo(y.TypeName); } } @@ -1194,14 +1179,14 @@ namespace Server.Commands html.WriteLine(" "); } - private static void DocumentTailorBOD(StreamWriter html, List items, string amt, BulkMaterialType material, + private static void DocumentTailorBOD(StreamWriter html, List items, string amt, BulkMaterialType material, Type type) { bool[] rewards = new bool[20]; for (int i = 0; i < items.Count; ++i) { - Item item = items[i]; + Item item = items[i].Construct(); if (item is Sandals) { @@ -1471,13 +1456,13 @@ namespace Server.Commands html.WriteLine(" "); } - private static void DocumentSmithBOD(StreamWriter html, List items, string amt, BulkMaterialType material) + private static void DocumentSmithBOD(StreamWriter html, List items, string amt, BulkMaterialType material) { bool[] rewards = new bool[24]; for (int i = 0; i < items.Count; ++i) { - Item item = items[i]; + Item item = items[i].Construct(); if (item is SturdyPickaxe || item is SturdyShovel) { @@ -2463,7 +2448,7 @@ namespace Server.Commands int extendCount = 0; - if (baseType != null && baseType != typeof(object) && baseType != typeof(ValueType) && !baseType.IsPrimitive) + if (baseType != typeof(object) && baseType != typeof(ValueType) && baseType?.IsPrimitive == false) { typeHtml.Write(" : "); @@ -2575,7 +2560,7 @@ namespace Server.Commands MethodInfo getMethod = pi.GetGetMethod(); MethodInfo setMethod = pi.GetSetMethod(); - if (getMethod != null && getMethod.IsStatic || setMethod != null && setMethod.IsStatic) + if (getMethod?.IsStatic == true || setMethod?.IsStatic == true) html.Write(StaticString); html.Write(GetPair(pi.PropertyType, pi.Name, false)); diff --git a/Scripts/Commands/GenCategorization.cs b/Scripts/Commands/GenCategorization.cs index 74a025c9d..6e1aaed50 100644 --- a/Scripts/Commands/GenCategorization.cs +++ b/Scripts/Commands/GenCategorization.cs @@ -175,7 +175,7 @@ namespace Server.Commands ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes); - return ctor != null && ctor.IsDefined(typeofConstructible, false); + return ctor?.IsDefined(typeofConstructible, false) == true; } private static void AddTypes(Assembly asm, List types) @@ -399,4 +399,4 @@ namespace Server.Commands return list.ToArray(); } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Generic/Commands/Interface.cs b/Scripts/Commands/Generic/Commands/Interface.cs index e602be9ae..f87c18b13 100644 --- a/Scripts/Commands/Generic/Commands/Interface.cs +++ b/Scripts/Commands/Generic/Commands/Interface.cs @@ -105,7 +105,7 @@ namespace Server.Commands.Generic PropertyInfo[] chain = Properties.GetPropertyInfoChain(m_From, obj.GetType(), m_Columns[i], PropertyAccess.Read, ref failReason); - if (chain != null && chain.Length > 0) + if (chain?.Length > 0) { m_Columns[i] = ""; @@ -565,4 +565,4 @@ namespace Server.Commands.Generic } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs b/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs index 558bf3ef0..66d25d7c9 100644 --- a/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs +++ b/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs @@ -90,93 +90,93 @@ namespace Server.Commands.Generic public void Acquire(TypeBuilder typeBuilder, ILGenerator il, string fieldName) { - if (Value is string toParse) - { - if (!Type.IsValueType && toParse == "null") - { - Value = null; - } - else if (Type == typeof(string)) - { - if (toParse == @"@""null""") - toParse = "null"; + if (!(Value is string toParse)) + return; - Value = toParse; - } - else if (Type.IsEnum) + if (!Type.IsValueType && toParse == "null") + { + Value = null; + } + else if (Type == typeof(string)) + { + if (toParse == @"@""null""") + toParse = "null"; + + Value = toParse; + } + else if (Type.IsEnum) + { + Value = Enum.Parse(Type, toParse, true); + } + else + { + MethodInfo parseMethod; + object[] parseArgs; + + MethodInfo parseNumber = Type.GetMethod( + "Parse", + BindingFlags.Public | BindingFlags.Static, + null, + new[] { typeof(string), typeof(NumberStyles) }, + null + ); + + if (parseNumber != null) { - Value = Enum.Parse(Type, toParse, true); + NumberStyles style = NumberStyles.Integer; + + if (Insensitive.StartsWith(toParse, "0x")) + { + style = NumberStyles.HexNumber; + toParse = toParse.Substring(2); + } + + parseMethod = parseNumber; + parseArgs = new object[] { toParse, style }; } else { - MethodInfo parseMethod; - object[] parseArgs; - - MethodInfo parseNumber = Type.GetMethod( + MethodInfo parseGeneral = Type.GetMethod( "Parse", BindingFlags.Public | BindingFlags.Static, null, - new[] { typeof(string), typeof(NumberStyles) }, + new[] { typeof(string) }, null ); - if (parseNumber != null) - { - NumberStyles style = NumberStyles.Integer; + parseMethod = parseGeneral; + parseArgs = new object[] { toParse }; + } - if (Insensitive.StartsWith(toParse, "0x")) - { - style = NumberStyles.HexNumber; - toParse = toParse.Substring(2); - } + if (parseMethod != null) + { + Value = parseMethod.Invoke(null, parseArgs); - parseMethod = parseNumber; - parseArgs = new object[] { toParse, style }; - } - else + if (!Type.IsPrimitive) { - MethodInfo parseGeneral = Type.GetMethod( - "Parse", - BindingFlags.Public | BindingFlags.Static, - null, - new[] { typeof(string) }, - null + Field = typeBuilder.DefineField( + fieldName, + Type, + FieldAttributes.Private | FieldAttributes.InitOnly ); - parseMethod = parseGeneral; - parseArgs = new object[] { toParse }; - } - - if (parseMethod != null) - { - Value = parseMethod.Invoke(null, parseArgs); - - if (!Type.IsPrimitive) - { - Field = typeBuilder.DefineField( - fieldName, - Type, - FieldAttributes.Private | FieldAttributes.InitOnly - ); - - il.Emit(OpCodes.Ldarg_0); - - 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); - } - } - else - { - throw new InvalidOperationException( - $"Unable to convert string \"{Value}\" into type '{Type}'." - ); + il.Emit(OpCodes.Ldarg_0); + + 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); } } + else + { + throw new InvalidOperationException( + $"Unable to convert string \"{Value}\" into type '{Type}'." + ); + } } } } @@ -542,4 +542,4 @@ namespace Server.Commands.Generic return (IConditional)Activator.CreateInstance(conditionalType); } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs b/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs index b4bcbc917..7be1e5c0f 100644 --- a/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs +++ b/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Server.Commands.Generic { @@ -36,28 +37,15 @@ namespace Server.Commands.Generic if (!CheckObjectTypes(from, command, ext, out bool items, out bool mobiles)) return; - IPooledEnumerable eable; - - if (items || mobiles) - eable = map.GetObjectsInBounds(rect, items, mobiles); - else + if (!(items || mobiles)) return; - eable.Free(); + IPooledEnumerable eable = map.GetObjectsInBounds(rect, items, mobiles); - List objs = new List(); - - foreach (IEntity obj in eable) - { - if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj)) - continue; - - if (ext.IsValid(obj)) - objs.Add(obj); - } + List objs = eable.Where(obj => !mobiles || !(obj is Mobile) || BaseCommand.IsAccessible(from, obj)) + .Where(obj => ext.IsValid(obj)).Cast().ToList(); eable.Free(); - ext.Filter(objs); RunCommand(from, objs, command, args); @@ -68,4 +56,4 @@ namespace Server.Commands.Generic } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Handlers.cs b/Scripts/Commands/Handlers.cs index 403e6a85e..f7825df2a 100644 --- a/Scripts/Commands/Handlers.cs +++ b/Scripts/Commands/Handlers.cs @@ -79,7 +79,7 @@ namespace Server.Commands } [Usage("SpeedBoost [true|false]")] - [Description("Enables a speed boost for the invoker. Disable with paramaters.")] + [Description("Enables a speed boost for the invoker. Disable with parameters.")] private static void SpeedBoost_OnCommand(CommandEventArgs e) { Mobile from = e.Mobile; @@ -299,7 +299,7 @@ namespace Server.Commands for (int i = 0; i < pets.Count; ++i) { - Mobile pet = (Mobile)pets[i]; + Mobile pet = pets[i]; if (pet is IMount mount) mount.Rider = null; // make sure it's dismounted @@ -410,18 +410,20 @@ namespace Server.Commands private static bool FixMap(ref Map map, ref Point3D loc, Item item) { - return map == null || map == Map.Internal && item.RootParent is Mobile m && FixMap(ref map, ref loc, m); + return map != null && map != Map.Internal || item.RootParent is Mobile m && FixMap(ref map, ref loc, m); } private static bool FixMap(ref Map map, ref Point3D loc, Mobile m) { - if (map == null || map == Map.Internal) + bool validMap = map != null && map != Map.Internal; + + if (!validMap) { map = m.LogoutMap; loc = m.LogoutLocation; } - return map != null && map != Map.Internal; + return validMap; } [Usage("Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W))]")] @@ -676,7 +678,7 @@ namespace Server.Commands { Mobile m = state.Mobile; - if (m != null && m.AccessLevel >= ac) + if (m?.AccessLevel >= ac) m.SendMessage(hue, message); } } @@ -957,4 +959,4 @@ namespace Server.Commands } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/HelpInfo.cs b/Scripts/Commands/HelpInfo.cs index 92dd0e76b..2d74884c1 100644 --- a/Scripts/Commands/HelpInfo.cs +++ b/Scripts/Commands/HelpInfo.cs @@ -337,12 +337,7 @@ namespace Server.Commands public class CommandInfoGump : Gump { - public CommandInfoGump(CommandInfo info) - : this(info, 320, 200) - { - } - - public CommandInfoGump(CommandInfo info, int width, int height) + public CommandInfoGump(CommandInfo info, int width = 320, int height = 200) : base(300, 50) { AddPage(0); @@ -352,7 +347,7 @@ namespace Server.Commands //AddImageTiled( 10, 10, width - 20, 20, 2624 ); //AddAlphaRegion( 10, 10, width - 20, 20 ); //AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false ); - AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000), false, false); + AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000)); //AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); //AddAlphaRegion( 10, 40, width - 20, height - 80 ); @@ -365,7 +360,7 @@ namespace Server.Commands string[] aliases = info.Aliases; - if (aliases != null && aliases.Length != 0) + if (aliases?.Length > 0) { sb.Append($"Alias{(aliases.Length == 1 ? "" : "es")}: "); @@ -404,4 +399,4 @@ namespace Server.Commands } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Profiling.cs b/Scripts/Commands/Profiling.cs index 9bfc975c6..0ab0ee23f 100644 --- a/Scripts/Commands/Profiling.cs +++ b/Scripts/Commands/Profiling.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/Scripts/Commands/Properties.cs b/Scripts/Commands/Properties.cs index 53070310d..6dc60e5c9 100644 --- a/Scripts/Commands/Properties.cs +++ b/Scripts/Commands/Properties.cs @@ -16,7 +16,7 @@ namespace Server.Commands ReadWrite = Read | Write } - public class Properties + public static class Properties { private static Type typeofCPA = typeof(CPA); @@ -174,10 +174,7 @@ namespace Server.Commands { PropertyInfo[] chain = GetPropertyInfoChain(from, obj.GetType(), propertyName, access, ref failReason); - if (chain == null) - return null; - - return GetPropertyInfo(ref obj, chain, ref failReason); + return chain == null ? null : GetPropertyInfo(ref obj, chain, ref failReason); } public static PropertyInfo GetPropertyInfo(ref object obj, PropertyInfo[] chain, ref string failReason) @@ -216,21 +213,19 @@ namespace Server.Commands PropertyInfo p = GetPropertyInfo(ref o, chain, ref failReason); - if (p == null) - return failReason; - - return InternalGetValue(o, p, chain); + return p == null ? failReason : InternalGetValue(o, p, chain); } public static string IncreaseValue(Mobile from, object o, string[] args) { - Type type = o.GetType(); + // Type type = o.GetType(); object[] realObjs = new object[args.Length / 2]; PropertyInfo[] realProps = new PropertyInfo[args.Length / 2]; int[] realValues = new int[args.Length / 2]; - bool positive = false, negative = false; + bool positive = false; + bool negative = false; for (int i = 0; i < realProps.Length; ++i) { @@ -315,9 +310,9 @@ namespace Server.Commands if (value == null) toString = "null"; else if (IsNumeric(type)) - toString = string.Format("{0} (0x{0:X})", value); + toString = $"{value} (0x{value:X})"; else if (IsChar(type)) - toString = string.Format("'{0}' ({1} [0x{1:X}])", value, (int)value); + toString = $"'{value}' ({(int)value} [0x{(int)value:X}])"; else if (IsString(type)) toString = (string)value == "null" ? @"@""null""" : $"\"{value}\""; else if (IsText(type)) @@ -348,10 +343,7 @@ namespace Server.Commands string failReason = ""; PropertyInfo p = GetPropertyInfo(from, ref o, name, PropertyAccess.Write, ref failReason); - if (p == null) - return failReason; - - return InternalSetValue(from, logObject, o, p, name, value, true); + return p == null ? failReason : InternalSetValue(from, logObject, o, p, name, value, true); } private static bool IsSerial(Type t) @@ -524,10 +516,7 @@ namespace Server.Commands object toSet = null; string result = ConstructFromString(p.PropertyType, o, value, ref toSet); - if (result != null) - return result; - - return SetDirect(from, logobj, o, p, pname, toSet, shouldLog); + return result ?? SetDirect(from, logobj, o, p, pname, toSet, shouldLog); } public static string InternalSetValue(object o, PropertyInfo p, string value) @@ -535,10 +524,7 @@ namespace Server.Commands object toSet = null; string result = ConstructFromString(p.PropertyType, o, value, ref toSet); - if (result != null) - return result; - - return SetDirect(o, p, toSet); + return result ?? SetDirect(o, p, toSet); } private class PropsTarget : Target @@ -639,18 +625,14 @@ namespace Server public abstract class ClearanceException : AccessException { - protected AccessLevel m_NeededAccess; - protected AccessLevel m_PlayerAccess; - public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType) : base(property, $"You must be at least {Mobile.GetAccessLevelName(neededAccess)} to {accessType} this property.") { } - public AccessLevel PlayerAccess => m_PlayerAccess; - - public AccessLevel NeededAccess => m_NeededAccess; + public AccessLevel PlayerAccess{ get; set; } + public AccessLevel NeededAccess{ get; set; } } public sealed class ReadAccessException : ClearanceException @@ -801,4 +783,4 @@ namespace Server return prop; } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/SignParser.cs b/Scripts/Commands/SignParser.cs index b5aa215ca..19409fb39 100644 --- a/Scripts/Commands/SignParser.cs +++ b/Scripts/Commands/SignParser.cs @@ -81,7 +81,7 @@ namespace Server.Commands break; // Tokuno Islands } - for (int j = 0; maps != null && j < maps.Length; ++j) + for (int j = 0; maps?.Length >= j; ++j) Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); } @@ -145,4 +145,4 @@ namespace Server.Commands } } } -} \ No newline at end of file +} diff --git a/Scripts/Commands/Statics.cs b/Scripts/Commands/Statics.cs index ab557ea39..f45fda070 100644 --- a/Scripts/Commands/Statics.cs +++ b/Scripts/Commands/Statics.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using System.IO; using Server.Commands; diff --git a/Scripts/Context Menus/EatEntry.cs b/Scripts/Context Menus/EatEntry.cs index 3aebaa29a..f7b63a902 100644 --- a/Scripts/Context Menus/EatEntry.cs +++ b/Scripts/Context Menus/EatEntry.cs @@ -15,10 +15,10 @@ namespace Server.ContextMenus public override void OnClick() { - if (m_Food.Deleted || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse(m_From)) + if (m_Food?.Deleted != false || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse(m_From)) return; m_Food.Eat(m_From); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/BODTarget.cs b/Scripts/Engines/BulkOrders/BODTarget.cs new file mode 100644 index 000000000..e443b0702 --- /dev/null +++ b/Scripts/Engines/BulkOrders/BODTarget.cs @@ -0,0 +1,28 @@ +using Server.Targeting; + +namespace Server.Engines.BulkOrders +{ + public class BODTarget : Target + { + private BaseBOD m_Deed; + + public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) + { + m_Deed = deed; + } + + 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))) + { + from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it. + return; + } + + m_Deed.EndCombine(from, item); + } + } +} diff --git a/Scripts/Engines/BulkOrders/BaseBOD.cs b/Scripts/Engines/BulkOrders/BaseBOD.cs new file mode 100644 index 000000000..95126716b --- /dev/null +++ b/Scripts/Engines/BulkOrders/BaseBOD.cs @@ -0,0 +1,153 @@ +using System.Collections.Generic; + +namespace Server.Engines.BulkOrders +{ + public abstract class BaseBOD : Item + { + private int m_AmountMax; + private bool m_RequireExceptional; + private BulkMaterialType m_Material; + + public static BulkMaterialType GetRandomMaterial(BulkMaterialType start, double[] chances) + { + double random = Utility.RandomDouble(); + + for ( int i = 0; i < chances.Length; ++i ) + { + if ( random < chances[i] ) + return i == 0 ? BulkMaterialType.None : start + (i - 1); + + random -= chances[i]; + } + + return BulkMaterialType.None; + } + + public BaseBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material) : this() + { + Hue = hue; + AmountMax = amountMax; + RequireExceptional = requireExeptional; + Material = material; + } + + public BaseBOD() : base(Core.AOS ? 0x2258 : 0x14EF) + { + Weight = 1.0; + LootType = LootType.Blessed; + } + + public BaseBOD(Serial serial) : base(serial) + { + } + + public abstract bool Complete{ get; } + + [CommandProperty(AccessLevel.GameMaster)] + public sealed override int Hue{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public int AmountMax + { + get => m_AmountMax; + set{ m_AmountMax = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public bool RequireExceptional + { + get => m_RequireExceptional; + set{ m_RequireExceptional = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public BulkMaterialType Material + { + get => m_Material; + set{ m_Material = value; InvalidateProperties(); } + } + + public abstract RewardGroup GetRewardGroup(); + + public abstract int ComputeGold(); + public abstract int ComputeFame(); + public abstract void EndCombine(Mobile from, Item item); + + public virtual void GetRewards(out Item reward, out int gold, out int fame) + { + gold = ComputeGold(); + fame = ComputeFame(); + + List rewards = ComputeRewards(false); + + reward = rewards.Count <= 0 ? null : rewards[Utility.Random(rewards.Count)].Construct(); + } + + public virtual List ComputeRewards(bool full) + { + RewardGroup rewardGroup = GetRewardGroup(); + + List list = new List(); + + if (full) + { + for (int i = 0; i < rewardGroup?.Items.Length; ++i) + { + RewardItem reward = rewardGroup.Items[i]; + + if (reward != null) + list.Add(reward); + } + } + else + { + RewardItem reward = rewardGroup.AcquireItem(); + + if (reward != null) + list.Add(reward); + } + + return list; + } + + public virtual void BeginCombine(Mobile from) + { + if (Complete) + from.SendLocalizedMessage(1045166); // The maximum amount of requested items have already been combined to this deed. + else + from.Target = new BODTarget(this); + } + + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + + writer.WriteEncodedInt( 0 ); // version + + writer.Write( m_AmountMax ); + writer.Write( m_RequireExceptional ); + writer.Write( (int) m_Material ); + } + + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + + int version = reader.ReadEncodedInt(); + + switch ( version ) + { + case 0: + { + m_AmountMax = reader.ReadInt(); + m_RequireExceptional = reader.ReadBool(); + m_Material = (BulkMaterialType)reader.ReadInt(); + break; + } + } + + if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero ) + Delete(); + } + } +} diff --git a/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs b/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs index cf8a60051..4a87e82cd 100644 --- a/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs +++ b/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs @@ -94,33 +94,31 @@ namespace Server.Engines.BulkOrders AddImage(5, 424, 10460); AddImage(585, 424, 10460); - AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor, false, false); // Filter Preference + AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor); // Filter Preference - AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor, false, false); // Bulk Order Type + AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor); // Bulk Order Type AddFilterList(25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0); - AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor, false, false); // Quality + AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor); // Quality AddFilterList(320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1); - AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor, false, false); // Material Type + AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor); // Material Type AddFilterList(25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2); - AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor, false, false); // Amount + AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor); // Amount AddFilterList(25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3); - AddHtmlLocalized(75, 416, 120, 32, 1062477, from.UseOwnFilter ? LabelColor : 16927, false, - false); // Set Book Filter - AddButton(40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(75, 416, 120, 32, 1062477, from.UseOwnFilter ? LabelColor : 16927); // Set Book Filter + AddButton(40, 416, 4005, 4007, 1); - AddHtmlLocalized(235, 416, 120, 32, 1062478, from.UseOwnFilter ? 16927 : LabelColor, false, - false); // Set Your Filter - AddButton(200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddHtmlLocalized(235, 416, 120, 32, 1062478, from.UseOwnFilter ? 16927 : LabelColor); // Set Your Filter + AddButton(200, 416, 4005, 4007, 2); - AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor, false, false); // Clear Filter - AddButton(370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); + AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor); // Clear Filter + AddButton(370, 416, 4005, 4007, 3); - AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor, false, false); // APPLY - AddButton(505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor); // APPLY + AddButton(505, 416, 4017, 4018, 0); } private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, @@ -133,15 +131,13 @@ namespace Server.Engines.BulkOrders if (number == 0) continue; - bool isSelected = filters[i, 1] == filterValue; - - if (!isSelected && i % xOffsets.Length == 0) - isSelected = filterValue == 0; + bool isSelected = filters[i, 1] == filterValue || + i % xOffsets.Length == 0 && filterValue == 0; AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, - xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false); + xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor); AddButton(x + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, 4005, 4007, - 4 + filterIndex + i * 4, GumpButtonType.Reply, 0); + 4 + filterIndex + i * 4); } } @@ -221,4 +217,4 @@ namespace Server.Engines.BulkOrders } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/Books/BOBGump.cs b/Scripts/Engines/BulkOrders/Books/BOBGump.cs index 84ee71da2..22655731d 100644 --- a/Scripts/Engines/BulkOrders/Books/BOBGump.cs +++ b/Scripts/Engines/BulkOrders/Books/BOBGump.cs @@ -56,7 +56,7 @@ namespace Server.Engines.BulkOrders { VendorItem vi = pv.GetVendorItem(book); - canBuy = vi != null && !vi.IsForSale; + canBuy = vi?.IsForSale == false; } int width = 600; @@ -103,45 +103,45 @@ namespace Server.Engines.BulkOrders AddImage(5, 424, 10460); AddImage(width - 15, 424, 10460); - AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false); // Bulk Order Book - AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor, false, false); // Type - AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false); // Item - AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor, false, false); // Quality - AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor, false, false); // Material - AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor, false, false); // Amount + AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor); // Bulk Order Book + AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor); // Type + AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor); // Item + AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor); // Quality + AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor); // Material + AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor); // Amount - AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter + AddButton(35, 32, 4005, 4007, 1); + AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor); // Set Filter BOBFilter f = from.UseOwnFilter ? from.BOBFilter : book.Filter; if (f.IsDefault) - AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); // Using No Filter + 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, false, false); // Using Your Filter + AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927); // Using Your Filter else - AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false); // Using Book Filter + AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927); // Using Book Filter - AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false); // EXIT + AddButton(375, 416, 4017, 4018, 0); + AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor); // EXIT if (canDrop) - AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false); // Drop + AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor); // Drop if (canPrice) { - AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false); // Price + AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor); // Price if (canBuy) { - AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false); // Buy + AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor); // Buy } else { - AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, false, false); // Set + AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor); // Set - AddButton(450, 416, 4005, 4007, 4, GumpButtonType.Reply, 0); - AddHtml(485, 416, 120, 20, "Price all", false, false); + AddButton(450, 416, 4005, 4007, 4); + AddHtml(485, 416, 120, 20, "Price all"); } } @@ -149,14 +149,14 @@ namespace Server.Engines.BulkOrders if (page > 0) { - AddButton(75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor, false, false); // Previous page + AddButton(75, 416, 4014, 4016, 2); + AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor); // Previous page } if (GetIndexForPage(page + 1) < list.Count) { - AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false); // Next page + AddButton(225, 416, 4005, 4007, 3); + AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor); // Next page } for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i) @@ -171,31 +171,31 @@ namespace Server.Engines.BulkOrders int y = 96 + tableIndex * 32; if (canDrop) - AddButton(35, y + 2, 5602, 5606, 5 + i * 2, GumpButtonType.Reply, 0); + AddButton(35, y + 2, 5602, 5606, 5 + i * 2); if (canDrop || canBuy && entry.Price > 0) { - AddButton(579, y + 2, 2117, 2118, 6 + i * 2, GumpButtonType.Reply, 0); + AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, entry.Price.ToString()); } - AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor, false, false); // Large + AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor); // Large for (int j = 0; j < largeEntry.Entries.Length; ++j) { BOBLargeSubEntry sub = largeEntry.Entries[j]; - AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor, false, false); + AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor); if (entry.RequireExceptional) - AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false); // exceptional + AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional else - AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false); // normal + AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal object name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType); if (name is int intName) - AddHtmlLocalized(316, y, 100, 20, intName, LabelColor, false, false); + AddHtmlLocalized(316, y, 100, 20, intName, LabelColor); else AddLabel(316, y, 1152, name.ToString()); @@ -212,27 +212,27 @@ namespace Server.Engines.BulkOrders int y = 96 + tableIndex++ * 32; if (canDrop) - AddButton(35, y + 2, 5602, 5606, 5 + i * 2, GumpButtonType.Reply, 0); + AddButton(35, y + 2, 5602, 5606, 5 + i * 2); if (canDrop || canBuy && smallEntry.Price > 0) { - AddButton(579, y + 2, 2117, 2118, 6 + i * 2, GumpButtonType.Reply, 0); + AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, smallEntry.Price.ToString()); } - AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor, false, false); // Small + AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor); // Small - AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor, false, false); + AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor); if (smallEntry.RequireExceptional) - AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false); // exceptional + AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional else - AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false); // normal + AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal object name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType); if (name is int intName) - AddHtmlLocalized(316, y, 100, 20, intName, LabelColor, false, false); + AddHtmlLocalized(316, y, 100, 20, intName, LabelColor); else AddLabel(316, y, 1152, name.ToString()); @@ -242,11 +242,11 @@ namespace Server.Engines.BulkOrders } public bool CheckFilter(IBOBEntry entry) - { + { if (entry is BOBLargeEntry largeEntry) return CheckFilter(entry.Material, entry.AmountMax, true, entry.RequireExceptional, entry.DeedType, largeEntry.Entries.Length > 0 ? largeEntry.Entries[0].ItemType : null); - + if (entry is BOBSmallEntry smallEntry) return CheckFilter(entry.Material, entry.AmountMax, false, entry.RequireExceptional, entry.DeedType, smallEntry.ItemType); @@ -355,7 +355,7 @@ namespace Server.Engines.BulkOrders int count = 0; int page = 0; int i; - + List list = m_List; for (i = 0; i < index && i < list.Count; i++) { @@ -510,8 +510,8 @@ namespace Server.Engines.BulkOrders Item item = bobEntry.Reconstruct(); Container pack = m_From.Backpack; - if (pack == null || !pack.CheckHold(m_From, item, true, true, 0, - item.PileWeight + item.TotalWeight)) + if (pack?.CheckHold(m_From, item, true, true, 0, + item.PileWeight + item.TotalWeight) != true) { m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); @@ -558,26 +558,26 @@ namespace Server.Engines.BulkOrders { VendorItem vi = pv.GetVendorItem(m_Book); - if (vi != null && !vi.IsForSale) - { - int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; - int price = bobEntry.Price; + if (vi?.IsForSale != false) + return; - if (price == 0) + int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; + int price = bobEntry.Price; + + if (price == 0) + { + m_From.SendLocalizedMessage(1062382); // The deed selected is not available. + } + else + { + if (m_Book.Entries.Count > 0) { - m_From.SendLocalizedMessage(1062382); // The deed selected is not available. + m_Page = GetPageForIndex(index, sizeOfDroppedBod); + m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price)); } else { - if (m_Book.Entries.Count > 0) - { - m_Page = GetPageForIndex(index, sizeOfDroppedBod); - m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price)); - } - else - { - m_From.SendLocalizedMessage(1062381); // The book is emptz - } + m_From.SendLocalizedMessage(1062381); // The book is emptz } } } @@ -625,7 +625,7 @@ namespace Server.Engines.BulkOrders if (!m_Book.Entries.Contains(entry)) continue; - + entry.Price = price; } @@ -644,4 +644,4 @@ namespace Server.Engines.BulkOrders } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs b/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs index bb0135ae0..0900c5d7f 100644 --- a/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs +++ b/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs @@ -67,7 +67,7 @@ namespace Server.Engines.BulkOrders else if (DeedType == BODType.Tailor) bod = new LargeTailorBOD(AmountMax, RequireExceptional, Material, ReconstructEntries()); - for (int i = 0; bod != null && i < bod.Entries.Length; ++i) + for (int i = 0; bod?.Entries.Length >= i; ++i) bod.Entries[i].Owner = bod; return bod; @@ -103,4 +103,4 @@ namespace Server.Engines.BulkOrders Entries[i].Serialize(writer); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs b/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs index ecbab7d84..5f9bccc61 100644 --- a/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs +++ b/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs @@ -25,17 +25,17 @@ namespace Server.Engines.BulkOrders AddBackground(100, 10, 300, 150, 5054); - AddHtmlLocalized(125, 20, 250, 24, 1019070, false, false); // You have agreed to purchase: - AddHtmlLocalized(125, 45, 250, 24, 1045151, false, false); // a bulk order deed + AddHtmlLocalized(125, 20, 250, 24, 1019070); // You have agreed to purchase: + AddHtmlLocalized(125, 45, 250, 24, 1045151); // a bulk order deed - AddHtmlLocalized(125, 70, 250, 24, 1019071, false, false); // for the amount of: + AddHtmlLocalized(125, 70, 250, 24, 1019071); // for the amount of: AddLabel(125, 95, 0, price.ToString()); - AddButton(250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(282, 130, 100, 24, 1011012, false, false); // CANCEL + AddButton(250, 130, 4005, 4007, 1); + AddHtmlLocalized(282, 130, 100, 24, 1011012); // CANCEL - AddButton(120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(152, 130, 100, 24, 1011036, false, false); // OKAY + AddButton(120, 130, 4005, 4007, 2); + AddHtmlLocalized(152, 130, 100, 24, 1011036); // OKAY } public override void OnResponse(NetState sender, RelayInfo info) @@ -57,12 +57,10 @@ namespace Server.Engines.BulkOrders pv.SayTo(m_From, 1062382); // The deed selected is not available. return; } - + int price = 0; - VendorItem vi = pv.GetVendorItem(m_Book); - - if (vi != null && !vi.IsForSale) + if (pv.GetVendorItem(m_Book)?.IsForSale == false) price = m_Entry.Price; if (price != m_Price) @@ -79,16 +77,17 @@ namespace Server.Engines.BulkOrders } Item item = m_Entry.Reconstruct(); - + pv.Say(m_From.Name); Container pack = m_From.Backpack; - if (pack == null || !pack.CheckHold(m_From, item, true, true, 0, - item.PileWeight + item.TotalWeight)) + if (pack?.CheckHold(m_From, item, true, true, 0, + item.PileWeight + item.TotalWeight) != true) { pv.SayTo(m_From, 503204); // You do not have room in your backpack for this m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); + item.Delete(); } else { @@ -120,4 +119,4 @@ namespace Server.Engines.BulkOrders } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs b/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs index 49dc2285e..e022fb799 100644 --- a/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs +++ b/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs @@ -64,23 +64,18 @@ namespace Server.Engines.BulkOrders { from.SendGump( new BOBGump( (PlayerMobile)from, this ) ); - SecureTradeContainer cont = GetSecureTradeCont(); + SecureTrade trade = GetSecureTradeCont()?.Trade; - if ( cont != null ) - { - SecureTrade trade = cont.Trade; - - if ( trade != null && trade.From.Mobile == from ) - trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) ); - else if ( trade != null && trade.To.Mobile == from ) - trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) ); - } + 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 ) ); } } public override bool OnDragDrop( Mobile from, Item dropped ) { - if ( dropped is LargeBOD || dropped is SmallBOD ) + if ( dropped is BaseBOD ) { if ( !IsChildOf( from.Backpack ) ) { @@ -142,7 +137,7 @@ namespace Server.Engines.BulkOrders } } - public void InvalidateContainers( object parent ) + public void InvalidateContainers(IEntity parent) { if ( parent is Container c ) { @@ -159,9 +154,9 @@ namespace Server.Engines.BulkOrders { base.Serialize( writer ); - writer.Write( (int) 2 ); // version + writer.Write( 2 ); // version - writer.Write( (int) ItemCount ); + writer.Write( ItemCount ); writer.Write( (int) Level ); @@ -169,7 +164,7 @@ namespace Server.Engines.BulkOrders Filter.Serialize( writer ); - writer.WriteEncodedInt( (int) Entries.Count ); + writer.WriteEncodedInt( Entries.Count ); for ( int i = 0; i < Entries.Count; ++i ) { diff --git a/Scripts/Engines/BulkOrders/BulkMaterialType.cs b/Scripts/Engines/BulkOrders/BulkMaterialType.cs index 82085ca4d..f628d09cf 100644 --- a/Scripts/Engines/BulkOrders/BulkMaterialType.cs +++ b/Scripts/Engines/BulkOrders/BulkMaterialType.cs @@ -30,15 +30,11 @@ namespace Server.Engines.BulkOrders { public static BulkGenericType Classify(BODType deedType, Type itemType) { - if (deedType == BODType.Tailor) - { - if (itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))) - return BulkGenericType.Leather; + if (deedType != BODType.Tailor) + return BulkGenericType.Iron; - return BulkGenericType.Cloth; - } - - return BulkGenericType.Iron; + return itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)) + ? BulkGenericType.Leather : BulkGenericType.Cloth; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/LargeBOD.cs b/Scripts/Engines/BulkOrders/LargeBOD.cs index 2133f37e8..ce4eb99b7 100644 --- a/Scripts/Engines/BulkOrders/LargeBOD.cs +++ b/Scripts/Engines/BulkOrders/LargeBOD.cs @@ -1,104 +1,41 @@ -using System.Collections.Generic; using Server.Mobiles; namespace Server.Engines.BulkOrders { - [TypeAlias( "Scripts.Engines.BulkOrders.LargeBOD" )] - public abstract class LargeBOD : Item + public abstract class LargeBOD : BaseBOD { - private int m_AmountMax; - private bool m_RequireExceptional; - private BulkMaterialType m_Material; private LargeBulkEntry[] m_Entries; - [CommandProperty( AccessLevel.GameMaster )] - public int AmountMax{ get => m_AmountMax; - set{ m_AmountMax = value; InvalidateProperties(); } } + public LargeBulkEntry[] Entries + { + get => m_Entries; + set{ m_Entries = value; InvalidateProperties(); } + } [CommandProperty( AccessLevel.GameMaster )] - public bool RequireExceptional{ get => m_RequireExceptional; - set{ m_RequireExceptional = value; InvalidateProperties(); } } - - [CommandProperty( AccessLevel.GameMaster )] - public BulkMaterialType Material{ get => m_Material; - set{ m_Material = value; InvalidateProperties(); } } - - public LargeBulkEntry[] Entries{ get => m_Entries; - set{ m_Entries = value; InvalidateProperties(); } } - - [CommandProperty( AccessLevel.GameMaster )] - public bool Complete + public override bool Complete { get { for ( int i = 0; i < m_Entries.Length; ++i ) - { - if ( m_Entries[i].Amount < m_AmountMax ) + if ( m_Entries[i].Amount < AmountMax ) return false; - } return true; } } - public abstract List ComputeRewards( bool full ); - public abstract int ComputeGold(); - public abstract int ComputeFame(); - - public virtual void GetRewards( out Item reward, out int gold, out int fame ) - { - reward = null; - gold = ComputeGold(); - fame = ComputeFame(); - - List rewards = ComputeRewards( false ); - - if ( rewards.Count > 0 ) - { - reward = rewards[Utility.Random( rewards.Count )]; - - for ( int i = 0; i < rewards.Count; ++i ) - { - if ( rewards[i] != reward ) - rewards[i].Delete(); - } - } - } - - public static BulkMaterialType GetRandomMaterial( BulkMaterialType start, double[] chances ) - { - double random = Utility.RandomDouble(); - - for ( int i = 0; i < chances.Length; ++i ) - { - if ( random < chances[i] ) - return ( i == 0 ? BulkMaterialType.None : start + (i - 1) ); - - random -= chances[i]; - } - - return BulkMaterialType.None; - } - public override int LabelNumber => 1045151; // a bulk order deed - public LargeBOD( int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries ) : base( Core.AOS ? 0x2258 : 0x14EF ) + public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : + base(hue, amountMax, requireExeptional, material) { - Weight = 1.0; - Hue = hue; // Blacksmith: 0x44E; Tailoring: 0x483 - LootType = LootType.Blessed; - - m_AmountMax = amountMax; - m_RequireExceptional = requireExeptional; - m_Material = material; m_Entries = entries; } - public LargeBOD() : base( Core.AOS ? 0x2258 : 0x14EF ) - { - Weight = 1.0; - LootType = LootType.Blessed; - } + public LargeBOD() + { + } public override void GetProperties( ObjectPropertyList list ) { @@ -106,13 +43,13 @@ namespace Server.Engines.BulkOrders list.Add( 1060655 ); // large bulk order - if ( m_RequireExceptional ) + if ( RequireExceptional ) list.Add( 1045141 ); // All items must be exceptional. - if ( m_Material != BulkMaterialType.None ) - list.Add( LargeBODGump.GetMaterialNumberFor( m_Material ) ); // All items must be made with x material. + if ( Material != BulkMaterialType.None ) + list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material. - list.Add( 1060656, m_AmountMax.ToString() ); // amount to make: ~1_val~ + list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~ for ( int 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~ @@ -136,81 +73,70 @@ namespace Server.Engines.BulkOrders from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it. } - public void BeginCombine( Mobile from ) - { - if ( !Complete ) - from.Target = new LargeBODTarget( this ); - else - from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed. - } + public override void EndCombine(Mobile from, Item item) + { + if (!(item is SmallBOD small)) + { + from.SendLocalizedMessage(1045159); // That is not a bulk order. + return; + } - public void EndCombine( Mobile from, object o ) - { - if ( o is Item item && item.IsChildOf( from.Backpack ) ) - { - if ( item is SmallBOD small ) - { - LargeBulkEntry entry = null; + LargeBulkEntry entry = null; - for ( int i = 0; entry == null && i < m_Entries.Length; ++i ) - { - if ( m_Entries[i].Details.Type == small.Type ) - entry = m_Entries[i]; - } + for (int i = 0; i < m_Entries.Length; ++i) + { + if (m_Entries[i].Details.Type == small.Type) + { + entry = m_Entries[i]; + break; + } + } - if ( entry == null ) - { - from.SendLocalizedMessage( 1045160 ); // That is not a bulk order for this large request. - } - else if ( m_RequireExceptional && !small.RequireExceptional ) - { - from.SendLocalizedMessage( 1045161 ); // Both orders must be of exceptional quality. - } - else if ( m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite && small.Material != m_Material ) - { - from.SendLocalizedMessage( 1045162 ); // Both orders must use the same ore type. - } - else if ( m_Material >= BulkMaterialType.Spined && m_Material <= BulkMaterialType.Barbed && small.Material != m_Material ) - { - from.SendLocalizedMessage( 1049351 ); // Both orders must use the same leather type. - } - else if ( m_AmountMax != small.AmountMax ) - { - from.SendLocalizedMessage( 1045163 ); // The two orders have different requested amounts and cannot be combined. - } - else if ( small.AmountCur < small.AmountMax ) - { - from.SendLocalizedMessage( 1045164 ); // The order to combine with is not completed. - } - else if ( entry.Amount >= m_AmountMax ) - { - from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed. - } - else - { - entry.Amount += small.AmountCur; - small.Delete(); + if (entry == null) + { + from.SendLocalizedMessage(1045160); // That is not a bulk order for this large request. + } + else if (RequireExceptional && !small.RequireExceptional) + { + from.SendLocalizedMessage(1045161); // Both orders must be of exceptional quality. + } + else if (Material >= BulkMaterialType.DullCopper && Material <= BulkMaterialType.Valorite && + small.Material != Material) + { + from.SendLocalizedMessage(1045162); // Both orders must use the same ore type. + } + else if (Material >= BulkMaterialType.Spined && Material <= BulkMaterialType.Barbed && + small.Material != Material) + { + from.SendLocalizedMessage(1049351); // Both orders must use the same leather type. + } + else if (AmountMax != small.AmountMax) + { + from.SendLocalizedMessage(1045163); // The two orders have different requested amounts and cannot be combined. + } + else if (small.AmountCur < small.AmountMax) + { + from.SendLocalizedMessage(1045164); // The order to combine with is not completed. + } + else if (entry.Amount >= AmountMax) + { + from.SendLocalizedMessage( + 1045166); // The maximum amount of requested items have already been combined to this deed. + } + else + { + entry.Amount += small.AmountCur; + small.Delete(); - from.SendLocalizedMessage( 1045165 ); // The orders have been combined. + from.SendLocalizedMessage(1045165); // The orders have been combined. + from.SendGump(new LargeBODGump(from, this)); - from.SendGump( new LargeBODGump( from, this ) ); + if (!Complete) + BeginCombine(from); + } + } - if ( !Complete ) - BeginCombine( from ); - } - } - else - { - from.SendLocalizedMessage( 1045159 ); // That is not a bulk order. - } - } - else - { - from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it. - } - } - - public LargeBOD( Serial serial ) : base( serial ) + public LargeBOD(Serial serial) : base(serial) { } @@ -218,13 +144,9 @@ namespace Server.Engines.BulkOrders { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.WriteEncodedInt( 0 ); // version - writer.Write( m_AmountMax ); - writer.Write( m_RequireExceptional ); - writer.Write( (int) m_Material ); - - writer.Write( (int) m_Entries.Length ); + writer.Write( m_Entries.Length ); for ( int i = 0; i < m_Entries.Length; ++i ) m_Entries[i].Serialize( writer ); @@ -234,16 +156,12 @@ namespace Server.Engines.BulkOrders { base.Deserialize( reader ); - int version = reader.ReadInt(); + int version = reader.ReadEncodedInt(); switch ( version ) { case 0: { - m_AmountMax = reader.ReadInt(); - m_RequireExceptional = reader.ReadBool(); - m_Material = (BulkMaterialType)reader.ReadInt(); - m_Entries = new LargeBulkEntry[reader.ReadInt()]; for ( int i = 0; i < m_Entries.Length; ++i ) @@ -252,15 +170,6 @@ namespace Server.Engines.BulkOrders break; } } - - if ( Weight == 0.0 ) - Weight = 1.0; - - if ( Core.AOS && ItemID == 0x14EF ) - ItemID = 0x2258; - - if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero ) - Delete(); } } } diff --git a/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs b/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs index 91815312d..6d852f7d7 100644 --- a/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs +++ b/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs @@ -30,48 +30,45 @@ namespace Server.Engines.BulkOrders AddImage(20, 225 + entries.Length * 24, 10460); AddImage(430, 225 + entries.Length * 24, 10460); - AddHtmlLocalized(180, 25, 120, 20, 1045134, 0x7FFF, false, false); // A large bulk order + AddHtmlLocalized(180, 25, 120, 20, 1045134, 0x7FFF); // A large bulk order - AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF, false, - false); // Ah! Thanks for the goods! Would you help me out? + AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF); // Ah! Thanks for the goods! Would you help me out? - AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF, false, false); // Amount to make: + AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF); // Amount to make: AddLabel(250, 72, 1152, deed.AmountMax.ToString()); - AddHtmlLocalized(40, 96, 120, 20, 1045137, 0x7FFF, false, false); // Items requested: + AddHtmlLocalized(40, 96, 120, 20, 1045137, 0x7FFF); // Items requested: int y = 120; for (int i = 0; i < entries.Length; ++i, y += 24) - AddHtmlLocalized(40, y, 210, 20, entries[i].Details.Number, 0x7FFF, false, false); + AddHtmlLocalized(40, y, 210, 20, entries[i].Details.Number, 0x7FFF); if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { - AddHtmlLocalized(40, y, 210, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: + AddHtmlLocalized(40, y, 210, 20, 1045140, 0x7FFF); // Special requirements to meet: y += 24; if (deed.RequireExceptional) { - AddHtmlLocalized(40, y, 350, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. + AddHtmlLocalized(40, y, 350, 20, 1045141, 0x7FFF); // All items must be exceptional. y += 24; } if (deed.Material != BulkMaterialType.None) { - AddHtmlLocalized(40, y, 350, 20, GetMaterialNumberFor(deed.Material), 0x7FFF, false, - false); // All items must be made with x material. + AddHtmlLocalized(40, y, 350, 20, GetMaterialNumberFor(deed.Material), 0x7FFF); // All items must be made with x material. y += 24; } } - AddHtmlLocalized(40, 192 + entries.Length * 24, 350, 20, 1045139, 0x7FFF, false, - false); // Do you want to accept this order? + AddHtmlLocalized(40, 192 + entries.Length * 24, 350, 20, 1045139, 0x7FFF); // Do you want to accept this order? - AddButton(100, 216 + entries.Length * 24, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(135, 216 + entries.Length * 24, 120, 20, 1006044, 0x7FFF, false, false); // Ok + AddButton(100, 216 + entries.Length * 24, 4005, 4007, 1); + AddHtmlLocalized(135, 216 + entries.Length * 24, 120, 20, 1006044, 0x7FFF); // Ok - AddButton(275, 216 + entries.Length * 24, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(310, 216 + entries.Length * 24, 120, 20, 1011012, 0x7FFF, false, false); // CANCEL + AddButton(275, 216 + entries.Length * 24, 4005, 4007, 0); + AddHtmlLocalized(310, 216 + entries.Length * 24, 120, 20, 1011012, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -94,6 +91,12 @@ 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) @@ -104,4 +107,4 @@ namespace Server.Engines.BulkOrders return 0; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/LargeBODGump.cs b/Scripts/Engines/BulkOrders/LargeBODGump.cs index 35792ff5a..b59065e61 100644 --- a/Scripts/Engines/BulkOrders/LargeBODGump.cs +++ b/Scripts/Engines/BulkOrders/LargeBODGump.cs @@ -30,13 +30,13 @@ namespace Server.Engines.BulkOrders AddImage(45, 221 + entries.Length * 24, 10460); AddImage(480, 221 + entries.Length * 24, 10460); - AddHtmlLocalized(225, 25, 120, 20, 1045134, 0x7FFF, false, false); // A large bulk order + AddHtmlLocalized(225, 25, 120, 20, 1045134, 0x7FFF); // A large bulk order - AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF, false, false); // Amount to make: + AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF); // Amount to make: AddLabel(275, 48, 1152, deed.AmountMax.ToString()); - AddHtmlLocalized(75, 72, 120, 20, 1045137, 0x7FFF, false, false); // Items requested: - AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF, false, false); // Amount finished: + AddHtmlLocalized(75, 72, 120, 20, 1045137, 0x7FFF); // Items requested: + AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF); // Amount finished: int y = 96; @@ -45,7 +45,7 @@ namespace Server.Engines.BulkOrders LargeBulkEntry entry = entries[i]; SmallBulkEntry details = entry.Details; - AddHtmlLocalized(75, y, 210, 20, details.Number, 0x7FFF, false, false); + AddHtmlLocalized(75, y, 210, 20, details.Number, 0x7FFF); AddLabel(275, y, 0x480, entry.Amount.ToString()); y += 24; @@ -53,26 +53,24 @@ namespace Server.Engines.BulkOrders if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { - AddHtmlLocalized(75, y, 200, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: + AddHtmlLocalized(75, y, 200, 20, 1045140, 0x7FFF); // Special requirements to meet: y += 24; } if (deed.RequireExceptional) { - AddHtmlLocalized(75, y, 300, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. + AddHtmlLocalized(75, y, 300, 20, 1045141, 0x7FFF); // All items must be exceptional. y += 24; } if (deed.Material != BulkMaterialType.None) - AddHtmlLocalized(75, y, 300, 20, GetMaterialNumberFor(deed.Material), 0x7FFF, false, - false); // All items must be made with x material. + AddHtmlLocalized(75, y, 300, 20, GetMaterialNumberFor(deed.Material), 0x7FFF); // All items must be made with x material. - AddButton(125, 168 + entries.Length * 24, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(160, 168 + entries.Length * 24, 300, 20, 1045155, 0x7FFF, false, - false); // Combine this deed with another deed. + AddButton(125, 168 + entries.Length * 24, 4005, 4007, 2); + AddHtmlLocalized(160, 168 + entries.Length * 24, 300, 20, 1045155, 0x7FFF); // Combine this deed with another deed. - AddButton(125, 192 + entries.Length * 24, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(160, 192 + entries.Length * 24, 120, 20, 1011441, 0x7FFF, false, false); // EXIT + AddButton(125, 192 + entries.Length * 24, 4005, 4007, 1); + AddHtmlLocalized(160, 192 + entries.Length * 24, 120, 20, 1011441, 0x7FFF); // EXIT } public override void OnResponse(NetState sender, RelayInfo info) @@ -97,4 +95,4 @@ namespace Server.Engines.BulkOrders return 0; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/LargeBODTarget.cs b/Scripts/Engines/BulkOrders/LargeBODTarget.cs deleted file mode 100644 index be8ec11ef..000000000 --- a/Scripts/Engines/BulkOrders/LargeBODTarget.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Server.Targeting; - -namespace Server.Engines.BulkOrders -{ - public class LargeBODTarget : Target - { - private LargeBOD m_Deed; - - public LargeBODTarget(LargeBOD deed) : base(18, false, TargetFlags.None) - { - m_Deed = deed; - } - - protected override void OnTarget(Mobile from, object targeted) - { - if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack)) - return; - - m_Deed.EndCombine(from, targeted); - } - } -} \ No newline at end of file diff --git a/Scripts/Engines/BulkOrders/LargeBulkEntry.cs b/Scripts/Engines/BulkOrders/LargeBulkEntry.cs index 04788746a..cd64581a9 100644 --- a/Scripts/Engines/BulkOrders/LargeBulkEntry.cs +++ b/Scripts/Engines/BulkOrders/LargeBulkEntry.cs @@ -9,10 +9,11 @@ namespace Server.Engines.BulkOrders public LargeBOD Owner { get; set; } - public int Amount{ get => m_Amount; - set{ m_Amount = value; - Owner?.InvalidateProperties(); - } } + public int Amount + { + get => m_Amount; + set{ m_Amount = value; Owner?.InvalidateProperties(); } + } public SmallBulkEntry Details { get; } public static SmallBulkEntry[] LargeRing => GetEntries( "Blacksmith", "largering" ); diff --git a/Scripts/Engines/BulkOrders/LargeSmithBOD.cs b/Scripts/Engines/BulkOrders/LargeSmithBOD.cs index 52827f459..667947547 100644 --- a/Scripts/Engines/BulkOrders/LargeSmithBOD.cs +++ b/Scripts/Engines/BulkOrders/LargeSmithBOD.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; using Mat = Server.Engines.BulkOrders.BulkMaterialType; namespace Server.Engines.BulkOrders { - [TypeAlias("Scripts.Engines.BulkOrders.LargeSmithBOD")] public class LargeSmithBOD : LargeBOD { public static double[] m_BlacksmithMaterialChances = @@ -63,12 +61,8 @@ namespace Server.Engines.BulkOrders int amountMax = Utility.RandomList(10, 15, 20, 20); bool reqExceptional = 0.825 > Utility.RandomDouble(); - BulkMaterialType material; - - if (useMaterials) - material = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); - else - material = BulkMaterialType.None; + BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances) + : BulkMaterialType.None; Hue = hue; AmountMax = amountMax; @@ -78,60 +72,20 @@ namespace Server.Engines.BulkOrders } public LargeSmithBOD(int amountMax, bool reqExceptional, BulkMaterialType mat, LargeBulkEntry[] entries) + : base(0x44E, amountMax, reqExceptional, mat, entries) { - Hue = 0x44E; - AmountMax = amountMax; - Entries = entries; - RequireExceptional = reqExceptional; - Material = mat; } public LargeSmithBOD(Serial serial) : base(serial) { } - public override int ComputeFame() - { - return SmithRewardCalculator.Instance.ComputeFame(this); - } + public override int ComputeFame() => SmithRewardCalculator.Instance.ComputeFame(this); - public override int ComputeGold() - { - return SmithRewardCalculator.Instance.ComputeGold(this); - } + public override int ComputeGold() => SmithRewardCalculator.Instance.ComputeGold(this); - public override List ComputeRewards(bool full) - { - List list = new List(); - - RewardGroup rewardGroup = - SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this)); - - if (rewardGroup != null) - { - if (full) - { - for (int i = 0; i < rewardGroup.Items.Length; ++i) - { - Item item = rewardGroup.Items[i].Construct(); - - if (item != null) - list.Add(item); - } - } - else - { - RewardItem rewardItem = rewardGroup.AcquireItem(); - - Item item = rewardItem?.Construct(); - - if (item != null) - list.Add(item); - } - } - - return list; - } + public override RewardGroup GetRewardGroup() => + SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this)); public override void Serialize(GenericWriter writer) { @@ -147,4 +101,4 @@ namespace Server.Engines.BulkOrders int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/LargeTailorBOD.cs b/Scripts/Engines/BulkOrders/LargeTailorBOD.cs index d2d3218fb..192b2c8df 100644 --- a/Scripts/Engines/BulkOrders/LargeTailorBOD.cs +++ b/Scripts/Engines/BulkOrders/LargeTailorBOD.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Mat = Server.Engines.BulkOrders.BulkMaterialType; namespace Server.Engines.BulkOrders @@ -75,12 +74,8 @@ namespace Server.Engines.BulkOrders int amountMax = Utility.RandomList(10, 15, 20, 20); bool reqExceptional = 0.825 > Utility.RandomDouble(); - BulkMaterialType material; - - if (useMaterials) - material = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances); - else - material = BulkMaterialType.None; + BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances) + : BulkMaterialType.None; Hue = hue; AmountMax = amountMax; @@ -90,12 +85,8 @@ namespace Server.Engines.BulkOrders } public LargeTailorBOD(int amountMax, bool reqExceptional, BulkMaterialType mat, LargeBulkEntry[] entries) + : base(0x483, amountMax, reqExceptional, mat, entries) { - Hue = 0x483; - AmountMax = amountMax; - Entries = entries; - RequireExceptional = reqExceptional; - Material = mat; } public LargeTailorBOD(Serial serial) : base(serial) @@ -112,38 +103,8 @@ namespace Server.Engines.BulkOrders return TailorRewardCalculator.Instance.ComputeGold(this); } - public override List ComputeRewards(bool full) - { - List list = new List(); - - RewardGroup rewardGroup = - TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this)); - - if (rewardGroup != null) - { - if (full) - { - for (int i = 0; i < rewardGroup.Items.Length; ++i) - { - Item item = rewardGroup.Items[i].Construct(); - - if (item != null) - list.Add(item); - } - } - else - { - RewardItem rewardItem = rewardGroup.AcquireItem(); - - Item item = rewardItem?.Construct(); - - if (item != null) - list.Add(item); - } - } - - return list; - } + public override RewardGroup GetRewardGroup() => + TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this)); public override void Serialize(GenericWriter writer) { @@ -159,4 +120,4 @@ namespace Server.Engines.BulkOrders int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/Rewards.cs b/Scripts/Engines/BulkOrders/Rewards.cs index 6a6feefda..66a3282b4 100644 --- a/Scripts/Engines/BulkOrders/Rewards.cs +++ b/Scripts/Engines/BulkOrders/Rewards.cs @@ -29,11 +29,7 @@ namespace Server.Engines.BulkOrders public sealed class RewardItem { - public RewardItem(int weight, ConstructCallback constructor) : this(weight, constructor, 0) - { - } - - public RewardItem(int weight, ConstructCallback constructor, int type) + public RewardItem(int weight, ConstructCallback constructor, int type = 0) { Weight = weight; Constructor = constructor; @@ -111,14 +107,12 @@ namespace Server.Engines.BulkOrders public virtual int ComputeFame(SmallBOD bod) { int points = ComputePoints(bod) / 50; - return points * points; } public virtual int ComputeFame(LargeBOD bod) { int points = ComputePoints(bod) / 50; - return points * points; } @@ -354,10 +348,10 @@ namespace Server.Engines.BulkOrders if (itemCount == 1) return 0; - int typeIdx; + int typeIdx = 0; // Loop through the RewardTypes defined earlier and find the correct one. - for (typeIdx = 0; typeIdx < 7; ++typeIdx) + for (; typeIdx < 7; ++typeIdx) if (m_Types[typeIdx].Contains(type)) break; @@ -403,14 +397,17 @@ namespace Server.Engines.BulkOrders private static Item CreateMiningGloves(int type) { - if (type == 1) - return new LeatherGlovesOfMining(1); - if (type == 3) - return new StuddedGlovesOfMining(3); - if (type == 5) - return new RingmailGlovesOfMining(5); - - throw new InvalidOperationException(); + switch (type) + { + case 1: + return new LeatherGlovesOfMining(1); + case 3: + return new StuddedGlovesOfMining(3); + case 5: + return new RingmailGlovesOfMining(5); + default: + throw new InvalidOperationException(); + } } private static Item CreateGargoylesPickaxe(int type) @@ -583,7 +580,7 @@ namespace Server.Engines.BulkOrders { Groups = new[] { - new RewardGroup(0, new RewardItem(1, Cloth, 0)), + new RewardGroup(0, new RewardItem(1, Cloth)), new RewardGroup(50, new RewardItem(1, Cloth, 1)), new RewardGroup(100, new RewardItem(1, Cloth, 2)), new RewardGroup(150, new RewardItem(9, Cloth, 3), new RewardItem(1, Sandals)), @@ -745,4 +742,4 @@ namespace Server.Engines.BulkOrders #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/SmallBOD.cs b/Scripts/Engines/BulkOrders/SmallBOD.cs index 85a108fb1..ea84d4f05 100644 --- a/Scripts/Engines/BulkOrders/SmallBOD.cs +++ b/Scripts/Engines/BulkOrders/SmallBOD.cs @@ -1,38 +1,25 @@ using System; -using System.Collections.Generic; using Server.Items; using Server.Mobiles; namespace Server.Engines.BulkOrders { - [TypeAlias("Scripts.Engines.BulkOrders.SmallBOD")] - public abstract class SmallBOD : Item + public abstract class SmallBOD : BaseBOD { - private int m_AmountCur, m_AmountMax; - private BulkMaterialType m_Material; + private int m_AmountCur; private int m_Number; - private bool m_RequireExceptional; - [Constructible] - public SmallBOD(int hue, int amountMax, Type type, int number, int graphic, bool requireExeptional, - BulkMaterialType material) : base(Core.AOS ? 0x2258 : 0x14EF) + public SmallBOD(int hue, int amountCur, int amountMax, Type type, int number, int graphic, bool requireExeptional, + BulkMaterialType material) : base(hue, amountMax, requireExeptional, material) { - Weight = 1.0; - Hue = hue; // Blacksmith: 0x44E; Tailoring: 0x483 - LootType = LootType.Blessed; - - m_AmountMax = amountMax; Type = type; - m_Number = number; Graphic = graphic; - m_RequireExceptional = requireExeptional; - m_Material = material; + m_AmountCur = amountCur; + m_Number = number; } - public SmallBOD() : base(Core.AOS ? 0x2258 : 0x14EF) + public SmallBOD() { - Weight = 1.0; - LootType = LootType.Blessed; } public SmallBOD(Serial serial) : base(serial) @@ -50,17 +37,6 @@ namespace Server.Engines.BulkOrders } } - [CommandProperty(AccessLevel.GameMaster)] - public int AmountMax - { - get => m_AmountMax; - set - { - m_AmountMax = value; - InvalidateProperties(); - } - } - [CommandProperty(AccessLevel.GameMaster)] public Type Type{ get; set; } @@ -79,60 +55,23 @@ namespace Server.Engines.BulkOrders public int Graphic{ get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool RequireExceptional - { - get => m_RequireExceptional; - set - { - m_RequireExceptional = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public BulkMaterialType Material - { - get => m_Material; - set - { - m_Material = value; - InvalidateProperties(); - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public bool Complete => m_AmountCur == m_AmountMax; + public override bool Complete => m_AmountCur == AmountMax; public override int LabelNumber => 1045151; // a bulk order deed - public static BulkMaterialType GetRandomMaterial(BulkMaterialType start, double[] chances) - { - double random = Utility.RandomDouble(); - - for (int i = 0; i < chances.Length; ++i) - { - if (random < chances[i]) - return i == 0 ? BulkMaterialType.None : start + (i - 1); - - random -= chances[i]; - } - - return BulkMaterialType.None; - } - public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); list.Add(1060654); // small bulk order - if (m_RequireExceptional) + if (RequireExceptional) list.Add(1045141); // All items must be exceptional. - if (m_Material != BulkMaterialType.None) - list.Add(SmallBODGump.GetMaterialNumberFor(m_Material)); // All items must be made with x material. + if (Material != BulkMaterialType.None) + list.Add(SmallBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material. - list.Add(1060656, m_AmountMax.ToString()); // amount to make: ~1_val~ + list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~ list.Add(1060658, "#{0}\t{1}", m_Number, m_AmountCur); // ~1_val~: ~2_val~ } @@ -154,37 +93,6 @@ namespace Server.Engines.BulkOrders OnDoubleClick(from); } - public void BeginCombine(Mobile from) - { - if (m_AmountCur < m_AmountMax) - from.Target = new SmallBODTarget(this); - else - from.SendLocalizedMessage( - 1045166); // The maximum amount of requested items have already been combined to this deed. - } - - public abstract List ComputeRewards(bool full); - public abstract int ComputeGold(); - public abstract int ComputeFame(); - - public virtual void GetRewards(out Item reward, out int gold, out int fame) - { - reward = null; - gold = ComputeGold(); - fame = ComputeFame(); - - List rewards = ComputeRewards(false); - - if (rewards.Count > 0) - { - reward = rewards[Utility.Random(rewards.Count)]; - - for (int i = 0; i < rewards.Count; ++i) - if (rewards[i] != reward) - rewards[i].Delete(); - } - } - public static BulkMaterialType GetMaterial(CraftResource resource) { switch (resource) @@ -205,13 +113,11 @@ namespace Server.Engines.BulkOrders return BulkMaterialType.None; } - public void EndCombine(Mobile from, object o) + public override void EndCombine(Mobile from, Item item) { - if (o is Item item && item.IsChildOf(from.Backpack)) - { - Type objectType = item.GetType(); + Type objectType = item.GetType(); - if (m_AmountCur >= m_AmountMax) + if (m_AmountCur >= AmountMax) { from.SendLocalizedMessage( 1045166); // The maximum amount of requested items have already been combined to this deed. @@ -228,13 +134,13 @@ namespace Server.Engines.BulkOrders BulkMaterialType material = GetMaterial(armor?.Resource ?? clothing?.Resource ?? CraftResource.None); - if (m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite && - material != m_Material) + if (Material >= BulkMaterialType.DullCopper && Material <= BulkMaterialType.Valorite && + material != Material) { from.SendLocalizedMessage(1045168); // The item is not made from the requested ore. } - else if (m_Material >= BulkMaterialType.Spined && m_Material <= BulkMaterialType.Barbed && - material != m_Material) + else if (Material >= BulkMaterialType.Spined && Material <= BulkMaterialType.Barbed && + material != Material) { from.SendLocalizedMessage(1049352); // The item is not made from the requested leather type. } @@ -249,7 +155,7 @@ namespace Server.Engines.BulkOrders else isExceptional = clothing.Quality == ClothingQuality.Exceptional; - if (m_RequireExceptional && !isExceptional) + if (RequireExceptional && !isExceptional) { from.SendLocalizedMessage(1045167); // The item must be exceptional. } @@ -259,19 +165,13 @@ namespace Server.Engines.BulkOrders ++AmountCur; from.SendLocalizedMessage(1045170); // The item has been combined with the deed. - from.SendGump(new SmallBODGump(from, this)); - if (m_AmountCur < m_AmountMax) + if (m_AmountCur < AmountMax) BeginCombine(from); } } } - } - else - { - from.SendLocalizedMessage(1045158); // You must have the item in your backpack to target it. - } } public override void Serialize(GenericWriter writer) @@ -281,12 +181,9 @@ namespace Server.Engines.BulkOrders writer.Write(0); // version writer.Write(m_AmountCur); - writer.Write(m_AmountMax); writer.Write(Type == null ? null : Type.FullName); writer.Write(m_Number); writer.Write(Graphic); - writer.Write(m_RequireExceptional); - writer.Write((int)m_Material); } public override void Deserialize(GenericReader reader) @@ -300,7 +197,6 @@ namespace Server.Engines.BulkOrders case 0: { m_AmountCur = reader.ReadInt(); - m_AmountMax = reader.ReadInt(); string type = reader.ReadString(); @@ -309,21 +205,9 @@ namespace Server.Engines.BulkOrders m_Number = reader.ReadInt(); Graphic = reader.ReadInt(); - m_RequireExceptional = reader.ReadBool(); - m_Material = (BulkMaterialType)reader.ReadInt(); - break; } } - - if (Weight == 0.0) - Weight = 1.0; - - if (Core.AOS && ItemID == 0x14EF) - ItemID = 0x2258; - - if (Parent == null && Map == Map.Internal && Location == Point3D.Zero) - Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs b/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs index 21260cafb..1234a9c2a 100644 --- a/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs +++ b/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs @@ -28,36 +28,35 @@ namespace Server.Engines.BulkOrders AddImage(20, 249, 10460); AddImage(430, 249, 10460); - AddHtmlLocalized(190, 25, 120, 20, 1045133, 0x7FFF, false, false); // A bulk order - AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF, false, - false); // Ah! Thanks for the goods! Would you help me out? + AddHtmlLocalized(190, 25, 120, 20, 1045133, 0x7FFF); // A bulk order + AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF); // Ah! Thanks for the goods! Would you help me out? - AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF, false, false); // Amount to make: + AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF); // Amount to make: AddLabel(250, 72, 1152, deed.AmountMax.ToString()); - AddHtmlLocalized(40, 96, 120, 20, 1045136, 0x7FFF, false, false); // Item requested: + AddHtmlLocalized(40, 96, 120, 20, 1045136, 0x7FFF); // Item requested: AddItem(385, 96, deed.Graphic); - AddHtmlLocalized(40, 120, 210, 20, deed.Number, 0xFFFFFF, false, false); + AddHtmlLocalized(40, 120, 210, 20, deed.Number, 0xFFFFFF); if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) { - AddHtmlLocalized(40, 144, 210, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: + AddHtmlLocalized(40, 144, 210, 20, 1045140, 0x7FFF); // Special requirements to meet: if (deed.RequireExceptional) - AddHtmlLocalized(40, 168, 350, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. + AddHtmlLocalized(40, 168, 350, 20, 1045141, 0x7FFF); // All items must be exceptional. if (deed.Material != BulkMaterialType.None) AddHtmlLocalized(40, deed.RequireExceptional ? 192 : 168, 350, 20, GetMaterialNumberFor(deed.Material), - 0x7FFF, false, false); // All items must be made with x material. + 0x7FFF); // All items must be made with x material. } - AddHtmlLocalized(40, 216, 350, 20, 1045139, 0x7FFF, false, false); // Do you want to accept this order? + AddHtmlLocalized(40, 216, 350, 20, 1045139, 0x7FFF); // Do you want to accept this order? - AddButton(100, 240, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(135, 240, 120, 20, 1006044, 0x7FFF, false, false); // Ok + AddButton(100, 240, 4005, 4007, 1); + AddHtmlLocalized(135, 240, 120, 20, 1006044, 0x7FFF); // Ok - AddButton(275, 240, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(310, 240, 120, 20, 1011012, 0x7FFF, false, false); // CANCEL + AddButton(275, 240, 4005, 4007, 0); + AddHtmlLocalized(310, 240, 120, 20, 1011012, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -80,6 +79,12 @@ 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) @@ -90,4 +95,4 @@ namespace Server.Engines.BulkOrders return 0; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/SmallBODGump.cs b/Scripts/Engines/BulkOrders/SmallBODGump.cs index 10f0125d1..342776555 100644 --- a/Scripts/Engines/BulkOrders/SmallBODGump.cs +++ b/Scripts/Engines/BulkOrders/SmallBODGump.cs @@ -27,34 +27,34 @@ namespace Server.Engines.BulkOrders AddImage(45, 245, 10460); AddImage(480, 245, 10460); - AddHtmlLocalized(225, 25, 120, 20, 1045133, 0x7FFF, false, false); // A bulk order + AddHtmlLocalized(225, 25, 120, 20, 1045133, 0x7FFF); // A bulk order - AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF, false, false); // Amount to make: + AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF); // Amount to make: AddLabel(275, 48, 1152, deed.AmountMax.ToString()); - AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF, false, false); // Amount finished: - AddHtmlLocalized(75, 72, 120, 20, 1045136, 0x7FFF, false, false); // Item requested: + AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF); // Amount finished: + AddHtmlLocalized(75, 72, 120, 20, 1045136, 0x7FFF); // Item requested: AddItem(410, 72, deed.Graphic); - AddHtmlLocalized(75, 96, 210, 20, deed.Number, 0x7FFF, false, false); + AddHtmlLocalized(75, 96, 210, 20, deed.Number, 0x7FFF); AddLabel(275, 96, 0x480, deed.AmountCur.ToString()); if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) - AddHtmlLocalized(75, 120, 200, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: + AddHtmlLocalized(75, 120, 200, 20, 1045140, 0x7FFF); // Special requirements to meet: if (deed.RequireExceptional) - AddHtmlLocalized(75, 144, 300, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. + AddHtmlLocalized(75, 144, 300, 20, 1045141, 0x7FFF); // All items must be exceptional. if (deed.Material != BulkMaterialType.None) AddHtmlLocalized(75, deed.RequireExceptional ? 168 : 144, 300, 20, GetMaterialNumberFor(deed.Material), - 0x7FFF, false, false); // All items must be made with x material. + 0x7FFF); // All items must be made with x material. - AddButton(125, 192, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(160, 192, 300, 20, 1045154, 0x7FFF, false, false); // Combine this deed with the item requested. + AddButton(125, 192, 4005, 4007, 2); + AddHtmlLocalized(160, 192, 300, 20, 1045154, 0x7FFF); // Combine this deed with the item requested. - AddButton(125, 216, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(160, 216, 120, 20, 1011441, 0x7FFF, false, false); // EXIT + AddButton(125, 216, 4005, 4007, 1); + AddHtmlLocalized(160, 216, 120, 20, 1011441, 0x7FFF); // EXIT } public override void OnResponse(NetState sender, RelayInfo info) @@ -79,4 +79,4 @@ namespace Server.Engines.BulkOrders return 0; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/SmallBODTarget.cs b/Scripts/Engines/BulkOrders/SmallBODTarget.cs deleted file mode 100644 index 2b412d0b2..000000000 --- a/Scripts/Engines/BulkOrders/SmallBODTarget.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Server.Targeting; - -namespace Server.Engines.BulkOrders -{ - public class SmallBODTarget : Target - { - private SmallBOD m_Deed; - - public SmallBODTarget(SmallBOD deed) : base(18, false, TargetFlags.None) - { - m_Deed = deed; - } - - protected override void OnTarget(Mobile from, object targeted) - { - if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack)) - return; - - m_Deed.EndCombine(from, targeted); - } - } -} \ No newline at end of file diff --git a/Scripts/Engines/BulkOrders/SmallBulkEntry.cs b/Scripts/Engines/BulkOrders/SmallBulkEntry.cs index b2a98920a..0d52ea1ec 100644 --- a/Scripts/Engines/BulkOrders/SmallBulkEntry.cs +++ b/Scripts/Engines/BulkOrders/SmallBulkEntry.cs @@ -78,10 +78,11 @@ namespace Server.Engines.BulkOrders list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) ); } } - catch - { - } - } + catch + { + // ignored + } + } } } diff --git a/Scripts/Engines/BulkOrders/SmallSmithBOD.cs b/Scripts/Engines/BulkOrders/SmallSmithBOD.cs index 6053a358d..35faf24b9 100644 --- a/Scripts/Engines/BulkOrders/SmallSmithBOD.cs +++ b/Scripts/Engines/BulkOrders/SmallSmithBOD.cs @@ -5,7 +5,6 @@ using Mat = Server.Engines.BulkOrders.BulkMaterialType; namespace Server.Engines.BulkOrders { - [TypeAlias("Scripts.Engines.BulkOrders.SmallSmithBOD")] public class SmallSmithBOD : SmallBOD { public static double[] m_BlacksmithMaterialChances = @@ -21,9 +20,33 @@ namespace Server.Engines.BulkOrders 0.001953125 // Valorite }; - private SmallSmithBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional) + private SmallSmithBOD(SmallBulkEntry entry, BulkMaterialType mat, int amountMax, bool reqExceptional) + : base(0x44E, 0, amountMax, entry.Type, entry.Number, entry.Graphic, reqExceptional, mat) { - Hue = 0x44E; + } + + [Constructible] + public SmallSmithBOD() + { + bool useMaterials = Utility.RandomBool(); + + SmallBulkEntry[] entries = useMaterials ? SmallBulkEntry.BlacksmithArmor : + SmallBulkEntry.BlacksmithWeapons; + + if (entries.Length <= 0) + return; + + int hue = 0x44E; + int amountMax = Utility.RandomList(10, 15, 20); + + BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances) + : BulkMaterialType.None; + + bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None; + + SmallBulkEntry entry = entries[Utility.Random(entries.Length)]; + + Hue = hue; AmountMax = amountMax; Type = entry.Type; Number = entry.Number; @@ -32,216 +55,128 @@ namespace Server.Engines.BulkOrders Material = material; } - [Constructible] - public SmallSmithBOD() - { - SmallBulkEntry[] entries; - bool useMaterials; - - if (useMaterials = Utility.RandomBool()) - entries = SmallBulkEntry.BlacksmithArmor; - else - entries = SmallBulkEntry.BlacksmithWeapons; - - if (entries.Length > 0) - { - int hue = 0x44E; - int amountMax = Utility.RandomList(10, 15, 20); - - BulkMaterialType material; - - if (useMaterials) - material = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); - else - material = BulkMaterialType.None; - - bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None; - - SmallBulkEntry entry = entries[Utility.Random(entries.Length)]; - - Hue = hue; - AmountMax = amountMax; - Type = entry.Type; - Number = entry.Number; - Graphic = entry.Graphic; - RequireExceptional = reqExceptional; - Material = material; - } - } - public SmallSmithBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, - BulkMaterialType mat) + BulkMaterialType mat) : base(0x44E, amountCur, amountMax, type, number, graphic, reqExceptional, mat) { - Hue = 0x44E; - AmountMax = amountMax; - AmountCur = amountCur; - Type = type; - Number = number; - Graphic = graphic; - RequireExceptional = reqExceptional; - Material = mat; } public SmallSmithBOD(Serial serial) : base(serial) { } - public override int ComputeFame() - { - return SmithRewardCalculator.Instance.ComputeFame(this); - } + public override int ComputeFame() => SmithRewardCalculator.Instance.ComputeFame(this); - public override int ComputeGold() - { - return SmithRewardCalculator.Instance.ComputeGold(this); - } + public override int ComputeGold() => SmithRewardCalculator.Instance.ComputeGold(this); - public override List ComputeRewards(bool full) - { - List list = new List(); - - RewardGroup rewardGroup = - SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this)); - - if (rewardGroup != null) - { - if (full) - { - for (int i = 0; i < rewardGroup.Items.Length; ++i) - { - Item item = rewardGroup.Items[i].Construct(); - - if (item != null) - list.Add(item); - } - } - else - { - RewardItem rewardItem = rewardGroup.AcquireItem(); - - Item item = rewardItem?.Construct(); - - if (item != null) - list.Add(item); - } - } - - return list; - } + public override RewardGroup GetRewardGroup() => + SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.Instance.ComputePoints(this)); public static SmallSmithBOD CreateRandomFor(Mobile m) { - SmallBulkEntry[] entries; - bool useMaterials; + bool useMaterials = Utility.RandomBool(); - if (useMaterials = Utility.RandomBool()) - entries = SmallBulkEntry.BlacksmithArmor; + SmallBulkEntry[] entries = useMaterials ? SmallBulkEntry.BlacksmithArmor : + SmallBulkEntry.BlacksmithWeapons; + + if (entries.Length <= 0) + return null; + + double 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 - entries = SmallBulkEntry.BlacksmithWeapons; + amountMax = Utility.RandomList(10, 10, 15, 20); - if (entries.Length > 0) - { - double theirSkill = m.Skills.Blacksmith.Base; - int amountMax; + BulkMaterialType material = BulkMaterialType.None; - 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); + if (useMaterials && theirSkill >= 70.1) + for (int i = 0; i < 20; ++i) + { + BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); + double skillReq = 0.0; - BulkMaterialType material = BulkMaterialType.None; - - if (useMaterials && theirSkill >= 70.1) - for (int i = 0; i < 20; ++i) + switch (check) { - BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); - double skillReq = 0.0; - - switch (check) - { - case BulkMaterialType.DullCopper: - skillReq = 65.0; - break; - case BulkMaterialType.ShadowIron: - skillReq = 70.0; - break; - case BulkMaterialType.Copper: - skillReq = 75.0; - break; - case BulkMaterialType.Bronze: - skillReq = 80.0; - break; - case BulkMaterialType.Gold: - skillReq = 85.0; - break; - case BulkMaterialType.Agapite: - skillReq = 90.0; - break; - case BulkMaterialType.Verite: - skillReq = 95.0; - break; - case BulkMaterialType.Valorite: - skillReq = 100.0; - break; - case BulkMaterialType.Spined: - skillReq = 65.0; - break; - case BulkMaterialType.Horned: - skillReq = 80.0; - break; - case BulkMaterialType.Barbed: - skillReq = 99.0; - break; - } - - if (theirSkill >= skillReq) - { - material = check; + case BulkMaterialType.DullCopper: + skillReq = 65.0; + break; + case BulkMaterialType.ShadowIron: + skillReq = 70.0; + break; + case BulkMaterialType.Copper: + skillReq = 75.0; + break; + case BulkMaterialType.Bronze: + skillReq = 80.0; + break; + case BulkMaterialType.Gold: + skillReq = 85.0; + break; + case BulkMaterialType.Agapite: + skillReq = 90.0; + break; + case BulkMaterialType.Verite: + skillReq = 95.0; + break; + case BulkMaterialType.Valorite: + skillReq = 100.0; + break; + case BulkMaterialType.Spined: + skillReq = 65.0; + break; + case BulkMaterialType.Horned: + skillReq = 80.0; + break; + case BulkMaterialType.Barbed: + skillReq = 99.0; break; - } } - double excChance = 0.0; - - if (theirSkill >= 70.1) - excChance = (theirSkill + 80.0) / 200.0; - - bool reqExceptional = excChance > Utility.RandomDouble(); - - CraftSystem system = DefBlacksmithy.CraftSystem; - - List validEntries = new List(); - - for (int i = 0; i < entries.Length; ++i) - { - CraftItem item = system.CraftItems.SearchFor(entries[i].Type); - - if (item != null) + if (theirSkill >= skillReq) { - bool allRequiredSkills = true; - double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); - - if (allRequiredSkills && chance >= 0.0) - { - if (reqExceptional) - chance = item.GetExceptionalChance(system, chance, m); - - if (chance > 0.0) - validEntries.Add(entries[i]); - } + material = check; + break; } } - if (validEntries.Count > 0) + double excChance = theirSkill >= 70.1 ? (theirSkill + 80.0) / 200.0 : 0.0; + + bool reqExceptional = excChance > Utility.RandomDouble(); + + CraftSystem system = DefBlacksmithy.CraftSystem; + + List validEntries = new List(); + + for (int i = 0; i < entries.Length; ++i) + { + CraftItem item = system.CraftItems.SearchFor(entries[i].Type); + + if (item != null) { - SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; - return new SmallSmithBOD(entry, material, amountMax, reqExceptional); + bool allRequiredSkills = true; + double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); + + if (allRequiredSkills && chance >= 0.0) + { + if (reqExceptional) + chance = item.GetExceptionalChance(system, chance, m); + + if (chance > 0.0) + validEntries.Add(entries[i]); + } } } - return null; + if (validEntries.Count <= 0) + return null; + + SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; + return new SmallSmithBOD(entry, material, amountMax, reqExceptional); + } public override void Serialize(GenericWriter writer) @@ -258,4 +193,4 @@ namespace Server.Engines.BulkOrders int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/BulkOrders/SmallTailorBOD.cs b/Scripts/Engines/BulkOrders/SmallTailorBOD.cs index 2015e1f7f..feeadffb8 100644 --- a/Scripts/Engines/BulkOrders/SmallTailorBOD.cs +++ b/Scripts/Engines/BulkOrders/SmallTailorBOD.cs @@ -14,9 +14,30 @@ namespace Server.Engines.BulkOrders 0.001953125 // Barbed }; - private SmallTailorBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional) + private SmallTailorBOD(SmallBulkEntry entry, BulkMaterialType mat, int amountMax, bool reqExceptional) + : base(0x483, 0, amountMax, entry.Type, entry.Number, entry.Graphic, reqExceptional, mat) { - Hue = 0x483; + } + + [Constructible] + public SmallTailorBOD() + { + bool useMaterials = Utility.RandomBool(); + SmallBulkEntry[] entries = useMaterials ? SmallBulkEntry.TailorLeather : SmallBulkEntry.TailorCloth; + + if (entries.Length <= 0) + return; + + int hue = 0x483; + int amountMax = Utility.RandomList(10, 15, 20); + + BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances) + : BulkMaterialType.None; + + bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None; + SmallBulkEntry entry = entries[Utility.Random(entries.Length)]; + + Hue = hue; AmountMax = amountMax; Type = entry.Type; Number = entry.Number; @@ -25,102 +46,21 @@ namespace Server.Engines.BulkOrders Material = material; } - [Constructible] - public SmallTailorBOD() - { - SmallBulkEntry[] entries; - bool useMaterials; - - if (useMaterials = Utility.RandomBool()) - entries = SmallBulkEntry.TailorLeather; - else - entries = SmallBulkEntry.TailorCloth; - - if (entries.Length > 0) - { - int hue = 0x483; - int amountMax = Utility.RandomList(10, 15, 20); - - BulkMaterialType material; - - if (useMaterials) - material = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances); - else - material = BulkMaterialType.None; - - bool reqExceptional = Utility.RandomBool() || material == BulkMaterialType.None; - - SmallBulkEntry entry = entries[Utility.Random(entries.Length)]; - - Hue = hue; - AmountMax = amountMax; - Type = entry.Type; - Number = entry.Number; - Graphic = entry.Graphic; - RequireExceptional = reqExceptional; - Material = material; - } - } - public SmallTailorBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, - BulkMaterialType mat) + BulkMaterialType mat) : base(0x483, amountCur, amountMax, type, number, graphic, reqExceptional, mat) { - Hue = 0x483; - AmountMax = amountMax; - AmountCur = amountCur; - Type = type; - Number = number; - Graphic = graphic; - RequireExceptional = reqExceptional; - Material = mat; } public SmallTailorBOD(Serial serial) : base(serial) { } - public override int ComputeFame() - { - return TailorRewardCalculator.Instance.ComputeFame(this); - } + public override int ComputeFame() => TailorRewardCalculator.Instance.ComputeFame(this); - public override int ComputeGold() - { - return TailorRewardCalculator.Instance.ComputeGold(this); - } + public override int ComputeGold() => TailorRewardCalculator.Instance.ComputeGold(this); - public override List ComputeRewards(bool full) - { - List list = new List(); - - RewardGroup rewardGroup = - TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this)); - - if (rewardGroup != null) - { - if (full) - { - for (int i = 0; i < rewardGroup.Items.Length; ++i) - { - Item item = rewardGroup.Items[i].Construct(); - - if (item != null) - list.Add(item); - } - } - else - { - RewardItem rewardItem = rewardGroup.AcquireItem(); - - Item item = rewardItem?.Construct(); - - if (item != null) - list.Add(item); - } - } - - return list; - } + public override RewardGroup GetRewardGroup() => + TailorRewardCalculator.Instance.LookupRewards(TailorRewardCalculator.Instance.ComputePoints(this)); public static SmallTailorBOD CreateRandomFor(Mobile m) { @@ -128,8 +68,9 @@ namespace Server.Engines.BulkOrders bool useMaterials = Utility.RandomBool(); double theirSkill = m.Skills.Tailoring.Base; - if (useMaterials && theirSkill >= 6.2 - ) // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill. + + // 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; @@ -247,4 +188,4 @@ namespace Server.Engines.BulkOrders int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs b/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs index 22440bee1..ad6becfd4 100644 --- a/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs +++ b/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs @@ -61,7 +61,7 @@ namespace Server.Engines.CannedEvil if (Deleted) return; - if (m_Skull != null && m_Skull.Deleted) + if (m_Skull?.Deleted == true) Skull = null; if (from.Map != Map || !from.InRange(GetWorldLocation(), 3)) @@ -88,7 +88,7 @@ namespace Server.Engines.CannedEvil if (Deleted) return; - if (m_Skull != null && m_Skull.Deleted) + if (m_Skull?.Deleted == true) Skull = null; if (from.Map != Map || !from.InRange(GetWorldLocation(), 3)) @@ -181,4 +181,4 @@ namespace Server.Engines.CannedEvil } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs b/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs index 6b3872606..a8166c708 100644 --- a/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs +++ b/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs @@ -86,7 +86,7 @@ namespace Server.Engines.CannedEvil public bool Validate(ChampionSkullBrazier brazier) { - return brazier?.Skull != null && !brazier.Skull.Deleted; + return brazier?.Skull?.Deleted == false; } public override void Serialize(GenericWriter writer) @@ -125,4 +125,4 @@ namespace Server.Engines.CannedEvil } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/CannedEvil/ChampionSpawn.cs b/Scripts/Engines/CannedEvil/ChampionSpawn.cs index 384daaa0b..a9e438d0d 100644 --- a/Scripts/Engines/CannedEvil/ChampionSpawn.cs +++ b/Scripts/Engines/CannedEvil/ChampionSpawn.cs @@ -348,7 +348,7 @@ namespace Server.Engines.CannedEvil } else { - if (killer.Corpse != null && !killer.Corpse.Deleted) + if (killer?.Corpse.Deleted == false) killer.Corpse.DropItem(scroll); else killer.AddToBackpack(scroll); @@ -421,7 +421,8 @@ namespace Server.Engines.CannedEvil { m_Altar.Hue = 0; - if (!Core.ML || Map == Map.Felucca) new StarRoomGate(true, m_Altar.Location, m_Altar.Map); + if (!Core.ML || Map == Map.Felucca) + new StarRoomGate(m_Altar.Location, m_Altar.Map, true); } Champion = null; @@ -440,7 +441,9 @@ namespace Server.Engines.CannedEvil if (m.Deleted) { - if (m.Corpse != null && !m.Corpse.Deleted) ((Corpse)m.Corpse).BeginDecay(TimeSpan.FromMinutes(1)); + if (m.Corpse?.Deleted == false) + ((Corpse)m.Corpse).BeginDecay(TimeSpan.FromMinutes(1)); + m_Creatures.RemoveAt(i); --i; ++m_Kills; @@ -574,6 +577,7 @@ namespace Server.Engines.CannedEvil } catch { + // ignored } Champion?.MoveToWorld(new Point3D(X, Y, Z - 15), Map); @@ -919,7 +923,7 @@ namespace Server.Engines.CannedEvil m_Creatures.Clear(); } - if (Champion != null && !Champion.Player) + if (Champion?.Player == false) Champion.Delete(); Stop(); @@ -950,7 +954,7 @@ namespace Server.Engines.CannedEvil public void RegisterDamage(Mobile from, int amount) { - if (from == null || !from.Player) + if (from?.Player != true) return; m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out int value) ? value : 0); @@ -997,7 +1001,7 @@ namespace Server.Engines.CannedEvil Container pack = to.Backpack; - if (pack == null || !pack.TryDropItem(to, artifact, false)) + if (pack?.TryDropItem(to, artifact, false) != true) artifact.Delete(); else to.SendLocalizedMessage( @@ -1006,8 +1010,8 @@ namespace Server.Engines.CannedEvil public bool IsEligible(Mobile m, Item Artifact) { - return m.Player && m.Alive && m.Region != null && m.Region == m_Region && m.Backpack != null && - m.Backpack.CheckHold(m, Artifact, false); + return m.Player && m.Alive && m.Region != null && m.Region == m_Region && + m.Backpack?.CheckHold(m, Artifact, false) == true; } public override void Serialize(GenericWriter writer) diff --git a/Scripts/Engines/CannedEvil/StarRoomGate.cs b/Scripts/Engines/CannedEvil/StarRoomGate.cs index 6bd092caa..31d6db763 100644 --- a/Scripts/Engines/CannedEvil/StarRoomGate.cs +++ b/Scripts/Engines/CannedEvil/StarRoomGate.cs @@ -9,19 +9,14 @@ namespace Server.Items private Timer m_Timer; [Constructible] - public StarRoomGate() : this(false) - { - } - - [Constructible] - public StarRoomGate(bool decays, Point3D loc, Map map) : this(decays) + public StarRoomGate(Point3D loc, Map map, bool decays) : this(decays) { MoveToWorld(loc, map); Effects.PlaySound(loc, map, 0x20E); } [Constructible] - public StarRoomGate(bool decays) : base(new Point3D(5143, 1774, 0), Map.Felucca) + public StarRoomGate(bool decays = false) : base(new Point3D(5143, 1774, 0), Map.Felucca) { Dispellable = false; ItemID = 0x1FD4; @@ -101,4 +96,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Chat/Channel.cs b/Scripts/Engines/Chat/Channel.cs index d50d7ee3e..9a88aa369 100644 --- a/Scripts/Engines/Chat/Channel.cs +++ b/Scripts/Engines/Chat/Channel.cs @@ -116,21 +116,15 @@ namespace Server.Engines.Chat public bool ValidateAccess(ChatUser from, ChatUser target) { - if (from != null && target != null && from.Mobile.AccessLevel < target.Mobile.AccessLevel) - { - from.Mobile.SendMessage("Your access level is too low to do this."); - return false; - } + 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; - return true; } - public bool AddUser(ChatUser user) - { - return AddUser(user, null); - } - - public bool AddUser(ChatUser user, string password) + public bool AddUser(ChatUser user, string password = null) { if (Contains(user)) { @@ -188,12 +182,7 @@ namespace Server.Engines.Chat } } - public void AdBan(ChatUser user) - { - AddBan(user, null); - } - - public void AddBan(ChatUser user, ChatUser moderator) + public void AddBan(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) return; @@ -210,12 +199,7 @@ namespace Server.Engines.Chat m_Banned.Remove(user); } - public void Kick(ChatUser user) - { - Kick(user, null); - } - - public void Kick(ChatUser user, ChatUser moderator) + public void Kick(ChatUser user, ChatUser moderator = null) { Kick(user, moderator, false); } @@ -248,12 +232,7 @@ namespace Server.Engines.Chat moderator?.SendMessage(62, user.Username); // You are banning %1 from this conference. } - public void AddVoiced(ChatUser user) - { - AddVoiced(user, null); - } - - public void AddVoiced(ChatUser user, ChatUser moderator) + public void AddVoiced(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator)) return; @@ -291,12 +270,7 @@ namespace Server.Engines.Chat } } - public void AddModerator(ChatUser user) - { - AddModerator(user, null); - } - - public void AddModerator(ChatUser user, ChatUser moderator) + public void AddModerator(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator)) return; @@ -316,12 +290,7 @@ namespace Server.Engines.Chat SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username); } - public void RemoveModerator(ChatUser user) - { - RemoveModerator(user, null); - } - - public void RemoveModerator(ChatUser user, ChatUser moderator) + public void RemoveModerator(ChatUser user, ChatUser moderator = null) { if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) return; @@ -338,32 +307,12 @@ namespace Server.Engines.Chat } } - public void SendMessage(int number) + public void SendMessage(int number, string param1 = null) { - SendMessage(number, null, null, null); + SendMessage(number, null, param1); } - public void SendMessage(int number, string param1) - { - SendMessage(number, null, param1, null); - } - - public void SendMessage(int number, string param1, string param2) - { - SendMessage(number, null, param1, param2); - } - - public void SendMessage(int number, ChatUser initiator) - { - SendMessage(number, initiator, null, null); - } - - public void SendMessage(int number, ChatUser initiator, string param1) - { - SendMessage(number, initiator, param1, null); - } - - public void SendMessage(int number, ChatUser initiator, string param1, string param2) + public void SendMessage(int number, ChatUser initiator, string param1 = null, string param2 = null) { for (int i = 0; i < m_Users.Count; ++i) { @@ -395,32 +344,12 @@ namespace Server.Engines.Chat } } - public void SendCommand(ChatCommand command) - { - SendCommand(command, null, null, null); - } - - public void SendCommand(ChatCommand command, string param1) - { - SendCommand(command, null, param1, null); - } - - public void SendCommand(ChatCommand command, string param1, string param2) + public void SendCommand(ChatCommand command, string param1 = null, string param2 = null) { SendCommand(command, null, param1, param2); } - public void SendCommand(ChatCommand command, ChatUser initiator) - { - SendCommand(command, initiator, null, null); - } - - public void SendCommand(ChatCommand command, ChatUser initiator, string param1) - { - SendCommand(command, initiator, param1, null); - } - - public void SendCommand(ChatCommand command, ChatUser initiator, string param1, string param2) + public void SendCommand(ChatCommand command, ChatUser initiator, string param1 = null, string param2 = null) { for (int i = 0; i < m_Users.Count; ++i) { @@ -457,12 +386,7 @@ namespace Server.Engines.Chat } } - public static Channel AddChannel(string name) - { - return AddChannel(name, null); - } - - public static Channel AddChannel(string name, string password) + public static Channel AddChannel(string name, string password = null) { Channel channel = FindChannelByName(name); @@ -521,4 +445,4 @@ namespace Server.Engines.Chat AddChannel(name).AlwaysAvailable = true; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Chat/Chat.cs b/Scripts/Engines/Chat/Chat.cs index 21ba2c493..7a65ad4e9 100644 --- a/Scripts/Engines/Chat/Chat.cs +++ b/Scripts/Engines/Chat/Chat.cs @@ -16,17 +16,7 @@ namespace Server.Engines.Chat PacketHandlers.Register(0xB3, 0, true, ChatAction); } - public static void SendCommandTo(Mobile to, ChatCommand type) - { - SendCommandTo(to, type, null, null); - } - - public static void SendCommandTo(Mobile to, ChatCommand type, string param1) - { - SendCommandTo(to, type, param1, null); - } - - public static void SendCommandTo(Mobile to, ChatCommand type, string param1, string param2) + public static void SendCommandTo(Mobile to, ChatCommand type, string param1 = null, string param2 = null) { to?.Send(new ChatMessagePacket(null, (int)type + 20, param1, param2)); } diff --git a/Scripts/Engines/Chat/ChatActionHandlers.cs b/Scripts/Engines/Chat/ChatActionHandlers.cs index 8175aa3da..b6ad6c2df 100644 --- a/Scripts/Engines/Chat/ChatActionHandlers.cs +++ b/Scripts/Engines/Chat/ChatActionHandlers.cs @@ -180,7 +180,7 @@ namespace Server.Engines.Chat password = password?.Trim(); - if (password != null && password.Length == 0) + if (password?.Length == 0) password = null; Channel joined = Channel.FindChannelByName(name); @@ -217,7 +217,7 @@ namespace Server.Engines.Chat password = password?.Trim(); - if (password != null && password.Length == 0) + if (password?.Length == 0) password = null; Channel.AddChannel(name, password).AddUser(from, password); @@ -355,4 +355,4 @@ namespace Server.Engines.Chat channel.VoiceRestricted = !channel.VoiceRestricted; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Chat/ChatUser.cs b/Scripts/Engines/Chat/ChatUser.cs index fd5bc596c..1fe1995d1 100644 --- a/Scripts/Engines/Chat/ChatUser.cs +++ b/Scripts/Engines/Chat/ChatUser.cs @@ -49,17 +49,12 @@ namespace Server.Engines.Chat public bool IgnorePrivateMessage{ get; set; } - public bool IsModerator => CurrentChannel != null && CurrentChannel.IsModerator(this); + public bool IsModerator => CurrentChannel?.IsModerator(this) == true; public char GetColorCharacter() { - if (CurrentChannel != null && CurrentChannel.IsModerator(this)) - return ModeratorColorCharacter; - - if (CurrentChannel != null && CurrentChannel.IsVoiced(this)) - return VoicedColorCharacter; - - return NormalColorCharacter; + return IsModerator ? ModeratorColorCharacter : + CurrentChannel?.IsVoiced(this) == true ? VoicedColorCharacter : NormalColorCharacter; } public bool CheckOnline() @@ -71,17 +66,7 @@ namespace Server.Engines.Chat return false; } - public void SendMessage(int number) - { - SendMessage(number, null, null); - } - - public void SendMessage(int number, string param1) - { - SendMessage(number, param1, null); - } - - public void SendMessage(int number, string param1, string param2) + public void SendMessage(int number, string param1 = null, string param2 = null) { if (Mobile.NetState != null) Mobile.Send(new ChatMessagePacket(Mobile, number, param1, param2)); @@ -135,28 +120,28 @@ namespace Server.Engines.Chat { ChatUser user = GetChatUser(from); - if (user == null) + if (user != null) + return user; + + user = new ChatUser(from); + + m_Users.Add(user); + m_Table[from] = user; + + Channel.SendChannelsTo(user); + + List list = Channel.Channels; + + for (int i = 0; i < list.Count; ++i) { - user = new ChatUser(from); + Channel c = list[i]; - m_Users.Add(user); - m_Table[from] = user; - - Channel.SendChannelsTo(user); - - List list = Channel.Channels; - - for (int i = 0; i < list.Count; ++i) - { - Channel c = list[i]; - - if (c.AddUser(user)) - break; - } - - //ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); + if (c.AddUser(user)) + break; } + //ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); + return user; } @@ -205,32 +190,12 @@ namespace Server.Engines.Chat return null; } - public static void GlobalSendCommand(ChatCommand command) - { - GlobalSendCommand(command, null, null, null); - } - - public static void GlobalSendCommand(ChatCommand command, string param1) - { - GlobalSendCommand(command, null, param1, null); - } - - public static void GlobalSendCommand(ChatCommand command, string param1, string param2) + public static void GlobalSendCommand(ChatCommand command, string param1, string param2 = null) { GlobalSendCommand(command, null, param1, param2); } - public static void GlobalSendCommand(ChatCommand command, ChatUser initiator) - { - GlobalSendCommand(command, initiator, null, null); - } - - public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1) - { - GlobalSendCommand(command, initiator, param1, null); - } - - public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1, string param2) + public static void GlobalSendCommand(ChatCommand command, ChatUser initiator = null, string param1 = null, string param2 = null) { for (int i = 0; i < m_Users.Count; ++i) { @@ -244,4 +209,4 @@ namespace Server.Engines.Chat } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/AcceptDuelGump.cs b/Scripts/Engines/ConPVP/AcceptDuelGump.cs index ac853fd84..7bf342a64 100644 --- a/Scripts/Engines/ConPVP/AcceptDuelGump.cs +++ b/Scripts/Engines/ConPVP/AcceptDuelGump.cs @@ -44,11 +44,11 @@ namespace Server.Engines.ConPVP AddImage(215, -43, 0xEE40); //AddImage( 330, 141, 0x8BA ); - AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); - AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); - AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); - AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); - AddHtml(22, 22, 294, 20, Color(Center("Duel Challenge"), LabelColor32), false, false); + AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); + AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); + AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); + AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); + AddHtml(22, 22, 294, 20, Color(Center("Duel Challenge"), LabelColor32)); string fmt; @@ -57,37 +57,37 @@ namespace Server.Engines.ConPVP 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), false, false); - AddHtml(22 + 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); - AddHtml(22, 50 - 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); - AddHtml(22, 50 + 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); - AddHtml(22, 50, 294, 40, Color(string.Format(fmt, challenger.Name), 0xB0C868), false, false); + 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)); + AddHtml(22, 50 - 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32)); + AddHtml(22, 50 + 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32)); + AddHtml(22, 50, 294, 40, Color(string.Format(fmt, challenger.Name), 0xB0C868)); AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(42, 90, 264, 1, 9157); AddRadio(24, 100, 9727, 9730, true, 1); - AddHtml(60 - 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); - AddHtml(60 + 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); - AddHtml(60, 105 - 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); - AddHtml(60, 105 + 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); - AddHtml(60, 105, 250, 20, Color("Yes, I will fight this duel.", LabelColor32), false, false); + AddHtml(60 - 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32)); + AddHtml(60 + 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32)); + AddHtml(60, 105 - 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32)); + AddHtml(60, 105 + 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32)); + AddHtml(60, 105, 250, 20, Color("Yes, I will fight this duel.", LabelColor32)); AddRadio(24, 135, 9727, 9730, false, 2); - AddHtml(60 - 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); - AddHtml(60 + 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); - AddHtml(60, 140 - 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); - AddHtml(60, 140 + 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); - AddHtml(60, 140, 250, 20, Color("No, I do not wish to fight.", LabelColor32), false, false); + AddHtml(60 - 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32)); + AddHtml(60 + 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32)); + AddHtml(60, 140 - 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32)); + AddHtml(60, 140 + 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32)); + AddHtml(60, 140, 250, 20, Color("No, I do not wish to fight.", LabelColor32)); AddRadio(24, 170, 9727, 9730, false, 3); - AddHtml(60 - 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); - AddHtml(60 + 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); - AddHtml(60, 175 - 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); - AddHtml(60, 175 + 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); - AddHtml(60, 175, 250, 20, Color("No, knave. Do not ask again.", LabelColor32), false, false); + AddHtml(60 - 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32)); + AddHtml(60 + 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32)); + AddHtml(60, 175 - 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32)); + AddHtml(60, 175 + 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32)); + AddHtml(60, 175, 250, 20, Color("No, knave. Do not ask again.", LabelColor32)); - AddButton(314, 173, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(314, 173, 247, 248, 1); Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject); } diff --git a/Scripts/Engines/ConPVP/Arena.cs b/Scripts/Engines/ConPVP/Arena.cs index 88e98f2a2..f36bd394c 100644 --- a/Scripts/Engines/ConPVP/Arena.cs +++ b/Scripts/Engines/ConPVP/Arena.cs @@ -86,13 +86,9 @@ namespace Server.Engines.ConPVP [PropertyObject] public class ArenaStartPoints { - public ArenaStartPoints() : this(new Point3D[8]) + public ArenaStartPoints(Point3D[] points = null) { - } - - public ArenaStartPoints(Point3D[] points) - { - Points = points; + Points = points ?? new Point3D[8]; } public ArenaStartPoints(GenericReader reader) @@ -176,7 +172,7 @@ namespace Server.Engines.ConPVP } [PropertyObject] - public class Arena : IComparable + public class Arena : IComparable { private bool m_Active; private Rectangle2D m_Bounds; @@ -407,7 +403,8 @@ namespace Server.Engines.ConPVP set { m_GateOut = value; - if (Teleporter != null) Teleporter.Location = m_GateOut; + if (Teleporter != null) + Teleporter.Location = m_GateOut; } } @@ -459,10 +456,8 @@ namespace Server.Engines.ConPVP public static List Arenas{ get; } = new List(); - public int CompareTo(object obj) + public int CompareTo(Arena c) { - Arena c = (Arena)obj; - string a = m_Name; string b = c.m_Name; @@ -478,18 +473,13 @@ namespace Server.Engines.ConPVP public Ladder AcquireLadder() { - if (Ladder != null) - return Ladder.Ladder; - - return ConPVP.Ladder.Instance; + return Ladder?.Ladder ?? ConPVP.Ladder.Instance; } public void Delete() { Active = false; - m_Region?.Unregister(); - m_Region = null; } @@ -664,7 +654,7 @@ namespace Server.Engines.ConPVP { ArenaController controller = allControllers[i]; - if (controller != null && !controller.Deleted && controller.Arena != null && controller.IsPrivate && + if (controller?.Deleted == false && controller.Arena != null && controller.IsPrivate && controller.Map == first.Map && first.InRange(controller, 24)) { BaseHouse house = BaseHouse.FindHouseAt(controller); @@ -832,4 +822,4 @@ namespace Server.Engines.ConPVP #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/DuelContext.cs b/Scripts/Engines/ConPVP/DuelContext.cs index a7342adf5..c5e667d52 100644 --- a/Scripts/Engines/ConPVP/DuelContext.cs +++ b/Scripts/Engines/ConPVP/DuelContext.cs @@ -48,11 +48,7 @@ namespace Server.Engines.ConPVP private bool m_Yielding; - public DuelContext(Mobile initiator, RulesetLayout layout) : this(initiator, layout, true) - { - } - - public DuelContext(Mobile initiator, RulesetLayout layout, bool addNew) + public DuelContext(Mobile initiator, RulesetLayout layout, bool addNew = true) { Initiator = initiator; Participants = new List(); @@ -123,13 +119,8 @@ namespace Server.Engines.ConPVP public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) { - if (!(from is PlayerMobile pm)) - return true; - - DuelContext dc = pm.DuelContext; - // No DuelContext, or InstaAllowSpecialMove - return dc?.InstAllowSpecialMove(from, name, move) != false; + return (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false; } public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move) @@ -139,7 +130,7 @@ namespace Server.Engines.ConPVP DuelPlayer pl = Find(from); - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) return true; if (CantDoAnything(from)) @@ -165,9 +156,7 @@ namespace Server.Engines.ConPVP if (!StartedBeginCountdown) return true; - DuelPlayer pl = Find(from); - - if (pl?.Eliminated != false) + if (Find(from)?.Eliminated != false) return true; if (CantDoAnything(from)) @@ -256,7 +245,7 @@ namespace Server.Engines.ConPVP DuelPlayer pl = Find(from); - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) return true; if (item is Dagger || CheckItemEquip(from, item)) @@ -350,7 +339,7 @@ namespace Server.Engines.ConPVP DuelPlayer pl = Find(from); - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) return true; if (CantDoAnything(from)) @@ -373,7 +362,7 @@ namespace Server.Engines.ConPVP DuelPlayer pl = Find(from); - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) return true; if (!(item is BaseRefreshPotion)) @@ -507,7 +496,7 @@ namespace Server.Engines.ConPVP DuelPlayer pl = Find(mob); - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) return; if (mob.Map == Map.Internal) @@ -533,30 +522,27 @@ namespace Server.Engines.ConPVP DuelPlayer pl = Find(mob); - if (pl != null && !pl.Eliminated) + if (pl?.Eliminated == true || m_EventGame != null && !m_EventGame.OnDeath(mob, corpse)) + return; + + pl.Eliminated = true; + + if (mob.Poison != null) + mob.Poison = null; + + Requip(mob, corpse); + DelayBounce(TimeSpan.FromSeconds(4.0), mob, corpse); + + Participant winner = CheckCompletion(); + + if (winner != null) { - if (m_EventGame != null && !m_EventGame.OnDeath(mob, corpse)) - return; - - pl.Eliminated = true; - - if (mob.Poison != null) - mob.Poison = null; - - Requip(mob, corpse); - DelayBounce(TimeSpan.FromSeconds(4.0), mob, corpse); - - Participant winner = CheckCompletion(); - - if (winner != null) - { - Finish(winner); - } - else if (!m_Yielding) - { - mob.LocalOverheadMessage(MessageType.Regular, 0x22, false, "You have been defeated."); - mob.NonlocalOverheadMessage(MessageType.Regular, 0x22, false, $"{mob.Name} has been defeated."); - } + Finish(winner); + } + else if (!m_Yielding) + { + mob.LocalOverheadMessage(MessageType.Regular, 0x22, false, "You have been defeated."); + mob.NonlocalOverheadMessage(MessageType.Regular, 0x22, false, $"{mob.Name} has been defeated."); } } @@ -564,7 +550,7 @@ namespace Server.Engines.ConPVP { for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; if (p.HasOpenSlot) return false; @@ -609,7 +595,7 @@ namespace Server.Engines.ConPVP Mobile killer = from.FindMostRecentDamager(false); - if (killer != null && killer.Player) + if (killer?.Player == true) killer.AddToBackpack(new Head(m_Tournament == null ? HeadType.Duel : HeadType.Tournament, from.Name)); } @@ -671,7 +657,7 @@ namespace Server.Engines.ConPVP { DuelPlayer pl = winner.Players[i]; - if (pl != null && !pl.Eliminated) + if (pl?.Eliminated == false) DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null); } @@ -688,7 +674,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < Participants.Count; ++i) { - Participant loser = (Participant)Participants[i]; + Participant loser = Participants[i]; if (loser != winner) { @@ -714,8 +700,8 @@ namespace Server.Engines.ConPVP if (IsOneVsOne) { - DuelPlayer dp1 = ((Participant)Participants[0]).Players[0]; - DuelPlayer dp2 = ((Participant)Participants[1]).Players[0]; + DuelPlayer dp1 = Participants[0].Players[0]; + DuelPlayer dp2 = Participants[1].Players[0]; if (dp1 != null && dp2 != null) { @@ -797,7 +783,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; for (int j = 0; j < p.Players.Length; ++j) { @@ -828,7 +814,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < Participants.Count; ++i) { - Participant oldPart = (Participant)Participants[i]; + Participant oldPart = Participants[i]; Participant newPart = new Participant(dc, oldPart.Players.Length); for (int j = 0; j < oldPart.Players.Length; ++j) @@ -858,7 +844,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; DuelPlayer pl = p.Find(mob); if (pl != null) @@ -873,7 +859,7 @@ namespace Server.Engines.ConPVP DuelPlayer pl1 = Find(m1); DuelPlayer pl2 = Find(m2); - return pl1 != null && pl2 != null && pl1.Participant == pl2.Participant; + return pl1 != null && pl1.Participant == pl2?.Participant; } public Participant CheckCompletion() @@ -885,7 +871,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; if (p.Eliminated) { @@ -900,10 +886,7 @@ namespace Server.Engines.ConPVP } } - if (hasWinner) - return winner ?? (Participant)Participants[0]; - - return null; + return hasWinner ? winner ?? Participants[0] : null; } public void StartCountdown(int count, CountdownCallback cb) @@ -953,13 +936,13 @@ namespace Server.Engines.ConPVP { for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer pl = p.Players[j]; - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) continue; pl.Mobile.SendSound(0x1E1); @@ -984,13 +967,13 @@ namespace Server.Engines.ConPVP { for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer pl = p.Players[j]; - if (pl == null || pl.Eliminated) + if (pl?.Eliminated != false) continue; pl.Mobile.SendSound(0x1E1); @@ -1065,7 +1048,7 @@ namespace Server.Engines.ConPVP { DuelPlayer pl = p.Players[j]; - if (pl != null && !pl.Eliminated) + if (pl?.Eliminated == false) DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null); } @@ -1511,7 +1494,7 @@ namespace Server.Engines.ConPVP } } } - + public void CloseAllGumps(DuelPlayer pl) { pl.Mobile.CloseGump(); @@ -1527,7 +1510,7 @@ namespace Server.Engines.ConPVP { for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; for (int j = 0; j < p.Players.Length; ++j) { @@ -1546,7 +1529,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < Participants.Count; ++i) { - Participant p = (Participant)Participants[i]; + Participant p = Participants[i]; for (int j = 0; j < p.Players.Length; ++j) { @@ -1571,7 +1554,7 @@ namespace Server.Engines.ConPVP else mob.SendMessage(0x22, "{0} has rejected the {1}.", rejector.Name, Rematch ? "rematch" : page); } - + // Close all of them? mob.CloseGump(); mob.CloseGump(); @@ -1851,9 +1834,9 @@ namespace Server.Engines.ConPVP for (int i = 0; i < ruleset.Flavors.Count; ++i) { - defs.Or(((Ruleset)ruleset.Flavors[i]).Options); + defs.Or(ruleset.Flavors[i].Options); - mob.SendMessage(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title); + mob.SendMessage(" + {0}", ruleset.Flavors[i].Title); } } else @@ -2084,10 +2067,7 @@ namespace Server.Engines.ConPVP } } - Arena arena = m_OverrideArena; - - if (arena == null) - arena = Arena.FindArena(players); + Arena arena = m_OverrideArena ?? Arena.FindArena(players); if (arena == null) { @@ -2482,7 +2462,7 @@ namespace Server.Engines.ConPVP } else { - if (m_Teleporter != null && !m_Teleporter.Deleted) + if (m_Teleporter?.Deleted == false) m_Teleporter.Register(m); base.UseGate(m); @@ -2512,4 +2492,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/DuelTeleporterAddon.cs b/Scripts/Engines/ConPVP/DuelTeleporterAddon.cs index e1a5dd094..8fb97223e 100644 --- a/Scripts/Engines/ConPVP/DuelTeleporterAddon.cs +++ b/Scripts/Engines/ConPVP/DuelTeleporterAddon.cs @@ -15,12 +15,7 @@ namespace Server.Engines.ConPVP public class DuelTeleporterAddon : BaseAddon { [Constructible] - public DuelTeleporterAddon() : this(DuelTeleporterType.Squares) - { - } - - [Constructible] - public DuelTeleporterAddon(DuelTeleporterType type) + public DuelTeleporterAddon(DuelTeleporterType type = DuelTeleporterType.Squares) { int itemID = (int)type; @@ -91,4 +86,4 @@ namespace Server.Engines.ConPVP int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Games/BombingRun.cs b/Scripts/Engines/ConPVP/Games/BombingRun.cs index 7adbe3b5d..c41cfb333 100644 --- a/Scripts/Engines/ConPVP/Games/BombingRun.cs +++ b/Scripts/Engines/ConPVP/Games/BombingRun.cs @@ -1,1812 +1,1797 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using Server.Gumps; -using Server.Items; -using Server.Mobiles; -using Server.Network; -using Server.Targeting; - -namespace Server.Engines.ConPVP -{ - public class BRBomb : Item - { - private bool m_Flying; - - private BRGame m_Game; - - private List m_Helpers; - - private Point3DList m_Path = new Point3DList(); - private int m_PathIdx; - private EffectTimer m_Timer; - - public BRBomb(BRGame game) : - base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball - { - Movable = false; - Hue = 0x35; - - m_Game = game; - - m_Helpers = new List(); - - m_Timer = new EffectTimer(this); - m_Timer.Start(); - } - - public BRBomb(Serial serial) : base(serial) - { - } - - public override string DefaultName => "da bomb"; - - public Mobile Thrower{ get; private set; } - - private Mobile FindOwner(object parent) - { - if (parent is Item item) - return item.RootParent as Mobile; - - if (parent is Mobile mobile) - return mobile; - - return null; - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 0: - { - break; - } - } - - Timer.DelayCall(TimeSpan.Zero, Delete).Start(); // delete this after the world loads - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void OnAdded(IEntity parent) - { - base.OnAdded(parent); - - Mobile mob = FindOwner(parent); - - if (mob != null) mob.SolidHueOverride = 0x0499; - } - - public override void OnRemoved(IEntity parent) - { - base.OnRemoved(parent); - - Mobile mob = FindOwner(parent); - - if (mob != null && m_Game != null) - mob.SolidHueOverride = m_Game.GetColor(mob); - } - - public void DropTo(Mobile mob, Mobile killer) - { - if (mob != null && !mob.Deleted) - MoveToWorld(mob.Location, mob.Map); - else if (killer != null && !killer.Deleted) - MoveToWorld(killer.Location, killer.Map); - else - m_Game?.ReturnBomb(); - } - - public override bool OnMoveOver(Mobile m) - { - if (m_Flying || !Visible || m_Game == null || m == null || !m.Alive) - return true; - - BRTeamInfo useTeam = m_Game.GetTeamInfo(m); - if (useTeam == null) - return true; - - return TakeBomb(m, useTeam, "picked up"); - } - - public override void OnLocationChange(Point3D oldLocation) - { - base.OnLocationChange(oldLocation); - - if (m_Flying || !Visible || m_Game == null || Parent != null) - return; - - IPooledEnumerable eable = GetClientsInRange(0); - foreach (NetState ns in eable) - { - Mobile m = ns.Mobile; - - if (m == null || !m.Player || !m.Alive) - continue; - - BRTeamInfo useTeam = m_Game.GetTeamInfo(m); - if (useTeam != null) - TakeBomb(m, useTeam, "got"); - } - } - - public override void OnAfterDelete() - { - base.OnAfterDelete(); - - m_Timer?.Stop(); - } - - public override void OnDoubleClick(Mobile m) - { - if (m_Game == null || !Visible || m == null || !m.Alive) - 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) - { - BRTeamInfo 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; - - Point3D 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; - Thrower = from; - MoveToWorld(GetWorldLocation(), from.Map); - - BeginFlight(pt); - return true; - } - - private void HitObject(Point3D ballLoc, int objZ, int objHeight) - { - DoAnim(GetWorldLocation(), ballLoc, Map); - MoveToWorld(ballLoc); - - m_Path.Clear(); - m_PathIdx = 0; - - Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight).Start(); - } - - private bool CheckCatch(Mobile m, Point3D myLoc) - { - if (m == null || !m.Alive || !m.Player || m_Game == null) - return false; - - if (m_Game.GetTeamInfo(m) == null) - return false; - - int zdiff = myLoc.Z - m.Z; - - if (zdiff < 0) - return false; - if (zdiff < 12) - return true; - if (zdiff < 16) - return Utility.RandomBool(); // 50% chance - - return false; - } - - private void DoAnim(Point3D start, Point3D end, Map map) - { - Effects.SendMovingEffect(new Entity(Serial.Zero, start, map), new Entity(Serial.Zero, end, map), - ItemID, 15, 0, false, false, Hue); - } - - private void DoCatch(Mobile m) - { - m_Flying = false; - Visible = true; - - if (m == null || !m.Alive || !m.Player || m_Game == null) - return; - - BRTeamInfo useTeam = m_Game.GetTeamInfo(m); - - if (useTeam == null) - return; - - DoAnim(GetWorldLocation(), m.Location, m.Map); - - string 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) - { - Point3D org = GetWorldLocation(); - - org.Z += 10; // always add 10 at the start cause we're coming from a mobile's eye level - - /*if ( org.X > dest.X || ( org.X == dest.X && org.Y > dest.Y ) || ( org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z ) ) - { - Point3D swap = org; - org = dest; - dest = swap; - }*/ - - List list = new List(); - - int xd = dest.X - org.X; - int yd = dest.Y - org.Y; - int zd = dest.Z - org.Z; - double dist2d = Math.Sqrt(xd * xd + yd * yd); - double dist3d = zd == 0 ? dist2d : Math.Sqrt(dist2d * dist2d + zd * zd); - - double rise = yd / dist3d; - double run = xd / dist3d; - double zslp = zd / dist3d; - - double x = org.X; - double y = org.Y; - double z = org.Z; - while (Utility.NumberBetween(x, dest.X, org.X, 0.5) && Utility.NumberBetween(y, dest.Y, org.Y, 0.5) && - Utility.NumberBetween(z, dest.Z, org.Z, 0.5)) - { - int ix = (int)Math.Round(x); - int iy = (int)Math.Round(y); - int iz = (int)Math.Round(z); - - if (list.Count > 0) - { - Point3D p = list[list.Count - 1]; - - if (p.X != ix || p.Y != iy || p.Z != iz) - list.Add(new Point3D(ix, iy, iz)); - } - else - { - list.Add(new Point3D(ix, iy, iz)); - } - - x += run; - y += rise; - z += zslp; - } - - if (list.Count > 0 && list[list.Count - 1] != dest) - list.Add(dest); - - /*if ( dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ) ) - { - int count = list.Count; - int i; - int climb = count / 2; - if ( climb > 3 ) - climb = 3; - - for ( i = 0; i < climb; i++ ) - { - p = ((Point3D)list[i]); - p.Z += (i+1) * 4; - list[i] = p; - } - - for ( ; i < count - climb; i++ ) - { - p = ((Point3D)list[i]); - p.Z += 16; - list[i] = p; - } - - for ( i = climb; i > 0; i-- ) - { - p = ((Point3D)list[i]); - p.Z += i * 4; - list[i] = p; - } - }*/ - - if (dist2d > 1) - { - int count = list.Count; - double height = count * 2 * (Utility.RandomDouble() * 0.40 + 0.10); // 10 - 50% - double coeff = -height / (count * count / 4.0); - - for (int i = 0; i < count; i++) - { - Point3D p = list[i]; - - int xp = i - count / 2; - - p.Z += (int)Math.Ceiling(coeff * xp * xp + height); - - list[i] = p; - } - } - - m_Path.Clear(); - for (int i = 0; i < list.Count; i++) - m_Path.Add(list[i]); - - m_PathIdx = 0; - - ContinueFlight(); - } - - private void ContinueFlight() - { - int height; - bool found = false; - - if (m_PathIdx < m_Path.Count && Map?.Tiles != null && Map != Map.Internal) - { - int 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); - - for (int i = m_PathIdx; i < pathCheckEnd; i++) - { - Point3D point = m_Path[i]; - - LandTile landTile = Map.Tiles.GetLandTile(point.X, point.Y); - int landZ = 0, landAvg = 0, landTop = 0; - Map.GetAverageZ(point.X, point.Y, ref landZ, ref landAvg, ref landTop); - - if (landZ <= point.Z && landTop >= point.Z && !landTile.Ignored) - { - HitObject(point, landTop, 0); - return; - } - - StaticTile[] statics = Map.Tiles.GetStaticTiles(point.X, point.Y, true); - - if (landTile.ID == 0x244 && statics.Length == 0) // 0x244 = invalid land tile - { - bool empty = true; - IPooledEnumerable eable = Map.GetItemsInRange(point, 0); - - foreach (Item item in eable) - if (item != this) - { - empty = false; - break; - } - - eable.Free(); - - if (empty) - { - HitObject(point, landTop, 0); - return; - } - } - - for (int j = 0; j < statics.Length; j++) - { - StaticTile t = statics[j]; - - ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; - height = id.CalcHeight; - - if (t.Z <= point.Z && t.Z + height >= point.Z && - (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; - } - } - } - - Rectangle2D rect = new Rectangle2D(pTop.X, pTop.Y, pBottom.X - pTop.X + 1, pBottom.Y - pTop.Y + 1); - - IPooledEnumerable area = Map.GetItemsInBounds(rect); - foreach (Item i in area) - { - if (i == this || i.ItemID >= 0x4000) - continue; - - if (i is BRGoal) - { - height = 17; - } - else if (i is Blocker) - { - height = 20; - } - else - { - ItemData id = i.ItemData; - if ((id.Flags & (TileFlag.Impassable | TileFlag.Wall | TileFlag.NoShoot)) == 0) - continue; - height = id.CalcHeight; - } - - Point3D point = i.Location; - Point3D loc = i.Location; - for (int j = m_PathIdx; j < pathCheckEnd; j++) - { - point = m_Path[j]; - - if (loc.X == point.X && loc.Y == point.Y && - (i is Blocker || loc.Z <= point.Z && loc.Z + height >= point.Z)) - { - 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) - { - Point3D oldLoc = new Point3D(GetWorldLocation()); - if (CheckScore(goal, Thrower, 3)) - DoAnim(oldLoc, point, Map); - else - HitObject(point, loc.Z, height); - } - else - { - HitObject(point, loc.Z, height); - } - - return; - } - - area.Free(); - - IPooledEnumerable clients = Map.GetClientsInBounds(rect); - foreach (NetState ns in clients) - { - Mobile m = ns.Mobile; - - if (m == null || m == Thrower) - continue; - - Point3D point; - Point3D loc = m.Location; - - for (int j = m_PathIdx; j < pathCheckEnd && !found; j++) - { - point = m_Path[j]; - - 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(); - - // TODO: probably need to change this a lot... - DoCatch(m); - - return; - } - - clients.Free(); - - 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).Start(); - } - 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); - - int myZ = Map.GetAverageZ(X, Y); - - StaticTile[] statics = Map.Tiles.GetStaticTiles(X, Y, true); - for (int j = 0; j < statics.Length; j++) - { - StaticTile t = statics[j]; - - ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; - height = id.CalcHeight; - - if (t.Z + height > myZ && t.Z + height <= Z) - myZ = t.Z + height; - } - - IPooledEnumerable eable = GetItemsInRange(0); - foreach (Item 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(); - - Z = myZ; - m_Flying = false; - Visible = true; - - m_Path.Clear(); - m_PathIdx = 0; - } - } - - public bool CheckScore(BRGoal goal, Mobile m, int points) - { - if (m_Game == null || m == null || goal == null) - return false; - - BRTeamInfo 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 (int i = m_Helpers.Count - 1; i >= 0; i--) - { - Mobile mob = m_Helpers[i]; - - BRPlayerInfo pi = team[mob]; - if (pi != null) - { - if (mob == m) - pi.Captures += points; - - pi.Score += points + 1; - - points /= 2; - } - } - - m_Game.ReturnBomb(); - - m_Flying = false; - Visible = true; - m_Path.Clear(); - m_PathIdx = 0; - - Target.Cancel(m); - - return true; - } - - private bool TakeBomb(Mobile m, BRTeamInfo team, string verb) - { - if (!m.Player || !m.Alive || m.NetState == null) - return false; - - if (m.PlaceInBackpack(this)) - { - m.RevealingAction(); - - m.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You got the bomb!"); - m_Game.Alert("{1} ({2}) {0} the bomb!", verb, m.Name, team.Name); - - m.Target = new BombTarget(this, m); - - if (m_Helpers.Contains(m)) - m_Helpers.Remove(m); - - if (m_Helpers.Count > 0) - { - Mobile last = m_Helpers[0]; - - if (m_Game.GetTeamInfo(last) != team) - m_Helpers.Clear(); - } - - m_Helpers.Add(m); - - return true; - } - - return false; - } - - private class EffectTimer : Timer - { - private BRBomb m_Bomb; - private int m_Count; - - public EffectTimer(BRBomb bomb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) - { - m_Bomb = bomb; - m_Count = 0; - Priority = TimerPriority.FiftyMS; - } - - protected override void OnTick() - { - 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) - { - if (++m_Count >= 30) - { - m_Bomb.m_Game.ReturnBomb(); - m_Bomb.m_Game.Alert("The bomb has been returned to it's starting point."); - - m_Count = 0; - m_Bomb.m_Helpers.Clear(); - } - } - else - { - m_Count = 0; - } - } - else - { - m_Count = 0; - } - } - } - - private class BombTarget : Target - { - private BRBomb m_Bomb; - private Mobile m_Mob; - private bool m_Resend = true; - - public BombTarget(BRBomb bomb, Mobile from) : base(10, true, TargetFlags.None) - { - CheckLOS = false; - - m_Bomb = bomb; - m_Mob = from; - - m_Mob.SendMessage(0x26, "Where do you want to throw it?"); - } - - protected override void OnTarget(Mobile from, object targeted) - { - m_Resend = !m_Bomb.OnBombTarget(from, targeted); - } - - protected override void OnTargetUntargetable(Mobile from, object targeted) - { - m_Resend = !m_Bomb.OnBombTarget(from, targeted); - } - - protected override void OnTargetFinish(Mobile from) - { - base.OnTargetFinish(from); - - // has to be delayed in case some other target canceled us... - if (m_Resend) - Timer.DelayCall(TimeSpan.Zero, ResendBombTarget).Start(); - } - - private void ResendBombTarget() - { - // Make sure they still have the bomb, then give them the target back - if (m_Bomb != null && !m_Bomb.Deleted && m_Mob != null && !m_Mob.Deleted && m_Mob.Alive) - if (m_Bomb.IsChildOf(m_Mob)) - m_Mob.Target = new BombTarget(m_Bomb, m_Mob); - } - } - } - - public class BRGoal : BaseAddon - { - private bool m_North; - - private BRTeamInfo m_Team; - - [Constructible] - public BRGoal() - { - ItemID = 0x51D; - Hue = 0x84C; - Visible = true; - - Remake(); - } - - public BRGoal(Serial serial) : base(serial) - { - } - - [CommandProperty(AccessLevel.GameMaster)] - public bool North - { - get => m_North; - set - { - m_North = value; - Remake(); - } - } - - public override string DefaultName => "Bombing Run Goal"; - - public override bool ShareHue => false; - - public BRTeamInfo Team - { - get => m_Team; - set - { - m_Team = value; - if (m_Team != null && m_Team.Color != 0) - Hue = m_Team.Color; - else - Hue = 0x84C; - } - } - - private static AddonComponent SetHue(AddonComponent ac, int hue) - { - ac.Hue = hue; - return ac; - } - - private void Remake() - { - foreach (AddonComponent ac in Components) - { - ac.Addon = null; - ac.Delete(); - } - - Components.Clear(); - - // stairs - AddComponent(new AddonComponent(0x74D), -1, +1, -5); - AddComponent(new AddonComponent(0x71F), 0, +1, -5); - AddComponent(new AddonComponent(0x74B), +1, +1, -5); - AddComponent(new AddonComponent(0x736), +1, 0, -5); - AddComponent(new AddonComponent(0x74C), +1, -1, -5); - AddComponent(new AddonComponent(0x737), 0, -1, -5); - AddComponent(new AddonComponent(0x74A), -1, -1, -5); - AddComponent(new AddonComponent(0x749), -1, 0, -5); - - // Center Sparkle - AddComponent(new AddonComponent(0x375A), 0, 0, -1); - - if (!m_North) - { - // Pillars - AddComponent(new AddonComponent(0x0CE), 0, +1, -2); - AddComponent(new AddonComponent(0x0CC), 0, -1, -2); - AddComponent(new AddonComponent(0x0D0), 0, 0, -2); - - // Yellow parts - AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, +1, 7); - AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, 0, 16); - AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, -1, 7); - - // Blue Sparkles - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, +1, 12); - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, +1, -1); - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, -1, 12); - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, -1, -1); - } - else - { - // Pillars - AddComponent(new AddonComponent(0x0CF), +1, 0, -2); - AddComponent(new AddonComponent(0x0CC), -1, 0, -2); - AddComponent(new AddonComponent(0x0D1), 0, 0, -2); - - // Yellow parts - AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), +1, 0, 7); - AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, 0, 16); - AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), -1, 0, 7); - - // Blue Sparkles - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), +1, 0, 12); - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), +1, 0, -1); - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), -1, 0, 12); - AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), -1, 0, -1); - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(1); // version - - writer.Write(m_North); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 1: - { - m_North = reader.ReadBool(); - goto case 0; - } - case 0: - { - break; - } - } - - Hue = 0x84C; - } - - public override bool OnMoveOver(Mobile m) - { - if (!Visible) - return true; - - if (m == null || !m.Player || !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; - } - } - - public sealed class BRBoard : Item - { - public BRTeamInfo m_TeamInfo; - - [Constructible] - public BRBoard() - : base(7774) - { - Movable = false; - } - - public BRBoard(Serial serial) - : base(serial) - { - } - - public override string DefaultName => "Scoreboard"; - - public override void OnDoubleClick(Mobile from) - { - if (m_TeamInfo?.Game != null) - { - from.CloseGump(); - from.SendGump(new BRBoardGump(from, m_TeamInfo.Game)); - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - } - - public class BRBoardGump : Gump - { - private const int LabelColor32 = 0xFFFFFF; - private const int BlackColor32 = 0x000000; - - private BRGame m_Game; - - public BRBoardGump(Mobile mob, BRGame game) - : this(mob, game, null) - { - } - - public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section) : base(60, 60) - { - m_Game = game; - - BRTeamInfo ourTeam = game.GetTeamInfo(mob); - - List entries = new List(); - int total = 0; - - if (section == null) - { - for (int i = 0; i < game.Context.Participants.Count; ++i) - { - BRTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; - - if (teamInfo == null) - continue; - - entries.Add(teamInfo); - } - - total = entries.Count; - } - else - foreach (BRPlayerInfo player in section.Players.Values) - if (player.Score > 0) - total++; - - entries.Sort(); - - int height = 0; - - if (section == null) - height = 73 + entries.Count * 75 + 28; - - Closable = false; - - AddPage(0); - - AddBackground(1, 1, 398, height, 3600); - - AddImageTiled(16, 15, 369, height - 29, 3604); - - for (int i = 0; i < total; i += 1) - AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); - - AddAlphaRegion(16, 15, 369, height - 29); - - AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); - - AddBorderedText(22, 22, 294, 20, Center("BR Scoreboard"), LabelColor32, BlackColor32); - - AddImageTiled(32, 50, 264, 1, 9107); - AddImageTiled(42, 52, 264, 1, 9157); - - if (section == null) - for (int i = 0; i < entries.Count; ++i) - { - BRTeamInfo teamInfo = entries[i]; - - AddImage(30, 70 + i * 75, 10152); - AddImage(30, 85 + i * 75, 10151); - AddImage(30, 100 + i * 75, 10151); - AddImage(30, 106 + i * 75, 10154); - - AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); - - int nameColor = LabelColor32; - int borderColor = BlackColor32; - - switch (teamInfo.Color) - { - case 0x47E: - nameColor = 0xFFFFFF; - break; - - case 0x4F2: - nameColor = 0x3399FF; - break; - - case 0x4F7: - nameColor = 0x33FF33; - break; - - case 0x4FC: - nameColor = 0xFF00FF; - break; - - case 0x021: - nameColor = 0xFF3333; - break; - - case 0x01A: - nameColor = 0xFF66FF; - break; - - case 0x455: - nameColor = 0x333333; - borderColor = 0xFFFFFF; - break; - } - - AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name}", nameColor, - borderColor); - - AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); - AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); - AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Points:", 0xFFC000, BlackColor32); - AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, - BlackColor32); - - BRPlayerInfo pl = teamInfo.Leader; - - 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, GumpButtonType.Reply, 0); - } - - public string Center(string text) - { - return $"
{text}
"; - } - - public string Color(string text, int color) - { - return $"{text}"; - } - - private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) - { - AddColoredText(x - 1, y - 1, width, height, text, borderColor); - AddColoredText(x - 1, y + 1, width, height, text, borderColor); - AddColoredText(x + 1, y - 1, width, height, text, borderColor); - AddColoredText(x + 1, y + 1, width, height, text, borderColor); - AddColoredText(x, y, width, height, text, color); - } - - private void AddColoredText(int x, int y, int width, int height, string text, int color) - { - if (color == 0) - AddHtml(x, y, width, height, text, false, false); - else - AddHtml(x, y, width, height, Color(text, color), false, false); - } - } - - public sealed class BRPlayerInfo : IRankedCTF, IComparable - { - private int m_Captures; - - private int m_Kills; - - private int m_Score; - private BRTeamInfo m_TeamInfo; - - public BRPlayerInfo(BRTeamInfo teamInfo, Mobile player) - { - m_TeamInfo = teamInfo; - Player = player; - } - - public Mobile Player{ get; } - - public int CompareTo(object obj) - { - BRPlayerInfo pi = (BRPlayerInfo)obj; - int res = pi.Captures.CompareTo(Captures); - if (res == 0) - { - res = pi.Score.CompareTo(Score); - - if (res == 0) - res = pi.Kills.CompareTo(Kills); - } - - return res; - } - - public string Name => Player.Name; - - public int Kills - { - get => m_Kills; - set - { - m_TeamInfo.Kills += value - m_Kills; - m_Kills = value; - } - } - - public int Captures - { - get => m_Captures; - set - { - m_TeamInfo.Captures += value - m_Captures; - m_Captures = value; - } - } - - public int Score - { - get => m_Score; - set - { - m_TeamInfo.Score += value - m_Score; - m_Score = value; - - if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) - m_TeamInfo.Leader = this; - } - } - } - - [PropertyObject] - public sealed class BRTeamInfo : IRankedCTF, IComparable - { - private BRGoal m_Goal; - - public BRTeamInfo(int teamID) - { - TeamID = teamID; - Players = new Dictionary(); - } - - public BRTeamInfo(int teamID, GenericReader ip) - { - TeamID = teamID; - Players = new Dictionary(); - - int version = ip.ReadEncodedInt(); - - switch (version) - { - case 0: - { - Board = ip.ReadItem() as BRBoard; - TeamName = ip.ReadString(); - Color = ip.ReadEncodedInt(); - m_Goal = ip.ReadItem() as BRGoal; - break; - } - } - } - - public BRGame Game{ get; set; } - - public int TeamID{ get; } - - public BRPlayerInfo Leader{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public BRBoard Board{ get; set; } - - public Dictionary Players{ get; } - - public BRPlayerInfo this[Mobile mob] - { - get - { - if (mob == null) - return null; - - if (!Players.TryGetValue(mob, out BRPlayerInfo val)) - Players[mob] = val = new BRPlayerInfo(this, mob); - - return val; - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public string TeamName{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public BRGoal Goal - { - get => m_Goal; - set - { - m_Goal = value; - if (m_Goal != null) - m_Goal.Team = this; - } - } - - public int CompareTo(BRTeamInfo ti) - { - int res = ti.Captures.CompareTo(Captures); - if (res == 0) - { - res = ti.Score.CompareTo(Score); - - if (res == 0) - res = ti.Kills.CompareTo(Kills); - } - - return res; - } - - public string Name => $"{TeamName} Team"; - - public int Kills{ get; set; } - - public int Captures{ get; set; } - - public int Score{ get; set; } - - public void Reset() - { - Kills = 0; - Captures = 0; - Score = 0; - - Leader = null; - - Players.Clear(); - - if (Board != null) - Board.m_TeamInfo = this; - if (m_Goal != null) - m_Goal.Team = this; - } - - public void Serialize(GenericWriter op) - { - op.WriteEncodedInt(0); // version - - op.Write(Board); - - op.Write(TeamName); - - op.WriteEncodedInt(Color); - - op.Write(m_Goal); - } - - public override string ToString() - { - if (TeamName != null) - return $"({Name}) ..."; - return "..."; - } - } - - public sealed class BRController : EventController - { - [Constructible] - public BRController() - { - Visible = false; - Movable = false; - - Duration = TimeSpan.FromMinutes(30.0); - - BombHome = Point3D.Zero; - - TeamInfo = new BRTeamInfo[4]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new BRTeamInfo(i); - } - - public BRController(Serial serial) - : base(serial) - { - } - - public BRTeamInfo[] TeamInfo{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public BRTeamInfo Team1 => TeamInfo[0]; - - [CommandProperty(AccessLevel.GameMaster)] - public BRTeamInfo Team2 => TeamInfo[1]; - - [CommandProperty(AccessLevel.GameMaster)] - public BRTeamInfo Team3 => TeamInfo[2]; - - [CommandProperty(AccessLevel.GameMaster)] - public BRTeamInfo Team4 => TeamInfo[3]; - - [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public Point3D BombHome{ get; set; } - - public override string Title => "Bombing Run"; - public override string DefaultName => "Bombing Run Controller"; - - public override string GetTeamName(int teamID) - { - return TeamInfo[teamID % TeamInfo.Length].Name; - } - - public override EventGame Construct(DuelContext context) - { - return new BRGame(this, context); - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - - writer.Write(BombHome); - - writer.Write(Duration); - - writer.WriteEncodedInt(TeamInfo.Length); - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i].Serialize(writer); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 0: - { - BombHome = reader.ReadPoint3D(); - - Duration = reader.ReadTimeSpan(); - - TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new BRTeamInfo(i, reader); - - break; - } - } - } - } - - public sealed class BRGame : EventGame - { - private BRBomb m_Bomb; - - private Timer m_FinishTimer; - - private TimerCallback m_UnhideCallback; - - public BRGame(BRController controller, DuelContext context) : base(context) - { - Controller = controller; - } - - public BRController Controller{ get; } - - public Map Facet - { - get - { - if (m_Context.Arena != null) - return m_Context.Arena.Facet; - - return Controller.Map; - } - } - - public override bool CantDoAnything(Mobile mob) - { - if (mob?.Backpack == null || GetTeamInfo(mob) == null) - return false; - - return mob.Backpack.FindItemByType() != null; - } - - public void ReturnBomb() - { - if (m_Bomb != null && Controller != null) - { - if (m_UnhideCallback == null) - m_UnhideCallback = UnhideBomb; - m_Bomb.Visible = false; - m_Bomb.MoveToWorld(Controller.BombHome, Controller.Map); - Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 15)), m_UnhideCallback); - } - } - - private void UnhideBomb() - { - if (m_Bomb != null) - { - m_Bomb.Visible = true; - m_Bomb.OnLocationChange(m_Bomb.Location); - } - } - - public void Alert(string text) - { - m_Context.m_Tournament?.Alert(text); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - Participant p = m_Context.Participants[i]; - - for (int j = 0; j < p.Players.Length; ++j) - if (p.Players[j] != null) - p.Players[j].Mobile.SendMessage(0x35, text); - } - } - - public void Alert(string format, params object[] args) - { - Alert(string.Format(format, args)); - } - - public BRTeamInfo GetTeamInfo(Mobile mob) - { - int teamID = GetTeamID(mob); - - if (teamID >= 0) - return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; - - return null; - } - - 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 == null || pm.DuelPlayer.Eliminated) - return -1; - - return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); - } - - public int GetColor(Mobile mob) - { - return GetTeamInfo(mob)?.Color ?? -1; - } - - private void ApplyHues(Participant p, int hueOverride) - { - for (int 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) - { - Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); - } - - private void DelayBounce_Callback(Mobile mob, Container corpse) - { - DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; - - m_Context.RemoveAggressions(mob); - - if (dp != null && !dp.Eliminated) - mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); - else - m_Context.SendOutside(mob); - - m_Context.Refresh(mob, corpse); - DuelContext.Debuff(mob); - DuelContext.CancelSpell(mob); - mob.Frozen = false; - } - - public override bool OnDeath(Mobile mob, Container corpse) - { - Mobile killer = mob.FindMostRecentDamager(false); - - bool hadBomb = false; - - corpse.FindItemsByType(false).ForEach(bomb => - { - hadBomb = true; - bomb.DropTo(mob, killer); - }); - - mob.Backpack?.FindItemsByType(false).ForEach(bomb => - { - hadBomb = true; - bomb.DropTo(mob, killer); - }); - - if (killer != null && killer.Player) - { - BRTeamInfo teamInfo = GetTeamInfo(killer); - BRTeamInfo victInfo = GetTeamInfo(mob); - - if (teamInfo != null && teamInfo != victInfo) - { - BRPlayerInfo playerInfo = teamInfo[killer]; - - if (playerInfo != null) - { - playerInfo.Kills += 1; - playerInfo.Score += 1; // base frag - - if (hadBomb) - playerInfo.Score += 4; // fragged bomb carrier - } - } - } - - mob.CloseGump(); - mob.SendGump(new BRBoardGump(mob, this)); - - m_Context.Requip(mob, corpse); - DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); - - return false; - } - - public override void OnStart() - { - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - BRTeamInfo teamInfo = Controller.TeamInfo[i]; - - teamInfo.Game = this; - teamInfo.Reset(); - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], - Controller.TeamInfo[i % Controller.TeamInfo.Length].Color); - - m_FinishTimer?.Stop(); - - m_Bomb = new BRBomb(this); - ReturnBomb(); - - m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); - } - - private void Finish_Callback() - { - List teams = new List(); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - BRTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; - - if (teamInfo != null) - teams.Add(teamInfo); - } - - teams.Sort(); - - Tournament tourney = m_Context.m_Tournament; - - StringBuilder sb = new StringBuilder(); - - if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll) - { - sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); - sb.Append("-man FFA"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue) - { - sb.Append("Red v Blue"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.Faction) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team Faction"); - } - else if (tourney != null) - { - for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) - { - if (sb.Length > 0) - sb.Append('v'); - - sb.Append(tourney.PlayersPerParticipant); - } - } - - if (Controller != null) - sb.Append(' ').Append(Controller.Title); - - string title = sb.ToString(); - - BRTeamInfo winner = teams.Count > 0 ? teams[0] : null; - - for (int i = 0; i < teams.Count; ++i) - { - TrophyRank rank = TrophyRank.Bronze; - - if (i == 0) - rank = TrophyRank.Gold; - else if (i == 1) - rank = TrophyRank.Silver; - - BRPlayerInfo leader = teams[i].Leader; - - foreach (BRPlayerInfo pl in teams[i].Players.Values) - { - Mobile mob = pl.Player; - - if (mob == null) - continue; - - sb = new StringBuilder(); - - sb.Append(title); - - if (pl == leader) - sb.Append(" Leader"); - - if (pl.Score > 0) - { - sb.Append(": "); - - //sb.Append( pl.Score.ToString( "N0" ) ); - //sb.Append( pl.Score == 1 ? " point" : " points" ); - - sb.Append(pl.Kills.ToString("N0")); - sb.Append(pl.Kills == 1 ? " kill" : " kills"); - - if (pl.Captures > 0) - { - sb.Append(", "); - sb.Append(pl.Captures.ToString("N0")); - sb.Append(pl.Captures == 1 ? " point" : " points"); - } - } - - 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); - - int cash = pl.Score * 250; - - 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.", - rank.ToString().ToLower(), cash); - } - else - { - mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", - rank.ToString().ToLower()); - } - } - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - if (!(m_Context.Participants[i] is Participant p) || p.Players == null) - continue; - - for (int j = 0; j < p.Players.Length; ++j) - { - DuelPlayer dp = p.Players[j]; - - if (dp?.Mobile != null) - { - dp.Mobile.CloseGump(); - dp.Mobile.SendGump(new BRBoardGump(dp.Mobile, this)); - } - } - - if (i == winner.TeamID) - continue; - - if (p.Players != null) - for (int 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]); - } - - public override void OnStop() - { - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - BRTeamInfo teamInfo = Controller.TeamInfo[i]; - - if (teamInfo.Board != null) - teamInfo.Board.m_TeamInfo = null; - - teamInfo.Game = null; - } - - ReturnBomb(); - - m_Bomb?.Delete(); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], -1); - - m_FinishTimer?.Stop(); - m_FinishTimer = null; - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Server.Gumps; +using Server.Items; +using Server.Mobiles; +using Server.Network; +using Server.Targeting; + +namespace Server.Engines.ConPVP +{ + public class BRBomb : Item + { + private bool m_Flying; + + private BRGame m_Game; + + private List m_Helpers; + + private Point3DList m_Path = new Point3DList(); + private int m_PathIdx; + private EffectTimer m_Timer; + + public BRBomb(BRGame game) : + base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball + { + Movable = false; + Hue = 0x35; + + m_Game = game; + + m_Helpers = new List(); + + m_Timer = new EffectTimer(this); + m_Timer.Start(); + } + + public BRBomb(Serial serial) : base(serial) + { + } + + public override string DefaultName => "da bomb"; + + public Mobile Thrower{ get; private set; } + + private Mobile FindOwner(IEntity parent) + { + if (parent is Item item) + return item.RootParent as Mobile; + + if (parent is Mobile mobile) + return mobile; + + return null; + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 0: + { + break; + } + } + + Timer.DelayCall(TimeSpan.Zero, Delete).Start(); // delete this after the world loads + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); // version + } + + public override void OnAdded(IEntity parent) + { + base.OnAdded(parent); + + Mobile mob = FindOwner(parent); + + if (mob != null) + mob.SolidHueOverride = 0x0499; + } + + public override void OnRemoved(IEntity parent) + { + base.OnRemoved(parent); + + Mobile 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; + + BRTeamInfo useTeam = m_Game.GetTeamInfo(m); + return useTeam == null || TakeBomb(m, useTeam, "picked up"); + } + + public override void OnLocationChange(Point3D oldLocation) + { + base.OnLocationChange(oldLocation); + + if (m_Flying || !Visible || m_Game == null || Parent != null) + return; + + IPooledEnumerable eable = GetClientsInRange(0); + foreach (NetState ns in eable) + { + Mobile m = ns.Mobile; + + if (m == null || !m.Player || !m.Alive) + continue; + + BRTeamInfo useTeam = m_Game.GetTeamInfo(m); + if (useTeam != null) + TakeBomb(m, useTeam, "got"); + } + } + + public override void OnAfterDelete() + { + base.OnAfterDelete(); + + m_Timer?.Stop(); + } + + 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) + { + BRTeamInfo 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; + + Point3D 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; + Thrower = from; + MoveToWorld(GetWorldLocation(), from.Map); + + BeginFlight(pt); + return true; + } + + private void HitObject(Point3D ballLoc, int objZ, int objHeight) + { + DoAnim(GetWorldLocation(), ballLoc, Map); + MoveToWorld(ballLoc); + + m_Path.Clear(); + m_PathIdx = 0; + + Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight).Start(); + } + + private bool CheckCatch(Mobile m, Point3D myLoc) + { + if (m == null || !m.Alive || !m.Player || m_Game == null) + return false; + + if (m_Game.GetTeamInfo(m) == null) + return false; + + int zdiff = myLoc.Z - m.Z; + + if (zdiff < 0) + return false; + if (zdiff < 12) + return true; + if (zdiff < 16) + return Utility.RandomBool(); // 50% chance + + return false; + } + + private void DoAnim(Point3D start, Point3D end, Map map) + { + Effects.SendMovingEffect(new Entity(Serial.Zero, start, map), new Entity(Serial.Zero, end, map), + ItemID, 15, 0, false, false, Hue); + } + + private void DoCatch(Mobile m) + { + m_Flying = false; + Visible = true; + + if (m == null || !m.Alive || !m.Player || m_Game == null) + return; + + BRTeamInfo useTeam = m_Game.GetTeamInfo(m); + + if (useTeam == null) + return; + + DoAnim(GetWorldLocation(), m.Location, m.Map); + + string 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) + { + Point3D org = GetWorldLocation(); + + org.Z += 10; // always add 10 at the start cause we're coming from a mobile's eye level + + /*if ( org.X > dest.X || ( org.X == dest.X && org.Y > dest.Y ) || ( org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z ) ) + { + Point3D swap = org; + org = dest; + dest = swap; + }*/ + + List list = new List(); + + int xd = dest.X - org.X; + int yd = dest.Y - org.Y; + int zd = dest.Z - org.Z; + double dist2d = Math.Sqrt(xd * xd + yd * yd); + double dist3d = zd == 0 ? dist2d : Math.Sqrt(dist2d * dist2d + zd * zd); + + double rise = yd / dist3d; + double run = xd / dist3d; + double zslp = zd / dist3d; + + double x = org.X; + double y = org.Y; + double z = org.Z; + while (Utility.NumberBetween(x, dest.X, org.X, 0.5) && Utility.NumberBetween(y, dest.Y, org.Y, 0.5) && + Utility.NumberBetween(z, dest.Z, org.Z, 0.5)) + { + int ix = (int)Math.Round(x); + int iy = (int)Math.Round(y); + int iz = (int)Math.Round(z); + + if (list.Count > 0) + { + Point3D p = list[list.Count - 1]; + + if (p.X != ix || p.Y != iy || p.Z != iz) + list.Add(new Point3D(ix, iy, iz)); + } + else + { + list.Add(new Point3D(ix, iy, iz)); + } + + x += run; + y += rise; + z += zslp; + } + + if (list.Count > 0 && list[list.Count - 1] != dest) + list.Add(dest); + + /*if ( dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ) ) + { + int count = list.Count; + int i; + int climb = count / 2; + if ( climb > 3 ) + climb = 3; + + for ( i = 0; i < climb; i++ ) + { + p = ((Point3D)list[i]); + p.Z += (i+1) * 4; + list[i] = p; + } + + for ( ; i < count - climb; i++ ) + { + p = ((Point3D)list[i]); + p.Z += 16; + list[i] = p; + } + + for ( i = climb; i > 0; i-- ) + { + p = ((Point3D)list[i]); + p.Z += i * 4; + list[i] = p; + } + }*/ + + if (dist2d > 1) + { + int count = list.Count; + double height = count * 2 * (Utility.RandomDouble() * 0.40 + 0.10); // 10 - 50% + double coeff = -height / (count * count / 4.0); + + for (int i = 0; i < count; i++) + { + Point3D p = list[i]; + + int xp = i - count / 2; + + p.Z += (int)Math.Ceiling(coeff * xp * xp + height); + + list[i] = p; + } + } + + m_Path.Clear(); + for (int i = 0; i < list.Count; i++) + m_Path.Add(list[i]); + + m_PathIdx = 0; + + ContinueFlight(); + } + + private void ContinueFlight() + { + int height; + bool found = false; + + if (m_PathIdx < m_Path.Count && Map?.Tiles != null && Map != Map.Internal) + { + int 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); + + for (int i = m_PathIdx; i < pathCheckEnd; i++) + { + Point3D point = m_Path[i]; + + LandTile landTile = Map.Tiles.GetLandTile(point.X, point.Y); + int landZ = 0, landAvg = 0, landTop = 0; + Map.GetAverageZ(point.X, point.Y, ref landZ, ref landAvg, ref landTop); + + if (landZ <= point.Z && landTop >= point.Z && !landTile.Ignored) + { + HitObject(point, landTop, 0); + return; + } + + StaticTile[] statics = Map.Tiles.GetStaticTiles(point.X, point.Y, true); + + if (landTile.ID == 0x244 && statics.Length == 0) // 0x244 = invalid land tile + { + IPooledEnumerable eable = Map.GetItemsInRange(point, 0); + + bool empty = eable.All(item => item == this); + + eable.Free(); + + if (empty) + { + HitObject(point, landTop, 0); + return; + } + } + + for (int j = 0; j < statics.Length; j++) + { + StaticTile t = statics[j]; + + ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; + height = id.CalcHeight; + + if (t.Z <= point.Z && t.Z + height >= point.Z && + (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; + } + } + } + + Rectangle2D rect = new Rectangle2D(pTop.X, pTop.Y, pBottom.X - pTop.X + 1, pBottom.Y - pTop.Y + 1); + + IPooledEnumerable area = Map.GetItemsInBounds(rect); + foreach (Item i in area) + { + if (i == this || i.ItemID >= 0x4000) + continue; + + if (i is BRGoal) + { + height = 17; + } + else if (i is Blocker) + { + height = 20; + } + else + { + ItemData id = i.ItemData; + if ((id.Flags & (TileFlag.Impassable | TileFlag.Wall | TileFlag.NoShoot)) == 0) + continue; + height = id.CalcHeight; + } + + Point3D point = i.Location; + Point3D loc = i.Location; + for (int j = m_PathIdx; j < pathCheckEnd; j++) + { + point = m_Path[j]; + + if (loc.X == point.X && loc.Y == point.Y && + (i is Blocker || loc.Z <= point.Z && loc.Z + height >= point.Z)) + { + 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) + { + Point3D oldLoc = new Point3D(GetWorldLocation()); + if (CheckScore(goal, Thrower, 3)) + DoAnim(oldLoc, point, Map); + else + HitObject(point, loc.Z, height); + } + else + { + HitObject(point, loc.Z, height); + } + + return; + } + + area.Free(); + + IPooledEnumerable clients = Map.GetClientsInBounds(rect); + foreach (NetState ns in clients) + { + Mobile m = ns.Mobile; + + if (m == null || m == Thrower) + continue; + + Point3D point; + Point3D loc = m.Location; + + for (int j = m_PathIdx; j < pathCheckEnd && !found; j++) + { + point = m_Path[j]; + + 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(); + + // TODO: probably need to change this a lot... + DoCatch(m); + + return; + } + + clients.Free(); + + 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).Start(); + } + 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); + + int myZ = Map.GetAverageZ(X, Y); + + StaticTile[] statics = Map.Tiles.GetStaticTiles(X, Y, true); + for (int j = 0; j < statics.Length; j++) + { + StaticTile t = statics[j]; + + ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; + height = id.CalcHeight; + + if (t.Z + height > myZ && t.Z + height <= Z) + myZ = t.Z + height; + } + + IPooledEnumerable eable = GetItemsInRange(0); + foreach (Item 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(); + + Z = myZ; + m_Flying = false; + Visible = true; + + m_Path.Clear(); + m_PathIdx = 0; + } + } + + public bool CheckScore(BRGoal goal, Mobile m, int points) + { + if (m_Game == null || m == null || goal == null) + return false; + + BRTeamInfo 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 (int i = m_Helpers.Count - 1; i >= 0; i--) + { + Mobile mob = m_Helpers[i]; + + BRPlayerInfo pi = team[mob]; + if (pi != null) + { + if (mob == m) + pi.Captures += points; + + pi.Score += points + 1; + + points /= 2; + } + } + + m_Game.ReturnBomb(); + + m_Flying = false; + Visible = true; + m_Path.Clear(); + m_PathIdx = 0; + + Target.Cancel(m); + + return true; + } + + private bool TakeBomb(Mobile m, BRTeamInfo team, string verb) + { + if (!m.Player || !m.Alive || m.NetState == null) + return false; + + if (m.PlaceInBackpack(this)) + { + m.RevealingAction(); + + m.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You got the bomb!"); + m_Game.Alert("{1} ({2}) {0} the bomb!", verb, m.Name, team.Name); + + m.Target = new BombTarget(this, m); + + if (m_Helpers.Contains(m)) + m_Helpers.Remove(m); + + if (m_Helpers.Count > 0) + { + Mobile last = m_Helpers[0]; + + if (m_Game.GetTeamInfo(last) != team) + m_Helpers.Clear(); + } + + m_Helpers.Add(m); + + return true; + } + + return false; + } + + private class EffectTimer : Timer + { + private BRBomb m_Bomb; + private int m_Count; + + public EffectTimer(BRBomb bomb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) + { + m_Bomb = bomb; + m_Count = 0; + Priority = TimerPriority.FiftyMS; + } + + protected override void OnTick() + { + 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) + { + if (++m_Count >= 30) + { + m_Bomb.m_Game.ReturnBomb(); + m_Bomb.m_Game.Alert("The bomb has been returned to it's starting point."); + + m_Count = 0; + m_Bomb.m_Helpers.Clear(); + } + } + else + { + m_Count = 0; + } + } + else + { + m_Count = 0; + } + } + } + + private class BombTarget : Target + { + private BRBomb m_Bomb; + private Mobile m_Mob; + private bool m_Resend = true; + + public BombTarget(BRBomb bomb, Mobile from) : base(10, true, TargetFlags.None) + { + CheckLOS = false; + + m_Bomb = bomb; + m_Mob = from; + + m_Mob.SendMessage(0x26, "Where do you want to throw it?"); + } + + protected override void OnTarget(Mobile from, object targeted) + { + m_Resend = !m_Bomb.OnBombTarget(from, targeted); + } + + protected override void OnTargetUntargetable(Mobile from, object targeted) + { + m_Resend = !m_Bomb.OnBombTarget(from, targeted); + } + + protected override void OnTargetFinish(Mobile from) + { + base.OnTargetFinish(from); + + // has to be delayed in case some other target canceled us... + if (m_Resend) + Timer.DelayCall(TimeSpan.Zero, ResendBombTarget).Start(); + } + + 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); + } + } + } + + public class BRGoal : BaseAddon + { + private bool m_North; + + private BRTeamInfo m_Team; + + [Constructible] + public BRGoal() + { + ItemID = 0x51D; + Hue = 0x84C; + Visible = true; + + Remake(); + } + + public BRGoal(Serial serial) : base(serial) + { + } + + [CommandProperty(AccessLevel.GameMaster)] + public bool North + { + get => m_North; + set + { + m_North = value; + Remake(); + } + } + + public override string DefaultName => "Bombing Run Goal"; + + public override bool ShareHue => false; + + public BRTeamInfo Team + { + get => m_Team; + set + { + m_Team = value; + if (m_Team != null && m_Team.Color != 0) + Hue = m_Team.Color; + else + Hue = 0x84C; + } + } + + private static AddonComponent SetHue(AddonComponent ac, int hue) + { + ac.Hue = hue; + return ac; + } + + private void Remake() + { + foreach (AddonComponent ac in Components) + { + ac.Addon = null; + ac.Delete(); + } + + Components.Clear(); + + // stairs + AddComponent(new AddonComponent(0x74D), -1, +1, -5); + AddComponent(new AddonComponent(0x71F), 0, +1, -5); + AddComponent(new AddonComponent(0x74B), +1, +1, -5); + AddComponent(new AddonComponent(0x736), +1, 0, -5); + AddComponent(new AddonComponent(0x74C), +1, -1, -5); + AddComponent(new AddonComponent(0x737), 0, -1, -5); + AddComponent(new AddonComponent(0x74A), -1, -1, -5); + AddComponent(new AddonComponent(0x749), -1, 0, -5); + + // Center Sparkle + AddComponent(new AddonComponent(0x375A), 0, 0, -1); + + if (!m_North) + { + // Pillars + AddComponent(new AddonComponent(0x0CE), 0, +1, -2); + AddComponent(new AddonComponent(0x0CC), 0, -1, -2); + AddComponent(new AddonComponent(0x0D0), 0, 0, -2); + + // Yellow parts + AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, +1, 7); + AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, 0, 16); + AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, -1, 7); + + // Blue Sparkles + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, +1, 12); + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, +1, -1); + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, -1, 12); + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), 0, -1, -1); + } + else + { + // Pillars + AddComponent(new AddonComponent(0x0CF), +1, 0, -2); + AddComponent(new AddonComponent(0x0CC), -1, 0, -2); + AddComponent(new AddonComponent(0x0D1), 0, 0, -2); + + // Yellow parts + AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), +1, 0, 7); + AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), 0, 0, 16); + AddComponent(SetHue(new AddonComponent(0x0DF), 0x499), -1, 0, 7); + + // Blue Sparkles + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), +1, 0, 12); + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), +1, 0, -1); + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), -1, 0, 12); + AddComponent(SetHue(new AddonComponent(0x377A), 0x84C), -1, 0, -1); + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(1); // version + + writer.Write(m_North); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 1: + { + m_North = reader.ReadBool(); + goto case 0; + } + case 0: + { + break; + } + } + + Hue = 0x84C; + } + + 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; + } + } + + public sealed class BRBoard : Item + { + public BRTeamInfo m_TeamInfo; + + [Constructible] + public BRBoard() + : base(7774) + { + Movable = false; + } + + public BRBoard(Serial serial) + : base(serial) + { + } + + public override string DefaultName => "Scoreboard"; + + public override void OnDoubleClick(Mobile from) + { + if (m_TeamInfo?.Game != null) + { + from.CloseGump(); + from.SendGump(new BRBoardGump(from, m_TeamInfo.Game)); + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + } + + public class BRBoardGump : Gump + { + private const int LabelColor32 = 0xFFFFFF; + private const int BlackColor32 = 0x000000; + +// private BRGame m_Game; + + public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60) + { +// m_Game = game; + + BRTeamInfo ourTeam = game.GetTeamInfo(mob); + + List entries = new List(); + int total = 0; + + if (section == null) + { + for (int i = 0; i < game.Context.Participants.Count; ++i) + { + BRTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; + + if (teamInfo == null) + continue; + + entries.Add(teamInfo); + } + + total = entries.Count; + } + else + foreach (BRPlayerInfo player in section.Players.Values) + if (player.Score > 0) + total++; + + entries.Sort(); + + int height = 0; + + if (section == null) + height = 73 + entries.Count * 75 + 28; + + Closable = false; + + AddPage(0); + + AddBackground(1, 1, 398, height, 3600); + + AddImageTiled(16, 15, 369, height - 29, 3604); + + for (int i = 0; i < total; i += 1) + AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + + AddAlphaRegion(16, 15, 369, height - 29); + + AddImage(215, -45, 0xEE40); + //AddImage( 330, 141, 0x8BA ); + + AddBorderedText(22, 22, 294, 20, Center("BR Scoreboard"), LabelColor32, BlackColor32); + + AddImageTiled(32, 50, 264, 1, 9107); + AddImageTiled(42, 52, 264, 1, 9157); + + if (section == null) + for (int i = 0; i < entries.Count; ++i) + { + BRTeamInfo teamInfo = entries[i]; + + AddImage(30, 70 + i * 75, 10152); + AddImage(30, 85 + i * 75, 10151); + AddImage(30, 100 + i * 75, 10151); + AddImage(30, 106 + i * 75, 10154); + + AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); + + int nameColor = LabelColor32; + int borderColor = BlackColor32; + + switch (teamInfo.Color) + { + case 0x47E: + nameColor = 0xFFFFFF; + break; + + case 0x4F2: + nameColor = 0x3399FF; + break; + + case 0x4F7: + nameColor = 0x33FF33; + break; + + case 0x4FC: + nameColor = 0xFF00FF; + break; + + case 0x021: + nameColor = 0xFF3333; + break; + + case 0x01A: + nameColor = 0xFF66FF; + break; + + case 0x455: + nameColor = 0x333333; + borderColor = 0xFFFFFF; + break; + } + + AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name}", nameColor, + borderColor); + + AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); + AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); + AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Points:", 0xFFC000, BlackColor32); + AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, + BlackColor32); + + BRPlayerInfo pl = teamInfo.Leader; + + 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); + } + + public string Center(string text) + { + return $"
{text}
"; + } + + public string Color(string text, int color) + { + return $"{text}"; + } + + private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) + { + AddColoredText(x - 1, y - 1, width, height, text, borderColor); + AddColoredText(x - 1, y + 1, width, height, text, borderColor); + AddColoredText(x + 1, y - 1, width, height, text, borderColor); + AddColoredText(x + 1, y + 1, width, height, text, borderColor); + AddColoredText(x, y, width, height, text, color); + } + + 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 sealed class BRPlayerInfo : IRankedCTF, IComparable + { + private int m_Captures; + + private int m_Kills; + + private int m_Score; + private BRTeamInfo m_TeamInfo; + + public BRPlayerInfo(BRTeamInfo teamInfo, Mobile player) + { + m_TeamInfo = teamInfo; + Player = player; + } + + public Mobile Player{ get; } + + public int CompareTo(BRPlayerInfo pi) + { + int 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; + } + + public string Name => Player.Name; + + public int Kills + { + get => m_Kills; + set + { + m_TeamInfo.Kills += value - m_Kills; + m_Kills = value; + } + } + + public int Captures + { + get => m_Captures; + set + { + m_TeamInfo.Captures += value - m_Captures; + m_Captures = value; + } + } + + public int Score + { + get => m_Score; + set + { + m_TeamInfo.Score += value - m_Score; + m_Score = value; + + if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + m_TeamInfo.Leader = this; + } + } + } + + [PropertyObject] + public sealed class BRTeamInfo : IRankedCTF, IComparable + { + private BRGoal m_Goal; + + public BRTeamInfo(int teamID) + { + TeamID = teamID; + Players = new Dictionary(); + } + + public BRTeamInfo(int teamID, GenericReader ip) + { + TeamID = teamID; + Players = new Dictionary(); + + int version = ip.ReadEncodedInt(); + + switch (version) + { + case 0: + { + Board = ip.ReadItem() as BRBoard; + TeamName = ip.ReadString(); + Color = ip.ReadEncodedInt(); + m_Goal = ip.ReadItem() as BRGoal; + break; + } + } + } + + public BRGame Game{ get; set; } + + public int TeamID{ get; } + + public BRPlayerInfo Leader{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public BRBoard Board{ get; set; } + + public Dictionary Players{ get; } + + public BRPlayerInfo this[Mobile mob] + { + get + { + if (mob == null) + return null; + + if (!Players.TryGetValue(mob, out BRPlayerInfo val)) + Players[mob] = val = new BRPlayerInfo(this, mob); + + return val; + } + } + + [CommandProperty(AccessLevel.GameMaster)] + public int Color{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public string TeamName{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public BRGoal Goal + { + get => m_Goal; + set + { + m_Goal = value; + if (m_Goal != null) + m_Goal.Team = this; + } + } + + public int CompareTo(BRTeamInfo ti) + { + int res = ti.Captures.CompareTo(Captures); + if (res == 0) + { + res = ti.Score.CompareTo(Score); + + if (res == 0) + res = ti.Kills.CompareTo(Kills); + } + + return res; + } + + public string Name => $"{TeamName} Team"; + + public int Kills{ get; set; } + + public int Captures{ get; set; } + + public int Score{ get; set; } + + public void Reset() + { + Kills = 0; + Captures = 0; + Score = 0; + + Leader = null; + + Players.Clear(); + + if (Board != null) + Board.m_TeamInfo = this; + if (m_Goal != null) + m_Goal.Team = this; + } + + public void Serialize(GenericWriter op) + { + op.WriteEncodedInt(0); // version + + op.Write(Board); + + op.Write(TeamName); + + op.WriteEncodedInt(Color); + + op.Write(m_Goal); + } + + public override string ToString() + { + if (TeamName != null) + return $"({Name}) ..."; + return "..."; + } + } + + public sealed class BRController : EventController + { + [Constructible] + public BRController() + { + Visible = false; + Movable = false; + + Duration = TimeSpan.FromMinutes(30.0); + + BombHome = Point3D.Zero; + + TeamInfo = new BRTeamInfo[4]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new BRTeamInfo(i); + } + + public BRController(Serial serial) + : base(serial) + { + } + + public BRTeamInfo[] TeamInfo{ get; private set; } + + [CommandProperty(AccessLevel.GameMaster)] + public BRTeamInfo Team1 => TeamInfo[0]; + + [CommandProperty(AccessLevel.GameMaster)] + public BRTeamInfo Team2 => TeamInfo[1]; + + [CommandProperty(AccessLevel.GameMaster)] + public BRTeamInfo Team3 => TeamInfo[2]; + + [CommandProperty(AccessLevel.GameMaster)] + public BRTeamInfo Team4 => TeamInfo[3]; + + [CommandProperty(AccessLevel.GameMaster)] + public TimeSpan Duration{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public Point3D BombHome{ get; set; } + + public override string Title => "Bombing Run"; + public override string DefaultName => "Bombing Run Controller"; + + public override string GetTeamName(int teamID) + { + return TeamInfo[teamID % TeamInfo.Length].Name; + } + + public override EventGame Construct(DuelContext context) + { + return new BRGame(this, context); + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + + writer.Write(BombHome); + + writer.Write(Duration); + + writer.WriteEncodedInt(TeamInfo.Length); + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i].Serialize(writer); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 0: + { + BombHome = reader.ReadPoint3D(); + + Duration = reader.ReadTimeSpan(); + + TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new BRTeamInfo(i, reader); + + break; + } + } + } + } + + public sealed class BRGame : EventGame + { + private BRBomb m_Bomb; + + private Timer m_FinishTimer; + + private TimerCallback m_UnhideCallback; + + public BRGame(BRController controller, DuelContext context) : base(context) + { + Controller = controller; + } + + public BRController Controller{ get; } + + public Map Facet + { + get + { + if (m_Context.Arena != null) + return m_Context.Arena.Facet; + + return Controller.Map; + } + } + + public override bool CantDoAnything(Mobile mob) + { + return mob.Backpack?.FindItemByType() != null && GetTeamInfo(mob) != null; + } + + public void ReturnBomb() + { + if (m_Bomb != null && Controller != null) + { + if (m_UnhideCallback == null) + m_UnhideCallback = UnhideBomb; + m_Bomb.Visible = false; + m_Bomb.MoveToWorld(Controller.BombHome, Controller.Map); + Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 15)), m_UnhideCallback); + } + } + + private void UnhideBomb() + { + if (m_Bomb != null) + { + m_Bomb.Visible = true; + m_Bomb.OnLocationChange(m_Bomb.Location); + } + } + + public void Alert(string text) + { + m_Context.m_Tournament?.Alert(text); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + Participant p = m_Context.Participants[i]; + + for (int j = 0; j < p.Players.Length; ++j) + if (p.Players[j] != null) + p.Players[j].Mobile.SendMessage(0x35, text); + } + } + + public void Alert(string format, params object[] args) + { + Alert(string.Format(format, args)); + } + + public BRTeamInfo GetTeamInfo(Mobile mob) + { + int teamID = GetTeamID(mob); + + if (teamID >= 0) + return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + + return null; + } + + 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 == null || pm.DuelPlayer.Eliminated) + return -1; + + return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); + } + + public int GetColor(Mobile mob) + { + return GetTeamInfo(mob)?.Color ?? -1; + } + + private void ApplyHues(Participant p, int hueOverride) + { + for (int 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) + { + Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); + } + + private void DelayBounce_Callback(Mobile mob, Container corpse) + { + DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; + + 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); + DuelContext.CancelSpell(mob); + mob.Frozen = false; + } + + public override bool OnDeath(Mobile mob, Container corpse) + { + Mobile killer = mob.FindMostRecentDamager(false); + + bool hadBomb = false; + + corpse.FindItemsByType(false).ForEach(bomb => + { + hadBomb = true; + bomb.DropTo(mob, killer); + }); + + mob.Backpack?.FindItemsByType(false).ForEach(bomb => + { + hadBomb = true; + bomb.DropTo(mob, killer); + }); + + if (killer?.Player == true) + { + BRTeamInfo teamInfo = GetTeamInfo(killer); + BRTeamInfo victInfo = GetTeamInfo(mob); + + if (teamInfo != null && teamInfo != victInfo) + { + BRPlayerInfo playerInfo = teamInfo[killer]; + + if (playerInfo != null) + { + playerInfo.Kills += 1; + playerInfo.Score += 1; // base frag + + if (hadBomb) + playerInfo.Score += 4; // fragged bomb carrier + } + } + } + + mob.CloseGump(); + mob.SendGump(new BRBoardGump(mob, this)); + + m_Context.Requip(mob, corpse); + DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); + + return false; + } + + public override void OnStart() + { + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + BRTeamInfo teamInfo = Controller.TeamInfo[i]; + + teamInfo.Game = this; + teamInfo.Reset(); + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], + Controller.TeamInfo[i % Controller.TeamInfo.Length].Color); + + m_FinishTimer?.Stop(); + + m_Bomb = new BRBomb(this); + ReturnBomb(); + + m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); + } + + private void Finish_Callback() + { + List teams = new List(); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + BRTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; + + if (teamInfo != null) + teams.Add(teamInfo); + } + + teams.Sort(); + + Tournament tourney = m_Context.m_Tournament; + + StringBuilder sb = new StringBuilder(); + + if (tourney != null) + { + if (tourney.TourneyType == TourneyType.FreeForAll) + { + sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); + sb.Append("-man FFA"); + } + else if (tourney.TourneyType == TourneyType.RandomTeam) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team"); + } + else if (tourney.TourneyType == TourneyType.RedVsBlue) + { + sb.Append("Red v Blue"); + } + else if (tourney.TourneyType == TourneyType.Faction) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team Faction"); + } + else + { + for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) + { + if (sb.Length > 0) + sb.Append('v'); + + sb.Append(tourney.PlayersPerParticipant); + } + } + } + + if (Controller != null) + sb.Append(' ').Append(Controller.Title); + + string title = sb.ToString(); + + BRTeamInfo winner = teams.Count > 0 ? teams[0] : null; + + for (int i = 0; i < teams.Count; ++i) + { + TrophyRank rank = TrophyRank.Bronze; + + if (i == 0) + rank = TrophyRank.Gold; + else if (i == 1) + rank = TrophyRank.Silver; + + BRPlayerInfo leader = teams[i].Leader; + + foreach (BRPlayerInfo pl in teams[i].Players.Values) + { + Mobile mob = pl.Player; + + if (mob == null) + continue; + + sb = new StringBuilder(); + + sb.Append(title); + + if (pl == leader) + sb.Append(" Leader"); + + if (pl.Score > 0) + { + sb.Append(": "); + + //sb.Append( pl.Score.ToString( "N0" ) ); + //sb.Append( pl.Score == 1 ? " point" : " points" ); + + sb.Append(pl.Kills.ToString("N0")); + sb.Append(pl.Kills == 1 ? " kill" : " kills"); + + if (pl.Captures > 0) + { + sb.Append(", "); + sb.Append(pl.Captures.ToString("N0")); + sb.Append(pl.Captures == 1 ? " point" : " points"); + } + } + + 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); + + int cash = pl.Score * 250; + + 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.", + rank.ToString().ToLower(), cash); + } + else + { + mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", + rank.ToString().ToLower()); + } + } + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + if (!(m_Context.Participants[i] is Participant p) || p.Players == null) + continue; + + for (int j = 0; j < p.Players.Length; ++j) + { + DuelPlayer dp = p.Players[j]; + + if (dp?.Mobile != null) + { + dp.Mobile.CloseGump(); + dp.Mobile.SendGump(new BRBoardGump(dp.Mobile, this)); + } + } + + if (i == winner.TeamID) + continue; + + if (p.Players != null) + for (int 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]); + } + + public override void OnStop() + { + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + BRTeamInfo teamInfo = Controller.TeamInfo[i]; + + if (teamInfo.Board != null) + teamInfo.Board.m_TeamInfo = null; + + teamInfo.Game = null; + } + + ReturnBomb(); + + m_Bomb?.Delete(); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], -1); + + m_FinishTimer?.Stop(); + m_FinishTimer = null; + } + } +} diff --git a/Scripts/Engines/ConPVP/Games/CTF.cs b/Scripts/Engines/ConPVP/Games/CTF.cs index abce7730b..d8b98dc48 100644 --- a/Scripts/Engines/ConPVP/Games/CTF.cs +++ b/Scripts/Engines/ConPVP/Games/CTF.cs @@ -1,1202 +1,1205 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Server.Gumps; -using Server.Items; -using Server.Mobiles; -using Server.Network; -using Server.Targeting; - -namespace Server.Engines.ConPVP -{ - public sealed class CTFBoard : Item - { - public CTFTeamInfo m_TeamInfo; - - [Constructible] - public CTFBoard() - : base(7774) - { - Movable = false; - } - - public CTFBoard(Serial serial) - : base(serial) - { - } - - public override string DefaultName => "scoreboard"; - - public override void OnDoubleClick(Mobile from) - { - if (m_TeamInfo?.Game != null) - { - from.CloseGump(); - from.SendGump(new CTFBoardGump(from, m_TeamInfo.Game)); - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - } - - public class CTFBoardGump : Gump - { - private const int LabelColor32 = 0xFFFFFF; - private const int BlackColor32 = 0x000000; - - private CTFGame m_Game; - - public CTFBoardGump(Mobile mob, CTFGame game, CTFTeamInfo section = null) - : base(60, 60) - { - m_Game = game; - - CTFTeamInfo ourTeam = game.GetTeamInfo(mob); - - List entries = new List(); - - if (section == null) - for (int i = 0; i < game.Context.Participants.Count; ++i) - { - CTFTeamInfo teamInfo = game.Controller.TeamInfo[i % 8]; - - if (teamInfo?.Flag == null) - continue; - - entries.Add(teamInfo); - } - else - foreach (CTFPlayerInfo player in section.Players.Values) - if (player.Score > 0) - entries.Add(player); - - entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); - - int height = 0; - - if (section == null) - height = 73 + entries.Count * 75 + 28; - - Closable = false; - - AddPage(0); - - AddBackground(1, 1, 398, height, 3600); - - AddImageTiled(16, 15, 369, height - 29, 3604); - - for (int i = 0; i < entries.Count; i += 1) - AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); - - AddAlphaRegion(16, 15, 369, height - 29); - - AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); - - AddBorderedText(22, 22, 294, 20, Center("CTF Scoreboard"), LabelColor32, BlackColor32); - - AddImageTiled(32, 50, 264, 1, 9107); - AddImageTiled(42, 52, 264, 1, 9157); - - if (section == null) - for (int i = 0; i < entries.Count; ++i) - { - CTFTeamInfo teamInfo = entries[i] as CTFTeamInfo; - - AddImage(30, 70 + i * 75, 10152); - AddImage(30, 85 + i * 75, 10151); - AddImage(30, 100 + i * 75, 10151); - AddImage(30, 106 + i * 75, 10154); - - AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); - - int nameColor = LabelColor32; - int borderColor = BlackColor32; - - switch (teamInfo.Color) - { - case 0x47E: - nameColor = 0xFFFFFF; - break; - - case 0x4F2: - nameColor = 0x3399FF; - break; - - case 0x4F7: - nameColor = 0x33FF33; - break; - - case 0x4FC: - nameColor = 0xFF00FF; - break; - - case 0x021: - nameColor = 0xFF3333; - break; - - case 0x01A: - nameColor = 0xFF66FF; - break; - - case 0x455: - nameColor = 0x333333; - borderColor = 0xFFFFFF; - break; - } - - AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name} Team", nameColor, - borderColor); - - AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); - AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); - AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Captures:", 0xFFC000, BlackColor32); - AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, - BlackColor32); - - CTFPlayerInfo pl = teamInfo.Leader; - - 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, GumpButtonType.Reply, 0); - } - - public string Center(string text) - { - return $"
{text}
"; - } - - public string Color(string text, int color) - { - return $"{text}"; - } - - private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) - { - AddColoredText(x - 1, y - 1, width, height, text, borderColor); - AddColoredText(x - 1, y + 1, width, height, text, borderColor); - AddColoredText(x + 1, y - 1, width, height, text, borderColor); - AddColoredText(x + 1, y + 1, width, height, text, borderColor); - AddColoredText(x, y, width, height, text, color); - } - - private void AddColoredText(int x, int y, int width, int height, string text, int color) - { - if (color == 0) - AddHtml(x, y, width, height, text, false, false); - else - AddHtml(x, y, width, height, Color(text, color), false, false); - } - } - - public sealed class CTFFlag : Item - { - public Mobile m_Fragger; - public DateTime m_FragTime; - - private int m_ReturnCount; - - public Mobile m_Returner; - public DateTime m_ReturnTime; - private Timer m_ReturnTimer; - public CTFTeamInfo m_TeamInfo; - - [Constructible] - public CTFFlag() - : base(5643) - { - Movable = false; - } - - public CTFFlag(Serial serial) - : base(serial) - { - } - - public override string DefaultName => "old people cookies"; - - public override void OnDoubleClick(Mobile from) - { - if (m_TeamInfo?.Game != null) - { - CTFTeamInfo ourTeam = m_TeamInfo; - CTFTeamInfo useTeam = m_TeamInfo.Game.GetTeamInfo(from); - - if (ourTeam == null || useTeam == null) - return; - - if (IsChildOf(from.Backpack)) - { - from.BeginTarget(1, false, TargetFlags.None, Flag_OnTarget); - } - else if (!from.InRange(this, 1) || !from.InLOS(this)) - { - from.LocalOverheadMessage(MessageType.Regular, 0x26, 1019045); // I can't reach that - } - else if (ourTeam == useTeam) - { - if (Location == m_TeamInfo.Origin && Map == m_TeamInfo.Game.Facet) - { - from.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", Name, - "Touch me not for I am chaste.")); - } - else - { - CTFPlayerInfo playerInfo = useTeam[from]; - - if (playerInfo != null) - playerInfo.Score += 4; // return - - m_Returner = from; - m_ReturnTime = DateTime.UtcNow; - - SendHome(); - - from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You returned the cookies!"); - m_TeamInfo.Game.Alert("The {1} cookies have been returned by {0}.", from.Name, ourTeam.Name); - } - } - else if (!from.PlaceInBackpack(this)) - { - from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't hold that."); - } - else - { - from.RevealingAction(); - - from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You stole the cookies!"); - m_TeamInfo.Game.Alert("The {1} cookies have been stolen by {0} ({2}).", from.Name, ourTeam.Name, - useTeam.Name); - - BeginCountdown(120); - } - } - } - - public override void Delete() - { - if (Parent != null) - { - SendHome(); - return; - } - - base.Delete(); - } - - public void DropTo(Mobile mob, Mobile killer) - { - m_Fragger = killer; - m_FragTime = DateTime.UtcNow; - - if (mob != null) - { - MoveToWorld(new Point3D(mob.X, mob.Y, mob.Z + 2), mob.Map); - - m_ReturnCount = Math.Min(m_ReturnCount, 10); - } - else - { - SendHome(); - } - } - - private void StopCountdown() - { - m_ReturnTimer?.Stop(); - - m_ReturnTimer = null; - } - - private void BeginCountdown(int returnCount) - { - StopCountdown(); - - m_ReturnTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Countdown_OnTick); - m_ReturnCount = returnCount; - } - - private void Countdown_OnTick() - { - Mobile owner = RootParent as Mobile; - - switch (m_ReturnCount) - { - case 60: - case 30: - case 15: - case 10: - case 5: - case 4: - case 3: - case 2: - case 1: - { - owner?.SendMessage(0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount, - m_ReturnCount == 1 ? "second" : "seconds"); - - break; - } - - case 0: - { - if (owner != null) - { - owner.SendMessage(0x26, "You have taken too long to capture the cookies!"); - owner.Kill(); - } - - SendHome(); - - m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name); - - return; - } - } - - --m_ReturnCount; - } - - private void Flag_OnTarget(Mobile from, object obj) - { - if (m_TeamInfo == null) - return; - - if (!IsChildOf(from.Backpack)) - return; - - CTFTeamInfo ourTeam = m_TeamInfo; - CTFTeamInfo useTeam = m_TeamInfo.Game.GetTeamInfo(from); - - if (obj is CTFFlag) - { - if (obj == useTeam.Flag) - { - from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You captured the cookies!"); - m_TeamInfo.Game.Alert("{0} captured the {1} cookies!", from.Name, ourTeam.Name); - - SendHome(); - - CTFPlayerInfo playerInfo = useTeam[from]; - - if (playerInfo != null) - { - playerInfo.Captures += 1; - playerInfo.Score += 50; // capture - - CTFFlag teamFlag = useTeam.Flag; - - if (teamFlag.m_Fragger != null && - DateTime.UtcNow < teamFlag.m_FragTime + TimeSpan.FromSeconds(5.0) && - m_TeamInfo.Game.GetTeamInfo(teamFlag.m_Fragger) == useTeam) - { - CTFPlayerInfo assistInfo = useTeam[teamFlag.m_Fragger]; - - if (assistInfo != null) - assistInfo.Score += 6; // frag assist - } - - if (teamFlag.m_Returner != null && - DateTime.UtcNow < teamFlag.m_ReturnTime + TimeSpan.FromSeconds(5.0)) - { - CTFPlayerInfo assistInfo = useTeam[teamFlag.m_Returner]; - - if (assistInfo != null) - assistInfo.Score += 4; // return assist - } - } - } - else - { - from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "Those are not my cookies."); - } - } - else if (obj is Mobile passTo) - { - CTFTeamInfo passTeam = m_TeamInfo.Game.GetTeamInfo(passTo); - - if (passTo == from) - 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!"); - else - from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them."); - } - } - - public void SendHome() - { - StopCountdown(); - - if (m_TeamInfo == null) - return; - - MoveToWorld(m_TeamInfo.Origin, m_TeamInfo.Game.Facet); - } - - private Mobile FindOwner(object parent) - { - if (parent is Item item) - return item.RootParent as Mobile; - - if (parent is Mobile mobile) - return mobile; - - return null; - } - - public override void OnAdded(IEntity parent) - { - base.OnAdded(parent); - - Mobile mob = FindOwner(parent); - - if (mob != null) - mob.SolidHueOverride = 0x4001; - } - - public override void OnRemoved(IEntity parent) - { - base.OnRemoved(parent); - - Mobile mob = FindOwner(parent); - - if (mob != null) - mob.SolidHueOverride = m_TeamInfo?.Game.GetColor(mob) ?? -1; - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - } - - public interface IRankedCTF - { - int Kills{ get; } - int Captures{ get; } - int Score{ get; } - string Name{ get; } - } - - public sealed class CTFPlayerInfo : IRankedCTF - { - private int m_Captures; - - private int m_Kills; - - private int m_Score; - private CTFTeamInfo m_TeamInfo; - - public CTFPlayerInfo(CTFTeamInfo teamInfo, Mobile player) - { - m_TeamInfo = teamInfo; - Player = player; - } - - public Mobile Player{ get; } - - string IRankedCTF.Name => Player.Name; - - public int Kills - { - get => m_Kills; - set - { - m_TeamInfo.Kills += value - m_Kills; - m_Kills = value; - } - } - - public int Captures - { - get => m_Captures; - set - { - m_TeamInfo.Captures += value - m_Captures; - m_Captures = value; - } - } - - public int Score - { - get => m_Score; - set - { - m_TeamInfo.Score += value - m_Score; - m_Score = value; - - if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) - m_TeamInfo.Leader = this; - } - } - } - - [PropertyObject] - public sealed class CTFTeamInfo : IRankedCTF - { - public CTFTeamInfo(int teamID) - { - TeamID = teamID; - Players = new Dictionary(); - } - - public CTFTeamInfo(int teamID, GenericReader ip) - { - TeamID = teamID; - Players = new Dictionary(); - - int version = ip.ReadEncodedInt(); - - switch (version) - { - case 2: - { - Board = ip.ReadItem() as CTFBoard; - - goto case 1; - } - case 1: - { - Name = ip.ReadString(); - - goto case 0; - } - case 0: - { - Color = ip.ReadEncodedInt(); - - Flag = ip.ReadItem() as CTFFlag; - Origin = ip.ReadPoint3D(); - break; - } - } - } - - public CTFGame Game{ get; set; } - - public int TeamID{ get; } - - public CTFPlayerInfo Leader{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public CTFBoard Board{ get; set; } - - public Dictionary Players{ get; } - - public CTFPlayerInfo this[Mobile mob] - { - get - { - if (mob == null) - return null; - - if (!Players.TryGetValue(mob, out CTFPlayerInfo val)) - Players[mob] = val = new CTFPlayerInfo(this, mob); - - return val; - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public string Name{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public CTFFlag Flag{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public Point3D Origin{ get; set; } - - string IRankedCTF.Name => $"{Name} Team"; - - public int Kills{ get; set; } - - public int Captures{ get; set; } - - public int Score{ get; set; } - - public void Reset() - { - Kills = 0; - Captures = 0; - - Score = 0; - - Leader = null; - - Players.Clear(); - - if (Flag != null) - { - Flag.m_TeamInfo = this; - Flag.Hue = Color; - Flag.SendHome(); - } - - if (Board != null) - Board.m_TeamInfo = this; - } - - public void Serialize(GenericWriter op) - { - op.WriteEncodedInt(2); // version - - op.Write(Board); - - op.Write(Name); - - op.WriteEncodedInt(Color); - - op.Write(Flag); - op.Write(Origin); - } - - public override string ToString() - { - return "..."; - } - } - - public sealed class CTFController : EventController - { - [Constructible] - public CTFController() - { - Visible = false; - Movable = false; - - Duration = TimeSpan.FromMinutes(30.0); - - TeamInfo = new CTFTeamInfo[8]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new CTFTeamInfo(i); - } - - public CTFController(Serial serial) - : base(serial) - { - } - - public CTFTeamInfo[] TeamInfo{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team1 => TeamInfo[0]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team2 => TeamInfo[1]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team3 => TeamInfo[2]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team4 => TeamInfo[3]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team5 => TeamInfo[4]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team6 => TeamInfo[5]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team7 => TeamInfo[6]; - - [CommandProperty(AccessLevel.GameMaster)] - public CTFTeamInfo Team8 => TeamInfo[7]; - - [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } - - public override string Title => "CTF"; - - public override string GetTeamName(int teamID) - { - return TeamInfo[teamID % TeamInfo.Length].Name; - } - - public override EventGame Construct(DuelContext context) - { - return new CTFGame(this, context); - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(2); - - writer.Write(Duration); - - writer.WriteEncodedInt(TeamInfo.Length); - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i].Serialize(writer); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 2: - { - Duration = reader.ReadTimeSpan(); - - goto case 1; - } - case 1: - { - TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new CTFTeamInfo(i, reader); - - break; - } - case 0: - { - TeamInfo = new CTFTeamInfo[8]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new CTFTeamInfo(i); - - break; - } - } - - if (version < 2) - Duration = TimeSpan.FromMinutes(30.0); - } - } - - public sealed class CTFGame : EventGame - { - private Timer m_FinishTimer; - - public CTFGame(CTFController controller, DuelContext context) : base(context) - { - Controller = controller; - } - - public CTFController Controller{ get; } - - public Map Facet - { - get - { - if (m_Context.Arena != null) - return m_Context.Arena.Facet; - - return Controller.Map; - } - } - - public static void Initialize() - { - for (int i = 0x7C9; i <= 0x7D0; ++i) - TileData.ItemTable[i].Flags |= TileFlag.NoShoot; - } - - public void Alert(string text) - { - m_Context.m_Tournament?.Alert(text); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - Participant p = m_Context.Participants[i]; - - for (int j = 0; j < p.Players.Length; ++j) - if (p.Players[j] != null) - p.Players[j].Mobile.SendMessage(0x35, text); - } - } - - public void Alert(string format, params object[] args) - { - Alert(string.Format(format, args)); - } - - public CTFTeamInfo GetTeamInfo(Mobile mob) - { - int teamID = GetTeamID(mob); - - if (teamID >= 0) - return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; - - return null; - } - - 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 == null || pm.DuelPlayer.Eliminated) - return -1; - - return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); - } - - public int GetColor(Mobile mob) - { - CTFTeamInfo teamInfo = GetTeamInfo(mob); - - if (teamInfo != null) - return teamInfo.Color; - - return -1; - } - - private void ApplyHues(Participant p, int hueOverride) - { - for (int 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) - { - Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); - } - - private void DelayBounce_Callback(Mobile mob, Container corpse) - { - DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; - - m_Context.RemoveAggressions(mob); - - if (dp != null && !dp.Eliminated) - mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); - else - m_Context.SendOutside(mob); - - m_Context.Refresh(mob, corpse); - DuelContext.Debuff(mob); - DuelContext.CancelSpell(mob); - mob.Frozen = false; - } - - public override bool OnDeath(Mobile mob, Container corpse) - { - Mobile killer = mob.FindMostRecentDamager(false); - - bool hadFlag = false; - - corpse.FindItemsByType(false).ForEach(flag => - { - hadFlag = true; - flag.DropTo(mob, killer); - }); - - mob.Backpack?.FindItemsByType(false).ForEach(flag => - { - hadFlag = true; - flag.DropTo(mob, killer); - }); - - if (killer != null && killer.Player) - { - CTFTeamInfo teamInfo = GetTeamInfo(killer); - CTFTeamInfo victInfo = GetTeamInfo(mob); - - if (teamInfo != null && teamInfo != victInfo) - { - CTFPlayerInfo playerInfo = teamInfo[killer]; - - if (playerInfo != null) - { - playerInfo.Kills += 1; - 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 (int 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) - { - for (int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j) - { - if (!(ourFlagCarrier.Aggressors[j] is AggressorInfo aggr) || - aggr.Defender != ourFlagCarrier || aggr.Attacker != mob) - continue; - - playerInfo.Score += 2; // helped defend guy capturing enemy flag - break; - } - - if (mob.Map == ourFlagCarrier.Map && ourFlagCarrier.InRange(mob, 12)) - playerInfo.Score += 1; // helped defend guy capturing enemy flag - } - } - } - } - } - - mob.CloseGump(); - mob.SendGump(new CTFBoardGump(mob, this)); - - m_Context.Requip(mob, corpse); - DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); - - return false; - } - - public override void OnStart() - { - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - CTFTeamInfo teamInfo = Controller.TeamInfo[i]; - - teamInfo.Game = this; - teamInfo.Reset(); - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], Controller.TeamInfo[i % 8].Color); - - m_FinishTimer?.Stop(); - - m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); - } - - private void Finish_Callback() - { - List teams = new List(); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - CTFTeamInfo teamInfo = Controller.TeamInfo[i % 8]; - - if (teamInfo?.Flag == null) - continue; - - teams.Add(teamInfo); - } - - teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return b.Score - a.Score; }); - - Tournament tourney = m_Context.m_Tournament; - - StringBuilder sb = new StringBuilder(); - - if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll) - { - sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); - sb.Append("-man FFA"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue) - { - sb.Append("Red v Blue"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.Faction) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team Faction"); - } - else if (tourney != null) - { - for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) - { - if (sb.Length > 0) - sb.Append('v'); - - sb.Append(tourney.PlayersPerParticipant); - } - } - - if (Controller != null) - sb.Append(' ').Append(Controller.Title); - - string title = sb.ToString(); - - CTFTeamInfo winner = teams.Count > 0 ? teams[0] : null; - - for (int i = 0; i < teams.Count; ++i) - { - TrophyRank rank = TrophyRank.Bronze; - - if (i == 0) - rank = TrophyRank.Gold; - else if (i == 1) - rank = TrophyRank.Silver; - - CTFPlayerInfo leader = teams[i].Leader; - - foreach (CTFPlayerInfo pl in teams[i].Players.Values) - { - Mobile mob = pl.Player; - - if (mob == null) - continue; - - //"Red v Blue CTF Champion" - - sb = new StringBuilder(); - - sb.Append(title); - - if (pl == leader) - sb.Append(" Leader"); - - if (pl.Score > 0) - { - sb.Append(": "); - - sb.Append(pl.Score.ToString("N0")); - sb.Append(pl.Score == 1 ? " point" : " points"); - - if (pl.Kills > 0) - { - sb.Append(", "); - sb.Append(pl.Kills.ToString("N0")); - sb.Append(pl.Kills == 1 ? " kill" : " kills"); - } - - if (pl.Captures > 0) - { - sb.Append(", "); - sb.Append(pl.Captures.ToString("N0")); - sb.Append(pl.Captures == 1 ? " capture" : " captures"); - } - } - - 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); - - int cash = pl.Score * 250; - - 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.", - rank.ToString().ToLower(), cash); - } - else - { - mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", - rank.ToString().ToLower()); - } - } - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - Participant p = m_Context.Participants[i]; - - for (int j = 0; j < p.Players.Length; ++j) - { - DuelPlayer dp = p.Players[j]; - - if (dp?.Mobile != null) - { - dp.Mobile.CloseGump(); - dp.Mobile.SendGump(new CTFBoardGump(dp.Mobile, this)); - } - } - - if (i == winner.TeamID) - continue; - - for (int 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]); - } - - public override void OnStop() - { - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - CTFTeamInfo teamInfo = Controller.TeamInfo[i]; - - if (teamInfo.Flag != null) - { - teamInfo.Flag.SendHome(); - teamInfo.Flag.m_TeamInfo = null; - } - - if (teamInfo.Board != null) - teamInfo.Board.m_TeamInfo = null; - - teamInfo.Game = null; - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], -1); - - m_FinishTimer?.Stop(); - - m_FinishTimer = null; - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using System.Text; +using Server.Gumps; +using Server.Items; +using Server.Mobiles; +using Server.Network; +using Server.Targeting; + +namespace Server.Engines.ConPVP +{ + public sealed class CTFBoard : Item + { + public CTFTeamInfo m_TeamInfo; + + [Constructible] + public CTFBoard() + : base(7774) + { + Movable = false; + } + + public CTFBoard(Serial serial) + : base(serial) + { + } + + public override string DefaultName => "scoreboard"; + + public override void OnDoubleClick(Mobile from) + { + if (m_TeamInfo?.Game != null) + { + from.CloseGump(); + from.SendGump(new CTFBoardGump(from, m_TeamInfo.Game)); + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + } + + public class CTFBoardGump : Gump + { + private const int LabelColor32 = 0xFFFFFF; + private const int BlackColor32 = 0x000000; + + private CTFGame m_Game; + + public CTFBoardGump(Mobile mob, CTFGame game, CTFTeamInfo section = null) + : base(60, 60) + { + m_Game = game; + + CTFTeamInfo ourTeam = game.GetTeamInfo(mob); + + List entries = new List(); + + if (section == null) + for (int i = 0; i < game.Context.Participants.Count; ++i) + { + CTFTeamInfo teamInfo = game.Controller.TeamInfo[i % 8]; + + if (teamInfo?.Flag == null) + continue; + + entries.Add(teamInfo); + } + else + foreach (CTFPlayerInfo player in section.Players.Values) + if (player.Score > 0) + entries.Add(player); + + entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); + + int height = 0; + + if (section == null) + height = 73 + entries.Count * 75 + 28; + + Closable = false; + + AddPage(0); + + AddBackground(1, 1, 398, height, 3600); + + AddImageTiled(16, 15, 369, height - 29, 3604); + + for (int i = 0; i < entries.Count; i += 1) + AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + + AddAlphaRegion(16, 15, 369, height - 29); + + AddImage(215, -45, 0xEE40); + //AddImage( 330, 141, 0x8BA ); + + AddBorderedText(22, 22, 294, 20, Center("CTF Scoreboard"), LabelColor32, BlackColor32); + + AddImageTiled(32, 50, 264, 1, 9107); + AddImageTiled(42, 52, 264, 1, 9157); + + if (section == null) + for (int i = 0; i < entries.Count; ++i) + { + CTFTeamInfo teamInfo = entries[i] as CTFTeamInfo; + + AddImage(30, 70 + i * 75, 10152); + AddImage(30, 85 + i * 75, 10151); + AddImage(30, 100 + i * 75, 10151); + AddImage(30, 106 + i * 75, 10154); + + AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); + + int nameColor = LabelColor32; + int borderColor = BlackColor32; + + switch (teamInfo.Color) + { + case 0x47E: + nameColor = 0xFFFFFF; + break; + + case 0x4F2: + nameColor = 0x3399FF; + break; + + case 0x4F7: + nameColor = 0x33FF33; + break; + + case 0x4FC: + nameColor = 0xFF00FF; + break; + + case 0x021: + nameColor = 0xFF3333; + break; + + case 0x01A: + nameColor = 0xFF66FF; + break; + + case 0x455: + nameColor = 0x333333; + borderColor = 0xFFFFFF; + break; + } + + AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name} Team", nameColor, + borderColor); + + AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); + AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); + AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Captures:", 0xFFC000, BlackColor32); + AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, + BlackColor32); + + CTFPlayerInfo pl = teamInfo.Leader; + + 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); + } + + public string Center(string text) + { + return $"
{text}
"; + } + + public string Color(string text, int color) + { + return $"{text}"; + } + + private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) + { + AddColoredText(x - 1, y - 1, width, height, text, borderColor); + AddColoredText(x - 1, y + 1, width, height, text, borderColor); + AddColoredText(x + 1, y - 1, width, height, text, borderColor); + AddColoredText(x + 1, y + 1, width, height, text, borderColor); + AddColoredText(x, y, width, height, text, color); + } + + 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 sealed class CTFFlag : Item + { + public Mobile m_Fragger; + public DateTime m_FragTime; + + private int m_ReturnCount; + + public Mobile m_Returner; + public DateTime m_ReturnTime; + private Timer m_ReturnTimer; + public CTFTeamInfo m_TeamInfo; + + [Constructible] + public CTFFlag() + : base(5643) + { + Movable = false; + } + + public CTFFlag(Serial serial) + : base(serial) + { + } + + public override string DefaultName => "old people cookies"; + + public override void OnDoubleClick(Mobile from) + { + if (m_TeamInfo?.Game != null) + { + CTFTeamInfo ourTeam = m_TeamInfo; + CTFTeamInfo useTeam = m_TeamInfo.Game.GetTeamInfo(from); + + if (ourTeam == null || useTeam == null) + return; + + if (IsChildOf(from.Backpack)) + { + from.BeginTarget(1, false, TargetFlags.None, Flag_OnTarget); + } + else if (!from.InRange(this, 1) || !from.InLOS(this)) + { + from.LocalOverheadMessage(MessageType.Regular, 0x26, 1019045); // I can't reach that + } + else if (ourTeam == useTeam) + { + if (Location == m_TeamInfo.Origin && Map == m_TeamInfo.Game.Facet) + { + from.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", Name, + "Touch me not for I am chaste.")); + } + else + { + CTFPlayerInfo playerInfo = useTeam[from]; + + if (playerInfo != null) + playerInfo.Score += 4; // return + + m_Returner = from; + m_ReturnTime = DateTime.UtcNow; + + SendHome(); + + from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You returned the cookies!"); + m_TeamInfo.Game.Alert("The {1} cookies have been returned by {0}.", from.Name, ourTeam.Name); + } + } + else if (!from.PlaceInBackpack(this)) + { + from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't hold that."); + } + else + { + from.RevealingAction(); + + from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You stole the cookies!"); + m_TeamInfo.Game.Alert("The {1} cookies have been stolen by {0} ({2}).", from.Name, ourTeam.Name, + useTeam.Name); + + BeginCountdown(120); + } + } + } + + public override void Delete() + { + if (Parent != null) + { + SendHome(); + return; + } + + base.Delete(); + } + + public void DropTo(Mobile mob, Mobile killer) + { + m_Fragger = killer; + m_FragTime = DateTime.UtcNow; + + if (mob != null) + { + MoveToWorld(new Point3D(mob.X, mob.Y, mob.Z + 2), mob.Map); + + m_ReturnCount = Math.Min(m_ReturnCount, 10); + } + else + { + SendHome(); + } + } + + private void StopCountdown() + { + m_ReturnTimer?.Stop(); + + m_ReturnTimer = null; + } + + private void BeginCountdown(int returnCount) + { + StopCountdown(); + + m_ReturnTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Countdown_OnTick); + m_ReturnCount = returnCount; + } + + private void Countdown_OnTick() + { + Mobile owner = RootParent as Mobile; + + switch (m_ReturnCount) + { + case 60: + case 30: + case 15: + case 10: + case 5: + case 4: + case 3: + case 2: + case 1: + { + owner?.SendMessage(0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount, + m_ReturnCount == 1 ? "second" : "seconds"); + + break; + } + + case 0: + { + if (owner != null) + { + owner.SendMessage(0x26, "You have taken too long to capture the cookies!"); + owner.Kill(); + } + + SendHome(); + + m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name); + + return; + } + } + + --m_ReturnCount; + } + + private void Flag_OnTarget(Mobile from, object obj) + { + if (m_TeamInfo == null) + return; + + if (!IsChildOf(from.Backpack)) + return; + + CTFTeamInfo ourTeam = m_TeamInfo; + CTFTeamInfo useTeam = m_TeamInfo.Game.GetTeamInfo(from); + + if (obj is CTFFlag) + { + if (obj == useTeam.Flag) + { + from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You captured the cookies!"); + m_TeamInfo.Game.Alert("{0} captured the {1} cookies!", from.Name, ourTeam.Name); + + SendHome(); + + CTFPlayerInfo playerInfo = useTeam[from]; + + if (playerInfo != null) + { + playerInfo.Captures += 1; + playerInfo.Score += 50; // capture + + CTFFlag teamFlag = useTeam.Flag; + + if (teamFlag.m_Fragger != null && + DateTime.UtcNow < teamFlag.m_FragTime + TimeSpan.FromSeconds(5.0) && + m_TeamInfo.Game.GetTeamInfo(teamFlag.m_Fragger) == useTeam) + { + CTFPlayerInfo assistInfo = useTeam[teamFlag.m_Fragger]; + + if (assistInfo != null) + assistInfo.Score += 6; // frag assist + } + + if (teamFlag.m_Returner != null && + DateTime.UtcNow < teamFlag.m_ReturnTime + TimeSpan.FromSeconds(5.0)) + { + CTFPlayerInfo assistInfo = useTeam[teamFlag.m_Returner]; + + if (assistInfo != null) + assistInfo.Score += 4; // return assist + } + } + } + else + { + from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "Those are not my cookies."); + } + } + else if (obj is Mobile passTo) + { + CTFTeamInfo passTeam = m_TeamInfo.Game.GetTeamInfo(passTo); + + if (passTo == from) + 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!"); + else + from.LocalOverheadMessage(MessageType.Regular, 0x26, false, "I can't pass to them."); + } + } + + public void SendHome() + { + StopCountdown(); + + if (m_TeamInfo == null) + return; + + MoveToWorld(m_TeamInfo.Origin, m_TeamInfo.Game.Facet); + } + + private Mobile FindOwner(IEntity parent) + { + if (parent is Item item) + return item.RootParent as Mobile; + + if (parent is Mobile mobile) + return mobile; + + return null; + } + + public override void OnAdded(IEntity parent) + { + base.OnAdded(parent); + + Mobile mob = FindOwner(parent); + + if (mob != null) + mob.SolidHueOverride = 0x4001; + } + + public override void OnRemoved(IEntity parent) + { + base.OnRemoved(parent); + + Mobile mob = FindOwner(parent); + + if (mob != null) + mob.SolidHueOverride = m_TeamInfo?.Game.GetColor(mob) ?? -1; + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + } + + public interface IRankedCTF + { + int Kills{ get; } + int Captures{ get; } + int Score{ get; } + string Name{ get; } + } + + public sealed class CTFPlayerInfo : IRankedCTF + { + private int m_Captures; + + private int m_Kills; + + private int m_Score; + private CTFTeamInfo m_TeamInfo; + + public CTFPlayerInfo(CTFTeamInfo teamInfo, Mobile player) + { + m_TeamInfo = teamInfo; + Player = player; + } + + public Mobile Player{ get; } + + string IRankedCTF.Name => Player.Name; + + public int Kills + { + get => m_Kills; + set + { + m_TeamInfo.Kills += value - m_Kills; + m_Kills = value; + } + } + + public int Captures + { + get => m_Captures; + set + { + m_TeamInfo.Captures += value - m_Captures; + m_Captures = value; + } + } + + public int Score + { + get => m_Score; + set + { + m_TeamInfo.Score += value - m_Score; + m_Score = value; + + if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + m_TeamInfo.Leader = this; + } + } + } + + [PropertyObject] + public sealed class CTFTeamInfo : IRankedCTF + { + public CTFTeamInfo(int teamID) + { + TeamID = teamID; + Players = new Dictionary(); + } + + public CTFTeamInfo(int teamID, GenericReader ip) + { + TeamID = teamID; + Players = new Dictionary(); + + int version = ip.ReadEncodedInt(); + + switch (version) + { + case 2: + { + Board = ip.ReadItem() as CTFBoard; + + goto case 1; + } + case 1: + { + Name = ip.ReadString(); + + goto case 0; + } + case 0: + { + Color = ip.ReadEncodedInt(); + + Flag = ip.ReadItem() as CTFFlag; + Origin = ip.ReadPoint3D(); + break; + } + } + } + + public CTFGame Game{ get; set; } + + public int TeamID{ get; } + + public CTFPlayerInfo Leader{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public CTFBoard Board{ get; set; } + + public Dictionary Players{ get; } + + public CTFPlayerInfo this[Mobile mob] + { + get + { + if (mob == null) + return null; + + if (!Players.TryGetValue(mob, out CTFPlayerInfo val)) + Players[mob] = val = new CTFPlayerInfo(this, mob); + + return val; + } + } + + [CommandProperty(AccessLevel.GameMaster)] + public int Color{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public string Name{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public CTFFlag Flag{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public Point3D Origin{ get; set; } + + string IRankedCTF.Name => $"{Name} Team"; + + public int Kills{ get; set; } + + public int Captures{ get; set; } + + public int Score{ get; set; } + + public void Reset() + { + Kills = 0; + Captures = 0; + + Score = 0; + + Leader = null; + + Players.Clear(); + + if (Flag != null) + { + Flag.m_TeamInfo = this; + Flag.Hue = Color; + Flag.SendHome(); + } + + if (Board != null) + Board.m_TeamInfo = this; + } + + public void Serialize(GenericWriter op) + { + op.WriteEncodedInt(2); // version + + op.Write(Board); + + op.Write(Name); + + op.WriteEncodedInt(Color); + + op.Write(Flag); + op.Write(Origin); + } + + public override string ToString() + { + return "..."; + } + } + + public sealed class CTFController : EventController + { + [Constructible] + public CTFController() + { + Visible = false; + Movable = false; + + Duration = TimeSpan.FromMinutes(30.0); + + TeamInfo = new CTFTeamInfo[8]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new CTFTeamInfo(i); + } + + public CTFController(Serial serial) + : base(serial) + { + } + + public CTFTeamInfo[] TeamInfo{ get; private set; } + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team1 => TeamInfo[0]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team2 => TeamInfo[1]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team3 => TeamInfo[2]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team4 => TeamInfo[3]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team5 => TeamInfo[4]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team6 => TeamInfo[5]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team7 => TeamInfo[6]; + + [CommandProperty(AccessLevel.GameMaster)] + public CTFTeamInfo Team8 => TeamInfo[7]; + + [CommandProperty(AccessLevel.GameMaster)] + public TimeSpan Duration{ get; set; } + + public override string Title => "CTF"; + + public override string GetTeamName(int teamID) + { + return TeamInfo[teamID % TeamInfo.Length].Name; + } + + public override EventGame Construct(DuelContext context) + { + return new CTFGame(this, context); + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(2); + + writer.Write(Duration); + + writer.WriteEncodedInt(TeamInfo.Length); + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i].Serialize(writer); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 2: + { + Duration = reader.ReadTimeSpan(); + + goto case 1; + } + case 1: + { + TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new CTFTeamInfo(i, reader); + + break; + } + case 0: + { + TeamInfo = new CTFTeamInfo[8]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new CTFTeamInfo(i); + + break; + } + } + + if (version < 2) + Duration = TimeSpan.FromMinutes(30.0); + } + } + + public sealed class CTFGame : EventGame + { + private Timer m_FinishTimer; + + public CTFGame(CTFController controller, DuelContext context) : base(context) + { + Controller = controller; + } + + public CTFController Controller{ get; } + + public Map Facet + { + get + { + if (m_Context.Arena != null) + return m_Context.Arena.Facet; + + return Controller.Map; + } + } + + public static void Initialize() + { + for (int i = 0x7C9; i <= 0x7D0; ++i) + TileData.ItemTable[i].Flags |= TileFlag.NoShoot; + } + + public void Alert(string text) + { + m_Context.m_Tournament?.Alert(text); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + Participant p = m_Context.Participants[i]; + + for (int j = 0; j < p.Players.Length; ++j) + if (p.Players[j] != null) + p.Players[j].Mobile.SendMessage(0x35, text); + } + } + + public void Alert(string format, params object[] args) + { + Alert(string.Format(format, args)); + } + + public CTFTeamInfo GetTeamInfo(Mobile mob) + { + int teamID = GetTeamID(mob); + + if (teamID >= 0) + return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + + return null; + } + + 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 == null || pm.DuelPlayer.Eliminated) + return -1; + + return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); + } + + public int GetColor(Mobile mob) + { + CTFTeamInfo teamInfo = GetTeamInfo(mob); + + if (teamInfo != null) + return teamInfo.Color; + + return -1; + } + + private void ApplyHues(Participant p, int hueOverride) + { + for (int 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) + { + Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); + } + + private void DelayBounce_Callback(Mobile mob, Container corpse) + { + DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; + + 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); + DuelContext.CancelSpell(mob); + mob.Frozen = false; + } + + public override bool OnDeath(Mobile mob, Container corpse) + { + Mobile killer = mob.FindMostRecentDamager(false); + + bool hadFlag = false; + + corpse.FindItemsByType(false).ForEach(flag => + { + hadFlag = true; + flag.DropTo(mob, killer); + }); + + mob.Backpack?.FindItemsByType(false).ForEach(flag => + { + hadFlag = true; + flag.DropTo(mob, killer); + }); + + if (killer?.Player == true) + { + CTFTeamInfo teamInfo = GetTeamInfo(killer); + CTFTeamInfo victInfo = GetTeamInfo(mob); + + if (teamInfo != null && teamInfo != victInfo) + { + CTFPlayerInfo playerInfo = teamInfo[killer]; + + if (playerInfo != null) + { + playerInfo.Kills += 1; + 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 (int 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) + { + for (int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j) + { + if (!(ourFlagCarrier.Aggressors[j] is AggressorInfo aggr) || + aggr.Defender != ourFlagCarrier || aggr.Attacker != mob) + continue; + + playerInfo.Score += 2; // helped defend guy capturing enemy flag + break; + } + + if (mob.Map == ourFlagCarrier.Map && ourFlagCarrier.InRange(mob, 12)) + playerInfo.Score += 1; // helped defend guy capturing enemy flag + } + } + } + } + } + + mob.CloseGump(); + mob.SendGump(new CTFBoardGump(mob, this)); + + m_Context.Requip(mob, corpse); + DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); + + return false; + } + + public override void OnStart() + { + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + CTFTeamInfo teamInfo = Controller.TeamInfo[i]; + + teamInfo.Game = this; + teamInfo.Reset(); + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], Controller.TeamInfo[i % 8].Color); + + m_FinishTimer?.Stop(); + + m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); + } + + private void Finish_Callback() + { + List teams = new List(); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + CTFTeamInfo teamInfo = Controller.TeamInfo[i % 8]; + + if (teamInfo?.Flag == null) + continue; + + teams.Add(teamInfo); + } + + teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return b.Score - a.Score; }); + + Tournament tourney = m_Context.m_Tournament; + + StringBuilder sb = new StringBuilder(); + + if (tourney != null) + { + if (tourney.TourneyType == TourneyType.FreeForAll) + { + sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); + sb.Append("-man FFA"); + } + else if (tourney.TourneyType == TourneyType.RandomTeam) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team"); + } + else if (tourney.TourneyType == TourneyType.RedVsBlue) + { + sb.Append("Red v Blue"); + } + else if (tourney.TourneyType == TourneyType.Faction) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team Faction"); + } + else + { + for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) + { + if (sb.Length > 0) + sb.Append('v'); + + sb.Append(tourney.PlayersPerParticipant); + } + } + } + + if (Controller != null) + sb.Append(' ').Append(Controller.Title); + + string title = sb.ToString(); + + CTFTeamInfo winner = teams.Count > 0 ? teams[0] : null; + + for (int i = 0; i < teams.Count; ++i) + { + TrophyRank rank = TrophyRank.Bronze; + + if (i == 0) + rank = TrophyRank.Gold; + else if (i == 1) + rank = TrophyRank.Silver; + + CTFPlayerInfo leader = teams[i].Leader; + + foreach (CTFPlayerInfo pl in teams[i].Players.Values) + { + Mobile mob = pl.Player; + + if (mob == null) + continue; + + //"Red v Blue CTF Champion" + + sb = new StringBuilder(); + + sb.Append(title); + + if (pl == leader) + sb.Append(" Leader"); + + if (pl.Score > 0) + { + sb.Append(": "); + + sb.Append(pl.Score.ToString("N0")); + sb.Append(pl.Score == 1 ? " point" : " points"); + + if (pl.Kills > 0) + { + sb.Append(", "); + sb.Append(pl.Kills.ToString("N0")); + sb.Append(pl.Kills == 1 ? " kill" : " kills"); + } + + if (pl.Captures > 0) + { + sb.Append(", "); + sb.Append(pl.Captures.ToString("N0")); + sb.Append(pl.Captures == 1 ? " capture" : " captures"); + } + } + + 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); + + int cash = pl.Score * 250; + + 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.", + rank.ToString().ToLower(), cash); + } + else + { + mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", + rank.ToString().ToLower()); + } + } + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + Participant p = m_Context.Participants[i]; + + for (int j = 0; j < p.Players.Length; ++j) + { + DuelPlayer dp = p.Players[j]; + + if (dp?.Mobile != null) + { + dp.Mobile.CloseGump(); + dp.Mobile.SendGump(new CTFBoardGump(dp.Mobile, this)); + } + } + + if (i == winner.TeamID) + continue; + + for (int 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]); + } + + public override void OnStop() + { + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + CTFTeamInfo teamInfo = Controller.TeamInfo[i]; + + if (teamInfo.Flag != null) + { + teamInfo.Flag.SendHome(); + teamInfo.Flag.m_TeamInfo = null; + } + + if (teamInfo.Board != null) + teamInfo.Board.m_TeamInfo = null; + + teamInfo.Game = null; + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], -1); + + m_FinishTimer?.Stop(); + + m_FinishTimer = null; + } + } +} diff --git a/Scripts/Engines/ConPVP/Games/DoubleDom.cs b/Scripts/Engines/ConPVP/Games/DoubleDom.cs index db89b1648..f0c4c5a92 100644 --- a/Scripts/Engines/ConPVP/Games/DoubleDom.cs +++ b/Scripts/Engines/ConPVP/Games/DoubleDom.cs @@ -1,1118 +1,1109 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Server.Gumps; -using Server.Items; -using Server.Mobiles; - -namespace Server.Engines.ConPVP -{ - public sealed class DDBoard : Item - { - public DDTeamInfo m_TeamInfo; - - [Constructible] - public DDBoard() - : base(7774) - { - Movable = false; - } - - public DDBoard(Serial serial) - : base(serial) - { - } - - public override string DefaultName => "scoreboard"; - - public override void OnDoubleClick(Mobile from) - { - if (m_TeamInfo?.Game != null) - { - from.CloseGump(); - from.SendGump(new DDBoardGump(from, m_TeamInfo.Game)); - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - } - - public class DDBoardGump : Gump - { - private const int LabelColor32 = 0xFFFFFF; - private const int BlackColor32 = 0x000000; - - private DDGame m_Game; - - public DDBoardGump(Mobile mob, DDGame game) - : this(mob, game, null) - { - } - - public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section) - : base(60, 60) - { - m_Game = game; - - DDTeamInfo ourTeam = game.GetTeamInfo(mob); - - List entries = new List(); - - if (section == null) - for (int i = 0; i < game.Context.Participants.Count; ++i) - { - DDTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; - - if (teamInfo != null) - entries.Add(teamInfo); - } - else - foreach (DDPlayerInfo player in section.Players.Values) - if (player.Score > 0) - entries.Add(player); - - entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); - - int height = 0; - - if (section == null) - height = 73 + entries.Count * 75 + 28; - - Closable = false; - - AddPage(0); - - AddBackground(1, 1, 398, height, 3600); - - AddImageTiled(16, 15, 369, height - 29, 3604); - - for (int i = 0; i < entries.Count; i += 1) - AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); - - AddAlphaRegion(16, 15, 369, height - 29); - - AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); - - AddBorderedText(22, 22, 294, 20, Center("DD Scoreboard"), LabelColor32, BlackColor32); - - AddImageTiled(32, 50, 264, 1, 9107); - AddImageTiled(42, 52, 264, 1, 9157); - - if (section == null) - for (int i = 0; i < entries.Count; ++i) - { - DDTeamInfo teamInfo = entries[i] as DDTeamInfo; - - AddImage(30, 70 + i * 75, 10152); - AddImage(30, 85 + i * 75, 10151); - AddImage(30, 100 + i * 75, 10151); - AddImage(30, 106 + i * 75, 10154); - - AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); - - int nameColor = LabelColor32; - int borderColor = BlackColor32; - - switch (teamInfo.Color) - { - case 0x47E: - nameColor = 0xFFFFFF; - break; - - case 0x4F2: - nameColor = 0x3399FF; - break; - - case 0x4F7: - nameColor = 0x33FF33; - break; - - case 0x4FC: - nameColor = 0xFF00FF; - break; - - case 0x021: - nameColor = 0xFF3333; - break; - - case 0x01A: - nameColor = 0xFF66FF; - break; - - case 0x455: - nameColor = 0x333333; - borderColor = 0xFFFFFF; - break; - } - - AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name}", nameColor, - borderColor); - - AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); - AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); - AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Captures:", 0xFFC000, BlackColor32); - AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, - BlackColor32); - - DDPlayerInfo pl = teamInfo.Leader; - - 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, GumpButtonType.Reply, 0); - } - - public string Center(string text) - { - return $"
{text}
"; - } - - public string Color(string text, int color) - { - return $"{text}"; - } - - private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) - { - AddColoredText(x - 1, y - 1, width, height, text, borderColor); - AddColoredText(x - 1, y + 1, width, height, text, borderColor); - AddColoredText(x + 1, y - 1, width, height, text, borderColor); - AddColoredText(x + 1, y + 1, width, height, text, borderColor); - AddColoredText(x, y, width, height, text, color); - } - - private void AddColoredText(int x, int y, int width, int height, string text, int color) - { - if (color == 0) - AddHtml(x, y, width, height, text, false, false); - else - AddHtml(x, y, width, height, Color(text, color), false, false); - } - } - - public sealed class DDPlayerInfo : IRankedCTF - { - private int m_Captures; - - private int m_Kills; - - private int m_Score; - private DDTeamInfo m_TeamInfo; - - public DDPlayerInfo(DDTeamInfo teamInfo, Mobile player) - { - m_TeamInfo = teamInfo; - Player = player; - } - - public Mobile Player{ get; } - - public string Name => Player.Name; - - public int Kills - { - get => m_Kills; - set - { - m_TeamInfo.Kills += value - m_Kills; - m_Kills = value; - } - } - - public int Captures - { - get => m_Captures; - set - { - m_TeamInfo.Captures += value - m_Captures; - m_Captures = value; - } - } - - public int Score - { - get => m_Score; - set - { - m_TeamInfo.Score += value - m_Score; - m_Score = value; - - if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) - m_TeamInfo.Leader = this; - } - } - } - - [PropertyObject] - public sealed class DDTeamInfo : IRankedCTF - { - public DDTeamInfo(int teamID) - { - TeamID = teamID; - Players = new Dictionary(); - } - - public DDTeamInfo(int teamID, GenericReader ip) - { - TeamID = teamID; - Players = new Dictionary(); - - int version = ip.ReadEncodedInt(); - - switch (version) - { - case 0: - { - Board = ip.ReadItem() as DDBoard; - TeamName = ip.ReadString(); - Color = ip.ReadEncodedInt(); - Origin = ip.ReadPoint3D(); - break; - } - } - } - - public DDGame Game{ get; set; } - - public int TeamID{ get; } - - public DDPlayerInfo Leader{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public DDBoard Board{ get; set; } - - public Dictionary Players{ get; } - - public DDPlayerInfo this[Mobile mob] - { - get - { - if (mob == null) - return null; - - if (!Players.TryGetValue(mob, out DDPlayerInfo val)) - Players[mob] = val = new DDPlayerInfo(this, mob); - - return val; - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public string TeamName{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public Point3D Origin{ get; set; } - - public string Name => $"{TeamName} Team"; - - public int Kills{ get; set; } - - public int Captures{ get; set; } - - public int Score{ get; set; } - - public void Reset() - { - Kills = 0; - Captures = 0; - - Score = 0; - - Leader = null; - - Players.Clear(); - - if (Board != null) - Board.m_TeamInfo = this; - } - - public void Serialize(GenericWriter op) - { - op.WriteEncodedInt(0); // version - - op.Write(Board); - op.Write(TeamName); - op.WriteEncodedInt(Color); - op.Write(Origin); - } - - public override string ToString() - { - return "..."; - } - } - - public sealed class DDController : EventController - { - [Constructible] - public DDController() - { - Visible = false; - Movable = false; - - Duration = TimeSpan.FromMinutes(30.0); - - TeamInfo = new DDTeamInfo[2]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new DDTeamInfo(i); - } - - public DDController(Serial serial) - : base(serial) - { - } - - public DDTeamInfo[] TeamInfo{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public DDTeamInfo Team1 => TeamInfo[0]; - - [CommandProperty(AccessLevel.GameMaster)] - public DDTeamInfo Team2 => TeamInfo[1]; - - [CommandProperty(AccessLevel.GameMaster)] - public DDWayPoint PointA{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public DDWayPoint PointB{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } - - public override string Title => "DoubleDom"; - - public override string DefaultName => "DD Controller"; - - public override string GetTeamName(int teamID) - { - return TeamInfo[teamID % TeamInfo.Length].Name; - } - - public override EventGame Construct(DuelContext context) - { - return new DDGame(this, context); - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - - writer.Write(Duration); - - writer.WriteEncodedInt(TeamInfo.Length); - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i].Serialize(writer); - - writer.Write(PointA); - writer.Write(PointB); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 0: - { - Duration = reader.ReadTimeSpan(); - TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new DDTeamInfo(i, reader); - - PointA = reader.ReadItem() as DDWayPoint; - PointB = reader.ReadItem() as DDWayPoint; - - break; - } - } - } - } - - public sealed class DDGame : EventGame - { - private int m_CapStage; - - private bool m_Capturable = true; - private Timer m_CaptureTimer; - - private Timer m_FinishTimer; - private Timer m_UncaptureTimer; - - public DDGame(DDController controller, DuelContext context) : base(context) - { - Controller = controller; - } - - public DDController Controller{ get; } - - public Map Facet - { - get - { - if (m_Context.Arena != null) - return m_Context.Arena.Facet; - - return Controller.Map; - } - } - - public void Alert(string text) - { - m_Context.m_Tournament?.Alert(text); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - Participant p = m_Context.Participants[i]; - - for (int j = 0; j < p.Players.Length; ++j) - if (p.Players[j] != null) - p.Players[j].Mobile.SendMessage(0x35, text); - } - } - - public void Alert(string format, params object[] args) - { - Alert(string.Format(format, args)); - } - - public DDTeamInfo GetTeamInfo(Mobile mob) - { - int teamID = GetTeamID(mob); - - if (teamID >= 0) - return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; - - return null; - } - - 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 == null || pm.DuelPlayer.Eliminated) - return -1; - - return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); - } - - public int GetColor(Mobile mob) - { - return GetTeamInfo(mob)?.Color ?? -1; - } - - private void ApplyHues(Participant p, int hueOverride) - { - for (int 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) - { - Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); - } - - private void DelayBounce_Callback(Mobile mob, Container corpse) - { - DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; - - m_Context.RemoveAggressions(mob); - - if (dp != null && !dp.Eliminated) - mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); - else - m_Context.SendOutside(mob); - - m_Context.Refresh(mob, corpse); - DuelContext.Debuff(mob); - DuelContext.CancelSpell(mob); - mob.Frozen = false; - } - - public override bool OnDeath(Mobile mob, Container corpse) - { - Mobile killer = mob.FindMostRecentDamager(false); - - if (killer != null && killer.Player) - { - DDTeamInfo teamInfo = GetTeamInfo(killer); - DDTeamInfo victInfo = GetTeamInfo(mob); - - if (teamInfo != null && teamInfo != victInfo) - { - DDPlayerInfo playerInfo = teamInfo[killer]; - - if (playerInfo != null) - { - playerInfo.Kills += 1; - playerInfo.Score += 1; // base frag - - // 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; - } - } - - mob.CloseGump(); - mob.SendGump(new DDBoardGump(mob, this)); - - m_Context.Requip(mob, corpse); - DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); - - return false; - } - - public override void OnStart() - { - m_Capturable = true; - - if (m_CaptureTimer != null) - { - m_CaptureTimer.Stop(); - m_CaptureTimer = null; - } - - if (m_UncaptureTimer != null) - { - m_UncaptureTimer.Stop(); - m_UncaptureTimer = null; - } - - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - DDTeamInfo teamInfo = Controller.TeamInfo[i]; - - teamInfo.Game = this; - teamInfo.Reset(); - } - - if (Controller.PointA != null) - Controller.PointA.Game = this; - - if (Controller.PointB != null) - Controller.PointB.Game = this; - - for (int 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); - } - - private void Finish_Callback() - { - List teams = new List(); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - DDTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; - - if (teamInfo != null) - teams.Add(teamInfo); - } - - teams.Sort((a, b) => b.Score - a.Score); - - Tournament tourney = m_Context.m_Tournament; - - StringBuilder sb = new StringBuilder(); - - if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll) - { - sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); - sb.Append("-man FFA"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue) - { - sb.Append("Red v Blue"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.Faction) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team Faction"); - } - else if (tourney != null) - { - for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) - { - if (sb.Length > 0) - sb.Append('v'); - - sb.Append(tourney.PlayersPerParticipant); - } - } - - if (Controller != null) - sb.Append(' ').Append(Controller.Title); - - string title = sb.ToString(); - - DDTeamInfo winner = teams.Count > 0 ? teams[0] : null; - - for (int i = 0; i < teams.Count; ++i) - { - TrophyRank rank = TrophyRank.Bronze; - - if (i == 0) - rank = TrophyRank.Gold; - else if (i == 1) - rank = TrophyRank.Silver; - - DDPlayerInfo leader = teams[i].Leader; - - foreach (DDPlayerInfo pl in teams[i].Players.Values) - { - Mobile mob = pl.Player; - - if (mob == null) - continue; - - //"Red v Blue DD Champion" - - sb = new StringBuilder(); - - sb.Append(title); - - if (pl == leader) - sb.Append(" Leader"); - - if (pl.Score > 0) - { - sb.Append(": "); - - sb.Append(pl.Score.ToString("N0")); - sb.Append(pl.Score == 1 ? " point" : " points"); - - if (pl.Kills > 0) - { - sb.Append(", "); - sb.Append(pl.Kills.ToString("N0")); - sb.Append(pl.Kills == 1 ? " kill" : " kills"); - } - - if (pl.Captures > 0) - { - sb.Append(", "); - sb.Append(pl.Captures.ToString("N0")); - sb.Append(pl.Captures == 1 ? " capture" : " captures"); - } - } - - 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); - - int cash = pl.Score * 250; - - 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.", - rank.ToString().ToLower(), cash); - } - else - { - mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", - rank.ToString().ToLower()); - } - } - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - Participant p = m_Context.Participants[i]; - - for (int j = 0; j < p.Players.Length; ++j) - { - DuelPlayer dp = p.Players[j]; - - if (dp?.Mobile != null) - { - dp.Mobile.CloseGump(); - dp.Mobile.SendGump(new DDBoardGump(dp.Mobile, this)); - } - } - - if (i == winner.TeamID) - continue; - - for (int 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]); - } - - public override void OnStop() - { - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - DDTeamInfo 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; - - if (m_CaptureTimer != null) - { - m_CaptureTimer.Stop(); - m_CaptureTimer = null; - } - - if (m_UncaptureTimer != null) - { - m_UncaptureTimer.Stop(); - m_UncaptureTimer = null; - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], -1); - - m_FinishTimer?.Stop(); - m_FinishTimer = null; - } - - public void Dominate(DDWayPoint point, Mobile from, DDTeamInfo team) - { - if (point == null || from == null || team == null || !m_Capturable) - return; - - bool wasDom = Controller.PointA != null && Controller.PointB != null && - Controller.PointA.TeamOwner == Controller.PointB.TeamOwner && Controller.PointA.TeamOwner != null; - - point.TeamOwner = team; - Alert("{0} has captured {1}!", team.Name, point.Name); - - bool isDom = Controller.PointA != null && Controller.PointB != null && - Controller.PointA.TeamOwner == Controller.PointB.TeamOwner && Controller.PointA.TeamOwner != null; - - if (wasDom && !isDom) - { - Alert("Domination averted!"); - - Controller.PointA?.SetNonCaptureHue(); - Controller.PointB?.SetNonCaptureHue(); - m_CaptureTimer?.Stop(); - m_CaptureTimer = null; - } - - if (!wasDom && isDom) - { - m_CapStage = 0; - m_CaptureTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick); - m_CaptureTimer.Start(); - } - } - - private void CaptureTick() - { - DDTeamInfo team = null; - - if (Controller.PointA?.TeamOwner != null) - team = Controller.PointA.TeamOwner; - else if (Controller.PointB?.TeamOwner != null) - team = Controller.PointB.TeamOwner; - - if (team == null) - { - m_Capturable = true; - m_CaptureTimer?.Stop(); - m_CaptureTimer = null; - return; - } - - if (++m_CapStage < 10) - { - Alert("{0} is dominating... {1}", team.Name, 10 - m_CapStage); - - Controller.PointA?.SetCaptureHue(m_CapStage); - Controller.PointB?.SetCaptureHue(m_CapStage); - } - else - { - Alert("{0} has scored!", team.Name); - - team.Score += 100; - team.Captures += 1; - - m_Capturable = false; - m_CapStage = 0; - m_CaptureTimer.Stop(); - m_CaptureTimer = null; - - if (Controller.PointA != null) - { - Controller.PointA.TeamOwner = null; - Controller.PointA.SetUncapturableHue(); - } - - if (Controller.PointB != null) - { - Controller.PointB.TeamOwner = null; - Controller.PointB.SetUncapturableHue(); - } - - m_UncaptureTimer = Timer.DelayCall(TimeSpan.FromSeconds(30.0), UncaptureTick); - m_UncaptureTimer.Start(); - } - } - - private void UncaptureTick() - { - m_Capturable = true; - - if (m_CaptureTimer != null) - { - m_CaptureTimer.Stop(); - m_CaptureTimer = null; - } - - if (m_UncaptureTimer != null) - { - m_UncaptureTimer.Stop(); - m_UncaptureTimer = null; - } - - if (Controller.PointA != null) - { - Controller.PointA.TeamOwner = null; - Controller.PointA.SetNonCaptureHue(); - } - - if (Controller.PointB != null) - { - Controller.PointB.TeamOwner = null; - Controller.PointB.SetNonCaptureHue(); - } - } - } - - public class DDWayPoint : BaseAddon - { - public const int UncapturableHue = 0x497; - public const int NonCapturedHue = 0x38A; - private DDGame m_Game; - private DDTeamInfo m_TeamOwner; - - [Constructible] - public DDWayPoint() - { - ItemID = 0x519; - Visible = true; - Name = "SET MY NAME"; - - AddComponent(new DDStep(0x7A8), -1, -1, -5); - AddComponent(new DDStep(0x7A6), 0, -1, -5); - AddComponent(new DDStep(0x7AA), 1, -1, -5); - - AddComponent(new DDStep(0x7A5), 1, 0, -5); - - AddComponent(new DDStep(0x7A9), 1, 1, -5); - AddComponent(new DDStep(0x7A4), 0, 1, -5); - AddComponent(new DDStep(0x7AB), -1, 1, -5); - - AddComponent(new DDStep(0x7A7), -1, 0, -5); - - SetUncapturableHue(); - } - - public DDWayPoint(Serial serial) : base(serial) - { - } - - public override bool ShareHue => false; - - public DDGame Game - { - get => m_Game; - set - { - m_Game = value; - m_TeamOwner = null; - - if (m_Game != null) - SetNonCaptureHue(); - else - SetUncapturableHue(); - } - } - - public DDTeamInfo TeamOwner - { - get => m_TeamOwner; - set - { - m_TeamOwner = value; - - SetNonCaptureHue(); - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - - public void SetUncapturableHue() - { - for (int i = 0; i < Components.Count; i++) - Components[i].Hue = UncapturableHue; - Hue = UncapturableHue; - } - - public void SetNonCaptureHue() - { - for (int 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 (int 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) - { - if (m_Game == null) - { - SetUncapturableHue(); - } - else if (from.Alive) - { - DDTeamInfo team = m_Game.GetTeamInfo(from); - - if (team != null && team != TeamOwner) - m_Game.Dominate(this, from, team); - } - - return true; - } - - public class DDStep : AddonComponent - { - public DDStep(int itemID) : base(itemID) - { - Visible = true; - } - - public DDStep(Serial serial) : base(serial) - { - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); //version - } - - public override bool OnMoveOver(Mobile m) - { - return Addon.OnMoveOver(m); - } - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using System.Text; +using Server.Gumps; +using Server.Items; +using Server.Mobiles; + +namespace Server.Engines.ConPVP +{ + public sealed class DDBoard : Item + { + public DDTeamInfo m_TeamInfo; + + [Constructible] + public DDBoard() + : base(7774) + { + Movable = false; + } + + public DDBoard(Serial serial) + : base(serial) + { + } + + public override string DefaultName => "scoreboard"; + + public override void OnDoubleClick(Mobile from) + { + if (m_TeamInfo?.Game != null) + { + from.CloseGump(); + from.SendGump(new DDBoardGump(from, m_TeamInfo.Game)); + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + } + + public class DDBoardGump : Gump + { + private const int LabelColor32 = 0xFFFFFF; + private const int BlackColor32 = 0x000000; + +// private DDGame m_Game; + + public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null) + : base(60, 60) + { +// m_Game = game; + + DDTeamInfo ourTeam = game.GetTeamInfo(mob); + + List entries = new List(); + + if (section == null) + for (int i = 0; i < game.Context.Participants.Count; ++i) + { + DDTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; + + if (teamInfo != null) + entries.Add(teamInfo); + } + else + foreach (DDPlayerInfo player in section.Players.Values) + if (player.Score > 0) + entries.Add(player); + + entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); + + int height = 0; + + if (section == null) + height = 73 + entries.Count * 75 + 28; + + Closable = false; + + AddPage(0); + + AddBackground(1, 1, 398, height, 3600); + + AddImageTiled(16, 15, 369, height - 29, 3604); + + for (int i = 0; i < entries.Count; i += 1) + AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + + AddAlphaRegion(16, 15, 369, height - 29); + + AddImage(215, -45, 0xEE40); + //AddImage( 330, 141, 0x8BA ); + + AddBorderedText(22, 22, 294, 20, Center("DD Scoreboard"), LabelColor32, BlackColor32); + + AddImageTiled(32, 50, 264, 1, 9107); + AddImageTiled(42, 52, 264, 1, 9157); + + if (section == null) + for (int i = 0; i < entries.Count; ++i) + { + DDTeamInfo teamInfo = entries[i] as DDTeamInfo; + + AddImage(30, 70 + i * 75, 10152); + AddImage(30, 85 + i * 75, 10151); + AddImage(30, 100 + i * 75, 10151); + AddImage(30, 106 + i * 75, 10154); + + AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); + + int nameColor = LabelColor32; + int borderColor = BlackColor32; + + switch (teamInfo.Color) + { + case 0x47E: + nameColor = 0xFFFFFF; + break; + + case 0x4F2: + nameColor = 0x3399FF; + break; + + case 0x4F7: + nameColor = 0x33FF33; + break; + + case 0x4FC: + nameColor = 0xFF00FF; + break; + + case 0x021: + nameColor = 0xFF3333; + break; + + case 0x01A: + nameColor = 0xFF66FF; + break; + + case 0x455: + nameColor = 0x333333; + borderColor = 0xFFFFFF; + break; + } + + AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name}", nameColor, + borderColor); + + AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); + AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); + AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Captures:", 0xFFC000, BlackColor32); + AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, + BlackColor32); + + DDPlayerInfo pl = teamInfo.Leader; + + 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); + } + + public string Center(string text) + { + return $"
{text}
"; + } + + public string Color(string text, int color) + { + return $"{text}"; + } + + private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) + { + AddColoredText(x - 1, y - 1, width, height, text, borderColor); + AddColoredText(x - 1, y + 1, width, height, text, borderColor); + AddColoredText(x + 1, y - 1, width, height, text, borderColor); + AddColoredText(x + 1, y + 1, width, height, text, borderColor); + AddColoredText(x, y, width, height, text, color); + } + + 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 sealed class DDPlayerInfo : IRankedCTF + { + private int m_Captures; + + private int m_Kills; + + private int m_Score; + private DDTeamInfo m_TeamInfo; + + public DDPlayerInfo(DDTeamInfo teamInfo, Mobile player) + { + m_TeamInfo = teamInfo; + Player = player; + } + + public Mobile Player{ get; } + + public string Name => Player.Name; + + public int Kills + { + get => m_Kills; + set + { + m_TeamInfo.Kills += value - m_Kills; + m_Kills = value; + } + } + + public int Captures + { + get => m_Captures; + set + { + m_TeamInfo.Captures += value - m_Captures; + m_Captures = value; + } + } + + public int Score + { + get => m_Score; + set + { + m_TeamInfo.Score += value - m_Score; + m_Score = value; + + if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + m_TeamInfo.Leader = this; + } + } + } + + [PropertyObject] + public sealed class DDTeamInfo : IRankedCTF + { + public DDTeamInfo(int teamID) + { + TeamID = teamID; + Players = new Dictionary(); + } + + public DDTeamInfo(int teamID, GenericReader ip) + { + TeamID = teamID; + Players = new Dictionary(); + + int version = ip.ReadEncodedInt(); + + switch (version) + { + case 0: + { + Board = ip.ReadItem() as DDBoard; + TeamName = ip.ReadString(); + Color = ip.ReadEncodedInt(); + Origin = ip.ReadPoint3D(); + break; + } + } + } + + public DDGame Game{ get; set; } + + public int TeamID{ get; } + + public DDPlayerInfo Leader{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public DDBoard Board{ get; set; } + + public Dictionary Players{ get; } + + public DDPlayerInfo this[Mobile mob] + { + get + { + if (mob == null) + return null; + + if (!Players.TryGetValue(mob, out DDPlayerInfo val)) + Players[mob] = val = new DDPlayerInfo(this, mob); + + return val; + } + } + + [CommandProperty(AccessLevel.GameMaster)] + public int Color{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public string TeamName{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public Point3D Origin{ get; set; } + + public string Name => $"{TeamName} Team"; + + public int Kills{ get; set; } + + public int Captures{ get; set; } + + public int Score{ get; set; } + + public void Reset() + { + Kills = 0; + Captures = 0; + + Score = 0; + + Leader = null; + + Players.Clear(); + + if (Board != null) + Board.m_TeamInfo = this; + } + + public void Serialize(GenericWriter op) + { + op.WriteEncodedInt(0); // version + + op.Write(Board); + op.Write(TeamName); + op.WriteEncodedInt(Color); + op.Write(Origin); + } + + public override string ToString() + { + return "..."; + } + } + + public sealed class DDController : EventController + { + [Constructible] + public DDController() + { + Visible = false; + Movable = false; + + Duration = TimeSpan.FromMinutes(30.0); + + TeamInfo = new DDTeamInfo[2]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new DDTeamInfo(i); + } + + public DDController(Serial serial) + : base(serial) + { + } + + public DDTeamInfo[] TeamInfo{ get; private set; } + + [CommandProperty(AccessLevel.GameMaster)] + public DDTeamInfo Team1 => TeamInfo[0]; + + [CommandProperty(AccessLevel.GameMaster)] + public DDTeamInfo Team2 => TeamInfo[1]; + + [CommandProperty(AccessLevel.GameMaster)] + public DDWayPoint PointA{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public DDWayPoint PointB{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public TimeSpan Duration{ get; set; } + + public override string Title => "DoubleDom"; + + public override string DefaultName => "DD Controller"; + + public override string GetTeamName(int teamID) + { + return TeamInfo[teamID % TeamInfo.Length].Name; + } + + public override EventGame Construct(DuelContext context) + { + return new DDGame(this, context); + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + + writer.Write(Duration); + + writer.WriteEncodedInt(TeamInfo.Length); + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i].Serialize(writer); + + writer.Write(PointA); + writer.Write(PointB); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 0: + { + Duration = reader.ReadTimeSpan(); + TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new DDTeamInfo(i, reader); + + PointA = reader.ReadItem() as DDWayPoint; + PointB = reader.ReadItem() as DDWayPoint; + + break; + } + } + } + } + + public sealed class DDGame : EventGame + { + private int m_CapStage; + + private bool m_Capturable = true; + private Timer m_CaptureTimer; + + private Timer m_FinishTimer; + private Timer m_UncaptureTimer; + + public DDGame(DDController controller, DuelContext context) : base(context) + { + Controller = controller; + } + + public DDController Controller{ get; } + + public Map Facet + { + get + { + if (m_Context.Arena != null) + return m_Context.Arena.Facet; + + return Controller.Map; + } + } + + public void Alert(string text) + { + m_Context.m_Tournament?.Alert(text); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + Participant p = m_Context.Participants[i]; + + for (int j = 0; j < p.Players.Length; ++j) + if (p.Players[j] != null) + p.Players[j].Mobile.SendMessage(0x35, text); + } + } + + public void Alert(string format, params object[] args) + { + Alert(string.Format(format, args)); + } + + public DDTeamInfo GetTeamInfo(Mobile mob) + { + int teamID = GetTeamID(mob); + + if (teamID >= 0) + return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + + return null; + } + + 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 == null || pm.DuelPlayer.Eliminated) + return -1; + + return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); + } + + public int GetColor(Mobile mob) + { + return GetTeamInfo(mob)?.Color ?? -1; + } + + private void ApplyHues(Participant p, int hueOverride) + { + for (int 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) + { + Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); + } + + private void DelayBounce_Callback(Mobile mob, Container corpse) + { + DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; + + 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); + DuelContext.CancelSpell(mob); + mob.Frozen = false; + } + + public override bool OnDeath(Mobile mob, Container corpse) + { + Mobile killer = mob.FindMostRecentDamager(false); + + if (killer?.Player == true) + { + DDTeamInfo teamInfo = GetTeamInfo(killer); + DDTeamInfo victInfo = GetTeamInfo(mob); + + if (teamInfo != null && teamInfo != victInfo) + { + DDPlayerInfo playerInfo = teamInfo[killer]; + + if (playerInfo != null) + { + playerInfo.Kills += 1; + playerInfo.Score += 1; // base frag + + // 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; + } + } + + mob.CloseGump(); + mob.SendGump(new DDBoardGump(mob, this)); + + m_Context.Requip(mob, corpse); + DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); + + return false; + } + + public override void OnStart() + { + m_Capturable = true; + + if (m_CaptureTimer != null) + { + m_CaptureTimer.Stop(); + m_CaptureTimer = null; + } + + if (m_UncaptureTimer != null) + { + m_UncaptureTimer.Stop(); + m_UncaptureTimer = null; + } + + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + DDTeamInfo teamInfo = Controller.TeamInfo[i]; + + teamInfo.Game = this; + teamInfo.Reset(); + } + + if (Controller.PointA != null) + Controller.PointA.Game = this; + + if (Controller.PointB != null) + Controller.PointB.Game = this; + + for (int 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); + } + + private void Finish_Callback() + { + List teams = new List(); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + DDTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; + + if (teamInfo != null) + teams.Add(teamInfo); + } + + teams.Sort((a, b) => b.Score - a.Score); + + Tournament tourney = m_Context.m_Tournament; + + StringBuilder sb = new StringBuilder(); + + if (tourney != null) + { + if (tourney.TourneyType == TourneyType.FreeForAll) + { + sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); + sb.Append("-man FFA"); + } + else if (tourney.TourneyType == TourneyType.RandomTeam) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team"); + } + else if (tourney.TourneyType == TourneyType.RedVsBlue) + { + sb.Append("Red v Blue"); + } + else if (tourney.TourneyType == TourneyType.Faction) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team Faction"); + } + else + { + for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) + { + if (sb.Length > 0) + sb.Append('v'); + + sb.Append(tourney.PlayersPerParticipant); + } + } + } + + if (Controller != null) + sb.Append(' ').Append(Controller.Title); + + string title = sb.ToString(); + + DDTeamInfo winner = teams.Count > 0 ? teams[0] : null; + + for (int i = 0; i < teams.Count; ++i) + { + TrophyRank rank = TrophyRank.Bronze; + + if (i == 0) + rank = TrophyRank.Gold; + else if (i == 1) + rank = TrophyRank.Silver; + + DDPlayerInfo leader = teams[i].Leader; + + foreach (DDPlayerInfo pl in teams[i].Players.Values) + { + Mobile mob = pl.Player; + + if (mob == null) + continue; + + //"Red v Blue DD Champion" + + sb = new StringBuilder(); + + sb.Append(title); + + if (pl == leader) + sb.Append(" Leader"); + + if (pl.Score > 0) + { + sb.Append(": "); + + sb.Append(pl.Score.ToString("N0")); + sb.Append(pl.Score == 1 ? " point" : " points"); + + if (pl.Kills > 0) + { + sb.Append(", "); + sb.Append(pl.Kills.ToString("N0")); + sb.Append(pl.Kills == 1 ? " kill" : " kills"); + } + + if (pl.Captures > 0) + { + sb.Append(", "); + sb.Append(pl.Captures.ToString("N0")); + sb.Append(pl.Captures == 1 ? " capture" : " captures"); + } + } + + 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); + + int cash = pl.Score * 250; + + 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.", + rank.ToString().ToLower(), cash); + } + else + { + mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", + rank.ToString().ToLower()); + } + } + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + Participant p = m_Context.Participants[i]; + + for (int j = 0; j < p.Players.Length; ++j) + { + DuelPlayer dp = p.Players[j]; + + if (dp?.Mobile != null) + { + dp.Mobile.CloseGump(); + dp.Mobile.SendGump(new DDBoardGump(dp.Mobile, this)); + } + } + + if (i == winner.TeamID) + continue; + + for (int 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]); + } + + public override void OnStop() + { + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + DDTeamInfo 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; + + if (m_CaptureTimer != null) + { + m_CaptureTimer.Stop(); + m_CaptureTimer = null; + } + + if (m_UncaptureTimer != null) + { + m_UncaptureTimer.Stop(); + m_UncaptureTimer = null; + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], -1); + + m_FinishTimer?.Stop(); + m_FinishTimer = null; + } + + public void Dominate(DDWayPoint point, Mobile from, DDTeamInfo team) + { + if (point == null || from == null || team == null || !m_Capturable) + return; + + bool wasDom = Controller.PointA?.TeamOwner == Controller.PointB?.TeamOwner && Controller.PointA?.TeamOwner != null; + + point.TeamOwner = team; + Alert("{0} has captured {1}!", team.Name, point.Name); + + bool isDom = Controller.PointA?.TeamOwner == Controller.PointB?.TeamOwner && Controller.PointA?.TeamOwner != null; + + if (wasDom && !isDom) + { + Alert("Domination averted!"); + + Controller.PointA?.SetNonCaptureHue(); + Controller.PointB?.SetNonCaptureHue(); + m_CaptureTimer?.Stop(); + m_CaptureTimer = null; + } + + if (!wasDom && isDom) + { + m_CapStage = 0; + m_CaptureTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick); + m_CaptureTimer.Start(); + } + } + + private void CaptureTick() + { + DDTeamInfo team = Controller.PointA?.TeamOwner ?? Controller.PointB?.TeamOwner; + + if (team == null) + { + m_Capturable = true; + m_CaptureTimer?.Stop(); + m_CaptureTimer = null; + return; + } + + if (++m_CapStage < 10) + { + Alert("{0} is dominating... {1}", team.Name, 10 - m_CapStage); + + Controller.PointA?.SetCaptureHue(m_CapStage); + Controller.PointB?.SetCaptureHue(m_CapStage); + } + else + { + Alert("{0} has scored!", team.Name); + + team.Score += 100; + team.Captures += 1; + + m_Capturable = false; + m_CapStage = 0; + m_CaptureTimer.Stop(); + m_CaptureTimer = null; + + if (Controller.PointA != null) + { + Controller.PointA.TeamOwner = null; + Controller.PointA.SetUncapturableHue(); + } + + if (Controller.PointB != null) + { + Controller.PointB.TeamOwner = null; + Controller.PointB.SetUncapturableHue(); + } + + m_UncaptureTimer = Timer.DelayCall(TimeSpan.FromSeconds(30.0), UncaptureTick); + m_UncaptureTimer.Start(); + } + } + + private void UncaptureTick() + { + m_Capturable = true; + + if (m_CaptureTimer != null) + { + m_CaptureTimer.Stop(); + m_CaptureTimer = null; + } + + if (m_UncaptureTimer != null) + { + m_UncaptureTimer.Stop(); + m_UncaptureTimer = null; + } + + if (Controller.PointA != null) + { + Controller.PointA.TeamOwner = null; + Controller.PointA.SetNonCaptureHue(); + } + + if (Controller.PointB != null) + { + Controller.PointB.TeamOwner = null; + Controller.PointB.SetNonCaptureHue(); + } + } + } + + public class DDWayPoint : BaseAddon + { + public const int UncapturableHue = 0x497; + public const int NonCapturedHue = 0x38A; + private DDGame m_Game; + private DDTeamInfo m_TeamOwner; + + [Constructible] + public DDWayPoint() + { + ItemID = 0x519; + Visible = true; + Name = "SET MY NAME"; + + AddComponent(new DDStep(0x7A8), -1, -1, -5); + AddComponent(new DDStep(0x7A6), 0, -1, -5); + AddComponent(new DDStep(0x7AA), 1, -1, -5); + + AddComponent(new DDStep(0x7A5), 1, 0, -5); + + AddComponent(new DDStep(0x7A9), 1, 1, -5); + AddComponent(new DDStep(0x7A4), 0, 1, -5); + AddComponent(new DDStep(0x7AB), -1, 1, -5); + + AddComponent(new DDStep(0x7A7), -1, 0, -5); + + SetUncapturableHue(); + } + + public DDWayPoint(Serial serial) : base(serial) + { + } + + public override bool ShareHue => false; + + public DDGame Game + { + get => m_Game; + set + { + m_Game = value; + m_TeamOwner = null; + + if (m_Game != null) + SetNonCaptureHue(); + else + SetUncapturableHue(); + } + } + + public DDTeamInfo TeamOwner + { + get => m_TeamOwner; + set + { + m_TeamOwner = value; + + SetNonCaptureHue(); + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + + public void SetUncapturableHue() + { + for (int i = 0; i < Components.Count; i++) + Components[i].Hue = UncapturableHue; + Hue = UncapturableHue; + } + + public void SetNonCaptureHue() + { + for (int 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 (int 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) + { + if (m_Game == null) + { + SetUncapturableHue(); + } + else if (from.Alive) + { + DDTeamInfo team = m_Game.GetTeamInfo(from); + + if (team != null && team != TeamOwner) + m_Game.Dominate(this, from, team); + } + + return true; + } + + public class DDStep : AddonComponent + { + public DDStep(int itemID) : base(itemID) + { + Visible = true; + } + + public DDStep(Serial serial) : base(serial) + { + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); //version + } + + public override bool OnMoveOver(Mobile m) + { + return Addon.OnMoveOver(m); + } + } + } +} diff --git a/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs b/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs index 231d693bb..f93023b88 100644 --- a/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs +++ b/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs @@ -1,1200 +1,1184 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using Server.Gumps; -using Server.Items; -using Server.Mobiles; -using Server.Network; - -namespace Server.Engines.ConPVP -{ - public class HillOfTheKing : Item - { - private KHGame m_Game; - private KingTimer m_KingTimer; - - [Constructible] - public HillOfTheKing() - : base(0x520) - { - ScoreInterval = 10; - m_Game = null; - King = null; - Movable = false; - - Name = "the hill"; - } - - public HillOfTheKing(Serial s) - : base(s) - { - } - - public Mobile King{ get; private set; } - - public KHGame Game - { - get => m_Game; - set - { - if (m_Game != value) - { - m_KingTimer?.Stop(); - m_Game = value; - King = null; - } - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int ScoreInterval{ get; set; } - - public int CapturesSoFar - { - get - { - if (m_KingTimer != null) - return m_KingTimer.Captures; - return 0; - } - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 0: - { - ScoreInterval = reader.ReadEncodedInt(); - break; - } - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - - writer.WriteEncodedInt(ScoreInterval); - } - - private bool CanBeKing(Mobile m) - { - // Game running? - if (m_Game == null) - return false; - - // Mobile exists and is alive and is a player? - if (m == null || m.Deleted || !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 - if (m_Game.GetTeamInfo(m) == null) - return false; - - return true; - } - - public override bool OnMoveOver(Mobile m) - { - if (m_Game == null || m == null || !m.Alive) - return base.OnMoveOver(m); - - if (CanBeKing(m)) - { - if (base.OnMoveOver(m)) - { - ReKingify(m); - return true; - } - } - else - { - // 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; - } - - public override bool OnMoveOff(Mobile m) - { - if (base.OnMoveOff(m)) - { - if (King == m) - DeKingify(); - - return true; - } - - return false; - } - - public virtual void OnKingDied(Mobile king, KHTeamInfo kingTeam, Mobile killer, KHTeamInfo killerTeam) - { - if (m_Game != null && CapturesSoFar > 0 && killer != null && king != null && kingTeam != null && - killerTeam != null) - { - string kingName = king.Name; - if (kingName == null) - kingName = ""; - string killerName = killer.Name; - if (killerName == null) - killerName = ""; - - m_Game.Alert("{0} ({1}) was dethroned by {2} ({3})!", kingName, kingTeam.Name, killerName, killerTeam.Name); - } - - DeKingify(); - } - - private void DeKingify() - { - PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Free!"); - - m_KingTimer?.Stop(); - - King = null; - } - - private void ReKingify(Mobile m) - { - if (m_Game == null || m == null) - return; - - if (m_Game.GetTeamInfo(m) == null) - return; - - King = m; - - if (m_KingTimer == null) - m_KingTimer = new KingTimer(this); - m_KingTimer.Stop(); - m_KingTimer.StartHillTicker(); - - if (King.Name != null) - PublicOverheadMessage(MessageType.Regular, 0x0481, false, $"Taken by {King.Name}!"); - } - - private class KingTimer : Timer - { - private int m_Counter; - private HillOfTheKing m_Hill; - - public KingTimer(HillOfTheKing hill) - : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) - { - m_Hill = hill; - Captures = 0; - m_Counter = 0; - - Priority = TimerPriority.FiftyMS; - } - - public int Captures{ get; private set; } - - public void StartHillTicker() - { - Captures = 0; - m_Counter = 0; - - Start(); - } - - protected override void OnTick() - { - KHPlayerInfo pi = null; - - if (m_Hill == null || m_Hill.Deleted || m_Hill.Game == null) - { - Stop(); - return; - } - - if (m_Hill.King == null || m_Hill.King.Deleted || !m_Hill.King.Alive) - { - m_Hill.DeKingify(); - Stop(); - return; - } - - KHTeamInfo ti = m_Hill.Game.GetTeamInfo(m_Hill.King); - if (ti != null) - pi = ti[m_Hill.King]; - - if (ti == null || pi == null) - { - // error, bail - m_Hill.DeKingify(); - Stop(); - return; - } - - m_Counter++; - - m_Hill.King.RevealingAction(); - - if (m_Counter >= m_Hill.ScoreInterval) - { - string hill = m_Hill.Name; - string king = m_Hill.King.Name ?? ""; - - if (string.IsNullOrEmpty(hill)) - hill = "the hill"; - - m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill); - - m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Capture!"); - - pi.Captures++; - Captures++; - - pi.Score += m_Counter; - - m_Counter = 0; - } - else - { - m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, - (m_Hill.ScoreInterval - m_Counter).ToString()); - } - } - } - } - - public class KHBoard : Item - { - private KHController m_Controller; - public KHGame m_Game; - - [Constructible] - public KHBoard() - : base(7774) - { - Name = "King of the Hill Scoreboard"; - Movable = false; - } - - public KHBoard(Serial serial) - : base(serial) - { - } - - [CommandProperty(AccessLevel.GameMaster)] - public KHController Controller - { - get => m_Controller; - set - { - if (m_Controller != value) - { - m_Controller?.RemoveBoard(this); - m_Controller = value; - m_Controller?.AddBoard(this); - } - } - } - - public override void OnDoubleClick(Mobile from) - { - if (m_Game != null) - { - from.CloseGump(); - from.SendGump(new KHBoardGump(from, m_Game)); - } - else - { - from.SendMessage("There is no King of the Hill game in progress."); - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - - writer.Write(m_Controller); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 0: - { - m_Controller = reader.ReadItem() as KHController; - break; - } - } - } - } - - public sealed class KHBoardGump : Gump - { - private const int LabelColor32 = 0xFFFFFF; - private const int BlackColor32 = 0x000000; - - private KHGame m_Game; - - public KHBoardGump(Mobile mob, KHGame game) - : base(60, 60) - { - m_Game = game; - - KHTeamInfo ourTeam = game.GetTeamInfo(mob); - - List entries = new List(); - - for (int i = 0; i < game.Context.Participants.Count; ++i) - { - KHTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; - - if (teamInfo != null) - entries.Add(teamInfo); - } - - entries.Sort(); - /* - delegate( IRankedCTF a, IRankedCTF b ) - { - return b.Score - a.Score; - } );*/ - - int height = 73 + entries.Count * 75 + 28; - - Closable = false; - - AddPage(0); - - AddBackground(1, 1, 398, height, 3600); - - AddImageTiled(16, 15, 369, height - 29, 3604); - - for (int i = 0; i < entries.Count; i += 1) - AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); - - AddAlphaRegion(16, 15, 369, height - 29); - - AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); - - AddBorderedText(22, 22, 294, 20, Center("King of the Hill Scoreboard"), LabelColor32, BlackColor32); - - AddImageTiled(32, 50, 264, 1, 9107); - AddImageTiled(42, 52, 264, 1, 9157); - - for (int i = 0; i < entries.Count; ++i) - { - KHTeamInfo teamInfo = entries[i]; - - AddImage(30, 70 + i * 75, 10152); - AddImage(30, 85 + i * 75, 10151); - AddImage(30, 100 + i * 75, 10151); - AddImage(30, 106 + i * 75, 10154); - - AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); - - int nameColor = LabelColor32; - int borderColor = BlackColor32; - - switch (teamInfo.Color) - { - case 0x47E: - nameColor = 0xFFFFFF; - break; - - case 0x4F2: - nameColor = 0x3399FF; - break; - - case 0x4F7: - nameColor = 0x33FF33; - break; - - case 0x4FC: - nameColor = 0xFF00FF; - break; - - case 0x021: - nameColor = 0xFF3333; - break; - - case 0x01A: - nameColor = 0xFF66FF; - break; - - case 0x455: - nameColor = 0x333333; - borderColor = 0xFFFFFF; - break; - } - - AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name}", nameColor, - borderColor); - - AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); - AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); - AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); - - AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Captures:", 0xFFC000, BlackColor32); - AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, BlackColor32); - - string leader = null; - if (teamInfo.Leader != null) - leader = teamInfo.Leader.Name; - if (leader == null) - leader = "(none)"; - - AddBorderedText(235 + 10, 85 + i * 75, 250, 20, "Leader:", 0xFFC000, BlackColor32); - AddBorderedText(235 + 15, 105 + i * 75, 250, 20, leader, 0xFFC000, BlackColor32); - } - - AddButton(314, height - 42, 247, 248, 1, GumpButtonType.Reply, 0); - } - - public string Center(string text) - { - return $"
{text}
"; - } - - public string Color(string text, int color) - { - return $"{text}"; - } - - private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) - { - AddColoredText(x - 1, y - 1, width, height, text, borderColor); - AddColoredText(x - 1, y + 1, width, height, text, borderColor); - AddColoredText(x + 1, y - 1, width, height, text, borderColor); - AddColoredText(x + 1, y + 1, width, height, text, borderColor); - AddColoredText(x, y, width, height, text, color); - } - - private void AddColoredText(int x, int y, int width, int height, string text, int color) - { - if (color == 0) - AddHtml(x, y, width, height, text, false, false); - else - AddHtml(x, y, width, height, Color(text, color), false, false); - } - } - - public sealed class KHPlayerInfo : IRankedCTF, IComparable - { - private int m_Captures; - - private int m_Kills; - private int m_Score; - private KHTeamInfo m_TeamInfo; - - public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player) - { - m_TeamInfo = teamInfo; - Player = player; - } - - public Mobile Player{ get; } - - public int CompareTo(KHPlayerInfo pi) - { - int res = pi.Score.CompareTo(Score); - if (res != 0) - return res; - - res = pi.Captures.CompareTo(Captures); - - return res != 0 ? res : pi.Kills.CompareTo(Kills); - } - - public string Name => Player.Name ?? ""; - - public int Kills - { - get => m_Kills; - set - { - m_TeamInfo.Kills += value - m_Kills; - m_Kills = value; - } - } - - public int Captures - { - get => m_Captures; - set - { - m_TeamInfo.Captures += value - m_Captures; - m_Captures = value; - } - } - - public int Score - { - get => m_Score; - set - { - m_TeamInfo.Score += value - m_Score; - m_Score = value; - - if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) - m_TeamInfo.Leader = this; - } - } - } - - [PropertyObject] - public sealed class KHTeamInfo : IRankedCTF, IComparable - { - public KHTeamInfo(int teamID) - { - TeamID = teamID; - Players = new Dictionary(); - } - - public KHTeamInfo(int teamID, GenericReader ip) - { - TeamID = teamID; - Players = new Dictionary(); - - int version = ip.ReadEncodedInt(); - - switch (version) - { - case 0: - { - TeamName = ip.ReadString(); - Color = ip.ReadEncodedInt(); - break; - } - } - } - - public KHGame Game{ get; set; } - - public int TeamID{ get; } - - public KHPlayerInfo Leader{ get; set; } - - public Dictionary Players{ get; } - - public KHPlayerInfo this[Mobile mob] - { - get - { - if (mob == null) - return null; - - if (!Players.TryGetValue(mob, out KHPlayerInfo val)) - Players[mob] = val = new KHPlayerInfo(this, mob); - - return val; - } - } - - [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public string TeamName{ get; set; } - - public int CompareTo(object obj) - { - KHTeamInfo ti = (KHTeamInfo)obj; - int res = ti.Score.CompareTo(Score); - if (res == 0) - { - res = ti.Captures.CompareTo(Captures); - - if (res == 0) - res = ti.Kills.CompareTo(Kills); - } - - return res; - } - - public string Name - { - get - { - if (TeamName == null) - return "(null) Team"; - return $"{TeamName} Team"; - } - } - - public int Kills{ get; set; } - - public int Captures{ get; set; } - - public int Score{ get; set; } - - public void Reset() - { - Kills = 0; - Captures = 0; - Score = 0; - - Leader = null; - - Players.Clear(); - } - - public void Serialize(GenericWriter op) - { - op.WriteEncodedInt(0); // version - - op.Write(TeamName); - op.WriteEncodedInt(Color); - } - - public override string ToString() - { - if (TeamName != null) - return $"({Name}) ..."; - return "..."; - } - } - - public sealed class KHController : EventController - { - private int m_ScoreInterval; - - [Constructible] - public KHController() - { - Visible = false; - Movable = false; - - Name = "King of the Hill Controller"; - - Duration = TimeSpan.FromMinutes(30.0); - Boards = new List(); - Hills = new HillOfTheKing[4]; - TeamInfo = new KHTeamInfo[8]; - - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new KHTeamInfo(i); - } - - public KHController(Serial serial) - : base(serial) - { - } - - public KHTeamInfo[] TeamInfo{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team1_W => TeamInfo[0]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team2_E => TeamInfo[1]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team3_N => TeamInfo[2]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team4_S => TeamInfo[3]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team5_NW => TeamInfo[4]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team6_SE => TeamInfo[5]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team7_SW => TeamInfo[6]; - - [CommandProperty(AccessLevel.GameMaster)] - public KHTeamInfo Team8_NE => TeamInfo[7]; - - public HillOfTheKing[] Hills{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public HillOfTheKing Hill1 - { - get => Hills[0]; - set => Hills[0] = value; - } - - [CommandProperty(AccessLevel.GameMaster)] - public HillOfTheKing Hill2 - { - get => Hills[1]; - set => Hills[1] = value; - } - - [CommandProperty(AccessLevel.GameMaster)] - public HillOfTheKing Hill3 - { - get => Hills[2]; - set => Hills[2] = value; - } - - [CommandProperty(AccessLevel.GameMaster)] - public HillOfTheKing Hill4 - { - get => Hills[3]; - set => Hills[3] = value; - } - - public List Boards{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } - - public override string Title => "King of the Hill"; - - public override string GetTeamName(int teamID) - { - return TeamInfo[teamID % TeamInfo.Length].Name; - } - - public override EventGame Construct(DuelContext context) - { - return new KHGame(this, context); - } - - public void RemoveBoard(KHBoard b) - { - if (b != null) - { - Boards.Remove(b); - b.m_Game = null; - } - } - - public void AddBoard(KHBoard b) - { - if (b != null) - Boards.Add(b); - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - - writer.WriteEncodedInt(m_ScoreInterval); - writer.Write(Duration); - - writer.WriteItemList(Boards, true); - - writer.WriteEncodedInt(Hills.Length); - for (int i = 0; i < Hills.Length; ++i) - writer.Write(Hills[i]); - - writer.WriteEncodedInt(TeamInfo.Length); - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i].Serialize(writer); - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - - switch (version) - { - case 0: - { - m_ScoreInterval = reader.ReadEncodedInt(); - - Duration = reader.ReadTimeSpan(); - - Boards = reader.ReadStrongItemList(); - - Hills = new HillOfTheKing[reader.ReadEncodedInt()]; - for (int i = 0; i < Hills.Length; ++i) - Hills[i] = reader.ReadItem() as HillOfTheKing; - - TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()]; - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new KHTeamInfo(i, reader); - - break; - } - } - } - } - - public sealed class KHGame : EventGame - { - private Timer m_FinishTimer; - - public KHGame(KHController controller, DuelContext context) : base(context) - { - Controller = controller; - } - - public KHController Controller{ get; } - - public Map Facet - { - get - { - if (m_Context?.Arena != null) - return m_Context.Arena.Facet; - - return Controller.Map; - } - } - - public override bool CantDoAnything(Mobile mob) - { - if (mob != null && GetTeamInfo(mob) != null && Controller != null) - for (int i = 0; i < Controller.Hills.Length; i++) - if (Controller.Hills[i] != null && Controller.Hills[i].King == mob) - return true; - - return false; - } - - public void Alert(string text) - { - m_Context.m_Tournament?.Alert(text); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - Participant p = m_Context.Participants[i]; - - for (int j = 0; j < p.Players.Length; ++j) - if (p.Players[j] != null) - p.Players[j].Mobile.SendMessage(0x35, text); - } - } - - public void Alert(string format, params object[] args) - { - Alert(string.Format(format, args)); - } - - public KHTeamInfo GetTeamInfo(Mobile mob) - { - int teamID = GetTeamID(mob); - - if (teamID >= 0) - return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; - - return null; - } - - 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 == null || pm.DuelPlayer.Eliminated) - return -1; - - return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); - } - - public int GetColor(Mobile mob) - { - return GetTeamInfo(mob)?.Color ?? -1; - } - - private void ApplyHues(Participant p, int hueOverride) - { - for (int 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) - { - Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); - } - - private void DelayBounce_Callback(Mobile mob, Container corpse) - { - DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; - - m_Context.RemoveAggressions(mob); - - if (dp != null && !dp.Eliminated) - mob.MoveToWorld(m_Context.Arena.GetBaseStartPoint(GetTeamID(mob)), Facet); - else - m_Context.SendOutside(mob); - - m_Context.Refresh(mob, corpse); - DuelContext.Debuff(mob); - DuelContext.CancelSpell(mob); - mob.Frozen = false; - - if (corpse != null && !corpse.Deleted) - Timer.DelayCall(TimeSpan.FromSeconds(30), corpse.Delete); - } - - public override bool OnDeath(Mobile mob, Container corpse) - { - Mobile killer = mob.FindMostRecentDamager(false); - KHTeamInfo teamInfo = null; - KHTeamInfo victInfo = GetTeamInfo(mob); - int bonus = 0; - - if (killer != null && killer.Player) - teamInfo = GetTeamInfo(killer); - - for (int i = 0; i < Controller.Hills.Length; i++) - { - if (Controller.Hills[i] == null) - continue; - - if (Controller.Hills[i].King == mob) - { - bonus += Controller.Hills[i].CapturesSoFar; - Controller.Hills[i].OnKingDied(mob, victInfo, killer, teamInfo); - } - - if (Controller.Hills[i].King == killer) - bonus += 2; - } - - if (teamInfo != null && teamInfo != victInfo) - { - KHPlayerInfo playerInfo = teamInfo[killer]; - - if (playerInfo != null) - { - playerInfo.Kills += 1; - playerInfo.Score += 1 + bonus; - } - } - - mob.CloseGump(); - mob.SendGump(new KHBoardGump(mob, this)); - - m_Context.Requip(mob, corpse); - DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); - - return false; - } - - public override void OnStart() - { - for (int i = 0; i < Controller.TeamInfo.Length; ++i) - { - KHTeamInfo teamInfo = Controller.TeamInfo[i]; - - teamInfo.Game = this; - teamInfo.Reset(); - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], - Controller.TeamInfo[i % Controller.TeamInfo.Length].Color); - - m_FinishTimer?.Stop(); - - for (int i = 0; i < Controller.Hills.Length; i++) - if (Controller.Hills[i] != null) - Controller.Hills[i].Game = this; - - foreach (KHBoard board in Controller.Boards) - if (board != null && !board.Deleted) - board.m_Game = this; - - m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); - } - - private void Finish_Callback() - { - List teams = new List(); - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - KHTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; - - if (teamInfo != null) - teams.Add(teamInfo); - } - - teams.Sort(); - - Tournament tourney = m_Context.m_Tournament; - - StringBuilder sb = new StringBuilder(); - - if (tourney != null && tourney.TourneyType == TourneyType.FreeForAll) - { - sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); - sb.Append("-man FFA"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RandomTeam) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-team"); - } - else if (tourney != null && tourney.TourneyType == TourneyType.RedVsBlue) - { - sb.Append("Red v Blue"); - } - else if (tourney != null) - { - for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) - { - if (sb.Length > 0) - sb.Append('v'); - - sb.Append(tourney.PlayersPerParticipant); - } - } - - if (Controller != null) - sb.Append(' ').Append(Controller.Title); - - string title = sb.ToString(); - - KHTeamInfo winner = teams.Count > 0 ? teams[0] : null; - - for (int i = 0; i < teams.Count; ++i) - { - TrophyRank rank = TrophyRank.Bronze; - - if (i == 0) - rank = TrophyRank.Gold; - else if (i == 1) - rank = TrophyRank.Silver; - - KHPlayerInfo leader = teams[i].Leader; - - foreach (KHPlayerInfo pl in teams[i].Players.Values) - { - Mobile mob = pl.Player; - - if (mob == null) - continue; - - sb = new StringBuilder(); - - sb.Append(title); - - if (pl == leader) - sb.Append(" Leader"); - - if (pl.Score > 0) - { - sb.Append(": "); - - sb.Append(pl.Score.ToString("N0")); - sb.Append(pl.Score == 1 ? " point" : " points"); - - sb.Append(", "); - sb.Append(pl.Kills.ToString("N0")); - sb.Append(pl.Kills == 1 ? " kill" : " kills"); - - if (pl.Captures > 0) - { - sb.Append(", "); - sb.Append(pl.Captures.ToString("N0")); - sb.Append(pl.Captures == 1 ? " capture" : " captures"); - } - } - - 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); - - int cash = pl.Score * 250; - - 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 game.", - rank.ToString().ToLower(), cash); - } - else - { - mob.SendMessage("You have been awarded a {0} trophy for your participation in this game.", - rank.ToString().ToLower()); - } - } - } - - for (int i = 0; i < m_Context.Participants.Count; ++i) - { - if (!(m_Context.Participants[i] is Participant p) || p.Players == null) - continue; - - for (int j = 0; j < p.Players.Length; ++j) - { - DuelPlayer dp = p.Players[j]; - - if (dp?.Mobile != null) - { - dp.Mobile.CloseGump(); - dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this)); - } - } - - if (i == winner?.TeamID) - continue; - - if (p.Players != null) - for (int 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 (int i = 0; i < Controller.TeamInfo.Length; ++i) - Controller.TeamInfo[i].Game = null; - - for (int i = 0; i < Controller.Hills.Length; ++i) - if (Controller.Hills[i] != null) - Controller.Hills[i].Game = null; - - foreach (KHBoard board in Controller.Boards) - if (board != null) - board.m_Game = null; - - for (int i = 0; i < m_Context.Participants.Count; ++i) - ApplyHues(m_Context.Participants[i], -1); - - m_FinishTimer?.Stop(); - m_FinishTimer = null; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Server.Gumps; +using Server.Items; +using Server.Mobiles; +using Server.Network; + +namespace Server.Engines.ConPVP +{ + public class HillOfTheKing : Item + { + private KHGame m_Game; + private KingTimer m_KingTimer; + + [Constructible] + public HillOfTheKing() + : base(0x520) + { + ScoreInterval = 10; + m_Game = null; + King = null; + Movable = false; + + Name = "the hill"; + } + + public HillOfTheKing(Serial s) + : base(s) + { + } + + public Mobile King{ get; private set; } + + public KHGame Game + { + get => m_Game; + set + { + if (m_Game != value) + { + m_KingTimer?.Stop(); + m_Game = value; + King = null; + } + } + } + + [CommandProperty(AccessLevel.GameMaster)] + public int ScoreInterval{ get; set; } + + public int CapturesSoFar + { + get + { + if (m_KingTimer != null) + return m_KingTimer.Captures; + return 0; + } + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 0: + { + ScoreInterval = reader.ReadEncodedInt(); + break; + } + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); // version + + writer.WriteEncodedInt(ScoreInterval); + } + + private bool CanBeKing(Mobile m) + { + // 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; + } + + public override bool OnMoveOver(Mobile m) + { + if (m_Game == null || m == null || !m.Alive) + return base.OnMoveOver(m); + + if (CanBeKing(m)) + { + if (base.OnMoveOver(m)) + { + ReKingify(m); + return true; + } + } + else + { + // 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; + } + + public override bool OnMoveOff(Mobile m) + { + if (base.OnMoveOff(m)) + { + if (King == m) + DeKingify(); + + return true; + } + + return false; + } + + public virtual void OnKingDied(Mobile king, KHTeamInfo kingTeam, Mobile killer, KHTeamInfo killerTeam) + { + if (m_Game != null && CapturesSoFar > 0 && killer != null && king != null && kingTeam != null && + killerTeam != null) + { + string kingName = king.Name ?? ""; + string killerName = killer.Name ?? ""; + + m_Game.Alert("{0} ({1}) was dethroned by {2} ({3})!", kingName, kingTeam.Name, killerName, killerTeam.Name); + } + + DeKingify(); + } + + private void DeKingify() + { + PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Free!"); + + m_KingTimer?.Stop(); + + King = null; + } + + private void ReKingify(Mobile m) + { + if (m_Game == null || m == null) + return; + + if (m_Game.GetTeamInfo(m) == null) + return; + + King = m; + + if (m_KingTimer == null) + m_KingTimer = new KingTimer(this); + m_KingTimer.Stop(); + m_KingTimer.StartHillTicker(); + + if (King.Name != null) + PublicOverheadMessage(MessageType.Regular, 0x0481, false, $"Taken by {King.Name}!"); + } + + private class KingTimer : Timer + { + private int m_Counter; + private HillOfTheKing m_Hill; + + public KingTimer(HillOfTheKing hill) + : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) + { + m_Hill = hill; + Captures = 0; + m_Counter = 0; + + Priority = TimerPriority.FiftyMS; + } + + public int Captures{ get; private set; } + + public void StartHillTicker() + { + Captures = 0; + m_Counter = 0; + + Start(); + } + + protected override void OnTick() + { + KHPlayerInfo pi = null; + + if (m_Hill?.Deleted != false || m_Hill.Game == null) + { + Stop(); + return; + } + + if (m_Hill.King?.Deleted != false || !m_Hill.King.Alive) + { + m_Hill.DeKingify(); + Stop(); + return; + } + + KHTeamInfo ti = m_Hill.Game.GetTeamInfo(m_Hill.King); + if (ti != null) + pi = ti[m_Hill.King]; + + if (ti == null || pi == null) + { + // error, bail + m_Hill.DeKingify(); + Stop(); + return; + } + + m_Counter++; + + m_Hill.King.RevealingAction(); + + if (m_Counter >= m_Hill.ScoreInterval) + { + string hill = m_Hill.Name; + string king = m_Hill.King.Name ?? ""; + + if (string.IsNullOrEmpty(hill)) + hill = "the hill"; + + m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill); + + m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Capture!"); + + pi.Captures++; + Captures++; + + pi.Score += m_Counter; + + m_Counter = 0; + } + else + { + m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, + (m_Hill.ScoreInterval - m_Counter).ToString()); + } + } + } + } + + public class KHBoard : Item + { + private KHController m_Controller; + public KHGame m_Game; + + [Constructible] + public KHBoard() + : base(7774) + { + Name = "King of the Hill Scoreboard"; + Movable = false; + } + + public KHBoard(Serial serial) + : base(serial) + { + } + + [CommandProperty(AccessLevel.GameMaster)] + public KHController Controller + { + get => m_Controller; + set + { + if (m_Controller != value) + { + m_Controller?.RemoveBoard(this); + m_Controller = value; + m_Controller?.AddBoard(this); + } + } + } + + public override void OnDoubleClick(Mobile from) + { + if (m_Game != null) + { + from.CloseGump(); + from.SendGump(new KHBoardGump(from, m_Game)); + } + else + { + from.SendMessage("There is no King of the Hill game in progress."); + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + + writer.Write(m_Controller); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 0: + { + m_Controller = reader.ReadItem() as KHController; + break; + } + } + } + } + + public sealed class KHBoardGump : Gump + { + private const int LabelColor32 = 0xFFFFFF; + private const int BlackColor32 = 0x000000; + + private KHGame m_Game; + + public KHBoardGump(Mobile mob, KHGame game) + : base(60, 60) + { + m_Game = game; + + KHTeamInfo ourTeam = game.GetTeamInfo(mob); + + List entries = new List(); + + for (int i = 0; i < game.Context.Participants.Count; ++i) + { + KHTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length]; + + if (teamInfo != null) + entries.Add(teamInfo); + } + + entries.Sort(); + /* + delegate( IRankedCTF a, IRankedCTF b ) + { + return b.Score - a.Score; + } );*/ + + int height = 73 + entries.Count * 75 + 28; + + Closable = false; + + AddPage(0); + + AddBackground(1, 1, 398, height, 3600); + + AddImageTiled(16, 15, 369, height - 29, 3604); + + for (int i = 0; i < entries.Count; i += 1) + AddImageTiled(22, 58 + i * 75, 357, 70, 0x2430); + + AddAlphaRegion(16, 15, 369, height - 29); + + AddImage(215, -45, 0xEE40); + //AddImage( 330, 141, 0x8BA ); + + AddBorderedText(22, 22, 294, 20, Center("King of the Hill Scoreboard"), LabelColor32, BlackColor32); + + AddImageTiled(32, 50, 264, 1, 9107); + AddImageTiled(42, 52, 264, 1, 9157); + + for (int i = 0; i < entries.Count; ++i) + { + KHTeamInfo teamInfo = entries[i]; + + AddImage(30, 70 + i * 75, 10152); + AddImage(30, 85 + i * 75, 10151); + AddImage(30, 100 + i * 75, 10151); + AddImage(30, 106 + i * 75, 10154); + + AddImage(24, 60 + i * 75, teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1); + + int nameColor = LabelColor32; + int borderColor = BlackColor32; + + switch (teamInfo.Color) + { + case 0x47E: + nameColor = 0xFFFFFF; + break; + + case 0x4F2: + nameColor = 0x3399FF; + break; + + case 0x4F7: + nameColor = 0x33FF33; + break; + + case 0x4FC: + nameColor = 0xFF00FF; + break; + + case 0x021: + nameColor = 0xFF3333; + break; + + case 0x01A: + nameColor = 0xFF66FF; + break; + + case 0x455: + nameColor = 0x333333; + borderColor = 0xFFFFFF; + break; + } + + AddBorderedText(60, 65 + i * 75, 250, 20, $"{LadderGump.Rank(1 + i)}: {teamInfo.Name}", nameColor, + borderColor); + + AddBorderedText(50 + 10, 85 + i * 75, 100, 20, "Score:", 0xFFC000, BlackColor32); + AddBorderedText(50 + 15, 105 + i * 75, 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(110 + 10, 85 + i * 75, 100, 20, "Kills:", 0xFFC000, BlackColor32); + AddBorderedText(110 + 15, 105 + i * 75, 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32); + + AddBorderedText(160 + 10, 85 + i * 75, 100, 20, "Captures:", 0xFFC000, BlackColor32); + AddBorderedText(160 + 15, 105 + i * 75, 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, BlackColor32); + + string leader = null; + if (teamInfo.Leader != null) + leader = teamInfo.Leader.Name; + if (leader == null) + leader = "(none)"; + + AddBorderedText(235 + 10, 85 + i * 75, 250, 20, "Leader:", 0xFFC000, BlackColor32); + AddBorderedText(235 + 15, 105 + i * 75, 250, 20, leader, 0xFFC000, BlackColor32); + } + + AddButton(314, height - 42, 247, 248, 1); + } + + public string Center(string text) + { + return $"
{text}
"; + } + + public string Color(string text, int color) + { + return $"{text}"; + } + + private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) + { + AddColoredText(x - 1, y - 1, width, height, text, borderColor); + AddColoredText(x - 1, y + 1, width, height, text, borderColor); + AddColoredText(x + 1, y - 1, width, height, text, borderColor); + AddColoredText(x + 1, y + 1, width, height, text, borderColor); + AddColoredText(x, y, width, height, text, color); + } + + 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 sealed class KHPlayerInfo : IRankedCTF, IComparable + { + private int m_Captures; + + private int m_Kills; + private int m_Score; + private KHTeamInfo m_TeamInfo; + + public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player) + { + m_TeamInfo = teamInfo; + Player = player; + } + + public Mobile Player{ get; } + + public int CompareTo(KHPlayerInfo pi) + { + int res = pi.Score.CompareTo(Score); + if (res != 0) + return res; + + res = pi.Captures.CompareTo(Captures); + + return res != 0 ? res : pi.Kills.CompareTo(Kills); + } + + public string Name => Player.Name ?? ""; + + public int Kills + { + get => m_Kills; + set + { + m_TeamInfo.Kills += value - m_Kills; + m_Kills = value; + } + } + + public int Captures + { + get => m_Captures; + set + { + m_TeamInfo.Captures += value - m_Captures; + m_Captures = value; + } + } + + public int Score + { + get => m_Score; + set + { + m_TeamInfo.Score += value - m_Score; + m_Score = value; + + if (m_TeamInfo.Leader == null || m_Score > m_TeamInfo.Leader.Score) + m_TeamInfo.Leader = this; + } + } + } + + [PropertyObject] + public sealed class KHTeamInfo : IRankedCTF, IComparable + { + public KHTeamInfo(int teamID) + { + TeamID = teamID; + Players = new Dictionary(); + } + + public KHTeamInfo(int teamID, GenericReader ip) + { + TeamID = teamID; + Players = new Dictionary(); + + int version = ip.ReadEncodedInt(); + + switch (version) + { + case 0: + { + TeamName = ip.ReadString(); + Color = ip.ReadEncodedInt(); + break; + } + } + } + + public KHGame Game{ get; set; } + + public int TeamID{ get; } + + public KHPlayerInfo Leader{ get; set; } + + public Dictionary Players{ get; } + + public KHPlayerInfo this[Mobile mob] + { + get + { + if (mob == null) + return null; + + if (!Players.TryGetValue(mob, out KHPlayerInfo val)) + Players[mob] = val = new KHPlayerInfo(this, mob); + + return val; + } + } + + [CommandProperty(AccessLevel.GameMaster)] + public int Color{ get; set; } + + [CommandProperty(AccessLevel.GameMaster)] + public string TeamName{ get; set; } + + public int CompareTo(KHTeamInfo ti) + { + int 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; + } + + public string Name => $"{TeamName ?? "(none)"} Team"; + + public int Kills{ get; set; } + + public int Captures{ get; set; } + + public int Score{ get; set; } + + public void Reset() + { + Kills = 0; + Captures = 0; + Score = 0; + + Leader = null; + + Players.Clear(); + } + + public void Serialize(GenericWriter op) + { + op.WriteEncodedInt(0); // version + + op.Write(TeamName); + op.WriteEncodedInt(Color); + } + + public override string ToString() + { + return TeamName != null ? $"({Name}) ..." : "..."; + } + } + + public sealed class KHController : EventController + { + private int m_ScoreInterval; + + [Constructible] + public KHController() + { + Visible = false; + Movable = false; + + Name = "King of the Hill Controller"; + + Duration = TimeSpan.FromMinutes(30.0); + Boards = new List(); + Hills = new HillOfTheKing[4]; + TeamInfo = new KHTeamInfo[8]; + + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new KHTeamInfo(i); + } + + public KHController(Serial serial) + : base(serial) + { + } + + public KHTeamInfo[] TeamInfo{ get; private set; } + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team1_W => TeamInfo[0]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team2_E => TeamInfo[1]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team3_N => TeamInfo[2]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team4_S => TeamInfo[3]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team5_NW => TeamInfo[4]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team6_SE => TeamInfo[5]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team7_SW => TeamInfo[6]; + + [CommandProperty(AccessLevel.GameMaster)] + public KHTeamInfo Team8_NE => TeamInfo[7]; + + public HillOfTheKing[] Hills{ get; private set; } + + [CommandProperty(AccessLevel.GameMaster)] + public HillOfTheKing Hill1 + { + get => Hills[0]; + set => Hills[0] = value; + } + + [CommandProperty(AccessLevel.GameMaster)] + public HillOfTheKing Hill2 + { + get => Hills[1]; + set => Hills[1] = value; + } + + [CommandProperty(AccessLevel.GameMaster)] + public HillOfTheKing Hill3 + { + get => Hills[2]; + set => Hills[2] = value; + } + + [CommandProperty(AccessLevel.GameMaster)] + public HillOfTheKing Hill4 + { + get => Hills[3]; + set => Hills[3] = value; + } + + public List Boards{ get; private set; } + + [CommandProperty(AccessLevel.GameMaster)] + public TimeSpan Duration{ get; set; } + + public override string Title => "King of the Hill"; + + public override string GetTeamName(int teamID) + { + return TeamInfo[teamID % TeamInfo.Length].Name; + } + + public override EventGame Construct(DuelContext context) + { + return new KHGame(this, context); + } + + public void RemoveBoard(KHBoard b) + { + if (b != null) + { + Boards.Remove(b); + b.m_Game = null; + } + } + + public void AddBoard(KHBoard b) + { + if (b != null) + Boards.Add(b); + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); + + writer.WriteEncodedInt(m_ScoreInterval); + writer.Write(Duration); + + writer.WriteItemList(Boards, true); + + writer.WriteEncodedInt(Hills.Length); + for (int i = 0; i < Hills.Length; ++i) + writer.Write(Hills[i]); + + writer.WriteEncodedInt(TeamInfo.Length); + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i].Serialize(writer); + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + + switch (version) + { + case 0: + { + m_ScoreInterval = reader.ReadEncodedInt(); + + Duration = reader.ReadTimeSpan(); + + Boards = reader.ReadStrongItemList(); + + Hills = new HillOfTheKing[reader.ReadEncodedInt()]; + for (int i = 0; i < Hills.Length; ++i) + Hills[i] = reader.ReadItem() as HillOfTheKing; + + TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()]; + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new KHTeamInfo(i, reader); + + break; + } + } + } + } + + public sealed class KHGame : EventGame + { + private Timer m_FinishTimer; + + public KHGame(KHController controller, DuelContext context) : base(context) + { + Controller = controller; + } + + public KHController Controller{ get; } + + public Map Facet + { + get + { + if (m_Context?.Arena != null) + return m_Context.Arena.Facet; + + return Controller.Map; + } + } + + public override bool CantDoAnything(Mobile mob) + { + if (mob != null && GetTeamInfo(mob) != null && Controller != null) + for (int i = 0; i < Controller.Hills.Length; i++) + if (Controller.Hills[i]?.King == mob) + return true; + + return false; + } + + public void Alert(string text) + { + m_Context.m_Tournament?.Alert(text); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + Participant p = m_Context.Participants[i]; + + for (int j = 0; j < p.Players.Length; ++j) + if (p.Players[j] != null) + p.Players[j].Mobile.SendMessage(0x35, text); + } + } + + public void Alert(string format, params object[] args) + { + Alert(string.Format(format, args)); + } + + public KHTeamInfo GetTeamInfo(Mobile mob) + { + int teamID = GetTeamID(mob); + + if (teamID >= 0) + return Controller.TeamInfo[teamID % Controller.TeamInfo.Length]; + + return null; + } + + 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 == null || pm.DuelPlayer.Eliminated) + return -1; + + return pm.DuelContext.Participants.IndexOf(pm.DuelPlayer.Participant); + } + + public int GetColor(Mobile mob) + { + return GetTeamInfo(mob)?.Color ?? -1; + } + + private void ApplyHues(Participant p, int hueOverride) + { + for (int 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) + { + Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse)); + } + + private void DelayBounce_Callback(Mobile mob, Container corpse) + { + DuelPlayer dp = mob is PlayerMobile mobile ? mobile.DuelPlayer : null; + + 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); + DuelContext.CancelSpell(mob); + mob.Frozen = false; + + if (corpse?.Deleted == false) + Timer.DelayCall(TimeSpan.FromSeconds(30), corpse.Delete); + } + + public override bool OnDeath(Mobile mob, Container corpse) + { + Mobile killer = mob.FindMostRecentDamager(false); + KHTeamInfo teamInfo = null; + KHTeamInfo victInfo = GetTeamInfo(mob); + int bonus = 0; + + if (killer?.Player == true) + teamInfo = GetTeamInfo(killer); + + for (int i = 0; i < Controller.Hills.Length; i++) + { + if (Controller.Hills[i] == null) + continue; + + if (Controller.Hills[i].King == mob) + { + bonus += Controller.Hills[i].CapturesSoFar; + Controller.Hills[i].OnKingDied(mob, victInfo, killer, teamInfo); + } + + if (Controller.Hills[i].King == killer) + bonus += 2; + } + + if (teamInfo != null && teamInfo != victInfo) + { + KHPlayerInfo playerInfo = teamInfo[killer]; + + if (playerInfo != null) + { + playerInfo.Kills += 1; + playerInfo.Score += 1 + bonus; + } + } + + mob.CloseGump(); + mob.SendGump(new KHBoardGump(mob, this)); + + m_Context.Requip(mob, corpse); + DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); + + return false; + } + + public override void OnStart() + { + for (int i = 0; i < Controller.TeamInfo.Length; ++i) + { + KHTeamInfo teamInfo = Controller.TeamInfo[i]; + + teamInfo.Game = this; + teamInfo.Reset(); + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], + Controller.TeamInfo[i % Controller.TeamInfo.Length].Color); + + m_FinishTimer?.Stop(); + + for (int i = 0; i < Controller.Hills.Length; i++) + if (Controller.Hills[i] != null) + Controller.Hills[i].Game = this; + + foreach (KHBoard board in Controller.Boards) + if (board?.Deleted == false) + board.m_Game = this; + + m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback); + } + + private void Finish_Callback() + { + List teams = new List(); + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + KHTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length]; + + if (teamInfo != null) + teams.Add(teamInfo); + } + + teams.Sort(); + + Tournament tourney = m_Context.m_Tournament; + + StringBuilder sb = new StringBuilder(); + + if (tourney != null) + { + if (tourney.TourneyType == TourneyType.FreeForAll) + { + sb.Append(m_Context.Participants.Count * tourney.PlayersPerParticipant); + sb.Append("-man FFA"); + } + else if (tourney.TourneyType == TourneyType.RandomTeam) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-team"); + } + else if (tourney.TourneyType == TourneyType.RedVsBlue) + { + sb.Append("Red v Blue"); + } + else + { + for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) + { + if (sb.Length > 0) + sb.Append('v'); + + sb.Append(tourney.PlayersPerParticipant); + } + } + } + + if (Controller != null) + sb.Append(' ').Append(Controller.Title); + + string title = sb.ToString(); + + KHTeamInfo winner = teams.Count > 0 ? teams[0] : null; + + for (int i = 0; i < teams.Count; ++i) + { + TrophyRank rank = TrophyRank.Bronze; + + if (i == 0) + rank = TrophyRank.Gold; + else if (i == 1) + rank = TrophyRank.Silver; + + KHPlayerInfo leader = teams[i].Leader; + + foreach (KHPlayerInfo pl in teams[i].Players.Values) + { + Mobile mob = pl.Player; + + if (mob == null) + continue; + + sb = new StringBuilder(); + + sb.Append(title); + + if (pl == leader) + sb.Append(" Leader"); + + if (pl.Score > 0) + { + sb.Append(": "); + + sb.Append(pl.Score.ToString("N0")); + sb.Append(pl.Score == 1 ? " point" : " points"); + + sb.Append(", "); + sb.Append(pl.Kills.ToString("N0")); + sb.Append(pl.Kills == 1 ? " kill" : " kills"); + + if (pl.Captures > 0) + { + sb.Append(", "); + sb.Append(pl.Captures.ToString("N0")); + sb.Append(pl.Captures == 1 ? " capture" : " captures"); + } + } + + 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); + + int cash = pl.Score * 250; + + 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 game.", + rank.ToString().ToLower(), cash); + } + else + { + mob.SendMessage("You have been awarded a {0} trophy for your participation in this game.", + rank.ToString().ToLower()); + } + } + } + + for (int i = 0; i < m_Context.Participants.Count; ++i) + { + if (!(m_Context.Participants[i] is Participant p) || p.Players == null) + continue; + + for (int j = 0; j < p.Players.Length; ++j) + { + DuelPlayer dp = p.Players[j]; + + if (dp?.Mobile != null) + { + dp.Mobile.CloseGump(); + dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this)); + } + } + + if (i == winner?.TeamID) + continue; + + if (p.Players != null) + for (int 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 (int i = 0; i < Controller.TeamInfo.Length; ++i) + Controller.TeamInfo[i].Game = null; + + for (int i = 0; i < Controller.Hills.Length; ++i) + if (Controller.Hills[i] != null) + Controller.Hills[i].Game = null; + + foreach (KHBoard board in Controller.Boards) + if (board != null) + board.m_Game = null; + + for (int i = 0; i < m_Context.Participants.Count; ++i) + ApplyHues(m_Context.Participants[i], -1); + + m_FinishTimer?.Stop(); + m_FinishTimer = null; + } + } +} diff --git a/Scripts/Engines/ConPVP/Games/TourneyMatch.cs b/Scripts/Engines/ConPVP/Games/TourneyMatch.cs index 71e351dde..1642a504f 100644 --- a/Scripts/Engines/ConPVP/Games/TourneyMatch.cs +++ b/Scripts/Engines/ConPVP/Games/TourneyMatch.cs @@ -49,7 +49,7 @@ namespace Server.Engines.ConPVP public DuelContext Context{ get; set; } - public bool InProgress => Context != null && Context.Registered; + public bool InProgress => Context?.Registered == true; public void Start(Arena arena, Tournament tourney) { @@ -120,4 +120,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs b/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs index 1300bb2df..e1526cc57 100644 --- a/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs @@ -47,7 +47,7 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (int i = 0; i < ruleset.Flavors.Count; ++i) - defs.Or(((Ruleset)ruleset.Flavors[i]).Options); + defs.Or(ruleset.Flavors[i].Options); height += ruleset.Flavors.Count * 18; } @@ -194,7 +194,7 @@ namespace Server.Engines.ConPVP y += 20; for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) - AddBorderedText(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", LabelColor32, BlackColor32); + AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32); y += 4; @@ -243,7 +243,7 @@ namespace Server.Engines.ConPVP y += 35; y -= 3; - AddButton(314, y, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(314, y, 247, 248, 1); Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject); } @@ -270,9 +270,9 @@ 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, false, false); + AddHtml(x, y, width, height, text); else - AddHtml(x, y, width, height, Color(text, color), false, false); + AddHtml(x, y, width, height, Color(text, color)); } public void AutoReject() @@ -379,4 +379,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs b/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs index 7c1685241..bd4aa7a6e 100644 --- a/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs @@ -105,18 +105,13 @@ namespace Server.Engines.ConPVP AddColumnHeader(325, "Participants"); AddColumnHeader(40, "Obs"); - AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0); - AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0); + AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1); + AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2); for (int i = 0; i < list.Count; ++i) { Arena ar = list[i]; - string name = ar.Name; - - if (name == null) - name = "(no name)"; - int x = 12; int y = 32 + i * 31; @@ -125,7 +120,7 @@ namespace Server.Engines.ConPVP AddRadio(x + 3, y + 1, 9727, 9730, false, i); x += 35; - AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0); + AddBorderedText(x + 5, y + 5, 115 - 5, ar.Name ?? "(no name)", color, 0); x += 115; StringBuilder sb = new StringBuilder(); @@ -271,9 +266,9 @@ 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, false, false); + AddHtml(x, y, width, 20, text); else - AddHtml(x, y, width, 20, Color(text, color), false, false); + AddHtml(x, y, width, 20, Color(text, color)); } private void AddColumnHeader(int width, string name) @@ -287,4 +282,4 @@ namespace Server.Engines.ConPVP m_ColumnX += width; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/BeginGump.cs b/Scripts/Engines/ConPVP/Gumps/BeginGump.cs index 6e02ae089..a90d151b1 100644 --- a/Scripts/Engines/ConPVP/Gumps/BeginGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/BeginGump.cs @@ -20,32 +20,32 @@ namespace Server.Engines.ConPVP AddImage(215, -43, 0xEE40); - AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); - AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); - AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); - AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); - AddHtml(22, 22, 294, 20, Color(Center("Duel Countdown"), LabelColor32), false, false); + AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32)); + AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32)); + AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32)); + AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32)); + AddHtml(22, 22, 294, 20, Color(Center("Duel Countdown"), LabelColor32)); AddHtml(22 - 1, 50, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", - BlackColor32), false, false); + BlackColor32)); AddHtml(22 + 1, 50, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", - BlackColor32), false, false); + BlackColor32)); AddHtml(22, 50 - 1, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", - BlackColor32), false, false); + BlackColor32)); AddHtml(22, 50 + 1, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", - BlackColor32), false, false); + BlackColor32)); AddHtml(22, 50, 294, 80, Color( "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", - 0xFFCC66), false, false); + 0xFFCC66)); /*AddImageTiled( 32, 128, 264, 1, 9107 ); AddImageTiled( 42, 130, 264, 1, 9157 ); @@ -56,7 +56,7 @@ namespace Server.Engines.ConPVP AddHtml( 60, 140+1, 250, 20, Color( String.Format( "Duel will begin in {0} second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false ); AddHtml( 60, 140, 250, 20, Color( String.Format( "Duel will begin in {0} second{1}.", count, count==1?"":"s", 0x66AACC ), 0x66AACC ), false, false );*/ - AddButton(314 - 50, 157 - offset, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(314 - 50, 157 - offset, 247, 248, 1); } public string Center(string text) @@ -69,4 +69,4 @@ namespace Server.Engines.ConPVP return $"{text}"; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs b/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs index e88ab26a9..78d4305ae 100644 --- a/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs @@ -1,566 +1,566 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using Server.Factions; -using Server.Gumps; -using Server.Mobiles; -using Server.Network; -using Server.Targeting; - -namespace Server.Engines.ConPVP -{ -public class ConfirmSignupGump : Gump - { - private const int BlackColor32 = 0x000008; - private const int LabelColor32 = 0xFFFFFF; - private Mobile m_From; - private List m_Players; - private Mobile m_Registrar; - private Tournament m_Tournament; - - public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List players) : base(50, 50) - { - m_From = from; - m_Registrar = registrar; - m_Tournament = tourney; - m_Players = players; - - m_From.CloseGump(); - m_From.CloseGump(); - m_From.CloseGump(); - m_From.CloseGump(); - - #region Rules - - Ruleset ruleset = tourney.Ruleset; - Ruleset basedef = ruleset.Base; - - int height = 185 + 60 + 12; - - int changes = 0; - - BitArray defs; - - if (ruleset.Flavors.Count > 0) - { - defs = new BitArray(basedef.Options); - - for (int i = 0; i < ruleset.Flavors.Count; ++i) - defs.Or(((Ruleset)ruleset.Flavors[i]).Options); - - height += ruleset.Flavors.Count * 18; - } - else - { - defs = basedef.Options; - } - - BitArray opts = ruleset.Options; - - for (int 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; - - #endregion - - Closable = false; - - AddPage(0); - - //AddBackground( 0, 0, 400, 220, 9150 ); - AddBackground(1, 1, 398, height, 3600); - //AddBackground( 16, 15, 369, 189, 9100 ); - - AddImageTiled(16, 15, 369, height - 29, 3604); - AddAlphaRegion(16, 15, 369, height - 29); - - AddImage(215, -43, 0xEE40); - //AddImage( 330, 141, 0x8BA ); - - StringBuilder sb = new StringBuilder(); - - if (tourney.TourneyType == TourneyType.FreeForAll) - { - sb.Append("FFA"); - } - else if (tourney.TourneyType == TourneyType.RandomTeam) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-Team"); - } - else if (tourney.TourneyType == TourneyType.Faction) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-Team Faction"); - } - else if (tourney.TourneyType == TourneyType.RedVsBlue) - { - sb.Append("Red v Blue"); - } - else - { - for (int 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"); - - AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32); - AddBorderedText(22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868, - BlackColor32); - - AddImageTiled(32, 88, 264, 1, 9107); - AddImageTiled(42, 90, 264, 1, 9157); - - #region Rules - - int y = 100; - - string groupText = null; - - switch (tourney.GroupType) - { - case GroupingType.HighVsLow: - groupText = "High vs Low"; - break; - case GroupingType.Nearest: - groupText = "Closest opponent"; - break; - case GroupingType.Random: - groupText = "Random"; - break; - } - - AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32); - y += 20; - - string tieText = null; - - switch (tourney.TieType) - { - case TieType.Random: - tieText = "Random"; - break; - case TieType.Highest: - tieText = "Highest advances"; - break; - case TieType.Lowest: - tieText = "Lowest advances"; - break; - case TieType.FullAdvancement: - tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"; - break; - case TieType.FullElimination: - tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"; - break; - } - - AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32); - y += 20; - - string sdText = "Off"; - - if (tourney.SuddenDeath > TimeSpan.Zero) - { - 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); - y += 20; - - y += 6; - AddImageTiled(32, y - 1, 264, 1, 9107); - AddImageTiled(42, y + 1, 264, 1, 9157); - y += 6; - - AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32); - y += 20; - - for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) - AddBorderedText(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", LabelColor32, BlackColor32); - - y += 4; - - if (changes > 0) - { - AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32); - y += 20; - - for (int i = 0; i < opts.Length; ++i) - if (defs[i] != opts[i]) - { - string name = ruleset.Layout.FindByIndex(i); - - if (name != null) // sanity - { - AddImage(35, y, opts[i] ? 0xD3 : 0xD2); - AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32); - } - - y += 22; - } - } - else - { - AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32); - y += 20; - } - - #endregion - - #region Team - - if (tourney.PlayersPerParticipant > 1) - { - y += 8; - AddImageTiled(32, y - 1, 264, 1, 9107); - AddImageTiled(42, y + 1, 264, 1, 9157); - y += 8; - - AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32); - y += 20; - - for (int 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); - } - - for (int 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); - } - } - - #endregion - - y += 8; - AddImageTiled(32, y - 1, 264, 1, 9107); - AddImageTiled(42, y + 1, 264, 1, 9157); - y += 8; - - AddRadio(24, y, 9727, 9730, true, 1); - AddBorderedText(60, y + 5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32); - y += 35; - - AddRadio(24, y, 9727, 9730, false, 2); - AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32); - y += 35; - - y -= 3; - AddButton(314, y, 247, 248, 1, GumpButtonType.Reply, 0); - } - - public string Center(string text) - { - return $"
{text}
"; - } - - public string Color(string text, int color) - { - return $"{text}"; - } - - private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) - { - AddColoredText(x - 1, y - 1, width, height, text, borderColor); - AddColoredText(x - 1, y + 1, width, height, text, borderColor); - AddColoredText(x + 1, y - 1, width, height, text, borderColor); - AddColoredText(x + 1, y + 1, width, height, text, borderColor); - AddColoredText(x, y, width, height, text, color); - } - - private void AddColoredText(int x, int y, int width, int height, string text, int color) - { - if (color == 0) - AddHtml(x, y, width, height, text, false, false); - else - AddHtml(x, y, width, height, Color(text, color), false, false); - } - - public void AddGoldenButton(int x, int y, int bid) - { - AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); - AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); - } - - public override void OnResponse(NetState sender, RelayInfo info) - { - if (info.ButtonID == 1 && info.IsSwitched(1)) - { - Tournament tourney = m_Tournament; - Mobile from = m_From; - - switch (tourney.Stage) - { - case TournamentStage.Fighting: - { - 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); - else - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "The tournament has already begun. You are too late to signup now.", - from.NetState); - } - - break; - } - case TournamentStage.Inactive: - { - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "The tournament is closed.", from.NetState); - - break; - } - case TournamentStage.Signup: - { - if (m_Players.Count != tourney.PlayersPerParticipant) - { - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have not yet chosen your team.", from.NetState); - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - break; - } - - Ladder ladder = Ladder.Instance; - - for (int i = 0; i < m_Players.Count; ++i) - { - Mobile mob = m_Players[i]; - - LadderEntry entry = ladder?.Find(mob); - - if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) - { - 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); - else - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.", - from.NetState); - } - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; - } - - if (tourney.IsFactionRestricted && Faction.Find(mob) == null) - { - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "Only those who have declared their faction allegiance may participate.", - from.NetState); - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; - } - - if (tourney.HasParticipant(mob)) - { - if (m_Registrar != null) - { - if (mob == from) - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have already entered this tournament.", from.NetState); - else - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState); - } - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; - } - - 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); - 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); - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; - } - } - - if (m_Registrar != null) - { - 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; - int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow) - .TotalMinutes); - - if (minutesUntil == 0) - timeUntil = "momentarily"; - else - timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}"; - - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState); - } - - TourneyParticipant part = new TourneyParticipant(from); - part.Players.Clear(); - part.Players.AddRange(m_Players); - - tourney.Participants.Add(part); - - break; - } - } - } - else if (info.ButtonID > 1) - { - int index = info.ButtonID - 1; - - if (index > 0 && index < m_Players.Count) - { - m_Players.RemoveAt(index); - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - } - else if (m_Players.Count < m_Tournament.PlayersPerParticipant) - { - m_From.BeginTarget(12, false, TargetFlags.None, AddPlayer_OnTarget); - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - } - } - } - - private void AddPlayer_OnTarget(Mobile from, object obj) - { - if (!(obj is Mobile mob) || mob == from) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "Excuse me?", from.NetState); - } - else if (!mob.Player) - { - 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. - else - mob.SayTo(from, 1005444); // The creature ignores your offer. - } - else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "They ignore your invitation.", from.NetState); - } - else - { - if (!(mob is PlayerMobile pm)) - return; - - if (pm.DuelContext != null) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "They are already assigned to another duel.", from.NetState); - } - else if (mob.HasGump()) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "They have already been offered a partnership.", from.NetState); - } - else if (mob.HasGump()) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "They are already trying to join this tournament.", from.NetState); - } - else if (m_Players.Contains(mob)) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "You have already named them as a team member.", from.NetState); - } - else if (m_Tournament.HasParticipant(mob)) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "They have already entered this tournament.", from.NetState); - } - else if (m_Players.Count >= m_Tournament.PlayersPerParticipant) - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "Your team is full.", from.NetState); - } - else - { - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - mob.SendGump(new AcceptTeamGump(from, mob, m_Tournament, m_Registrar, m_Players)); - - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x59, false, - $"As you command m'{(from.Female ? "Lady" : "Lord")}. I've given your offer to {mob.Name}.", - from.NetState); - } - } - } - } -} \ No newline at end of file +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Server.Factions; +using Server.Gumps; +using Server.Mobiles; +using Server.Network; +using Server.Targeting; + +namespace Server.Engines.ConPVP +{ +public class ConfirmSignupGump : Gump + { + private const int BlackColor32 = 0x000008; + private const int LabelColor32 = 0xFFFFFF; + private Mobile m_From; + private List m_Players; + private Mobile m_Registrar; + private Tournament m_Tournament; + + public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List players) : base(50, 50) + { + m_From = from; + m_Registrar = registrar; + m_Tournament = tourney; + m_Players = players; + + m_From.CloseGump(); + m_From.CloseGump(); + m_From.CloseGump(); + m_From.CloseGump(); + + #region Rules + + Ruleset ruleset = tourney.Ruleset; + Ruleset basedef = ruleset.Base; + + int height = 185 + 60 + 12; + + int changes = 0; + + BitArray defs; + + if (ruleset.Flavors.Count > 0) + { + defs = new BitArray(basedef.Options); + + for (int i = 0; i < ruleset.Flavors.Count; ++i) + defs.Or(ruleset.Flavors[i].Options); + + height += ruleset.Flavors.Count * 18; + } + else + { + defs = basedef.Options; + } + + BitArray opts = ruleset.Options; + + for (int 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; + + #endregion + + Closable = false; + + AddPage(0); + + //AddBackground( 0, 0, 400, 220, 9150 ); + AddBackground(1, 1, 398, height, 3600); + //AddBackground( 16, 15, 369, 189, 9100 ); + + AddImageTiled(16, 15, 369, height - 29, 3604); + AddAlphaRegion(16, 15, 369, height - 29); + + AddImage(215, -43, 0xEE40); + //AddImage( 330, 141, 0x8BA ); + + StringBuilder sb = new StringBuilder(); + + if (tourney.TourneyType == TourneyType.FreeForAll) + { + sb.Append("FFA"); + } + else if (tourney.TourneyType == TourneyType.RandomTeam) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-Team"); + } + else if (tourney.TourneyType == TourneyType.Faction) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-Team Faction"); + } + else if (tourney.TourneyType == TourneyType.RedVsBlue) + { + sb.Append("Red v Blue"); + } + else + { + for (int 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"); + + AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32); + AddBorderedText(22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868, + BlackColor32); + + AddImageTiled(32, 88, 264, 1, 9107); + AddImageTiled(42, 90, 264, 1, 9157); + + #region Rules + + int y = 100; + + string groupText = null; + + switch (tourney.GroupType) + { + case GroupingType.HighVsLow: + groupText = "High vs Low"; + break; + case GroupingType.Nearest: + groupText = "Closest opponent"; + break; + case GroupingType.Random: + groupText = "Random"; + break; + } + + AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32); + y += 20; + + string tieText = null; + + switch (tourney.TieType) + { + case TieType.Random: + tieText = "Random"; + break; + case TieType.Highest: + tieText = "Highest advances"; + break; + case TieType.Lowest: + tieText = "Lowest advances"; + break; + case TieType.FullAdvancement: + tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"; + break; + case TieType.FullElimination: + tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"; + break; + } + + AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32); + y += 20; + + string sdText = "Off"; + + if (tourney.SuddenDeath > TimeSpan.Zero) + { + 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); + y += 20; + + y += 6; + AddImageTiled(32, y - 1, 264, 1, 9107); + AddImageTiled(42, y + 1, 264, 1, 9157); + y += 6; + + AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32); + y += 20; + + for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) + AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32); + + y += 4; + + if (changes > 0) + { + AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32); + y += 20; + + for (int i = 0; i < opts.Length; ++i) + if (defs[i] != opts[i]) + { + string name = ruleset.Layout.FindByIndex(i); + + if (name != null) // sanity + { + AddImage(35, y, opts[i] ? 0xD3 : 0xD2); + AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32); + } + + y += 22; + } + } + else + { + AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32); + y += 20; + } + + #endregion + + #region Team + + if (tourney.PlayersPerParticipant > 1) + { + y += 8; + AddImageTiled(32, y - 1, 264, 1, 9107); + AddImageTiled(42, y + 1, 264, 1, 9157); + y += 8; + + AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32); + y += 20; + + for (int 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); + } + + for (int 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); + } + } + + #endregion + + y += 8; + AddImageTiled(32, y - 1, 264, 1, 9107); + AddImageTiled(42, y + 1, 264, 1, 9157); + y += 8; + + AddRadio(24, y, 9727, 9730, true, 1); + AddBorderedText(60, y + 5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32); + y += 35; + + AddRadio(24, y, 9727, 9730, false, 2); + AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32); + y += 35; + + y -= 3; + AddButton(314, y, 247, 248, 1); + } + + public string Center(string text) + { + return $"
{text}
"; + } + + public string Color(string text, int color) + { + return $"{text}"; + } + + private void AddBorderedText(int x, int y, int width, int height, string text, int color, int borderColor) + { + AddColoredText(x - 1, y - 1, width, height, text, borderColor); + AddColoredText(x - 1, y + 1, width, height, text, borderColor); + AddColoredText(x + 1, y - 1, width, height, text, borderColor); + AddColoredText(x + 1, y + 1, width, height, text, borderColor); + AddColoredText(x, y, width, height, text, color); + } + + 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) + { + AddButton(x, y, 0xD2, 0xD2, bid); + AddButton(x + 3, y + 3, 0xD8, 0xD8, bid); + } + + public override void OnResponse(NetState sender, RelayInfo info) + { + if (info.ButtonID == 1 && info.IsSwitched(1)) + { + Tournament tourney = m_Tournament; + Mobile from = m_From; + + switch (tourney.Stage) + { + case TournamentStage.Fighting: + { + 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); + else + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "The tournament has already begun. You are too late to signup now.", + from.NetState); + } + + break; + } + case TournamentStage.Inactive: + { + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "The tournament is closed.", from.NetState); + + break; + } + case TournamentStage.Signup: + { + if (m_Players.Count != tourney.PlayersPerParticipant) + { + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "You have not yet chosen your team.", from.NetState); + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + break; + } + + Ladder ladder = Ladder.Instance; + + for (int i = 0; i < m_Players.Count; ++i) + { + Mobile mob = m_Players[i]; + + LadderEntry entry = ladder?.Find(mob); + + if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) + { + 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); + else + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.", + from.NetState); + } + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } + + if (tourney.IsFactionRestricted && Faction.Find(mob) == null) + { + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "Only those who have declared their faction allegiance may participate.", + from.NetState); + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } + + if (tourney.HasParticipant(mob)) + { + if (m_Registrar != null) + { + if (mob == from) + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "You have already entered this tournament.", from.NetState); + else + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState); + } + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } + + 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); + 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); + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } + } + + if (m_Registrar != null) + { + 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; + int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow) + .TotalMinutes); + + if (minutesUntil == 0) + timeUntil = "momentarily"; + else + timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}"; + + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState); + } + + TourneyParticipant part = new TourneyParticipant(from); + part.Players.Clear(); + part.Players.AddRange(m_Players); + + tourney.Participants.Add(part); + + break; + } + } + } + else if (info.ButtonID > 1) + { + int index = info.ButtonID - 1; + + if (index > 0 && index < m_Players.Count) + { + m_Players.RemoveAt(index); + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + } + else if (m_Players.Count < m_Tournament.PlayersPerParticipant) + { + m_From.BeginTarget(12, false, TargetFlags.None, AddPlayer_OnTarget); + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + } + } + } + + private void AddPlayer_OnTarget(Mobile from, object obj) + { + if (!(obj is Mobile mob) || mob == from) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "Excuse me?", from.NetState); + } + else if (!mob.Player) + { + 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. + else + mob.SayTo(from, 1005444); // The creature ignores your offer. + } + else if (AcceptDuelGump.IsIgnored(mob, from) || mob.Blessed) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "They ignore your invitation.", from.NetState); + } + else + { + if (!(mob is PlayerMobile pm)) + return; + + if (pm.DuelContext != null) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "They are already assigned to another duel.", from.NetState); + } + else if (mob.HasGump()) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "They have already been offered a partnership.", from.NetState); + } + else if (mob.HasGump()) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "They are already trying to join this tournament.", from.NetState); + } + else if (m_Players.Contains(mob)) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "You have already named them as a team member.", from.NetState); + } + else if (m_Tournament.HasParticipant(mob)) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "They have already entered this tournament.", from.NetState); + } + else if (m_Players.Count >= m_Tournament.PlayersPerParticipant) + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "Your team is full.", from.NetState); + } + else + { + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + mob.SendGump(new AcceptTeamGump(from, mob, m_Tournament, m_Registrar, m_Players)); + + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x59, false, + $"As you command m'{(from.Female ? "Lady" : "Lord")}. I've given your offer to {mob.Name}.", + from.NetState); + } + } + } + } +} diff --git a/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs b/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs index 1d38f2d5c..f3de1eaa7 100644 --- a/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs @@ -26,7 +26,7 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, height, 9250); AddBackground(10, 10, 280, height - 20, 0xDAC); - AddHtml(35, 25, 230, 20, Center("Duel Setup"), false, false); + AddHtml(35, 25, 230, 20, Center("Duel Setup")); int x = 35; int y = 47; @@ -38,12 +38,12 @@ namespace Server.Engines.ConPVP AddGoldenButtonLabeled(x, y, 3, "Add Participant"); y += 30; - AddHtml(35, y, 230, 20, Center("Participants"), false, false); + AddHtml(35, y, 230, 20, Center("Participants")); y += 22; for (int i = 0; i < context.Participants.Count; ++i) { - Participant p = (Participant)context.Participants[i]; + Participant p = context.Participants[i]; AddGoldenButtonLabeled(x, y, 4 + i, string.Format(p.Count == 1 ? "Player {0}: {3}" : "Team {0}: {1}/{2}: {3}", 1 + i, p.FilledSlots, p.Count, @@ -63,14 +63,14 @@ namespace Server.Engines.ConPVP public void AddGoldenButton(int x, int y, int bid) { - AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); - AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); + AddButton(x, y, 0xD2, 0xD2, bid); + AddButton(x + 3, y + 3, 0xD8, 0xD8, bid); } public void AddGoldenButtonLabeled(int x, int y, int bid, string text) { AddGoldenButton(x, y, bid); - AddHtml(x + 25, y, 200, 20, text, false, false); + AddHtml(x + 25, y, 200, 20, text); } public override void OnResponse(NetState sender, RelayInfo info) @@ -129,11 +129,11 @@ namespace Server.Engines.ConPVP index -= 4; if (index >= 0 && index < Context.Participants.Count) - From.SendGump(new ParticipantGump(From, Context, (Participant)Context.Participants[index])); + From.SendGump(new ParticipantGump(From, Context, Context.Participants[index])); break; } } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/LadderGump.cs b/Scripts/Engines/ConPVP/Gumps/LadderGump.cs index f8a544e4f..c22dfa82b 100644 --- a/Scripts/Engines/ConPVP/Gumps/LadderGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/LadderGump.cs @@ -103,18 +103,18 @@ namespace Server.Engines.ConPVP AddAlphaRegion(10, 10, 479, height - 20); if (page > 0) - AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 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, GumpButtonType.Reply, 0); + AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2); else AddImage(466, height - 12 - 2 - 16, 0x2622); AddHtml(16, height - 12 - 2 - 18, 400, 20, Color(string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", m_List.Count, page + 1, (lc + 14) / 15, lc), - 0xFFC000), false, false); + 0xFFC000)); AddColumnHeader(75, "Rank"); AddColumnHeader(115, "Level"); @@ -231,9 +231,9 @@ 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, false, false); + AddHtml(x, y, width, 20, text); else - AddHtml(x, y, width, 20, Color(text, color), false, false); + AddHtml(x, y, width, 20, Color(text, color)); } private void AddColumnHeader(int width, string name) @@ -245,4 +245,4 @@ namespace Server.Engines.ConPVP m_ColumnX += width; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs b/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs index c4837161e..c412f98f5 100644 --- a/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs @@ -29,16 +29,16 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, height, 9250); AddBackground(10, 10, 280, height - 20, 0xDAC); - AddButton(240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0); + AddButton(240, 25, 0xFB1, 0xFB3, 3); - //AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 ); + //AddButton( 223, 54, 0x265A, 0x265A, 4, ); - AddHtml(35, 25, 230, 20, Center("Participant Setup"), false, false); + AddHtml(35, 25, 230, 20, Center("Participant Setup")); int x = 35; int y = 47; - AddHtml(x, y, 200, 20, $"Team Size: {p.Players.Length}", false, false); + AddHtml(x, y, 200, 20, $"Team Size: {p.Players.Length}"); y += 22; AddGoldenButtonLabeled(x + 20, y, 1, "Increase"); @@ -46,7 +46,7 @@ namespace Server.Engines.ConPVP AddGoldenButtonLabeled(x + 20, y, 2, "Decrease"); y += 30; - AddHtml(35, y, 230, 20, Center("Players"), false, false); + AddHtml(35, y, 230, 20, Center("Players")); y += 22; for (int i = 0; i < p.Players.Length; ++i) @@ -71,14 +71,14 @@ namespace Server.Engines.ConPVP public void AddGoldenButton(int x, int y, int bid) { - AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); - AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); + AddButton(x, y, 0xD2, 0xD2, bid); + AddButton(x + 3, y + 3, 0xD8, 0xD8, bid); } public void AddGoldenButtonLabeled(int x, int y, int bid, string text) { AddGoldenButton(x, y, bid); - AddHtml(x + 25, y, 200, 20, text, false, false); + AddHtml(x + 25, y, 200, 20, text); } public override void OnResponse(NetState sender, RelayInfo info) @@ -250,4 +250,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs b/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs index cd32ba582..0ba8f1340 100644 --- a/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs @@ -26,7 +26,7 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); - AddHtml(35, 25, 190, 20, Center("Rules"), false, false); + AddHtml(35, 25, 190, 20, Center("Rules")); int y = 25 + 20; @@ -34,37 +34,37 @@ namespace Server.Engines.ConPVP { Ruleset cur = m_Defaults[i]; - AddHtml(35 + 14, y, 176, 20, cur.Title, false, false); + 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, GumpButtonType.Reply, 0); + AddButton(35, y + 4, 0x93A, 0x939, 2 + i); else - AddButton(35, y + 4, 0x938, 0x939, 2 + i, GumpButtonType.Reply, 0); + AddButton(35, y + 4, 0x938, 0x939, 2 + i); y += 22; } - AddHtml(35 + 14, y, 176, 20, "Custom", false, false); - AddButton(35, y + 4, ruleset.Changed ? 0x939 : 0x938, 0x939, 1, GumpButtonType.Reply, 0); + AddHtml(35 + 14, y, 176, 20, "Custom"); + AddButton(35, y + 4, ruleset.Changed ? 0x939 : 0x938, 0x939, 1); y += 22; y += 6; - AddHtml(35, y, 190, 20, Center("Flavors"), false, false); + AddHtml(35, y, 190, 20, Center("Flavors")); y += 20; for (int i = 0; i < m_Flavors.Length; ++i) { Ruleset cur = m_Flavors[i]; - AddHtml(35 + 14, y, 176, 20, cur.Title, false, false); + AddHtml(35 + 14, y, 176, 20, cur.Title); if (ruleset.Flavors.Contains(cur)) - AddButton(35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0); + AddButton(35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i); else - AddButton(35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0); + AddButton(35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i); y += 22; } @@ -77,7 +77,7 @@ namespace Server.Engines.ConPVP public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Context != null && !m_Context.Registered) + if (m_Context?.Registered == false) return; switch (info.ButtonID) @@ -123,4 +123,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/ReadyGump.cs b/Scripts/Engines/ConPVP/Gumps/ReadyGump.cs index ff04ced65..6d87c6756 100644 --- a/Scripts/Engines/ConPVP/Gumps/ReadyGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/ReadyGump.cs @@ -22,7 +22,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < parts.Count; ++i) { - Participant p = (Participant)parts[i]; + Participant p = parts[i]; height += 4; @@ -44,19 +44,19 @@ namespace Server.Engines.ConPVP if (count == -1) { - AddHtml(35, 25, 190, 20, Center("Ready"), false, false); + AddHtml(35, 25, 190, 20, Center("Ready")); } else { - AddHtml(35, 25, 190, 20, Center("Starting"), false, false); - AddHtml(35, 25, 190, 20, "
" + count, false, false); + AddHtml(35, 25, 190, 20, Center("Starting")); + AddHtml(35, 25, 190, 20, "
" + count); } int y = 25 + 20; for (int i = 0; i < parts.Count; ++i) { - Participant p = (Participant)parts[i]; + Participant p = parts[i]; y += 4; @@ -66,7 +66,7 @@ namespace Server.Engines.ConPVP if (p.Players.Length > 1) { - AddHtml(35 + 14, y, 176, 20, $"Participant #{i + 1}", false, false); + AddHtml(35 + 14, y, 176, 20, $"Participant #{i + 1}"); y += 22; offset = 10; } @@ -75,7 +75,7 @@ namespace Server.Engines.ConPVP { DuelPlayer pl = p.Players[j]; - if (pl != null && pl.Ready) + if (pl?.Ready == true) { AddImage(35 + offset, y + 4, 0x939); } @@ -87,7 +87,7 @@ namespace Server.Engines.ConPVP string name = pl == null ? "(Empty)" : pl.Mobile.Name; - AddHtml(35 + offset + 14, y, 166, 20, name, false, false); + AddHtml(35 + offset + 14, y, 166, 20, name); y += 22; } @@ -106,4 +106,4 @@ namespace Server.Engines.ConPVP { } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs b/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs index c19878547..e97899ef9 100644 --- a/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs @@ -26,10 +26,10 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 210, height, 9250); AddBackground(10, 10, 190, height - 20, 0xDAC); - AddHtml(35, 25, 140, 20, Center("Rematch?"), false, false); + AddHtml(35, 25, 140, 20, Center("Rematch?")); - AddButton(35, 55, 247, 248, 1, GumpButtonType.Reply, 0); - AddButton(115, 55, 242, 241, 2, GumpButtonType.Reply, 0); + AddButton(35, 55, 247, 248, 1); + AddButton(115, 55, 242, 241, 2); } else { @@ -58,7 +58,7 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); - AddHtml(35, 25, 190, 20, Center("Participants"), false, false); + AddHtml(35, 25, 190, 20, Center("Participants")); int y = 20 + 25; @@ -72,7 +72,7 @@ namespace Server.Engines.ConPVP if (p.Players.Length > 1) { - AddHtml(35, y, 176, 20, $"Team #{i + 1}", false, false); + AddHtml(35, y, 176, 20, $"Team #{i + 1}"); y += 22; offset = 10; } @@ -83,7 +83,7 @@ namespace Server.Engines.ConPVP string name = pl == null ? "(Empty)" : pl.Mobile.Name; - AddHtml(35 + offset, y, 166, 20, name, false, false); + AddHtml(35 + offset, y, 166, 20, name); y += 22; } @@ -91,12 +91,12 @@ namespace Server.Engines.ConPVP y += 8; - AddHtml(35, y, 176, 20, "Continue?", false, false); + AddHtml(35, y, 176, 20, "Continue?"); y -= 2; AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2); - AddButton(169, y, 242, 241, 2, GumpButtonType.Reply, 0); + AddButton(169, y, 242, 241, 2); #endregion @@ -118,7 +118,7 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (int i = 0; i < ruleset.Flavors.Count; ++i) - defs.Or(((Ruleset)ruleset.Flavors[i]).Options); + defs.Or(ruleset.Flavors[i].Options); height += ruleset.Flavors.Count * 18; } @@ -140,20 +140,20 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); - AddHtml(35, 25, 190, 20, Center("Rules"), false, false); + AddHtml(35, 25, 190, 20, Center("Rules")); - AddHtml(35, 50, 190, 20, $"Set: {basedef.Title}", false, false); + AddHtml(35, 50, 190, 20, $"Set: {basedef.Title}"); y = 70; for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) - AddHtml(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", false, false); + AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}"); y += 4; if (changes > 0) { - AddHtml(35, y, 190, 20, "Modifications:", false, false); + AddHtml(35, y, 190, 20, "Modifications:"); y += 20; for (int i = 0; i < opts.Length; ++i) @@ -164,7 +164,7 @@ namespace Server.Engines.ConPVP if (name != null) // sanity { AddImage(35, y, opts[i] ? 0xD3 : 0xD2); - AddHtml(60, y, 165, 22, name, false, false); + AddHtml(60, y, 165, 22, name); } y += 22; @@ -172,18 +172,18 @@ namespace Server.Engines.ConPVP } else { - AddHtml(35, y, 190, 20, "Modifications: None", false, false); + AddHtml(35, y, 190, 20, "Modifications: None"); y += 20; } y += 8; - AddHtml(35, y, 176, 20, "Continue?", false, false); + AddHtml(35, y, 176, 20, "Continue?"); y -= 2; - AddButton(102, y, 247, 248, 1, GumpButtonType.Reply, 0); - AddButton(169, y, 242, 241, 3, GumpButtonType.Reply, 0); + AddButton(102, y, 247, 248, 1); + AddButton(169, y, 242, 241, 3); #endregion } @@ -196,8 +196,8 @@ namespace Server.Engines.ConPVP public void AddGoldenButton(int x, int y, int bid) { - AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); - AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); + AddButton(x, y, 0xD2, 0xD2, bid); + AddButton(x + 3, y + 3, 0xD8, 0xD8, bid); } public override void OnResponse(NetState sender, RelayInfo info) @@ -230,4 +230,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs b/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs index 3470e6ac5..bb9372ede 100644 --- a/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs @@ -45,7 +45,7 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); - AddHtml(35, 25, 190, 20, Center(page.Title), false, false); + AddHtml(35, 25, 190, 20, Center(page.Title)); int x = 35; int y = 47; @@ -53,7 +53,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < page.Children.Length; ++i) { AddGoldenButton(x, y, 1 + i); - AddHtml(x + 25, y, 250, 22, page.Children[i].Title, false, false); + AddHtml(x + 25, y, 250, 22, page.Children[i].Title); y += 22; } @@ -67,7 +67,7 @@ namespace Server.Engines.ConPVP else AddCheck(x, y, 0xD2, 0xD3, enabled, i); - AddHtml(x + 25, y, 250, 22, page.Options[i], false, false); + AddHtml(x + 25, y, 250, 22, page.Options[i]); y += 22; } @@ -80,13 +80,13 @@ namespace Server.Engines.ConPVP public void AddGoldenButton(int x, int y, int bid) { - AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); - AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); + AddButton(x, y, 0xD2, 0xD2, bid); + AddButton(x + 3, y + 3, 0xD8, 0xD8, bid); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_DuelContext != null && !m_DuelContext.Registered) + if (m_DuelContext?.Registered == false) return; if (!m_ReadOnly) @@ -127,4 +127,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs index 85b88c532..0743d9353 100644 --- a/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs +++ b/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs @@ -19,7 +19,7 @@ namespace Server.Engines.ConPVP Match_Info, Player_Info } - + public class TournamentBracketGump : Gump { private const int BlackColor32 = 0x000008; @@ -86,7 +86,7 @@ namespace Server.Engines.ConPVP sb.Append(" Tournament Bracket"); - AddHtml(25, 35, 250, 20, Center(sb.ToString()), false, false); + AddHtml(25, 35, 250, 20, Center(sb.ToString())); AddRightArrow(25, 53, ToButtonID(0, 4), "Rules"); AddRightArrow(25, 71, ToButtonID(0, 1), "Participants"); @@ -117,7 +117,7 @@ namespace Server.Engines.ConPVP text = "The tournament will begin shortly."; } - AddHtml(25, 92, 250, 40, text, false, false); + AddHtml(25, 92, 250, 40, text); } else { @@ -138,7 +138,7 @@ namespace Server.Engines.ConPVP defs = new BitArray(basedef.Options); for (int i = 0; i < ruleset.Flavors.Count; ++i) - defs.Or(((Ruleset)ruleset.Flavors[i]).Options); + defs.Or(ruleset.Flavors[i].Options); } else { @@ -158,7 +158,7 @@ namespace Server.Engines.ConPVP 60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380); AddLeftArrow(25, 11, ToButtonID(0, 0)); - AddHtml(25, 35, 250, 20, Center("Rules"), false, false); + AddHtml(25, 35, 250, 20, Center("Rules")); int y = 53; @@ -177,7 +177,7 @@ namespace Server.Engines.ConPVP break; } - AddHtml(35, y, 190, 20, $"Grouping: {groupText}", false, false); + AddHtml(35, y, 190, 20, $"Grouping: {groupText}"); y += 20; string tieText = null; @@ -201,7 +201,7 @@ namespace Server.Engines.ConPVP break; } - AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}", false, false); + AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}"); y += 20; string sdText = "Off"; @@ -216,22 +216,22 @@ namespace Server.Engines.ConPVP sdText = $"{sdText} (all rounds)"; } - AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}", false, false); + AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}"); y += 20; y += 8; - AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}", false, false); + AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}"); y += 20; for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) - AddHtml(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", false, false); + AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}"); y += 4; if (changes > 0) { - AddHtml(35, y, 190, 20, "Modifications:", false, false); + AddHtml(35, y, 190, 20, "Modifications:"); y += 20; for (int i = 0; i < opts.Length; ++i) @@ -242,7 +242,7 @@ namespace Server.Engines.ConPVP if (name != null) // sanity { AddImage(35, y, opts[i] ? 0xD3 : 0xD2); - AddHtml(60, y, 165, 22, name, false, false); + AddHtml(60, y, 165, 22, name); } y += 22; @@ -250,7 +250,7 @@ namespace Server.Engines.ConPVP } else { - AddHtml(35, y, 190, 20, "Modifications: None", false, false); + AddHtml(35, y, 190, 20, "Modifications: None"); } break; @@ -265,8 +265,7 @@ namespace Server.Engines.ConPVP : new List(tourney.Participants); AddLeftArrow(25, 11, ToButtonID(0, 0)); - AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}"), false, - false); + AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}")); StartPage(out int index, out int count, out int y, 12); @@ -293,11 +292,11 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380); AddLeftArrow(25, 11, ToButtonID(0, 1)); - AddHtml(25, 35, 250, 20, Center("Participants"), false, false); + AddHtml(25, 35, 250, 20, Center("Participants")); int y = 53; - AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team", false, false); + AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team"); y += 20; for (int i = 0; i < part.Players.Count; ++i) @@ -314,10 +313,10 @@ namespace Server.Engines.ConPVP } AddHtml(25, y, 200, 20, - $"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}", false, false); + $"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}"); y += 20; - AddHtml(25, y, 200, 20, "Log:", false, false); + AddHtml(25, y, 200, 20, "Log:"); y += 20; StringBuilder sb = new StringBuilder(); @@ -343,7 +342,7 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, 300, 9380); AddLeftArrow(25, 11, ToButtonID(0, 3)); - AddHtml(25, 35, 250, 20, Center("Participants"), false, false); + AddHtml(25, 35, 250, 20, Center("Participants")); if (!(obj is Mobile mob)) break; @@ -351,16 +350,13 @@ namespace Server.Engines.ConPVP Ladder ladder = Ladder.Instance; LadderEntry entry = ladder?.Find(mob); - AddHtml(25, 53, 250, 20, $"Name: {mob.Name}", false, false); + AddHtml(25, 53, 250, 20, $"Name: {mob.Name}"); AddHtml(25, 73, 250, 20, - $"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}", - false, false); - AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}", false, - false); - AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}", false, - false); - AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}", false, false); - AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}", false, false); + $"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}"); + AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}"); + AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}"); + AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}"); + AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}"); break; } @@ -370,7 +366,7 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, 300, 9380); AddLeftArrow(25, 11, ToButtonID(0, 0)); - AddHtml(25, 35, 250, 20, Center("Rounds"), false, false); + AddHtml(25, 35, 250, 20, Center("Rounds")); // List levelsList = m_List != null // ? Utility.CastListCovariant(m_List) @@ -389,11 +385,11 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, 300, 9380); AddLeftArrow(25, 11, ToButtonID(0, 2)); - AddHtml(25, 35, 250, 20, Center("Rounds"), false, false); + AddHtml(25, 35, 250, 20, Center("Rounds")); if (!(m_Object is PyramidLevel level)) break; - + List matchesList = m_List != null ? Utility.CastListCovariant(m_List) : new List(level.Matches); @@ -401,7 +397,7 @@ namespace Server.Engines.ConPVP AddRightArrow(25, 53, ToButtonID(5, 0), $"Free Advance: {(level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList)}"); - AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}", false, false); + AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}"); StartPage(out int index, out int count, out int y, 10); @@ -529,14 +525,12 @@ namespace Server.Engines.ConPVP AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + ct * 18 + 6, 9380); AddLeftArrow(25, 11, ToButtonID(0, 5)); - AddHtml(25, 35, 250, 20, Center("Rounds"), false, false); + AddHtml(25, 35, 250, 20, Center("Rounds")); - AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}", false, - false); + AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}"); AddHtml(25, 73, 250, 20, - $"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}", - false, false); - AddHtml(25, 93, 250, 20, "Participants:", false, false); + $"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}"); + AddHtml(25, 93, 250, 20, "Participants:"); if (m_Tournament.TourneyType == TourneyType.Standard) for (int i = 0; i < match.Participants.Count; ++i) @@ -613,7 +607,7 @@ namespace Server.Engines.ConPVP } } else if (m_Tournament.TourneyType == TourneyType.FreeForAll) - AddHtml(25, 113, 250, 20, "Free For All", false, false); + AddHtml(25, 113, 250, 20, "Free For All"); break; } @@ -642,17 +636,17 @@ 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, false, false); + AddHtml(x, y, width, height, text); else - AddHtml(x, y, width, height, Color(text, color), false, false); + AddHtml(x, y, width, height, Color(text, color)); } public void AddRightArrow(int x, int y, int bid, string text) { - AddButton(x, y, 0x15E1, 0x15E5, bid, GumpButtonType.Reply, 0); + AddButton(x, y, 0x15E1, 0x15E5, bid); if (text != null) - AddHtml(x + 20, y - 1, 230, 20, text, false, false); + AddHtml(x + 20, y - 1, 230, 20, text); } public void AddRightArrow(int x, int y, int bid) @@ -662,10 +656,10 @@ namespace Server.Engines.ConPVP public void AddLeftArrow(int x, int y, int bid, string text) { - AddButton(x, y, 0x15E3, 0x15E7, bid, GumpButtonType.Reply, 0); + AddButton(x, y, 0x15E3, 0x15E7, bid); if (text != null) - AddHtml(x + 20, y - 1, 230, 20, text, false, false); + AddHtml(x + 20, y - 1, 230, 20, text); } public void AddLeftArrow(int x, int y, int bid) @@ -859,4 +853,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Ladder.cs b/Scripts/Engines/ConPVP/Ladder.cs index 01be31f5d..8457abd69 100644 --- a/Scripts/Engines/ConPVP/Ladder.cs +++ b/Scripts/Engines/ConPVP/Ladder.cs @@ -296,7 +296,7 @@ namespace Server.Engines.ConPVP } } - public class LadderEntry : IComparable + public class LadderEntry : IComparable { private int m_Experience; private Ladder m_Ladder; @@ -350,9 +350,9 @@ namespace Server.Engines.ConPVP [CommandProperty(AccessLevel.GameMaster)] public int Rank => Index; - public int CompareTo(object obj) + public int CompareTo(LadderEntry l) { - return ((LadderEntry)obj).m_Experience - m_Experience; + return (l?.m_Experience ?? 0) - m_Experience; } public void Serialize(GenericWriter writer) diff --git a/Scripts/Engines/ConPVP/Participant.cs b/Scripts/Engines/ConPVP/Participant.cs index e228c1466..8638252da 100644 --- a/Scripts/Engines/ConPVP/Participant.cs +++ b/Scripts/Engines/ConPVP/Participant.cs @@ -52,7 +52,7 @@ namespace Server.Engines.ConPVP get { for (int i = 0; i < Players.Length; ++i) - if (Players[i] != null && !Players[i].Eliminated) + if (Players[i]?.Eliminated == false) return false; return true; @@ -96,7 +96,7 @@ namespace Server.Engines.ConPVP } for (int i = 0; i < Players.Length; ++i) - if (Players[i] != null && Players[i].Mobile == mob) + if (Players[i]?.Mobile == mob) return Players[i]; return null; @@ -228,4 +228,4 @@ namespace Server.Engines.ConPVP public Participant Participant{ get; set; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Preferences.cs b/Scripts/Engines/ConPVP/Preferences.cs index 1b81442c2..4417967a0 100644 --- a/Scripts/Engines/ConPVP/Preferences.cs +++ b/Scripts/Engines/ConPVP/Preferences.cs @@ -198,8 +198,8 @@ namespace Server.Engines.ConPVP AddColumnHeader(35, null); AddColumnHeader(115, "Arena"); - AddButton(499 + 40 - 365 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0); - AddButton(499 + 40 - 365 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0); + AddButton(499 + 40 - 365 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1); + AddButton(499 + 40 - 365 - 12 - 63, height - 12 - 24, 241, 242, 2); for (int i = 0; i < arenas.Count; ++i) { @@ -258,9 +258,9 @@ 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, false, false); + AddHtml(x, y, width, 20, text); else - AddHtml(x, y, width, 20, Color(text, color), false, false); + AddHtml(x, y, width, 20, Color(text, color)); } private void AddColumnHeader(int width, string name) diff --git a/Scripts/Engines/ConPVP/RulesetLayout.cs b/Scripts/Engines/ConPVP/RulesetLayout.cs index 12ab2438a..c15a06f5e 100644 --- a/Scripts/Engines/ConPVP/RulesetLayout.cs +++ b/Scripts/Engines/ConPVP/RulesetLayout.cs @@ -47,7 +47,7 @@ namespace Server.Engines.ConPVP { if (m_Root != null) return m_Root; - + List entries = new List { new RulesetLayout("Spells", @@ -761,4 +761,4 @@ namespace Server.Engines.ConPVP return TotalLength; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/SafeZone.cs b/Scripts/Engines/ConPVP/SafeZone.cs index e6e7f8f1c..12ceec1d7 100644 --- a/Scripts/Engines/ConPVP/SafeZone.cs +++ b/Scripts/Engines/ConPVP/SafeZone.cs @@ -21,10 +21,7 @@ namespace Server.Engines.ConPVP public override bool AllowHousing(Mobile from, Point3D p) { - if (from.AccessLevel < AccessLevel.GameMaster) - return false; - - return base.AllowHousing(from, p); + return from.AccessLevel >= AccessLevel.GameMaster && base.AllowHousing(from, p); } public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) @@ -35,12 +32,11 @@ namespace Server.Engines.ConPVP return false; } - PlayerMobile pm = m as PlayerMobile; + PlayerMobile pm = m as PlayerMobile ?? + (m is BaseCreature bc && bc.Summoned ? + bc.SummonMaster as PlayerMobile : null); - if (pm == null && m is BaseCreature bc && bc.Summoned) - pm = bc.SummonMaster as PlayerMobile; - - if (pm?.DuelContext != null && pm.DuelContext.StartedBeginCountdown) + if (pm?.DuelContext?.StartedBeginCountdown == true) return true; if (DuelContext.CheckCombat(m)) @@ -67,4 +63,4 @@ namespace Server.Engines.ConPVP return false; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/Tournament.cs b/Scripts/Engines/ConPVP/Tournament.cs index 7c46ababb..233f3348e 100644 --- a/Scripts/Engines/ConPVP/Tournament.cs +++ b/Scripts/Engines/ConPVP/Tournament.cs @@ -247,7 +247,7 @@ namespace Server.Engines.ConPVP sb.Append(remaining.Count == 2 ? "between " : "among "); sb.Append(remaining.Count); - + sb.Append(remaining[0].Players.Count == 1 ? " players: " : " teams: "); bool hasAppended = false; @@ -370,9 +370,7 @@ namespace Server.Engines.ConPVP for (int i = 0; i < part.Context.Participants.Count; ++i) { - Participant check = part.Context.Participants[i]; - - if (check != null && !check.Eliminated) + if (part.Context.Participants[i]?.Eliminated == false) ++rem; } @@ -559,7 +557,7 @@ namespace Server.Engines.ConPVP { Mobile mob = players[i]; - if (mob == null || mob.Deleted) + if (mob?.Deleted != false) continue; Item item = new Trophy(title, rank); @@ -762,7 +760,7 @@ namespace Server.Engines.ConPVP if (!match.InProgress) for (int j = 0; j < Arenas.Count; ++j) { - Arena arena = (Arena)Arenas[j]; + Arena arena = Arenas[j]; if (!arena.IsOccupied) { @@ -794,7 +792,7 @@ namespace Server.Engines.ConPVP if (!bad) continue; - + for (int j = 0; j < part.Players.Count; ++j) part.Players[j].SendMessage("You have been disqualified from the tournament."); @@ -882,7 +880,7 @@ namespace Server.Engines.ConPVP Undefeated.Clear(); break; } - + } if (Undefeated.Count > 1) @@ -895,7 +893,7 @@ namespace Server.Engines.ConPVP public void Alert(params string[] alerts) { for (int i = 0; i < Arenas.Count; ++i) - Alert((Arena)Arenas[i], alerts); + Alert(Arenas[i], alerts); } public void Alert(Arena arena, params string[] alerts) @@ -909,4 +907,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/TournamentController.cs b/Scripts/Engines/ConPVP/TournamentController.cs index 23d83eb01..67686f869 100644 --- a/Scripts/Engines/ConPVP/TournamentController.cs +++ b/Scripts/Engines/ConPVP/TournamentController.cs @@ -34,7 +34,7 @@ namespace Server.Engines.ConPVP { TournamentController controller = m_Instances[i]; - if (controller != null && !controller.Deleted && controller.Tournament != null && + if (controller?.Deleted == false && controller.Tournament != null && controller.Tournament.Stage != TournamentStage.Inactive) return true; } @@ -140,4 +140,4 @@ namespace Server.Engines.ConPVP } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/ConPVP/TournamentPyramid.cs b/Scripts/Engines/ConPVP/TournamentPyramid.cs index 520e4a3f0..36cec277c 100644 --- a/Scripts/Engines/ConPVP/TournamentPyramid.cs +++ b/Scripts/Engines/ConPVP/TournamentPyramid.cs @@ -70,7 +70,8 @@ namespace Server.Engines.ConPVP { Faction fac = Faction.Find(mob); - if (fac != null) index = fac.Definition.Sort; + if (fac != null) + index = fac.Definition.Sort; } else if (partsPerMatch == 2) { @@ -186,4 +187,4 @@ namespace Server.Engines.ConPVP public List Matches{ get; set; } = new List(); public TourneyParticipant FreeAdvance{ get; set; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/Core/CraftGump.cs b/Scripts/Engines/Craft/Core/CraftGump.cs index 929bd3ccf..97dcb7cc8 100644 --- a/Scripts/Engines/Craft/Core/CraftGump.cs +++ b/Scripts/Engines/Craft/Core/CraftGump.cs @@ -17,16 +17,7 @@ namespace Server.Engines.Craft private CraftPage m_Page; private BaseTool m_Tool; - /*public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool ): this( from, craftSystem, -1, -1, tool, null ) - { - }*/ - - public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice) : this(from, craftSystem, tool, - notice, CraftPage.None) - { - } - - private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40) + public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40) { m_From = from; m_CraftSystem = craftSystem; @@ -50,57 +41,56 @@ namespace Server.Engines.Craft AddAlphaRegion(10, 10, 510, 417); if (craftSystem.GumpTitleNumber > 0) - AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); + AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor); else - AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); + AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString); - AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); //
CATEGORIES
- AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); //
SELECTIONS
- AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); //
NOTICES
+ AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor); //
CATEGORIES
+ AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor); //
SELECTIONS
+ AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor); //
NOTICES
- AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false); // EXIT + AddButton(15, 402, 4017, 4019, 0); + AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor); // EXIT - AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); - AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST + AddButton(270, 402, 4005, 4007, GetButtonID(6, 2)); + AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor); // MAKE LAST // Mark option if (craftSystem.MarkOption) { - AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); - AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, - false, false); // MARK ITEM + AddButton(270, 362, 4005, 4007, GetButtonID(6, 6)); + AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor); // MARK ITEM } // **************************************** // Resmelt option if (craftSystem.Resmelt) { - AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM + AddButton(15, 342, 4005, 4007, GetButtonID(6, 1)); + AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor); // SMELT ITEM } // **************************************** // Repair option if (craftSystem.Repair) { - AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); - AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM + AddButton(270, 342, 4005, 4007, GetButtonID(6, 5)); + AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor); // REPAIR ITEM } // **************************************** // Enhance option if (craftSystem.CanEnhance) { - AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); - AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM + AddButton(270, 382, 4005, 4007, GetButtonID(6, 8)); + AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor); // ENHANCE ITEM } // **************************************** if (notice is int noticeInt && noticeInt > 0) - AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor, false, false); + AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor); else if (notice is string) - AddHtml(170, 295, 350, 40, $"{notice}", false, false); + AddHtml(170, 295, 350, 40, $"{notice}"); // If the system has more than one resource if (craftSystem.CraftSubRes.Init) @@ -131,10 +121,10 @@ namespace Server.Engines.Craft resourceCount += items[i].Amount; } - AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); + AddButton(15, 362, 4005, 4007, GetButtonID(6, 0)); if (nameNumber > 0) - AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); + AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor); else AddLabel(50, 362, LabelHue, $"{nameString} ({resourceCount} Available)"); } @@ -169,10 +159,10 @@ namespace Server.Engines.Craft resourceCount += items[i].Amount; } - AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); + AddButton(15, 382, 4005, 4007, GetButtonID(6, 7)); if (nameNumber > 0) - AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); + AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor); else AddLabel(50, 385, LabelHue, $"{nameString} ({resourceCount} Available)"); } @@ -184,7 +174,7 @@ namespace Server.Engines.Craft CreateResList(false, from); else if (page == CraftPage.PickResource2) CreateResList(true, from); - else if (context != null && context.LastGroupIndex > -1) + else if (context?.LastGroupIndex > -1) CreateItemList(context.LastGroupIndex); } @@ -210,9 +200,9 @@ namespace Server.Engines.Craft CraftContext context = m_CraftSystem.GetContext(m_From); - AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); + AddButton(220, 260, 4005, 4007, GetButtonID(6, 4)); AddHtmlLocalized(255, 263, 200, 18, context == null || !context.DoNotColor ? 1061591 : 1061590, - LabelColor, false, false); + LabelColor); } int resourceCount = 0; @@ -225,11 +215,11 @@ namespace Server.Engines.Craft resourceCount += items[j].Amount; } - AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0); + AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i)); if (subResource.NameNumber > 0) AddHtmlLocalized(255, 63 + index * 20, 250, 18, subResource.NameNumber, resourceCount.ToString(), - LabelColor, false, false); + LabelColor); else AddLabel(255, 60 + index * 20, LabelHue, $"{subResource.NameString} ({resourceCount})"); } @@ -256,7 +246,7 @@ namespace Server.Engines.Craft if (i > 0) { AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1); - AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor, false, false); // NEXT PAGE + AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor); // NEXT PAGE } AddPage(i / 10 + 1); @@ -264,21 +254,21 @@ namespace Server.Engines.Craft if (i > 0) { AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); - AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor, false, false); // PREV PAGE + AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor); // PREV PAGE } } - AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(3, i), GumpButtonType.Reply, 0); + AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(3, i)); if (craftItem.NameNumber > 0) - AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor, false, false); + 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), GumpButtonType.Reply, 0); + AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(4, i)); } else - AddHtmlLocalized(230, 62, 200, 22, 1044165, LabelColor, false, false); // You haven't made anything yet. + AddHtmlLocalized(230, 62, 200, 22, 1044165, LabelColor); // You haven't made anything yet. } public void CreateItemList(int selectedGroup) @@ -304,7 +294,7 @@ namespace Server.Engines.Craft if (i > 0) { AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1); - AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor, false, false); // NEXT PAGE + AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor); // NEXT PAGE } AddPage(i / 10 + 1); @@ -312,18 +302,18 @@ namespace Server.Engines.Craft if (i > 0) { AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); - AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor, false, false); // PREV PAGE + AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor); // PREV PAGE } } - AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(1, i), GumpButtonType.Reply, 0); + AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(1, i)); if (craftItem.NameNumber > 0) - AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor, false, false); + 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), GumpButtonType.Reply, 0); + AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(2, i)); } } @@ -331,17 +321,17 @@ namespace Server.Engines.Craft { CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups; - AddButton(15, 60, 4005, 4007, GetButtonID(6, 3), GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor, false, false); // LAST TEN + AddButton(15, 60, 4005, 4007, GetButtonID(6, 3)); + AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor); // LAST TEN for (int i = 0; i < craftGroupCol.Count; i++) { CraftGroup craftGroup = craftGroupCol.GetAt(i); - AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i), GumpButtonType.Reply, 0); + AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i)); if (craftGroup.NameNumber > 0) - AddHtmlLocalized(50, 83 + i * 20, 150, 18, craftGroup.NameNumber, LabelColor, false, false); + AddHtmlLocalized(50, 83 + i * 20, 150, 18, craftGroup.NameNumber, LabelColor); else AddLabel(50, 80 + i * 20, LabelHue, craftGroup.NameString); } @@ -608,11 +598,11 @@ namespace Server.Engines.Craft } } - private enum CraftPage + public enum CraftPage { None, PickResource, PickResource2 } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/Core/CraftGumpItem.cs b/Scripts/Engines/Craft/Core/CraftGumpItem.cs index af0d39317..406f0a19c 100644 --- a/Scripts/Engines/Craft/Core/CraftGumpItem.cs +++ b/Scripts/Engines/Craft/Core/CraftGumpItem.cs @@ -53,41 +53,40 @@ namespace Server.Engines.Craft AddImageTiled(10, 387, 510, 22, 2624); AddAlphaRegion(10, 10, 510, 399); - AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false); // ITEM - AddHtmlLocalized(10, 192, 150, 22, 1044054, LabelColor, false, false); //
SKILLS
- AddHtmlLocalized(10, 277, 150, 22, 1044055, LabelColor, false, false); //
MATERIALS
- AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor, false, false); //
OTHER
+ AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor); // ITEM + AddHtmlLocalized(10, 192, 150, 22, 1044054, LabelColor); //
SKILLS
+ AddHtmlLocalized(10, 277, 150, 22, 1044055, LabelColor); //
MATERIALS
+ AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor); //
OTHER
if (craftSystem.GumpTitleNumber > 0) - AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); + AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor); else - AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); + AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString); - AddButton(15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor, false, false); // BACK + AddButton(15, 387, 4014, 4016, 0); + AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor); // BACK bool needsRecipe = craftItem.Recipe != null && from is PlayerMobile mobile && !mobile.HasRecipe(craftItem.Recipe); if (needsRecipe) { - AddButton(270, 387, 4005, 4007, 0, GumpButtonType.Page, 0); - AddHtmlLocalized(305, 390, 150, 18, 1044151, GreyLabelColor, false, false); // MAKE NOW + AddButton(270, 387, 4005, 4007, 0, GumpButtonType.Page); + AddHtmlLocalized(305, 390, 150, 18, 1044151, GreyLabelColor); // MAKE NOW } else { - AddButton(270, 387, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(305, 390, 150, 18, 1044151, LabelColor, false, false); // MAKE NOW + AddButton(270, 387, 4005, 4007, 1); + AddHtmlLocalized(305, 390, 150, 18, 1044151, LabelColor); // MAKE NOW } if (craftItem.NameNumber > 0) - AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false); + AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor); else AddLabel(330, 40, LabelHue, craftItem.NameString); if (craftItem.UseAllRes) - AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1048176, LabelColor, false, - false); // Makes as many as possible at once + AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1048176, LabelColor); // Makes as many as possible at once DrawItem(); DrawSkill(); @@ -100,15 +99,14 @@ namespace Server.Engines.Craft if (craftItem.RequiredExpansion != Expansion.None) { - bool supportsEx = from.NetState != null && from.NetState.SupportsExpansion(craftItem.RequiredExpansion); + bool supportsEx = from.NetState?.SupportsExpansion(craftItem.RequiredExpansion) == true; TextDefinition.AddHtmlText(this, 170, 302 + m_OtherCount++ * 20, 310, 18, RequiredExpansionMessage(craftItem.RequiredExpansion), false, false, supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue); } if (needsRecipe) - AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1073620, RedLabelColor, false, - false); // You have not learned this recipe. + AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1073620, RedLabelColor); // You have not learned this recipe. } private TextDefinition RequiredExpansionMessage(Expansion expansion) @@ -132,8 +130,7 @@ namespace Server.Engines.Craft if (m_CraftItem.IsMarkable(type)) { - AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044059, LabelColor, false, - false); // This item may hold its maker's mark + AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044059, LabelColor); // This item may hold its maker's mark m_ShowExceptionalChance = true; } } @@ -148,8 +145,7 @@ namespace Server.Engines.Craft if (minSkill < 0) minSkill = 0; - AddHtmlLocalized(170, 132 + i * 20, 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, - false); + AddHtmlLocalized(170, 132 + i * 20, 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor); AddLabel(430, 132 + i * 20, LabelHue, $"{minSkill:F1}"); } @@ -171,7 +167,7 @@ namespace Server.Engines.Craft else if (chance > 1.0) chance = 1.0; - AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false); // Success Chance: + AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor); // Success Chance: AddLabel(430, 80, LabelHue, $"{chance * 100:F1}%"); if (m_ShowExceptionalChance) @@ -181,7 +177,7 @@ namespace Server.Engines.Craft else if (excepChance > 1.0) excepChance = 1.0; - AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false); // Exceptional Chance: + AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767); // Exceptional Chance: AddLabel(430, 100, LabelHue, $"{excepChance * 100:F1}%"); } } @@ -232,13 +228,12 @@ namespace Server.Engines.Craft if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type)) { retainedColor = true; - AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044152, LabelColor, false, - false); // * The item retains the color of this material + AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044152, LabelColor); // * The item retains the color of this material AddLabel(500, 219 + i * 20, LabelHue, "*"); } if (nameNumber > 0) - AddHtmlLocalized(170, 219 + i * 20, 310, 18, nameNumber, LabelColor, false, false); + AddHtmlLocalized(170, 219 + i * 20, 310, 18, nameNumber, LabelColor); else AddLabel(170, 219 + i * 20, LabelHue, nameString); @@ -247,13 +242,12 @@ namespace Server.Engines.Craft if (m_CraftItem.NameNumber == 1041267) // runebook { - AddHtmlLocalized(170, 219 + m_CraftItem.Resources.Count * 20, 310, 18, 1044447, LabelColor, false, false); + AddHtmlLocalized(170, 219 + m_CraftItem.Resources.Count * 20, 310, 18, 1044447, LabelColor); AddLabel(430, 219 + m_CraftItem.Resources.Count * 20, LabelHue, "1"); } if (cropScroll) - AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 360, 18, 1044379, LabelColor, false, - false); // Inscribing scrolls also requires a blank scroll and mana. + AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 360, 18, 1044379, LabelColor); // Inscribing scrolls also requires a blank scroll and mana. } public override void OnResponse(NetState sender, RelayInfo info) @@ -292,4 +286,4 @@ namespace Server.Engines.Craft } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/Core/CraftItem.cs b/Scripts/Engines/Craft/Core/CraftItem.cs index 16c0e27c1..6562b2cee 100644 --- a/Scripts/Engines/Craft/Core/CraftItem.cs +++ b/Scripts/Engines/Craft/Core/CraftItem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Commands; using Server.Factions; using Server.Items; @@ -273,16 +274,12 @@ namespace Server.Engines.Craft return false; IPooledEnumerable eable = map.GetItemsInRange(from.Location, 2); - - foreach (Item item in eable) - if (item.Z + 16 > from.Z && from.Z + 16 > item.Z && Find(item.ItemID, itemIDs)) - { - eable.Free(); - return true; - } - + bool 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 (int x = -2; x <= 2; ++x) for (int y = -2; y <= 2; ++y) { @@ -758,7 +755,7 @@ namespace Server.Engines.Craft if (from.BeginAction()) { if (RequiredExpansion == Expansion.None || - from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion)) + from.NetState?.SupportsExpansion(RequiredExpansion) == true) { bool allRequiredSkills = true; double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills); @@ -860,7 +857,7 @@ namespace Server.Engines.Craft if (badCraft > 0) { - if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); else from.SendLocalizedMessage(badCraft); @@ -876,7 +873,7 @@ namespace Server.Engines.Craft ref checkMessage) && ConsumeAttributes(from, ref checkMessage, false))) { - if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); else if (checkMessage is int messageInt && messageInt > 0) from.SendLocalizedMessage(messageInt); @@ -905,7 +902,7 @@ namespace Server.Engines.Craft if (!(ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message) && ConsumeAttributes(from, ref message, true))) { - if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, craftSystem, tool, message)); else if (message is int messageIn && messageIn > 0) from.SendLocalizedMessage(messageIn); @@ -992,7 +989,7 @@ namespace Server.Engines.Craft { Town town = Town.FromRegion(from.Region); - if (town != null && town.Owner == faction) + if (town?.Owner == faction) { Container pack = from.Backpack; @@ -1013,14 +1010,14 @@ namespace Server.Engines.Craft if (queryFactionImbue) from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction, def)); - else if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + else if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, craftSystem, tool, num)); else if (num > 0) from.SendLocalizedMessage(num); } else if (!allRequiredSkills) { - if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); else from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item. @@ -1036,7 +1033,7 @@ namespace Server.Engines.Craft // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true)) { - if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, craftSystem, tool, message)); else if (message is int messageInt && messageInt > 0) from.SendLocalizedMessage(messageInt); @@ -1104,7 +1101,7 @@ namespace Server.Engines.Craft if (badCraft > 0) { - if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 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); diff --git a/Scripts/Engines/Craft/Core/CraftRes.cs b/Scripts/Engines/Craft/Core/CraftRes.cs index 6e2c53294..42bd7155a 100644 --- a/Scripts/Engines/Craft/Core/CraftRes.cs +++ b/Scripts/Engines/Craft/Core/CraftRes.cs @@ -4,14 +4,11 @@ namespace Server.Engines.Craft { public class CraftRes { - public CraftRes(Type type, int amount) + public CraftRes(Type type, TextDefinition name, int amount, TextDefinition message = null) { ItemType = type; Amount = amount; - } - public CraftRes(Type type, TextDefinition name, int amount, TextDefinition message) : this(type, amount) - { NameNumber = name; MessageNumber = message; @@ -41,4 +38,4 @@ namespace Server.Engines.Craft from.SendLocalizedMessage(502925); // You don't have the resources required to make that item. } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/Core/CraftSubRes.cs b/Scripts/Engines/Craft/Core/CraftSubRes.cs index 5c1191853..61bd68da6 100644 --- a/Scripts/Engines/Craft/Core/CraftSubRes.cs +++ b/Scripts/Engines/Craft/Core/CraftSubRes.cs @@ -31,4 +31,4 @@ namespace Server.Engines.Craft public double RequiredSkill{ get; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs b/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs index 2330b23e5..fe7c17f1b 100644 --- a/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs +++ b/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs @@ -31,13 +31,13 @@ namespace Server.Engines.Craft AddBackground(0, 0, 220, 170, 5054); AddBackground(10, 10, 200, 150, 3000); - AddHtmlLocalized(20, 20, 180, 80, 1018317, false, false); // Do you wish to place your maker's mark on this item? + AddHtmlLocalized(20, 20, 180, 80, 1018317); // Do you wish to place your maker's mark on this item? - AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false); // CONTINUE - AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 100, 140, 25, 1011011); // CONTINUE + AddButton(20, 100, 4005, 4007, 1); - AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false); // CANCEL - AddButton(20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 125, 140, 25, 1011012); // CANCEL + AddButton(20, 125, 4005, 4007, 0); } public override void OnResponse(NetState sender, RelayInfo info) @@ -52,4 +52,4 @@ namespace Server.Engines.Craft m_CraftItem.CompleteCraft(m_Quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/Core/Recipes.cs b/Scripts/Engines/Craft/Core/Recipes.cs index cba5b4fc8..9f4b286a7 100644 --- a/Scripts/Engines/Craft/Core/Recipes.cs +++ b/Scripts/Engines/Craft/Core/Recipes.cs @@ -34,16 +34,7 @@ namespace Server.Engines.Craft public int ID{ get; } - public TextDefinition TextDefinition - { - get - { - if (m_TD == null) - m_TD = new TextDefinition(CraftItem.NameNumber, CraftItem.NameString); - - return m_TD; - } - } + public TextDefinition TextDefinition => m_TD ?? (m_TD = new TextDefinition(CraftItem.NameNumber, CraftItem.NameString)); public static void Initialize() { diff --git a/Scripts/Engines/Craft/Core/Resmelt.cs b/Scripts/Engines/Craft/Core/Resmelt.cs index 3fffe268e..12d392327 100644 --- a/Scripts/Engines/Craft/Core/Resmelt.cs +++ b/Scripts/Engines/Craft/Core/Resmelt.cs @@ -117,6 +117,7 @@ namespace Server.Engines.Craft } catch { + // ignored } return SmeltResult.Invalid; diff --git a/Scripts/Engines/Craft/DefAlchemy.cs b/Scripts/Engines/Craft/DefAlchemy.cs index a339df268..09e7572ca 100644 --- a/Scripts/Engines/Craft/DefAlchemy.cs +++ b/Scripts/Engines/Craft/DefAlchemy.cs @@ -17,16 +17,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044001; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefAlchemy(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefAlchemy()); public override double GetChanceAtMin(CraftItem item) { @@ -35,8 +26,9 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -180,4 +172,4 @@ namespace Server.Engines.Craft } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefBlacksmithy.cs b/Scripts/Engines/Craft/DefBlacksmithy.cs index 24b347ee1..fd42bc0f9 100644 --- a/Scripts/Engines/Craft/DefBlacksmithy.cs +++ b/Scripts/Engines/Craft/DefBlacksmithy.cs @@ -30,16 +30,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044002; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefBlacksmithy(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefBlacksmithy()); public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; @@ -111,7 +102,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -801,4 +792,4 @@ namespace Server.Engines.Craft public class AnvilAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefBowFletching.cs b/Scripts/Engines/Craft/DefBowFletching.cs index e64f7bf0f..5d6b385fc 100644 --- a/Scripts/Engines/Craft/DefBowFletching.cs +++ b/Scripts/Engines/Craft/DefBowFletching.cs @@ -15,16 +15,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044006; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefBowFletching(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefBowFletching()); public override CraftECA ECA => CraftECA.FiftyPercentChanceMinusTenPercent; @@ -35,7 +26,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -212,4 +203,4 @@ namespace Server.Engines.Craft Repair = Core.AOS; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefCarpentry.cs b/Scripts/Engines/Craft/DefCarpentry.cs index d4868f49d..a4a1ee132 100644 --- a/Scripts/Engines/Craft/DefCarpentry.cs +++ b/Scripts/Engines/Craft/DefCarpentry.cs @@ -15,16 +15,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044004; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefCarpentry(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCarpentry()); public override double GetChanceAtMin(CraftItem item) { @@ -33,7 +24,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -545,4 +536,4 @@ namespace Server.Engines.Craft AddSubRes(typeof(FrostwoodLog), 1072649, 100.0, 1044041, 1072652); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefCartography.cs b/Scripts/Engines/Craft/DefCartography.cs index edd2567c8..66207d36d 100644 --- a/Scripts/Engines/Craft/DefCartography.cs +++ b/Scripts/Engines/Craft/DefCartography.cs @@ -15,16 +15,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044008; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefCartography(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCartography()); public override double GetChanceAtMin(CraftItem item) { @@ -33,7 +24,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -76,4 +67,4 @@ namespace Server.Engines.Craft AddCraft(typeof(WorldMap), 1044448, 1015233, 39.5, 99.5, typeof(BlankMap), 1044449, 1, 1044450); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefCooking.cs b/Scripts/Engines/Craft/DefCooking.cs index aa5ccb59e..8afb26226 100644 --- a/Scripts/Engines/Craft/DefCooking.cs +++ b/Scripts/Engines/Craft/DefCooking.cs @@ -15,16 +15,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044003; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefCooking(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCooking()); public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; @@ -35,7 +26,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -292,4 +283,4 @@ namespace Server.Engines.Craft /* End Chocolatiering */ } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefGlassblowing.cs b/Scripts/Engines/Craft/DefGlassblowing.cs index dd0e803b6..c17378390 100644 --- a/Scripts/Engines/Craft/DefGlassblowing.cs +++ b/Scripts/Engines/Craft/DefGlassblowing.cs @@ -16,28 +16,16 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044622; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefGlassblowing(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefGlassblowing()); public override double GetChanceAtMin(CraftItem item) { - if (item.ItemType == typeof(HollowPrism)) - return 0.5; // 50% - - return 0.0; // 0% + return item.ItemType == typeof(HollowPrism) ? 0.5 : 0.0; } public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -48,10 +36,7 @@ namespace Server.Engines.Craft DefBlacksmithy.CheckAnvilAndForge(from, 2, out _, out bool forge); - if (forge) - return 0; - - return 1044628; // You must be near a forge to blow glass. + return forge ? 0 : 1044628; // You must be near a forge to blow glass. } public override void PlayCraftEffect(Mobile from) @@ -128,4 +113,4 @@ namespace Server.Engines.Craft } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefInscription.cs b/Scripts/Engines/Craft/DefInscription.cs index 80d6aeb99..c1922259e 100644 --- a/Scripts/Engines/Craft/DefInscription.cs +++ b/Scripts/Engines/Craft/DefInscription.cs @@ -36,16 +36,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044009; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefInscription(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefInscription()); public override double GetChanceAtMin(CraftItem item) { @@ -54,7 +45,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type typeItem) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -65,9 +56,7 @@ namespace Server.Engines.Craft if (o is SpellScroll scroll) { - Spellbook book = Spellbook.Find(from, scroll.SpellID); - - bool hasSpell = book != null && book.HasSpell(scroll.SpellID); + bool hasSpell = Spellbook.Find(from, scroll.SpellID)?.HasSpell(scroll.SpellID) == true; scroll.Delete(); @@ -121,7 +110,6 @@ namespace Server.Engines.Craft switch (m_Circle) { default: - case 0: minSkill = -25.0; maxSkill = 25.0; break; @@ -409,4 +397,4 @@ namespace Server.Engines.Craft SpidersSilk } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefMasonry.cs b/Scripts/Engines/Craft/DefMasonry.cs index 4825822a9..1e73469b1 100644 --- a/Scripts/Engines/Craft/DefMasonry.cs +++ b/Scripts/Engines/Craft/DefMasonry.cs @@ -16,16 +16,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044500; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefMasonry(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefMasonry()); public override double GetChanceAtMin(CraftItem item) { @@ -39,7 +30,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -139,4 +130,4 @@ namespace Server.Engines.Craft } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefTailoring.cs b/Scripts/Engines/Craft/DefTailoring.cs index 355dcf723..b2e3430a5 100644 --- a/Scripts/Engines/Craft/DefTailoring.cs +++ b/Scripts/Engines/Craft/DefTailoring.cs @@ -23,16 +23,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044005; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefTailoring(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefTailoring()); public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; @@ -43,7 +34,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -427,4 +418,4 @@ namespace Server.Engines.Craft CanEnhance = Core.AOS; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Craft/DefTinkering.cs b/Scripts/Engines/Craft/DefTinkering.cs index 2f20ea63b..813e074dd 100644 --- a/Scripts/Engines/Craft/DefTinkering.cs +++ b/Scripts/Engines/Craft/DefTinkering.cs @@ -31,16 +31,7 @@ namespace Server.Engines.Craft public override int GumpTitleNumber => 1044007; - public static CraftSystem CraftSystem - { - get - { - if (m_CraftSystem == null) - m_CraftSystem = new DefTinkering(); - - return m_CraftSystem; - } - } + public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefTinkering()); public override double GetChanceAtMin(CraftItem item) { @@ -52,7 +43,7 @@ namespace Server.Engines.Craft public override int CanCraft(Mobile from, BaseTool tool, Type itemType) { - if (tool == null || tool.Deleted || tool.UsesRemaining < 0) + 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. @@ -507,7 +498,7 @@ namespace Server.Engines.Craft Mobile from = m_TrapCraft.From; BaseTool tool = m_TrapCraft.Tool; - if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) + if (tool?.Deleted == false && tool.UsesRemaining > 0) from.SendGump(new CraftGump(from, m_TrapCraft.CraftSystem, tool, message)); else if (message > 0) from.SendLocalizedMessage(message); @@ -547,4 +538,4 @@ namespace Server.Engines.Craft public override TrapType TrapType => TrapType.ExplosionTrap; } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Doom/GauntletSpawner.cs b/Scripts/Engines/Doom/GauntletSpawner.cs index 5c231bc59..4386f012e 100644 --- a/Scripts/Engines/Doom/GauntletSpawner.cs +++ b/Scripts/Engines/Doom/GauntletSpawner.cs @@ -27,12 +27,7 @@ namespace Server.Engines.Doom private Timer m_Timer; [Constructible] - public GauntletSpawner() : this(null) - { - } - - [Constructible] - public GauntletSpawner(string typeName) : base(0x36FE) + public GauntletSpawner(string typeName = null) : base(0x36FE) { Visible = false; Movable = false; @@ -334,7 +329,7 @@ namespace Server.Engines.Doom { State = GauntletSpawnerState.InSequence; - if (Sequence != null && !Sequence.Deleted) + if (Sequence?.Deleted == false) Sequence.RecurseReset(); } } @@ -353,7 +348,7 @@ namespace Server.Engines.Doom { State = GauntletSpawnerState.Completed; - if (Sequence != null && !Sequence.Deleted) + if (Sequence?.Deleted == false) { if (Sequence.State == GauntletSpawnerState.Completed) RecurseReset(); @@ -428,7 +423,7 @@ namespace Server.Engines.Doom public static void CreateTeleporter(int xFrom, int yFrom, int xTo, int yTo) { Static telePad = new Static(0x1822); - Teleporter teleItem = new Teleporter(new Point3D(xTo, yTo, -1), Map.Malas, false); + Teleporter teleItem = new Teleporter(new Point3D(xTo, yTo, -1), Map.Malas); telePad.Hue = 0x482; telePad.MoveToWorld(new Point3D(xFrom, yFrom, -1), Map.Malas); @@ -652,4 +647,4 @@ namespace Server.Engines.Doom { } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs index cf45b0a6f..d4c5d4598 100644 --- a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Commands; using Server.Mobiles; using Server.Network; @@ -181,12 +182,11 @@ namespace Server.Engines.Doom [Description("Generates lamp room and lever puzzle in doom.")] public static void GenLampPuzzle_OnCommand(CommandEventArgs e) { - foreach (Item item in Map.Malas.GetItemsInRange(lp_Center, 0)) - if (item is LeverPuzzleController) - { - e.Mobile.SendMessage("Lamp room puzzle already exists: please delete the existing controller first ..."); - return; - } + if (Map.Malas.GetItemsInRange(lp_Center, 0).OfType().Any()) + { + e.Mobile.SendMessage("Lamp room puzzle already exists: please delete the existing controller first ..."); + return; + } e.Mobile.SendMessage("Generating Lamp Room puzzle..."); new LeverPuzzleController().MoveToWorld(lp_Center, Map.Malas); @@ -199,10 +199,11 @@ namespace Server.Engines.Doom public static Item AddLeverPuzzlePart(int[] Loc, Item newitem) { - if (newitem == null || newitem.Deleted) + if (newitem?.Deleted != false) installed = false; else newitem.MoveToWorld(new Point3D(Loc[0], Loc[1], Loc[2]), Map.Malas); + return newitem; } @@ -220,16 +221,17 @@ namespace Server.Engines.Doom m_LampRoom?.Unregister(); if (m_Tiles != null) - foreach (Region region in m_Tiles) + foreach (LeverPuzzleRegion region in m_Tiles) region.Unregister(); - if (m_Box != null && !m_Box.Deleted) m_Box.Delete(); + if (m_Box?.Deleted == false) + m_Box.Delete(); } public static void NukeItemList(List list) { - if (list != null && list.Count != 0) + if (list?.Count > 0) foreach (Item item in list) - if (item != null && !item.Deleted) + if (item?.Deleted == false) item.Delete(); } @@ -244,31 +246,29 @@ namespace Server.Engines.Doom public virtual LeverPuzzleStatue GetStatue(int index) { LeverPuzzleStatue statue = (LeverPuzzleStatue)m_Statues[index]; - - if (statue != null && !statue.Deleted) return statue; - return null; + return statue?.Deleted == false ? statue : null; } public virtual LeverPuzzleLever GetLever(int index) { LeverPuzzleLever lever = (LeverPuzzleLever)m_Levers[index]; - if (lever != null && !lever.Deleted) return lever; - return null; + return lever?.Deleted == false ? lever : null; } - public virtual void PuzzleStatus(int message, string fstring) + public virtual void PuzzleStatus(int message, string fstring = null) { for (int i = 0; i < 2; i++) { Item s; - if ((s = GetStatue(i)) != null) s.PublicOverheadMessage(MessageType.Regular, 0x3B2, message, fstring); + if ((s = GetStatue(i)) != null) + s.PublicOverheadMessage(MessageType.Regular, 0x3B2, message, fstring); } } public virtual void ResetPuzzle() { - PuzzleStatus(1062053, null); + PuzzleStatus(1062053); ResetLevers(); } @@ -289,8 +289,8 @@ namespace Server.Engines.Doom public virtual void KillTimers() { - if (l_Timer != null && l_Timer.Running) l_Timer.Stop(); - if (m_Timer != null && m_Timer.Running) m_Timer.Stop(); + if (l_Timer?.Running == true) l_Timer.Stop(); + if (m_Timer?.Running == true) m_Timer.Stop(); } public virtual void RemoveSuccessful() @@ -300,8 +300,7 @@ namespace Server.Engines.Doom public virtual void LeverPulled(ushort code) { - int Correct = 0; - Mobile m_Player; + int correct = 0; KillTimers(); @@ -315,20 +314,21 @@ namespace Server.Engines.Doom if (!CircleComplete) { - PuzzleStatus(1050004, null); // The circle is the key... + PuzzleStatus(1050004); // The circle is the key... } else { + Mobile player; if (TheirKey == MyKey) { GenKey(); - if ((Successful = m_Player = GetOccupant(0)) != null) + if ((Successful = player = GetOccupant(0)) != null) { SendLocationEffect(lp_Center, 0x1153, 0, 60, 1); PlaySounds(lp_Center, cs1); - Effects.SendBoltEffect(m_Player, true); - m_Player.MoveToWorld(lr_Enter, Map.Malas); + Effects.SendBoltEffect(player, true); + player.MoveToWorld(lr_Enter, Map.Malas); m_Timer = new LampRoomTimer(this); m_Timer.Start(); @@ -339,16 +339,13 @@ namespace Server.Engines.Doom { for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */ if (((MyKey >> i) & 1) == 1 && ((TheirKey >> i) & 1) == 1) - Correct++; + correct++; - PuzzleStatus(Statue_Msg[Correct], Correct > 0 ? Correct.ToString() : null); + PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null); for (int i = 0; i < 5; i++) - if ((m_Player = GetOccupant(i)) != null) - { - Timer smash = new RockTimer(m_Player, this); - smash.Start(); - } + if ((player = GetOccupant(i)) != null) + new RockTimer(player, this).Start(); } } @@ -357,33 +354,25 @@ namespace Server.Engines.Doom public virtual void GenKey() /* Shuffle & build key */ { - ushort tmp; - int n, i; ushort[] CA = { 1, 2, 4, 8 }; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - n = (n = Utility.Random(0, 3)) == i ? n & ~i : n; /* if (i==n) { return pointless; } */ - tmp = CA[i]; + int n = (n = Utility.Random(0, 3)) == i ? n & ~i : n; + ushort tmp = CA[i]; CA[i] = CA[n]; CA[n] = tmp; } - for (i = 0; i < 4; MyKey = (ushort)(CA[i++] | (MyKey <<= 4))) + for (int i = 0; i < 4; MyKey = (ushort)(CA[i++] | (MyKey <<= 4))) { } } private static bool IsValidDamagable(Mobile m) { - if (m != null && !m.Deleted) - { - if (m.Player && m.Alive) - return true; - - return m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet; - } - - return false; + return m?.Deleted == false && + (m.Player && m.Alive || + m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet); } public static void MoveMobileOut(Mobile m) @@ -391,7 +380,7 @@ namespace Server.Engines.Doom if (m != null) { if (m is PlayerMobile && !m.Alive) - if (m.Corpse != null && !m.Corpse.Deleted) + if (m.Corpse?.Deleted == false) m.Corpse.MoveToWorld(lr_Exit, Map.Malas); BaseCreature.TeleportPets(m, lr_Exit, Map.Malas); m.Location = lr_Exit; @@ -401,7 +390,7 @@ namespace Server.Engines.Doom public static bool AniSafe(Mobile m) { - return m != null && !TransformationSpellHelper.UnderTransformation(m) && m.BodyMod == 0 && m.Alive; + return m?.BodyMod == 0 && m.Alive && !TransformationSpellHelper.UnderTransformation(m); } public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta) @@ -411,7 +400,7 @@ namespace Server.Engines.Doom public static void DoDamage(Mobile m, int min, int max, bool poison) { - if (m != null && !m.Deleted && m.Alive) + if (m?.Deleted == false && m.Alive) { int damage = Utility.Random(min, max); AOS.Damage(m, damage, poison ? 0 : 100, 0, 0, poison ? 100 : 0, 0); @@ -559,8 +548,8 @@ namespace Server.Engines.Doom { IEntity m_IEntity = new Entity(Serial.Zero, RandomPointIn(m_Player.Location, 10), m_Player.Map); - List mobiles = new List(); - foreach (Mobile m in m_IEntity.Map.GetMobilesInRange(m_IEntity.Location, 2)) mobiles.Add(m); + List mobiles = m_IEntity.Map.GetMobilesInRange(m_IEntity.Location, 2).ToList(); + for (int k = 0; k < mobiles.Count; k++) if (IsValidDamagable(mobiles[k]) && mobiles[k] != m_Player) { @@ -615,7 +604,7 @@ namespace Server.Engines.Doom if (ticks >= 71 || m_Controller.m_LampRoom.GetPlayerCount() == 0) { foreach (Mobile mobile in mobiles) - if (mobile != null && !mobile.Deleted && !mobile.IsDeadBondedPet) + if (mobile?.Deleted == false && !mobile.IsDeadBondedPet) mobile.Kill(); m_Controller.Enabled = true; Stop(); @@ -637,7 +626,8 @@ namespace Server.Engines.Doom DoDamage(mobile, 15, 20, true); } - if (Utility.Random((int)(level & ~0xfffffffc), 3) == 3) mobile.ApplyPoison(mobile, PA2[level]); + 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]); } @@ -648,4 +638,4 @@ namespace Server.Engines.Doom } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs index 95aff9979..a1be099c1 100644 --- a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs @@ -32,7 +32,7 @@ namespace Server.Engines.Doom { m_Wanderer = new WandererOfTheVoid(); m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas); - m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002, ""); // I am the guardian of... + m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002); // I am the guardian of... Timer.DelayCall(TimeSpan.FromSeconds(5.0), CallBackMessage); } } @@ -44,7 +44,7 @@ namespace Server.Engines.Doom public override void OnAfterDelete() { - if (m_Controller != null && !m_Controller.Deleted) + if (m_Controller?.Deleted == false) m_Controller.Delete(); } @@ -80,7 +80,7 @@ namespace Server.Engines.Doom public override void OnAfterDelete() { - if (m_Controller != null && !m_Controller.Deleted) + if (m_Controller?.Deleted == false) m_Controller.Delete(); } @@ -134,7 +134,7 @@ namespace Server.Engines.Doom public override void OnAfterDelete() { - if (m_Controller != null && !m_Controller.Deleted) + if (m_Controller?.Deleted == false) m_Controller.Delete(); } @@ -202,4 +202,4 @@ namespace Server.Engines.Doom int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs index 5d3e91ec5..4c7898a07 100644 --- a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -5,12 +5,12 @@ namespace Server.Engines.Doom { public class LampRoomRegion : BaseRegion { - private LeverPuzzleController Controller; + private LeverPuzzleController m_Controller; public LampRoomRegion(LeverPuzzleController controller) : base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), LeverPuzzleController.lr_Rect) { - Controller = controller; + m_Controller = controller; Register(); } @@ -38,13 +38,13 @@ namespace Server.Engines.Doom if (m.AccessLevel > AccessLevel.Player) return; - if (Controller.Successful != null) + if (m_Controller.Successful != null) { if (m is PlayerMobile) { - if (m == Controller.Successful) return; + if (m == m_Controller.Successful) return; } - else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == Controller.Successful || + else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == m_Controller.Successful || bc.Summoned)) { return; @@ -57,49 +57,36 @@ namespace Server.Engines.Doom public override void OnExit(Mobile m) { - if (m != null && m == Controller.Successful) - Controller.RemoveSuccessful(); + if (m != null && m == m_Controller.Successful) + m_Controller.RemoveSuccessful(); } public override void OnDeath(Mobile m) { - if (m != null && !m.Deleted && !(m is WandererOfTheVoid)) - { - Timer kick = new LeverPuzzleController.LampRoomKickTimer(m); - kick.Start(); - } + if (m?.Deleted != false || m is WandererOfTheVoid) + return; + Timer kick = new LeverPuzzleController.LampRoomKickTimer(m); + kick.Start(); } public override bool OnSkillUse(Mobile m, int Skill) /* just in case */ { - if (Controller.Successful == null || m.AccessLevel == AccessLevel.Player && m != Controller.Successful) - return false; - return true; + return m_Controller.Successful != null && (m.AccessLevel != AccessLevel.Player || m == m_Controller.Successful); } } public class LeverPuzzleRegion : BaseRegion { - private LeverPuzzleController Controller; public Mobile m_Occupant; public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc) : base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0], loc[1], 1, 1)) { - Controller = controller; Register(); } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Occupant - { - get - { - if (m_Occupant != null && m_Occupant.Alive) - return m_Occupant; - return null; - } - } + public Mobile Occupant => m_Occupant?.Alive == true ? m_Occupant : null; public override void OnEnter(Mobile m) { @@ -113,4 +100,4 @@ namespace Server.Engines.Doom m_Occupant = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Core/Ethic.cs b/Scripts/Engines/Ethics/Core/Ethic.cs index 7b728ef22..333379997 100644 --- a/Scripts/Engines/Ethics/Core/Ethic.cs +++ b/Scripts/Engines/Ethics/Core/Ethic.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Ethics.Evil; using Server.Ethics.Hero; using Server.Items; @@ -126,16 +127,7 @@ namespace Server.Ethics if (!Insensitive.Equals(ethic.Definition.JoinPhrase.String, e.Speech)) continue; - bool isNearAnkh = false; - - foreach (Item item in e.Mobile.GetItemsInRange(2)) - if (item is AnkhNorth || item is AnkhWest) - { - isNearAnkh = true; - break; - } - - if (!isNearAnkh) + if (!e.Mobile.GetItemsInRange(2).Any(item => item is AnkhNorth || item is AnkhWest)) continue; pl = new Player(ethic, e.Mobile); @@ -239,4 +231,4 @@ namespace Server.Ethics m_Players[i].Serialize(writer); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Core/Persistance.cs b/Scripts/Engines/Ethics/Core/Persistance.cs index 8a5b200dc..6396149e6 100644 --- a/Scripts/Engines/Ethics/Core/Persistance.cs +++ b/Scripts/Engines/Ethics/Core/Persistance.cs @@ -8,7 +8,7 @@ namespace Server.Ethics { Movable = false; - if (Instance == null || Instance.Deleted) + if (Instance?.Deleted != false) Instance = this; else base.Delete(); @@ -56,4 +56,4 @@ namespace Server.Ethics { } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Core/Player.cs b/Scripts/Engines/Ethics/Core/Player.cs index 4069f89c7..3ee9468f8 100644 --- a/Scripts/Engines/Ethics/Core/Player.cs +++ b/Scripts/Engines/Ethics/Core/Player.cs @@ -104,7 +104,7 @@ namespace Server.Ethics Player pl = pm.EthicPlayer; - if (pl != null && !pl.Ethic.IsEligible(pl.Mobile)) + if (pl?.Ethic.IsEligible(pl.Mobile) == false) pm.EthicPlayer = pl = null; return pl; @@ -157,4 +157,4 @@ namespace Server.Ethics writer.WriteDeltaTime(m_Shield); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs b/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs index f4f52d4ce..53359a8cd 100644 --- a/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs +++ b/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs @@ -18,7 +18,7 @@ namespace Server.Ethics.Evil public override void BeginInvoke(Player from) { - if (from.Familiar != null && from.Familiar.Deleted) + if (from.Familiar?.Deleted == true) from.Familiar = null; if (from.Familiar != null) @@ -43,4 +43,4 @@ namespace Server.Ethics.Evil } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs b/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs index 4e20af9f5..fcef7b4e8 100644 --- a/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs +++ b/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs @@ -18,7 +18,7 @@ namespace Server.Ethics.Evil public override void BeginInvoke(Player from) { - if (from.Steed != null && from.Steed.Deleted) + if (from.Steed?.Deleted == true) from.Steed = null; if (from.Steed != null) @@ -43,4 +43,4 @@ namespace Server.Ethics.Evil } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs b/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs index 0f489b2dd..089e6e3a4 100644 --- a/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs +++ b/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs @@ -18,7 +18,7 @@ namespace Server.Ethics.Hero public override void BeginInvoke(Player from) { - if (from.Steed != null && from.Steed.Deleted) + if (from.Steed?.Deleted == true) from.Steed = null; if (from.Steed != null) @@ -43,4 +43,4 @@ namespace Server.Ethics.Hero } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs b/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs index b6935fa38..1a43a8fa6 100644 --- a/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs +++ b/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs @@ -18,7 +18,7 @@ namespace Server.Ethics.Hero public override void BeginInvoke(Player from) { - if (from.Familiar != null && from.Familiar.Deleted) + if (from.Familiar?.Deleted == true) from.Familiar = null; if (from.Familiar != null) @@ -43,4 +43,4 @@ namespace Server.Ethics.Hero } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Core/Election.cs b/Scripts/Engines/Factions/Core/Election.cs index 5778be84d..93507910e 100644 --- a/Scripts/Engines/Factions/Core/Election.cs +++ b/Scripts/Engines/Factions/Core/Election.cs @@ -550,4 +550,4 @@ namespace Server.Factions Campaign, Election } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Core/Faction.cs b/Scripts/Engines/Factions/Core/Faction.cs index 9363b9f64..d7d708aae 100644 --- a/Scripts/Engines/Factions/Core/Faction.cs +++ b/Scripts/Engines/Factions/Core/Faction.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Accounting; using Server.Commands; using Server.Commands.Generic; @@ -14,10 +15,10 @@ using Server.Targeting; namespace Server.Factions { [CustomEnum(new[] { "Minax", "Council of Mages", "True Britannians", "Shadowlords" })] - public abstract class Faction : IComparable + public abstract class Faction : IComparable { public const int StabilityFactor = 300; // 300% greater (3 times) than smallest faction - public const int StabilityActivation = 200; // Stablity code goes into effect when largest faction has > 200 people + public const int StabilityActivation = 200; // Stability code goes into effect when largest faction has > 200 people public static readonly TimeSpan LeavePeriod = TimeSpan.FromDays(3.0); @@ -87,9 +88,9 @@ namespace Server.Factions public static List Factions => Reflector.Factions; - public int CompareTo(object obj) + public int CompareTo(Faction f) { - return m_Definition.Sort - ((Faction)obj).m_Definition.Sort; + return m_Definition.Sort - (f?.m_Definition.Sort ?? 0); } public void Broadcast(string text) @@ -239,36 +240,18 @@ namespace Server.Factions return false; IPooledEnumerable eable = mob.Map.GetObjectsInRange(mob.Location, range, items, mobs); - - foreach (IEntity obj in eable) - if (type.IsInstanceOfType(obj)) - { - eable.Free(); - return true; - } - + bool isInstance = eable.Any(type.IsInstanceOfType); eable.Free(); - return false; + + return isInstance; } public static bool IsNearType(Mobile mob, Type[] types, int range) { IPooledEnumerable eable = mob.GetObjectsInRange(range); - - foreach (IEntity obj in eable) - { - Type objType = obj.GetType(); - - for (int i = 0; i < types.Length; i++) - if (types[i].IsAssignableFrom(objType)) - { - eable.Free(); - return true; - } - } - + bool found = eable.Any(obj => types.Any(t => t.IsInstanceOfType(obj))); eable.Free(); - return false; + return found; } public void RemovePlayerState(PlayerState pl) @@ -475,7 +458,7 @@ namespace Server.Factions pm.SendLocalizedMessage( 1042161); // You cannot join a faction because your guild is an Order or Chaos type. } - else if (!Guild.NewGuildSystem && guild.Enemies != null && guild.Enemies.Count > 0 + else if (!Guild.NewGuildSystem && guild.Enemies?.Count > 0 ) //CAN join w/wars in new system { pm.SendLocalizedMessage(1005056); // You cannot join a faction with active Wars @@ -1016,7 +999,7 @@ namespace Server.Factions Player killerEPL = Player.Find(killer); Player victimEPL = Player.Find(victim); - if (killerEPL != null && victimEPL != null && victimEPL.Power > 0 && victimState.CanGiveSilverTo(killer)) + if (killerEPL != null && victimEPL?.Power > 0 && victimState.CanGiveSilverTo(killer)) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); @@ -1078,7 +1061,7 @@ namespace Server.Factions Player killerEPL = Player.Find(killer); Player victimEPL = Player.Find(victim); - if (killerEPL != null && victimEPL != null && victimEPL.Power > 0) + if (killerEPL != null && victimEPL?.Power > 0) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); @@ -1385,4 +1368,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Core/FactionItem.cs b/Scripts/Engines/Factions/Core/FactionItem.cs index 9233cc2df..7c370e27f 100644 --- a/Scripts/Engines/Factions/Core/FactionItem.cs +++ b/Scripts/Engines/Factions/Core/FactionItem.cs @@ -44,7 +44,7 @@ namespace Server.Factions { get { - if (Item == null || Item.Deleted) + if (Item?.Deleted != false) return true; return Expiration != DateTime.MinValue && DateTime.UtcNow >= Expiration; @@ -77,7 +77,7 @@ namespace Server.Factions if (Item is IFactionItem item) item.FactionItemState = null; - if (Faction != null && Faction.State.FactionItems.Contains(this)) + if (Faction?.State.FactionItems.Contains(this) == true) Faction.State.FactionItems.Remove(this); } @@ -93,13 +93,7 @@ namespace Server.Factions { PlayerState pl = PlayerState.Find(mob); - if (pl == null) - return 0; - - if (pl.Faction.IsCommander(mob)) - return 9; - - return pl.Rank.MaxWearables; + return pl == null ? 0 : pl.Faction.IsCommander(mob) ? 9 : pl.Rank.MaxWearables; } public static FactionItem Find(Item item) @@ -140,4 +134,4 @@ namespace Server.Factions return item; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Core/Persistance.cs b/Scripts/Engines/Factions/Core/Persistance.cs index 71c3e01e6..cfdd0caac 100644 --- a/Scripts/Engines/Factions/Core/Persistance.cs +++ b/Scripts/Engines/Factions/Core/Persistance.cs @@ -8,7 +8,7 @@ namespace Server.Factions { Movable = false; - if (Instance == null || Instance.Deleted) + if (Instance?.Deleted == true) Instance = this; else base.Delete(); @@ -87,4 +87,4 @@ namespace Server.Factions Town } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Core/PlayerState.cs b/Scripts/Engines/Factions/Core/PlayerState.cs index 7f43fa40c..67e8fb963 100644 --- a/Scripts/Engines/Factions/Core/PlayerState.cs +++ b/Scripts/Engines/Factions/Core/PlayerState.cs @@ -4,7 +4,7 @@ using Server.Mobiles; namespace Server.Factions { - public class PlayerState : IComparable + public class PlayerState : IComparable { private Town m_Finance; @@ -241,17 +241,14 @@ namespace Server.Factions public bool IsActive{ get; set; } - public int CompareTo(object obj) + public int CompareTo(PlayerState ps) { - return ((PlayerState)obj).m_KillPoints - m_KillPoints; + return (ps?.m_KillPoints ?? 0) - m_KillPoints; } public bool CanGiveSilverTo(Mobile mob) { - if (SilverGiven == null) - return true; - - for (int i = 0; i < SilverGiven.Count; ++i) + for (int i = 0; i < SilverGiven?.Count; ++i) { SilverGivenEntry sge = SilverGiven[i]; @@ -307,4 +304,4 @@ namespace Server.Factions return mob is PlayerMobile mobile ? mobile.FactionPlayerState : null; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Core/Town.cs b/Scripts/Engines/Factions/Core/Town.cs index da8a2365d..4bca45747 100644 --- a/Scripts/Engines/Factions/Core/Town.cs +++ b/Scripts/Engines/Factions/Core/Town.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.Factions { [CustomEnum(new[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })] - public abstract class Town : IComparable, IComparable + public abstract class Town : IComparable { public const int SilverCaptureBonus = 10000; @@ -134,12 +134,7 @@ namespace Server.Factions public int CompareTo(Town other) { - return Definition.Sort - other.Definition.Sort; - } - - public int CompareTo(object obj) - { - return Definition.Sort - ((Town)obj).Definition.Sort; + return Definition.Sort - (other?.Definition.Sort ?? 0); } public static Town FromRegion(Region reg) @@ -386,18 +381,14 @@ namespace Server.Factions public bool IsSheriff(Mobile mob) { - if (mob == null || mob.Deleted) - return false; - - return mob.AccessLevel >= AccessLevel.GameMaster || mob == Sheriff; + return mob?.Deleted == false && + (mob.AccessLevel >= AccessLevel.GameMaster || mob == Sheriff); } public bool IsFinance(Mobile mob) { - if (mob == null || mob.Deleted) - return false; - - return mob.AccessLevel >= AccessLevel.GameMaster || mob == Finance; + return mob?.Deleted == false && + (mob.AccessLevel >= AccessLevel.GameMaster || mob == Finance); } public void Capture(Faction f) @@ -511,4 +502,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/ElectionGump.cs b/Scripts/Engines/Factions/Gumps/ElectionGump.cs index e708adc3e..227c4b442 100644 --- a/Scripts/Engines/Factions/Gumps/ElectionGump.cs +++ b/Scripts/Engines/Factions/Gumps/ElectionGump.cs @@ -31,16 +31,16 @@ namespace Server.Factions TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow; int days = (int)(toGo.TotalDays + 0.5); - AddHtmlLocalized(20, 40, 380, 20, 1038034, false, false); // A new election campaign is pending + AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending if (days > 0) { - AddHtmlLocalized(20, 60, 280, 20, 1018062, false, false); // Days until next election : + AddHtmlLocalized(20, 60, 280, 20, 1018062); // Days until next election : AddLabel(300, 60, 0, days.ToString()); } else { - AddHtmlLocalized(20, 60, 280, 20, 1018059, false, false); // Election campaigning begins tonight. + AddHtmlLocalized(20, 60, 280, 20, 1018059); // Election campaigning begins tonight. } break; @@ -50,31 +50,29 @@ namespace Server.Factions TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow; int days = (int)(toGo.TotalDays + 0.5); - AddHtmlLocalized(20, 40, 380, 20, 1018058, false, false); // There is an election campaign in progress. + AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress. if (days > 0) { - AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); // Days to go: + AddHtmlLocalized(20, 60, 280, 20, 1038033); // Days to go: AddLabel(300, 60, 0, days.ToString()); } else { - AddHtmlLocalized(20, 60, 280, 20, 1018061, false, - false); // Campaign in progress. Voting begins tonight. + AddHtmlLocalized(20, 60, 280, 20, 1018061); // Campaign in progress. Voting begins tonight. } if (m_Election.CanBeCandidate(m_From)) { - AddButton(20, 110, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 110, 350, 20, 1011427, false, false); // CAMPAIGN FOR LEADERSHIP + AddButton(20, 110, 4005, 4007, 2); + AddHtmlLocalized(55, 110, 350, 20, 1011427); // CAMPAIGN FOR LEADERSHIP } else { PlayerState pl = PlayerState.Find(m_From); if (pl == null || pl.Rank.Rank < Election.CandidateRank) - AddHtmlLocalized(20, 100, 380, 20, 1010118, false, - false); // You must have a higher rank to run for office + AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office } break; @@ -84,20 +82,20 @@ namespace Server.Factions TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow; int days = (int)Math.Ceiling(toGo.TotalDays); - AddHtmlLocalized(20, 40, 380, 20, 1018060, false, false); // There is an election vote in progress. + AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress. - AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); + AddHtmlLocalized(20, 60, 280, 20, 1038033); AddLabel(300, 60, 0, days.ToString()); - AddHtmlLocalized(55, 100, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP - AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 100, 380, 20, 1011428); // VOTE FOR LEADERSHIP + AddButton(20, 100, 4005, 4007, 1); break; } } - AddButton(20, 140, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 140, 350, 20, 1011012, false, false); // CANCEL + AddButton(20, 140, 4005, 4007, 0); + AddHtmlLocalized(55, 140, 350, 20, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -126,4 +124,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs b/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs index e4f0071dd..d0028826f 100644 --- a/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs +++ b/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs @@ -13,11 +13,7 @@ namespace Server.Factions private Election m_Election; private int m_Page; - public ElectionManagementGump(Election election) : this(election, null, 0) - { - } - - public ElectionManagementGump(Election election, Candidate candidate, int page) : base(40, 40) + public ElectionManagementGump(Election election, Candidate candidate = null, int page = 0) : base(40, 40) { m_Election = election; m_Candidate = candidate; @@ -30,40 +26,39 @@ namespace Server.Factions AddBackground(0, 0, 448, 354, 9270); AddAlphaRegion(10, 10, 428, 334); - AddHtml(10, 10, 428, 20, Color(Center("Candidate Management"), LabelColor), false, false); + AddHtml(10, 10, 428, 20, Color(Center("Candidate Management"), LabelColor)); - AddHtml(45, 35, 100, 20, Color("Player Name:", LabelColor), false, false); - AddHtml(145, 35, 100, 20, Color(candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor), - false, false); + AddHtml(45, 35, 100, 20, Color("Player Name:", LabelColor)); + AddHtml(145, 35, 100, 20, Color(candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor)); - AddHtml(45, 55, 100, 20, Color("Vote Count:", LabelColor), false, false); - AddHtml(145, 55, 100, 20, Color(candidate.Votes.ToString(), LabelColor), false, false); + AddHtml(45, 55, 100, 20, Color("Vote Count:", LabelColor)); + AddHtml(145, 55, 100, 20, Color(candidate.Votes.ToString(), LabelColor)); - AddButton(12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtml(45, 75, 100, 20, Color("Drop Candidate", LabelColor), false, false); + AddButton(12, 73, 4005, 4007, 1); + AddHtml(45, 75, 100, 20, Color("Drop Candidate", LabelColor)); AddImageTiled(13, 99, 422, 242, 9264); AddImageTiled(14, 100, 420, 240, 9274); AddAlphaRegion(14, 100, 420, 240); - AddHtml(14, 100, 420, 20, Color(Center("Voters"), LabelColor), false, false); + AddHtml(14, 100, 420, 20, Color(Center("Voters"), LabelColor)); if (page > 0) - AddButton(397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 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, GumpButtonType.Reply, 0); + AddButton(414, 104, 0x15E1, 0x15E5, 3); else AddImage(414, 104, 0x25E6); - AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false); - AddHtml(47, 120, 150, 20, Color("Name", LabelColor), false, false); - AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor), false, false); - AddHtml(295, 120, 80, 20, Color(Center("Time"), LabelColor), false, false); - AddHtml(355, 120, 60, 20, Color(Center("Legit"), LabelColor), false, false); + AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor)); + AddHtml(47, 120, 150, 20, Color("Name", LabelColor)); + AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor)); + AddHtml(295, 120, 80, 20, Color(Center("Time"), LabelColor)); + AddHtml(355, 120, 60, 20, Color(Center("Legit"), LabelColor)); int idx = 0; @@ -71,7 +66,7 @@ namespace Server.Factions { Voter voter = candidate.Voters[i]; - AddButton(13, 138 + idx * 20, 4002, 4004, 4 + i, GumpButtonType.Reply, 0); + AddButton(13, 138 + idx * 20, 4002, 4004, 4 + i); object[] fields = voter.AcquireFields(); @@ -83,23 +78,23 @@ namespace Server.Factions if (obj is Mobile mobile) { - AddHtml(x + 2, 140 + idx * 20, 150, 20, Color(mobile.Name, LabelColor), false, false); + AddHtml(x + 2, 140 + idx * 20, 150, 20, Color(mobile.Name, LabelColor)); x += 150; } else if (obj is IPAddress) { - AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(obj.ToString()), LabelColor), false, false); + AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(obj.ToString()), LabelColor)); x += 100; } else if (obj is DateTime time) { AddHtml(x, 140 + idx * 20, 80, 20, - Color(Center(FormatTimeSpan(time - election.LastStateTime)), LabelColor), false, false); + Color(Center(FormatTimeSpan(time - election.LastStateTime)), LabelColor)); x += 80; } else if (obj is int i1) { - AddHtml(x, 140 + idx * 20, 60, 20, Color(Center(i1 + "%"), LabelColor), false, false); + AddHtml(x, 140 + idx * 20, 60, 20, Color(Center(i1 + "%"), LabelColor)); x += 60; } } @@ -110,23 +105,23 @@ namespace Server.Factions AddBackground(0, 0, 288, 334, 9270); AddAlphaRegion(10, 10, 268, 314); - AddHtml(10, 10, 268, 20, Color(Center("Election Management"), LabelColor), false, false); + AddHtml(10, 10, 268, 20, Color(Center("Election Management"), LabelColor)); - AddHtml(45, 35, 100, 20, Color("Current State:", LabelColor), false, false); - AddHtml(145, 35, 100, 20, Color(election.State.ToString(), LabelColor), false, false); + AddHtml(45, 35, 100, 20, Color("Current State:", LabelColor)); + AddHtml(145, 35, 100, 20, Color(election.State.ToString(), LabelColor)); - AddButton(12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtml(45, 55, 100, 20, Color("Transition Time:", LabelColor), false, false); - AddHtml(145, 55, 100, 20, Color(FormatTimeSpan(election.NextStateTime), LabelColor), false, false); + AddButton(12, 53, 4005, 4007, 1); + AddHtml(45, 55, 100, 20, Color("Transition Time:", LabelColor)); + AddHtml(145, 55, 100, 20, Color(FormatTimeSpan(election.NextStateTime), LabelColor)); AddImageTiled(13, 79, 262, 242, 9264); AddImageTiled(14, 80, 260, 240, 9274); AddAlphaRegion(14, 80, 260, 240); - AddHtml(14, 80, 260, 20, Color(Center("Candidates"), LabelColor), false, false); - AddHtml(14, 100, 30, 20, Color(Center("-->"), LabelColor), false, false); - AddHtml(47, 100, 150, 20, Color("Name", LabelColor), false, false); - AddHtml(195, 100, 80, 20, Color(Center("Votes"), LabelColor), false, false); + AddHtml(14, 80, 260, 20, Color(Center("Candidates"), LabelColor)); + AddHtml(14, 100, 30, 20, Color(Center("-->"), LabelColor)); + AddHtml(47, 100, 150, 20, Color("Name", LabelColor)); + AddHtml(195, 100, 80, 20, Color(Center("Votes"), LabelColor)); for (int i = 0; i < election.Candidates.Count; ++i) { @@ -136,9 +131,9 @@ namespace Server.Factions if (mob == null) continue; - AddButton(13, 118 + i * 20, 4005, 4007, 2 + i, GumpButtonType.Reply, 0); - AddHtml(47, 120 + i * 20, 150, 20, Color(mob.Name, LabelColor), false, false); - AddHtml(195, 120 + i * 20, 80, 20, Color(Center(cd.Votes.ToString()), LabelColor), false, false); + AddButton(13, 118 + i * 20, 4005, 4007, 2 + i); + AddHtml(47, 120 + i * 20, 150, 20, Color(mob.Name, LabelColor)); + AddHtml(195, 120 + i * 20, 80, 20, Color(Center(cd.Votes.ToString()), LabelColor)); } } } @@ -181,7 +176,7 @@ namespace Server.Factions bid -= 2; if (bid >= 0 && bid < m_Election.Candidates.Count) - from.SendGump(new ElectionManagementGump(m_Election, m_Election.Candidates[bid], 0)); + from.SendGump(new ElectionManagementGump(m_Election, m_Election.Candidates[bid])); } } else @@ -216,4 +211,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/FactionGump.cs b/Scripts/Engines/Factions/Gumps/FactionGump.cs index 4a9911614..0ac6e7b64 100644 --- a/Scripts/Engines/Factions/Gumps/FactionGump.cs +++ b/Scripts/Engines/Factions/Gumps/FactionGump.cs @@ -37,10 +37,10 @@ namespace Server.Factions public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll) { - if (text != null && text.Number > 0) + 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); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs b/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs index d712520e6..8627dfb5a 100644 --- a/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs +++ b/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs @@ -32,33 +32,33 @@ namespace Server.Factions AddBackground(0, 0, 320, 270, 5054); AddBackground(10, 10, 300, 250, 3000); - AddHtmlLocalized(20, 20, 210, 25, 1011569, false, false); // Imbue with Faction properties? + AddHtmlLocalized(20, 20, 210, 25, 1011569); // Imbue with Faction properties? - AddHtmlLocalized(20, 60, 170, 25, 1018302, false, false); // Item quality: - AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality, false, false); // Exceptional, Average, Low + AddHtmlLocalized(20, 60, 170, 25, 1018302); // Item quality: + AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality); // Exceptional, Average, Low - AddHtmlLocalized(20, 80, 170, 25, 1011572, false, false); // Item Cost : + AddHtmlLocalized(20, 80, 170, 25, 1011572); // Item Cost : AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 100, 170, 25, 1011573, false, false); // Your Silver : + AddHtmlLocalized(20, 100, 170, 25, 1011573); // Your Silver : AddLabel(175, 100, 0x34, availableSilver.ToString("N0")); // NOTE: Added 'N0' AddRadio(20, 140, 210, 211, true, 1); AddLabel(55, 140, m_Faction.Definition.HuePrimary - 1, "*****"); - AddHtmlLocalized(150, 140, 150, 25, 1011570, false, false); // Primary Color + AddHtmlLocalized(150, 140, 150, 25, 1011570); // Primary Color AddRadio(20, 160, 210, 211, false, 2); AddLabel(55, 160, m_Faction.Definition.HueSecondary - 1, "*****"); - AddHtmlLocalized(150, 160, 150, 25, 1011571, false, false); // Secondary Color + AddHtmlLocalized(150, 160, 150, 25, 1011571); // Secondary Color - AddHtmlLocalized(55, 200, 200, 25, 1011011, false, false); // CONTINUE - AddButton(20, 200, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 200, 200, 25, 1011011); // CONTINUE + AddButton(20, 200, 4005, 4007, 1); - AddHtmlLocalized(55, 230, 200, 25, 1011012, false, false); // CANCEL - AddButton(20, 230, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 230, 200, 25, 1011012); // CANCEL + AddButton(20, 230, 4005, 4007, 0); } public override void OnResponse(NetState sender, RelayInfo info) @@ -89,7 +89,7 @@ namespace Server.Factions } } - if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0) + 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); @@ -97,4 +97,4 @@ namespace Server.Factions m_Mobile.SendLocalizedMessage(i); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs b/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs index 410ffc868..8ef7087f4 100644 --- a/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs +++ b/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs @@ -26,25 +26,25 @@ namespace Server.Factions AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false); - AddHtmlLocalized(20, 60, 100, 20, 1011429, false, false); // Led By : - AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false); + AddHtmlLocalized(20, 60, 100, 20, 1011429); // Led By : + AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody"); - AddHtmlLocalized(20, 80, 100, 20, 1011457, false, false); // Tithe rate : + 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, false, false); + AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10); else - AddHtml(125, 80, 350, 20, faction.Tithe + "%", false, false); + AddHtml(125, 80, 350, 20, faction.Tithe + "%"); - AddHtmlLocalized(20, 100, 100, 20, 1011458, false, false); // Traps placed : - AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString(), false, false); + AddHtmlLocalized(20, 100, 100, 20, 1011458); // Traps placed : + AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString()); - AddHtmlLocalized(55, 225, 200, 20, 1011428, false, false); // VOTE FOR LEADERSHIP - AddButton(20, 225, 4005, 4007, ToButtonID(0, 0), GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 225, 200, 20, 1011428); // VOTE FOR LEADERSHIP + AddButton(20, 225, 4005, 4007, ToButtonID(0, 0)); - AddHtmlLocalized(55, 150, 100, 20, 1011430, false, false); // CITY STATUS + AddHtmlLocalized(55, 150, 100, 20, 1011430); // CITY STATUS AddButton(20, 150, 4005, 4007, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(55, 175, 100, 20, 1011444, false, false); // STATISTICS + AddHtmlLocalized(55, 175, 100, 20, 1011444); // STATISTICS AddButton(20, 175, 4005, 4007, 0, GumpButtonType.Page, 4); bool isMerchantQualified = MerchantTitles.HasMerchantQualifications(from); @@ -53,31 +53,31 @@ namespace Server.Factions if (pl != null && pl.MerchantTitle != MerchantTitle.None) { - AddHtmlLocalized(55, 200, 250, 20, 1011460, false, false); // UNDECLARE FACTION MERCHANT - AddButton(20, 200, 4005, 4007, ToButtonID(1, 0), GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 200, 250, 20, 1011460); // UNDECLARE FACTION MERCHANT + AddButton(20, 200, 4005, 4007, ToButtonID(1, 0)); } else if (isMerchantQualified) { - AddHtmlLocalized(55, 200, 250, 20, 1011459, false, false); // DECLARE FACTION MERCHANT + AddHtmlLocalized(55, 200, 250, 20, 1011459); // DECLARE FACTION MERCHANT AddButton(20, 200, 4005, 4007, 0, GumpButtonType.Page, 5); } else { - AddHtmlLocalized(55, 200, 250, 20, 1011467, false, false); // MERCHANT OPTIONS + AddHtmlLocalized(55, 200, 250, 20, 1011467); // MERCHANT OPTIONS AddImage(20, 200, 4020); } - AddHtmlLocalized(55, 250, 300, 20, 1011461, false, false); // COMMANDER OPTIONS + 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, false, false); // LEAVE THIS FACTION - AddButton(20, 275, 4005, 4007, ToButtonID(0, 1), GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 275, 300, 20, 1011426); // LEAVE THIS FACTION + AddButton(20, 275, 4005, 4007, ToButtonID(0, 1)); - AddHtmlLocalized(55, 300, 200, 20, 1011441, false, false); // EXIT - AddButton(20, 300, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 300, 200, 20, 1011441); // EXIT + AddButton(20, 300, 4005, 4007, 0); #endregion @@ -85,7 +85,7 @@ namespace Server.Factions AddPage(2); - AddHtmlLocalized(20, 30, 250, 20, 1011430, false, false); // CITY STATUS + AddHtmlLocalized(20, 30, 250, 20, 1011430); // CITY STATUS List towns = Town.Towns; @@ -97,11 +97,11 @@ namespace Server.Factions if (town.Owner == null) { - AddHtmlLocalized(200, 55 + i * 30, 150, 20, 1011462, false, false); // : Neutral + AddHtmlLocalized(200, 55 + i * 30, 150, 20, 1011462); // : Neutral } else { - AddHtmlLocalized(200, 55 + i * 30, 150, 20, town.Owner.Definition.OwnerLabel, false, false); + AddHtmlLocalized(200, 55 + i * 30, 150, 20, town.Owner.Definition.OwnerLabel); BaseMonolith monolith = town.Monolith; @@ -111,12 +111,12 @@ namespace Server.Factions AddImage(20, 300, 2361); - AddHtmlLocalized(45, 295, 300, 20, 1011491, false, false); // sigil may be recaptured + AddHtmlLocalized(45, 295, 300, 20, 1011491); // sigil may be recaptured AddImage(20, 320, 2360); - AddHtmlLocalized(45, 315, 300, 20, 1011492, false, false); // sigil may not be recaptured + AddHtmlLocalized(45, 315, 300, 20, 1011492); // sigil may not be recaptured - AddHtmlLocalized(55, 350, 100, 20, 1011447, false, false); // BACK + AddHtmlLocalized(55, 350, 100, 20, 1011447); // BACK AddButton(20, 350, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -125,18 +125,18 @@ namespace Server.Factions AddPage(4); - AddHtmlLocalized(20, 30, 150, 20, 1011444, false, false); // STATISTICS + AddHtmlLocalized(20, 30, 150, 20, 1011444); // STATISTICS - AddHtmlLocalized(20, 100, 100, 20, 1011445, false, false); // Name : - AddHtml(120, 100, 150, 20, from.Name, false, false); + AddHtmlLocalized(20, 100, 100, 20, 1011445); // Name : + AddHtml(120, 100, 150, 20, from.Name); - AddHtmlLocalized(20, 130, 100, 20, 1018064, false, false); // score : - AddHtml(120, 130, 100, 20, (pl?.KillPoints ?? 0).ToString(), false, false); + AddHtmlLocalized(20, 130, 100, 20, 1018064); // score : + AddHtml(120, 130, 100, 20, (pl?.KillPoints ?? 0).ToString()); - AddHtmlLocalized(20, 160, 100, 20, 1011446, false, false); // Rank : - AddHtml(120, 160, 100, 20, (pl?.Rank.Rank ?? 0).ToString(), false, false); + AddHtmlLocalized(20, 160, 100, 20, 1011446); // Rank : + AddHtml(120, 160, 100, 20, (pl?.Rank.Rank ?? 0).ToString()); - AddHtmlLocalized(55, 250, 100, 20, 1011447, false, false); // BACK + AddHtmlLocalized(55, 250, 100, 20, 1011447); // BACK AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -147,9 +147,9 @@ namespace Server.Factions { AddPage(5); - AddHtmlLocalized(20, 30, 250, 20, 1011467, false, false); // MERCHANT OPTIONS + AddHtmlLocalized(20, 30, 250, 20, 1011467); // MERCHANT OPTIONS - AddHtmlLocalized(20, 80, 300, 20, 1011473, false, false); // Select the title you wish to display + AddHtmlLocalized(20, 80, 300, 20, 1011473); // Select the title you wish to display MerchantTitleInfo[] infos = MerchantTitles.Info; @@ -158,14 +158,14 @@ namespace Server.Factions MerchantTitleInfo info = infos[i]; if (MerchantTitles.IsQualified(from, info)) - AddButton(20, 100 + i * 30, 4005, 4007, ToButtonID(1, i + 1), GumpButtonType.Reply, 0); + 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); } - AddHtmlLocalized(55, 340, 100, 20, 1011447, false, false); // BACK + AddHtmlLocalized(55, 340, 100, 20, 1011447); // BACK AddButton(20, 340, 4005, 4007, 0, GumpButtonType.Page, 1); } @@ -179,27 +179,27 @@ namespace Server.Factions AddPage(6); - AddHtmlLocalized(20, 30, 200, 20, 1011461, false, false); // COMMANDER OPTIONS + AddHtmlLocalized(20, 30, 200, 20, 1011461); // COMMANDER OPTIONS - AddHtmlLocalized(20, 70, 120, 20, 1011457, false, false); // Tithe rate : + 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, false, false); + AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10); else - AddHtml(140, 70, 250, 20, faction.Tithe + "%", false, false); + AddHtml(140, 70, 250, 20, faction.Tithe + "%"); - AddHtmlLocalized(20, 100, 120, 20, 1011474, false, false); // Silver available : - AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0"), false, false); // NOTE: Added 'N0' formatting + AddHtmlLocalized(20, 100, 120, 20, 1011474); // Silver available : + AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0")); // NOTE: Added 'N0' formatting - AddHtmlLocalized(55, 130, 200, 20, 1011478, false, false); // CHANGE TITHE RATE + AddHtmlLocalized(55, 130, 200, 20, 1011478); // CHANGE TITHE RATE AddButton(20, 130, 4005, 4007, 0, GumpButtonType.Page, 8); - AddHtmlLocalized(55, 160, 200, 20, 1018301, false, false); // TRANSFER SILVER + 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, false, false); // BACK + AddHtmlLocalized(55, 310, 100, 20, 1011447); // BACK AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -210,9 +210,9 @@ namespace Server.Factions { AddPage(7); - AddHtmlLocalized(20, 30, 250, 20, 1011476, false, false); // TOWN FINANCE + AddHtmlLocalized(20, 30, 250, 20, 1011476); // TOWN FINANCE - AddHtmlLocalized(20, 50, 400, 20, 1011477, false, false); // Select a town to transfer 10000 silver to + AddHtmlLocalized(20, 50, 400, 20, 1011477); // Select a town to transfer 10000 silver to for (int i = 0; i < towns.Count; ++i) { @@ -221,12 +221,12 @@ 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), GumpButtonType.Reply, 0); + AddButton(20, 75 + i * 30, 4005, 4007, ToButtonID(2, i)); else AddImage(20, 75 + i * 30, 4020); } - AddHtmlLocalized(55, 310, 100, 20, 1011447, false, false); // BACK + AddHtmlLocalized(55, 310, 100, 20, 1011447); // BACK AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); } @@ -236,7 +236,7 @@ namespace Server.Factions AddPage(8); - AddHtmlLocalized(20, 30, 400, 20, 1011479, false, false); // Select the % for the new tithe rate + AddHtmlLocalized(20, 30, 400, 20, 1011479); // Select the % for the new tithe rate int y = 55; @@ -245,8 +245,8 @@ namespace Server.Factions if (i == 5) y += 5; - AddHtmlLocalized(55, y, 300, 20, 1011480 + i, false, false); - AddButton(20, y, 4005, 4007, ToButtonID(3, i), GumpButtonType.Reply, 0); + AddHtmlLocalized(55, y, 300, 20, 1011480 + i); + AddButton(20, y, 4005, 4007, ToButtonID(3, i)); y += 20; @@ -254,7 +254,7 @@ namespace Server.Factions y += 5; } - AddHtmlLocalized(55, 310, 300, 20, 1011447, false, false); // BACK + AddHtmlLocalized(55, 310, 300, 20, 1011447); // BACK AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -354,4 +354,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/FinanceGump.cs b/Scripts/Engines/Factions/Gumps/FinanceGump.cs index 8b37c80c2..a4ac3201f 100644 --- a/Scripts/Engines/Factions/Gumps/FinanceGump.cs +++ b/Scripts/Engines/Factions/Gumps/FinanceGump.cs @@ -35,20 +35,20 @@ namespace Server.Factions AddPage(1); - AddHtmlLocalized(20, 30, 260, 25, 1011541, false, false); // FINANCE MINISTER + AddHtmlLocalized(20, 30, 260, 25, 1011541); // FINANCE MINISTER - AddHtmlLocalized(55, 90, 200, 25, 1011539, false, false); // CHANGE PRICES + AddHtmlLocalized(55, 90, 200, 25, 1011539); // CHANGE PRICES AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(55, 120, 200, 25, 1011540, false, false); // BUY SHOPKEEPERS + AddHtmlLocalized(55, 120, 200, 25, 1011540); // BUY SHOPKEEPERS AddButton(20, 120, 4005, 4007, 0, GumpButtonType.Page, 3); - AddHtmlLocalized(55, 150, 200, 25, 1011495, false, false); // VIEW FINANCES + AddHtmlLocalized(55, 150, 200, 25, 1011495); // VIEW FINANCES AddButton(20, 150, 4005, 4007, 0, GumpButtonType.Page, 4); - AddHtmlLocalized(55, 360, 200, 25, 1011441, false, false); // EXIT - AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 360, 200, 25, 1011441); // EXIT + AddButton(20, 360, 4005, 4007, 0); #endregion @@ -56,7 +56,7 @@ namespace Server.Factions AddPage(2); - AddHtmlLocalized(20, 30, 200, 25, 1011539, false, false); // CHANGE PRICES + AddHtmlLocalized(20, 30, 200, 25, 1011539); // CHANGE PRICES for (int i = 0; i < m_PriceOffsets.Length; ++i) { @@ -74,12 +74,12 @@ namespace Server.Factions } AddRadio(20, 270, 208, 209, town.Tax == 0, 0); - AddHtmlLocalized(55, 270, 90, 25, 1011542, false, false); // normal + AddHtmlLocalized(55, 270, 90, 25, 1011542); // normal - AddHtmlLocalized(55, 330, 200, 25, 1011509, false, false); // Set Prices - AddButton(20, 330, 4005, 4007, ToButtonID(0, 0), GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 330, 200, 25, 1011509); // Set Prices + AddButton(20, 330, 4005, 4007, ToButtonID(0, 0)); - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -88,7 +88,7 @@ namespace Server.Factions AddPage(3); - AddHtmlLocalized(20, 30, 200, 25, 1011540, false, false); // BUY SHOPKEEPERS + AddHtmlLocalized(20, 30, 200, 25, 1011540); // BUY SHOPKEEPERS List vendorLists = town.VendorLists; @@ -101,7 +101,7 @@ namespace Server.Factions AddHtmlText(100, 90 + i * 40, 200, 25, list.Definition.Label, false, false); } - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -116,24 +116,24 @@ namespace Server.Factions int netCashFlow = town.NetCashFlow; - AddHtmlLocalized(20, 30, 300, 25, 1011524, false, false); // FINANCE STATEMENT + AddHtmlLocalized(20, 30, 300, 25, 1011524); // FINANCE STATEMENT - AddHtmlLocalized(20, 80, 300, 25, 1011538, false, false); // Current total money for town : + AddHtmlLocalized(20, 80, 300, 25, 1011538); // Current total money for town : AddLabel(20, 100, 0x44, town.Silver.ToString()); - AddHtmlLocalized(20, 130, 300, 25, 1011520, false, false); // Finance Minister Upkeep : + AddHtmlLocalized(20, 130, 300, 25, 1011520); // Finance Minister Upkeep : AddLabel(20, 150, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 180, 300, 25, 1011521, false, false); // Sheriff Upkeep : + AddHtmlLocalized(20, 180, 300, 25, 1011521); // Sheriff Upkeep : AddLabel(20, 200, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 230, 300, 25, 1011522, false, false); // Town Income : + AddHtmlLocalized(20, 230, 300, 25, 1011522); // Town Income : AddLabel(20, 250, 0x44, dailyIncome.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 280, 300, 25, 1011523, false, false); // Net Cash flow per day : + AddHtmlLocalized(20, 280, 300, 25, 1011523); // Net Cash flow per day : AddLabel(20, 300, 0x44, netCashFlow.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -149,31 +149,31 @@ namespace Server.Factions AddHtmlText(60, 30, 300, 25, vendorList.Definition.Header, false, false); AddItem(20, 30, vendorList.Definition.ItemID); - AddHtmlLocalized(20, 90, 200, 25, 1011514, false, false); // You have : + AddHtmlLocalized(20, 90, 200, 25, 1011514); // You have : AddLabel(230, 90, 0x26, vendorList.Vendors.Count.ToString()); - AddHtmlLocalized(20, 120, 200, 25, 1011515, false, false); // Maximum : + AddHtmlLocalized(20, 120, 200, 25, 1011515); // Maximum : AddLabel(230, 120, 0x256, vendorList.Definition.Maximum.ToString()); - AddHtmlLocalized(20, 150, 200, 25, 1011516, false, false); // Cost : + AddHtmlLocalized(20, 150, 200, 25, 1011516); // Cost : AddLabel(230, 150, 0x44, vendorList.Definition.Price.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 180, 200, 25, 1011517, false, false); // Daily Pay : + AddHtmlLocalized(20, 180, 200, 25, 1011517); // Daily Pay : AddLabel(230, 180, 0x37, vendorList.Definition.Upkeep.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 210, 200, 25, 1011518, false, false); // Current Silver : + AddHtmlLocalized(20, 210, 200, 25, 1011518); // Current Silver : AddLabel(230, 210, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 240, 200, 25, 1011519, false, false); // Current Payroll : + AddHtmlLocalized(20, 240, 200, 25, 1011519); // Current Payroll : AddLabel(230, 240, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0' AddHtmlText(55, 300, 200, 25, vendorList.Definition.Label, false, false); if (town.Silver >= vendorList.Definition.Price) - AddButton(20, 300, 4005, 4007, ToButtonID(1, i), GumpButtonType.Reply, 0); + AddButton(20, 300, 4005, 4007, ToButtonID(1, i)); else AddImage(20, 300, 4020); - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3); } @@ -289,4 +289,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs b/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs index 513fb6001..97aedfca3 100644 --- a/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs +++ b/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs @@ -22,7 +22,7 @@ namespace Server.Factions AddHtmlText(20, 30, 300, 25, faction.Definition.Header, false, false); - AddHtmlLocalized(20, 60, 300, 25, 1018306, false, false); // Purchase a Faction War Horse + AddHtmlLocalized(20, 60, 300, 25, 1018306); // Purchase a Faction War Horse AddItem(70, 120, 0x3FFE); AddItem(150, 120, 0xEF2); @@ -31,11 +31,11 @@ namespace Server.Factions AddItem(150, 150, 0xEEF); AddLabel(190, 152, 0x3E3, FactionWarHorse.GoldPrice.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(55, 210, 200, 25, 1011011, false, false); // CONTINUE - AddButton(20, 210, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 210, 200, 25, 1011011); // CONTINUE + AddButton(20, 210, 4005, 4007, 1); - AddHtmlLocalized(55, 240, 200, 25, 1011012, false, false); // CANCEL - AddButton(20, 240, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 240, 200, 25, 1011012); // CANCEL + AddButton(20, 240, 4005, 4007, 0); } public override void OnResponse(NetState sender, RelayInfo info) @@ -88,4 +88,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs b/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs index c53811756..96874dd37 100644 --- a/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs +++ b/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs @@ -24,21 +24,21 @@ namespace Server.Factions AddHtmlText(20, 130, 510, 100, faction.Definition.About, true, true); - AddHtmlLocalized(20, 60, 100, 20, 1011429, false, false); // Led By : - AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false); + AddHtmlLocalized(20, 60, 100, 20, 1011429); // Led By : + AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody"); - AddHtmlLocalized(20, 80, 100, 20, 1011457, false, false); // Tithe rate : + 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, false, false); + AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10); else - AddHtml(125, 80, 350, 20, faction.Tithe + "%", false, false); + AddHtml(125, 80, 350, 20, faction.Tithe + "%"); - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 200, 20, 1011425, false, false); // JOIN THIS FACTION + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 200, 20, 1011425); // JOIN THIS FACTION - AddButton(300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 200, 20, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 0); + AddHtmlLocalized(335, 400, 200, 20, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -47,4 +47,4 @@ namespace Server.Factions m_Faction.OnJoinAccepted(m_From); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs b/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs index db5d67b56..5c3ac78b7 100644 --- a/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs +++ b/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs @@ -25,11 +25,11 @@ namespace Server.Factions else AddHtmlLocalized(20, 15, 230, 60, 1018063, true, true); // Are you sure you want to leave this faction? - AddHtmlLocalized(55, 80, 75, 20, 1011011, false, false); // CONTINUE - AddButton(20, 80, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE + AddButton(20, 80, 4005, 4007, 1); - AddHtmlLocalized(170, 80, 75, 20, 1011012, false, false); // CANCEL - AddButton(135, 80, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddHtmlLocalized(170, 80, 75, 20, 1011012); // CANCEL + AddButton(135, 80, 4005, 4007, 2); } public override void OnResponse(NetState sender, RelayInfo info) @@ -90,4 +90,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/SheriffGump.cs b/Scripts/Engines/Factions/Gumps/SheriffGump.cs index ec8131e6e..0eaa77a09 100644 --- a/Scripts/Engines/Factions/Gumps/SheriffGump.cs +++ b/Scripts/Engines/Factions/Gumps/SheriffGump.cs @@ -28,16 +28,16 @@ namespace Server.Factions AddPage(1); - AddHtmlLocalized(20, 30, 260, 25, 1011431, false, false); // Sheriff + AddHtmlLocalized(20, 30, 260, 25, 1011431); // Sheriff - AddHtmlLocalized(55, 90, 200, 25, 1011494, false, false); // HIRE GUARDS + AddHtmlLocalized(55, 90, 200, 25, 1011494); // HIRE GUARDS AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 3); - AddHtmlLocalized(55, 120, 200, 25, 1011495, false, false); // VIEW FINANCES + AddHtmlLocalized(55, 120, 200, 25, 1011495); // VIEW FINANCES AddButton(20, 120, 4005, 4007, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(55, 360, 200, 25, 1011441, false, false); // Exit - AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 360, 200, 25, 1011441); // Exit + AddButton(20, 360, 4005, 4007, 0); #endregion @@ -50,24 +50,24 @@ namespace Server.Factions int dailyIncome = town.DailyIncome; int netCashFlow = town.NetCashFlow; - AddHtmlLocalized(20, 30, 300, 25, 1011524, false, false); // FINANCE STATEMENT + AddHtmlLocalized(20, 30, 300, 25, 1011524); // FINANCE STATEMENT - AddHtmlLocalized(20, 80, 300, 25, 1011538, false, false); // Current total money for town : + AddHtmlLocalized(20, 80, 300, 25, 1011538); // Current total money for town : AddLabel(20, 100, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 130, 300, 25, 1011520, false, false); // Finance Minister Upkeep : + AddHtmlLocalized(20, 130, 300, 25, 1011520); // Finance Minister Upkeep : AddLabel(20, 150, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 180, 300, 25, 1011521, false, false); // Sheriff Upkeep : + AddHtmlLocalized(20, 180, 300, 25, 1011521); // Sheriff Upkeep : AddLabel(20, 200, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 230, 300, 25, 1011522, false, false); // Town Income : + AddHtmlLocalized(20, 230, 300, 25, 1011522); // Town Income : AddLabel(20, 250, 0x44, dailyIncome.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 280, 300, 25, 1011523, false, false); // Net Cash flow per day : + AddHtmlLocalized(20, 280, 300, 25, 1011523); // Net Cash flow per day : AddLabel(20, 300, 0x44, netCashFlow.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -76,7 +76,7 @@ namespace Server.Factions AddPage(3); - AddHtmlLocalized(20, 30, 300, 25, 1011494, false, false); // HIRE GUARDS + AddHtmlLocalized(20, 30, 300, 25, 1011494); // HIRE GUARDS List guardLists = town.GuardLists; @@ -90,7 +90,7 @@ namespace Server.Factions AddHtmlText(120, y, 200, 25, guardList.Definition.Header, false, false); } - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); #endregion @@ -106,28 +106,28 @@ namespace Server.Factions AddHtmlText(90, 30, 300, 25, guardList.Definition.Header, false, false); CenterItem(guardList.Definition.ItemID, 10, 10, 80, 80); - AddHtmlLocalized(20, 90, 200, 25, 1011514, false, false); // You have : + AddHtmlLocalized(20, 90, 200, 25, 1011514); // You have : AddLabel(230, 90, 0x26, guardList.Guards.Count.ToString()); - AddHtmlLocalized(20, 120, 200, 25, 1011515, false, false); // Maximum : + AddHtmlLocalized(20, 120, 200, 25, 1011515); // Maximum : AddLabel(230, 120, 0x12A, guardList.Definition.Maximum.ToString()); - AddHtmlLocalized(20, 150, 200, 25, 1011516, false, false); // Cost : + AddHtmlLocalized(20, 150, 200, 25, 1011516); // Cost : AddLabel(230, 150, 0x44, guardList.Definition.Price.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 180, 200, 25, 1011517, false, false); // Daily Pay : + AddHtmlLocalized(20, 180, 200, 25, 1011517); // Daily Pay : AddLabel(230, 180, 0x37, guardList.Definition.Upkeep.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 210, 200, 25, 1011518, false, false); // Current Silver : + AddHtmlLocalized(20, 210, 200, 25, 1011518); // Current Silver : AddLabel(230, 210, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0' - AddHtmlLocalized(20, 240, 200, 25, 1011519, false, false); // Current Payroll : + AddHtmlLocalized(20, 240, 200, 25, 1011519); // Current Payroll : AddLabel(230, 240, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0' AddHtmlText(55, 300, 200, 25, guardList.Definition.Label, false, false); - AddButton(20, 300, 4005, 4007, 1 + i, GumpButtonType.Reply, 0); + AddButton(20, 300, 4005, 4007, 1 + i); - AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3); } @@ -185,4 +185,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/TownStoneGump.cs b/Scripts/Engines/Factions/Gumps/TownStoneGump.cs index 2e78f0c41..ddae02bb0 100644 --- a/Scripts/Engines/Factions/Gumps/TownStoneGump.cs +++ b/Scripts/Engines/Factions/Gumps/TownStoneGump.cs @@ -24,20 +24,20 @@ namespace Server.Factions AddHtmlText(25, 30, 250, 25, town.Definition.TownStoneHeader, false, false); - AddHtmlLocalized(55, 60, 150, 25, 1011557, false, false); // Hire Sheriff - AddButton(20, 60, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 60, 150, 25, 1011557); // Hire Sheriff + AddButton(20, 60, 4005, 4007, 1); - AddHtmlLocalized(55, 90, 150, 25, 1011559, false, false); // Hire Finance Minister - AddButton(20, 90, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 90, 150, 25, 1011559); // Hire Finance Minister + AddButton(20, 90, 4005, 4007, 2); - AddHtmlLocalized(55, 120, 150, 25, 1011558, false, false); // Fire Sheriff - AddButton(20, 120, 4005, 4007, 3, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 120, 150, 25, 1011558); // Fire Sheriff + AddButton(20, 120, 4005, 4007, 3); - AddHtmlLocalized(55, 150, 150, 25, 1011560, false, false); // Fire Finance Minister - AddButton(20, 150, 4005, 4007, 4, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 150, 150, 25, 1011560); // Fire Finance Minister + AddButton(20, 150, 4005, 4007, 4); - AddHtmlLocalized(55, 210, 150, 25, 1011441, false, false); // EXIT - AddButton(20, 210, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 210, 150, 25, 1011441); // EXIT + AddButton(20, 210, 4005, 4007, 0); } public override void OnResponse(NetState sender, RelayInfo info) @@ -201,4 +201,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Gumps/VoteGump.cs b/Scripts/Engines/Factions/Gumps/VoteGump.cs index fbe278890..98a697b06 100644 --- a/Scripts/Engines/Factions/Gumps/VoteGump.cs +++ b/Scripts/Engines/Factions/Gumps/VoteGump.cs @@ -24,23 +24,23 @@ namespace Server.Factions AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false); if (canVote) - AddHtmlLocalized(20, 60, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP + AddHtmlLocalized(20, 60, 380, 20, 1011428); // VOTE FOR LEADERSHIP else - AddHtmlLocalized(20, 60, 380, 20, 1038032, false, false); // You have already voted in this election. + AddHtmlLocalized(20, 60, 380, 20, 1038032); // You have already voted in this election. for (int i = 0; i < election.Candidates.Count; ++i) { Candidate cd = election.Candidates[i]; if (canVote) - AddButton(20, 100 + i * 20, 4005, 4007, i + 1, GumpButtonType.Reply, 0); + 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()); } - AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 310, 100, 20, 1011012, false, false); // CANCEL + AddButton(20, 310, 4005, 4007, 0); + AddHtmlLocalized(55, 310, 100, 20, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -63,4 +63,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/BaseMonolith.cs b/Scripts/Engines/Factions/Items/BaseMonolith.cs index 9675b421c..2ccb9e2e9 100644 --- a/Scripts/Engines/Factions/Items/BaseMonolith.cs +++ b/Scripts/Engines/Factions/Items/BaseMonolith.cs @@ -8,7 +8,7 @@ namespace Server.Factions private Sigil m_Sigil; private Town m_Town; - public BaseMonolith(Town town, Faction faction) : base(0x1183) + public BaseMonolith(Town town = null, Faction faction = null) : base(0x1183) { Movable = false; Town = town; @@ -80,7 +80,7 @@ namespace Server.Factions public virtual void UpdateSigil() { - if (m_Sigil == null || m_Sigil.Deleted) + if (m_Sigil?.Deleted != false) return; m_Sigil.MoveToWorld(new Point3D(X, Y, Z + 18), Map); @@ -126,4 +126,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/FactionStone.cs b/Scripts/Engines/Factions/Items/FactionStone.cs index aeecf5014..0881ba539 100644 --- a/Scripts/Engines/Factions/Items/FactionStone.cs +++ b/Scripts/Engines/Factions/Items/FactionStone.cs @@ -8,12 +8,7 @@ namespace Server.Factions private Faction m_Faction; [Constructible] - public FactionStone() : this(null) - { - } - - [Constructible] - public FactionStone(Faction faction) : base(0xEDC) + public FactionStone(Faction faction = null) : base(0xEDC) { Movable = false; Faction = faction; @@ -101,4 +96,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/JoinStone.cs b/Scripts/Engines/Factions/Items/JoinStone.cs index 3a29610fb..98baa22b7 100644 --- a/Scripts/Engines/Factions/Items/JoinStone.cs +++ b/Scripts/Engines/Factions/Items/JoinStone.cs @@ -8,12 +8,7 @@ namespace Server.Factions private Faction m_Faction; [Constructible] - public JoinStone() : this(null) - { - } - - [Constructible] - public JoinStone(Faction faction) : base(0xEDC) + public JoinStone(Faction faction = null) : base(0xEDC) { Movable = false; Faction = faction; @@ -76,4 +71,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs b/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs index d41c93929..87da13935 100644 --- a/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs +++ b/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Factions; using Server.Spells; using Server.Targeting; @@ -34,64 +35,61 @@ namespace Server Point3D origin = new Point3D(pt); Map facet = from.Map; - if (facet != null && facet.CanFit(pt.X, pt.Y, pt.Z, 16, false, false)) - { - Movable = false; + if (facet?.CanFit(pt.X, pt.Y, pt.Z, 16, false, false) != true) + return; - Effects.SendMovingEffect( - from, new Entity(Serial.Zero, origin, facet), - ItemID & 0x3FFF, 7, 0, false, false, Hue - 1 + Movable = false; + + Effects.SendMovingEffect( + from, new Entity(Serial.Zero, origin, facet), + ItemID & 0x3FFF, 7, 0, false, false, Hue - 1 + ); + + Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate + { + Delete(); + + Effects.PlaySound(origin, facet, 530); + Effects.PlaySound(origin, facet, 263); + + Effects.SendLocationEffect( + origin, facet, + 14284, 96, 1, 0, 2 ); - Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate + Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate { - Delete(); + List targets = facet.GetMobilesInRange(origin, 12).Where(mob => + from.CanBeHarmful(mob, false) && mob.InLOS(new Point3D(origin, origin.Z + 1)) && + Faction.Find(mob) != null).ToList(); - Effects.PlaySound(origin, facet, 530); - Effects.PlaySound(origin, facet, 263); - - Effects.SendLocationEffect( - origin, facet, - 14284, 96, 1, 0, 2 - ); - - Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate + foreach (Mobile mob in targets) { - List targets = new List(); + int damage = mob.Hits * 6 / 10; - foreach (Mobile mob in facet.GetMobilesInRange(origin, 12)) - if (from.CanBeHarmful(mob, false) && - mob.InLOS(new Point3D(origin, origin.Z + 1))) - if (Faction.Find(mob) != null) - targets.Add(mob); + if (!mob.Player && damage < 10) + damage = 10; + else if (damage > 75) + damage = 75; - foreach (Mobile mob in targets) - { - int damage = mob.Hits * 6 / 10; + Effects.SendMovingEffect( + new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob, + 14068, 1, 32, false, false, 1111, 2 + ); - if (!mob.Player && damage < 10) - damage = 10; - else if (damage > 75) damage = 75; + from.DoHarmful(mob); - Effects.SendMovingEffect( - new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob, - 14068, 1, 32, false, false, 1111, 2 - ); + SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3.0, 0, 0, 0, 0, + 100); + SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3.0, 0, 0, 0, 0, + 100); + SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0, + 100); - from.DoHarmful(mob); - - SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3.0, 0, 0, 0, 0, - 100); - SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3.0, 0, 0, 0, 0, - 100); - SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0, - 100); - - Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); }); - } - }); + Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); }); + } }); - } + }); } }); @@ -112,4 +110,4 @@ namespace Server int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs b/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs index e66bebb8e..4033462ba 100644 --- a/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs +++ b/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs @@ -36,7 +36,7 @@ namespace Server { Faction.ClearSkillLoss(mob); - mob.SendGump(new ResurrectGump(mob, from, ResurrectMessage.Generic)); + mob.SendGump(new ResurrectGump(mob, from)); used = true; } } diff --git a/Scripts/Engines/Factions/Items/Sigil.cs b/Scripts/Engines/Factions/Items/Sigil.cs index 916ab3be2..18a8d9bc9 100644 --- a/Scripts/Engines/Factions/Items/Sigil.cs +++ b/Scripts/Engines/Factions/Items/Sigil.cs @@ -181,7 +181,7 @@ namespace Server.Factions return false; } - private Mobile FindOwner(object parent) + private Mobile FindOwner(IEntity parent) { if (parent is Item item) return item.RootParent as Mobile; @@ -425,10 +425,10 @@ namespace Server.Factions if (monolith == null && m_Town != null) monolith = m_Town.Monolith; - if (monolith != null && !monolith.Deleted) + if (monolith?.Deleted == false) monolith.Sigil = this; - return monolith != null && !monolith.Deleted; + return monolith?.Deleted == false; } public override void OnParentDeleted(IEntity parent) @@ -453,4 +453,4 @@ namespace Server.Factions base.Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/StrongholdMonolith.cs b/Scripts/Engines/Factions/Items/StrongholdMonolith.cs index 5ac5edd1d..782f821cc 100644 --- a/Scripts/Engines/Factions/Items/StrongholdMonolith.cs +++ b/Scripts/Engines/Factions/Items/StrongholdMonolith.cs @@ -2,12 +2,9 @@ namespace Server.Factions { public class StrongholdMonolith : BaseMonolith { - public StrongholdMonolith() : this(null, null) + public StrongholdMonolith(Town town = null, Faction faction = null) : base(town, faction) { - } - public StrongholdMonolith(Town town, Faction faction) : base(town, faction) - { } public StrongholdMonolith(Serial serial) : base(serial) @@ -35,4 +32,4 @@ namespace Server.Factions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/TownMonolith.cs b/Scripts/Engines/Factions/Items/TownMonolith.cs index 83b7a95c2..feb670beb 100644 --- a/Scripts/Engines/Factions/Items/TownMonolith.cs +++ b/Scripts/Engines/Factions/Items/TownMonolith.cs @@ -2,11 +2,7 @@ namespace Server.Factions { public class TownMonolith : BaseMonolith { - public TownMonolith() : this(null) - { - } - - public TownMonolith(Town town) : base(town, null) + public TownMonolith(Town town = null) : base(town) { } @@ -35,4 +31,4 @@ namespace Server.Factions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/TownStone.cs b/Scripts/Engines/Factions/Items/TownStone.cs index 31f47229f..ab7ba5600 100644 --- a/Scripts/Engines/Factions/Items/TownStone.cs +++ b/Scripts/Engines/Factions/Items/TownStone.cs @@ -7,12 +7,7 @@ namespace Server.Factions private Town m_Town; [Constructible] - public TownStone() : this(null) - { - } - - [Constructible] - public TownStone(Town town) : base(0xEDE) + public TownStone(Town town = null) : base(0xEDE) { Movable = false; Town = town; @@ -81,4 +76,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs b/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs index c9f5f25be..405998579 100644 --- a/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs +++ b/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs @@ -80,7 +80,7 @@ namespace Server.Factions { PlayerState victimState = PlayerState.Find(from); - if (victimState != null && victimState.CanGiveSilverTo(Placer) && victimState.KillPoints > 0) + if (victimState?.CanGiveSilverTo(Placer) == true && victimState.KillPoints > 0) { int silverGiven = Faction.AwardSilver(Placer, silverToAward); @@ -236,7 +236,7 @@ namespace Server.Factions public override void OnDelete() { - if (Faction != null && Faction.Traps.Contains(this)) + if (Faction?.Traps.Contains(this) == true) Faction.Traps.Remove(this); base.OnDelete(); @@ -261,4 +261,4 @@ namespace Server.Factions return faction != Faction; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs b/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs index 254a55fe9..06646e33e 100644 --- a/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs +++ b/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs @@ -8,16 +8,12 @@ namespace Server.Factions { private Faction m_Faction; - public BaseFactionTrapDeed(int itemID) : base(itemID) + public BaseFactionTrapDeed(int itemID= 0x14F0) : base(itemID) { Weight = 1.0; LootType = LootType.Blessed; } - public BaseFactionTrapDeed(bool createdFromDeed) : this(0x14F0) - { - } - public BaseFactionTrapDeed(Serial serial) : base(serial) { } @@ -120,4 +116,4 @@ namespace Server.Factions m_Faction = Faction.ReadReference(reader); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Traps/FactionExplosionTrap.cs b/Scripts/Engines/Factions/Items/Traps/FactionExplosionTrap.cs index bcb193df5..920e5fa72 100644 --- a/Scripts/Engines/Factions/Items/Traps/FactionExplosionTrap.cs +++ b/Scripts/Engines/Factions/Items/Traps/FactionExplosionTrap.cs @@ -4,16 +4,7 @@ namespace Server.Factions { public class FactionExplosionTrap : BaseFactionTrap { - [Constructible] - public FactionExplosionTrap() : this(null) - { - } - - public FactionExplosionTrap(Faction f) : this(f, null) - { - } - - public FactionExplosionTrap(Faction f, Mobile m) : base(f, m, 0x11C1) + public FactionExplosionTrap(Faction f = null, Mobile m = null) : base(f, m, 0x11C1) { } @@ -81,4 +72,4 @@ namespace Server.Factions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Traps/FactionGasTrap.cs b/Scripts/Engines/Factions/Items/Traps/FactionGasTrap.cs index 8a8fdcfc4..ea8602e1a 100644 --- a/Scripts/Engines/Factions/Items/Traps/FactionGasTrap.cs +++ b/Scripts/Engines/Factions/Items/Traps/FactionGasTrap.cs @@ -4,16 +4,7 @@ namespace Server.Factions { public class FactionGasTrap : BaseFactionTrap { - [Constructible] - public FactionGasTrap() : this(null) - { - } - - public FactionGasTrap(Faction f) : this(f, null) - { - } - - public FactionGasTrap(Faction f, Mobile m) : base(f, m, 0x113C) + public FactionGasTrap(Faction f = null, Mobile m = null) : base(f, m, 0x113C) { } @@ -81,4 +72,4 @@ namespace Server.Factions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Traps/FactionSawTrap.cs b/Scripts/Engines/Factions/Items/Traps/FactionSawTrap.cs index 376652372..6432656ff 100644 --- a/Scripts/Engines/Factions/Items/Traps/FactionSawTrap.cs +++ b/Scripts/Engines/Factions/Items/Traps/FactionSawTrap.cs @@ -4,20 +4,7 @@ namespace Server.Factions { public class FactionSawTrap : BaseFactionTrap { - [Constructible] - public FactionSawTrap() : this(null) - { - } - - public FactionSawTrap(Serial serial) : base(serial) - { - } - - public FactionSawTrap(Faction f) : this(f, null) - { - } - - public FactionSawTrap(Faction f, Mobile m) : base(f, m, 0x11AC) + public FactionSawTrap(Faction f = null, Mobile m = null) : base(f, m, 0x11AC) { } @@ -81,4 +68,4 @@ namespace Server.Factions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Items/Traps/FactionSpikeTrap.cs b/Scripts/Engines/Factions/Items/Traps/FactionSpikeTrap.cs index 530d6df22..47303e819 100644 --- a/Scripts/Engines/Factions/Items/Traps/FactionSpikeTrap.cs +++ b/Scripts/Engines/Factions/Items/Traps/FactionSpikeTrap.cs @@ -4,16 +4,7 @@ namespace Server.Factions { public class FactionSpikeTrap : BaseFactionTrap { - [Constructible] - public FactionSpikeTrap() : this(null) - { - } - - public FactionSpikeTrap(Faction f) : this(f, null) - { - } - - public FactionSpikeTrap(Faction f, Mobile m) : base(f, m, 0x11A0) + public FactionSpikeTrap(Faction f = null, Mobile m = null) : base(f, m, 0x11A0) { } @@ -84,4 +75,4 @@ namespace Server.Factions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs b/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs index aa26edf01..ab9acc150 100644 --- a/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs +++ b/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs @@ -8,13 +8,8 @@ namespace Server.Factions public const int GoldPrice = 3000; private Faction m_Faction; - [Constructible] - public FactionWarHorse() : this(null) - { - } - - public FactionWarHorse(Faction faction) : base("a war horse", 0xE2, 0x3EA0, AIType.AI_Melee, FightMode.Aggressor, 10, - 1, 0.2, 0.4) + public FactionWarHorse(Faction faction = null) + : base("a war horse", 0xE2, 0x3EA0, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0xA8; @@ -109,4 +104,4 @@ namespace Server.Factions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs b/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs index 4282e7223..a69d30cf1 100644 --- a/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs +++ b/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs @@ -241,68 +241,68 @@ namespace Server.Factions } else if (DateTime.UtcNow < m_OrdersEnd) { - if (m_Town != null && m_Town.IsSheriff(from) && Town.FromRegion(Region) == m_Town) + if (m_Town?.IsSheriff(from) != true || Town.FromRegion(Region) != m_Town) + return; + + m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + + bool understood = true; + 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) { - m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0); + understood = false; - bool understood = true; - 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) + if (Insensitive.Contains(e.Speech, "civil")) { - understood = false; + ChangeReaction(null, newType); + understood = true; + } - if (Insensitive.Contains(e.Speech, "civil")) + List factions = Faction.Factions; + + for (int i = 0; i < factions.Count; ++i) + { + Faction faction = factions[i]; + + if (faction != m_Faction && Insensitive.Contains(e.Speech, faction.Definition.Keyword)) { - ChangeReaction(null, newType); + ChangeReaction(faction, newType); understood = true; } - - List factions = Faction.Factions; - - for (int i = 0; i < factions.Count; ++i) - { - Faction faction = factions[i]; - - if (faction != m_Faction && Insensitive.Contains(e.Speech, faction.Definition.Keyword)) - { - ChangeReaction(faction, newType); - understood = true; - } - } } - else if (Insensitive.Contains(e.Speech, "patrol")) - { - Home = Location; - RangeHome = 6; - Combatant = null; - Orders.Movement = MovementType.Patrol; - Say(1005146); // This spot looks like it needs protection! I shall guard it with my life. - understood = true; - } - else if (Insensitive.Contains(e.Speech, "follow")) - { - Home = Location; - RangeHome = 6; - Combatant = null; - Orders.Follow = from; - Orders.Movement = MovementType.Follow; - Say(1005144); // Yes, Sire. - understood = true; - } - - if (!understood) - Say(1042183); // I'm sorry, I don't understand your orders... } + else if (Insensitive.Contains(e.Speech, "patrol")) + { + Home = Location; + RangeHome = 6; + Combatant = null; + Orders.Movement = MovementType.Patrol; + Say(1005146); // This spot looks like it needs protection! I shall guard it with my life. + understood = true; + } + else if (Insensitive.Contains(e.Speech, "follow")) + { + Home = Location; + RangeHome = 6; + Combatant = null; + Orders.Follow = from; + Orders.Movement = MovementType.Follow; + Say(1005144); // Yes, Sire. + understood = true; + } + + if (!understood) + Say(1042183); // I'm sorry, I don't understand your orders... } } } @@ -525,4 +525,4 @@ namespace Server.Factions Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs index 2c1c2a774..b3f3e9451 100644 --- a/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -27,11 +27,7 @@ namespace Server.Factions public class ComboEntry { - public ComboEntry(Type spell) : this(spell, 100, TimeSpan.Zero) - { - } - - public ComboEntry(Type spell, int chance) : this(spell, chance, TimeSpan.Zero) + public ComboEntry(Type spell, int chance = 100) : this(spell, chance, TimeSpan.Zero) { } @@ -170,7 +166,7 @@ namespace Server.Factions public bool EquipWeapon() { Item weapon = m_Guard.Backpack?.FindItemByType(); - + return weapon != null && m_Guard.EquipItem(weapon); } @@ -225,18 +221,18 @@ namespace Server.Factions switch (Utility.Random(maxCircle * 2)) { case 0: - case 1: return new MagicArrowSpell(m_Guard, null); + case 1: return new MagicArrowSpell(m_Guard); case 2: - case 3: return new HarmSpell(m_Guard, null); + case 3: return new HarmSpell(m_Guard); case 4: - case 5: return new FireballSpell(m_Guard, null); + case 5: return new FireballSpell(m_Guard); case 6: - case 7: return new LightningSpell(m_Guard, null); - case 8: return new MindBlastSpell(m_Guard, null); - case 9: return new ParalyzeSpell(m_Guard, null); - case 10: return new EnergyBoltSpell(m_Guard, null); - case 11: return new ExplosionSpell(m_Guard, null); - default: return new FlameStrikeSpell(m_Guard, null); + case 7: return new LightningSpell(m_Guard); + case 8: return new MindBlastSpell(m_Guard); + case 9: return new ParalyzeSpell(m_Guard); + case 10: return new EnergyBoltSpell(m_Guard); + case 11: return new ExplosionSpell(m_Guard); + default: return new FlameStrikeSpell(m_Guard); } } @@ -255,7 +251,7 @@ namespace Server.Factions Mobile comb = m_Mobile.Combatant; - if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, 12) && + if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, 12) && CanDispel(comb)) { active = comb; @@ -317,7 +313,7 @@ namespace Server.Factions Mobile comb = m_Mobile.Combatant; - if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb)) + if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb)) { active = inactive = comb; actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb); @@ -427,7 +423,7 @@ namespace Server.Factions Mobile combatant = m_Guard.Combatant; - if (combatant == null || combatant.Deleted || !combatant.Alive || combatant.IsDeadBondedPet || + if (combatant?.Deleted != false || !combatant.Alive || combatant.IsDeadBondedPet || !m_Mobile.CanSee(combatant) || !m_Mobile.CanBeHarmful(combatant, false) || combatant.Map != m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them @@ -473,7 +469,7 @@ 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 is DispelSpell.InternalTarget) + else if ((targ as ISpellTarget)?.Spell is DispelSpell) targ.Cancel(m_Guard, TargetCancelType.Canceled); } else if ((targ.Flags & TargetFlags.Beneficial) != 0) @@ -512,10 +508,7 @@ namespace Server.Factions if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow) { - toFollow = m_Guard.Orders.Follow; - - if (toFollow == null) - toFollow = m_Guard.Town.Sheriff; + toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff; } if (toFollow != null && toFollow.Map == m_Guard.Map && @@ -577,7 +570,7 @@ namespace Server.Factions m_Guard.HitsMax - m_Guard.Hits > Utility.Random(250)) { if (IsAllowed(GuardAI.Bless)) - spell = new CureSpell(m_Guard, null); + spell = new CureSpell(m_Guard); else UseItemByType(typeof(BaseCurePotion)); } @@ -588,16 +581,16 @@ namespace Server.Factions m_Guard.Home != Point3D.Zero && !Utility.InRange(m_Guard.Location, m_Guard.Home, 15) && m_Guard.Mana >= 11) { - spell = new RecallSpell(m_Guard, null, - new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null)); + spell = new RecallSpell(m_Guard, + new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home")); } else if (IsAllowed(GuardAI.Bless)) { if (m_Guard.Mana >= 11 && m_Guard.Hits + 30 < m_Guard.HitsMax) - spell = new GreaterHealSpell(m_Guard, null); + 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, null); + spell = new HealSpell(m_Guard); } else if (m_Guard.CanBeginAction()) { @@ -608,9 +601,9 @@ namespace Server.Factions (IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse))) { if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && 40 > Utility.Random(100)) - spell = new ParalyzeSpell(m_Guard, null); + spell = new ParalyzeSpell(m_Guard); else - spell = new DispelSpell(m_Guard, null); + spell = new DispelSpell(m_Guard); } if (combatant != null) @@ -672,7 +665,7 @@ namespace Server.Factions if (IsAllowed(GuardAI.Bless)) { if (types.Count > 1) - spell = new BlessSpell(m_Guard, null); + spell = new BlessSpell(m_Guard); else if (types.Count == 1) spell = Activator.CreateInstance(types[0], m_Guard, null) as Spell; } @@ -690,7 +683,7 @@ namespace Server.Factions { if (!combatant.Poisoned && 40 > Utility.Random(100)) { - spell = new PoisonSpell(m_Guard, null); + spell = new PoisonSpell(m_Guard); } else { @@ -710,7 +703,7 @@ namespace Server.Factions types.Add(typeof(FeeblemindSpell)); if (types.Count > 1) - spell = new CurseSpell(m_Guard, null); + spell = new CurseSpell(m_Guard); else if (types.Count == 1) spell = (Spell)Activator.CreateInstance(types[0], m_Guard, null); } @@ -738,7 +731,7 @@ namespace Server.Factions if (spell is GreaterHealSpell) { if (m_Guard.Hits + 30 > m_Guard.HitsMax && m_Guard.Hits + 10 < m_Guard.HitsMax) - spell = new HealSpell(m_Guard, null); + spell = new HealSpell(m_Guard); } else { @@ -751,7 +744,7 @@ namespace Server.Factions UseItemByType(typeof(BaseRefreshPotion)); } - if (spell == null || !spell.Cast()) + if (spell?.Cast() != true) EquipWeapon(); } else if (spell?.State == SpellState.Sequencing) @@ -762,4 +755,4 @@ namespace Server.Factions return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Harvest/Core/HarvestSystem.cs b/Scripts/Engines/Harvest/Core/HarvestSystem.cs index f86223d1d..693a0a636 100644 --- a/Scripts/Engines/Harvest/Core/HarvestSystem.cs +++ b/Scripts/Engines/Harvest/Core/HarvestSystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Items; using Server.Targeting; @@ -16,7 +17,7 @@ namespace Server.Engines.Harvest public virtual bool CheckTool(Mobile from, Item tool) { - bool wornOut = tool == null || tool.Deleted || tool is IUsesRemaining remaining && remaining.UsesRemaining <= 0; + bool wornOut = tool?.Deleted != false || tool is IUsesRemaining remaining && remaining.UsesRemaining <= 0; if (wornOut) from.SendLocalizedMessage(1044038); // You have worn out your tool! @@ -47,7 +48,7 @@ namespace Server.Engines.Harvest public virtual bool CheckResources(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed) { HarvestBank bank = def.GetBank(map, loc.X, loc.Y); - bool available = bank != null && bank.Current >= def.ConsumedPerHarvest; + bool available = bank?.Current >= def.ConsumedPerHarvest; if (!available) def.SendMessageTo(from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage); @@ -136,7 +137,7 @@ namespace Server.Engines.Harvest HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback); double skillBase = from.Skills[def.Skill].Base; - double skillValue = from.Skills[def.Skill].Value; + // double skillValue = from.Skills[def.Skill].Value; Type type = null; @@ -194,7 +195,7 @@ namespace Server.Engines.Harvest BonusHarvestResource bonus = def.GetBonusResource(); - if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill) + if (bonus?.Type != null && skillBase >= bonus.ReqSkill) { Item bonusItem = Construct(bonus.Type, from); @@ -279,18 +280,8 @@ namespace Server.Engines.Harvest if (map == null) return false; - List atFeet = new List(); - - foreach (Item obj in m.GetItemsInRange(0)) - atFeet.Add(obj); - - for (int i = 0; i < atFeet.Count; ++i) - { - Item check = atFeet[i]; - - if (check.StackWith(m, item, false)) - return true; - } + if (m.GetItemsInRange(0).Any(t => t.StackWith(m, item, false))) + return true; item.MoveToWorld(m.Location, map); return true; @@ -305,10 +296,7 @@ namespace Server.Engines.Harvest public virtual Type GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource) { - if (resource.Types.Length > 0) - return resource.Types[Utility.Random(resource.Types.Length)]; - - return null; + return resource.Types.Length > 0 ? resource.Types[Utility.Random(resource.Types.Length)] : null; } public virtual HarvestResource MutateResource(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, @@ -391,17 +379,7 @@ namespace Server.Engines.Harvest public virtual HarvestDefinition GetDefinition(int tileID) { - HarvestDefinition def = null; - - for (int i = 0; def == null && i < Definitions.Count; ++i) - { - HarvestDefinition check = Definitions[i]; - - if (check.Validate(tileID)) - def = check; - } - - return def; + return Definitions.FirstOrDefault(check => check.Validate(tileID)); } public virtual void StartHarvesting(Mobile from, Item tool, object toHarvest) @@ -488,7 +466,7 @@ namespace Server { public static bool Check(Item item) { - return item != null && item.GetType().IsDefined(typeof(FurnitureAttribute), false); + return item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Harvest/Fishing.cs b/Scripts/Engines/Harvest/Fishing.cs index b51b9439d..d642da9ba 100644 --- a/Scripts/Engines/Harvest/Fishing.cs +++ b/Scripts/Engines/Harvest/Fishing.cs @@ -38,60 +38,38 @@ namespace Server.Engines.Harvest private Fishing() { - HarvestResource[] res; - HarvestVein[] veins; - - #region Fishing - - HarvestDefinition fish = new HarvestDefinition(); - - // Resource banks are every 8x8 tiles - fish.BankWidth = 8; - fish.BankHeight = 8; - - // Every bank holds from 5 to 15 fish - fish.MinTotal = 5; - fish.MaxTotal = 15; - - // A resource bank will respawn its content every 10 to 20 minutes - fish.MinRespawn = TimeSpan.FromMinutes(10.0); - fish.MaxRespawn = TimeSpan.FromMinutes(20.0); - - // Skill checking is done on the Fishing skill - fish.Skill = SkillName.Fishing; - - // Set the list of harvestable tiles - fish.Tiles = m_WaterTiles; - fish.RangedTiles = true; - - // Players must be within 4 tiles to harvest - fish.MaxRange = 4; - - // One fish per harvest action - fish.ConsumedPerHarvest = 1; - fish.ConsumedPerFeluccaHarvest = 1; - - // The fishing - fish.EffectActions = new[] { 12 }; - fish.EffectSounds = new int[0]; - fish.EffectCounts = new[] { 1 }; - fish.EffectDelay = TimeSpan.Zero; - fish.EffectSoundDelay = TimeSpan.FromSeconds(8.0); - - fish.NoResourcesMessage = 503172; // The fish don't seem to be biting here. - fish.FailMessage = 503171; // You fish a while, but fail to catch anything. - fish.TimedOutOfRangeMessage = 500976; // You need to be closer to the water to fish! - fish.OutOfRangeMessage = 500976; // You need to be closer to the water to fish! - fish.PackFullMessage = 503176; // You do not have room in your backpack for a fish. - fish.ToolBrokeMessage = 503174; // You broke your fishing pole. - - res = new[] + HarvestDefinition fish = new HarvestDefinition { + BankWidth = 8, + BankHeight = 8, + MinTotal = 5, + MaxTotal = 15, + MinRespawn = TimeSpan.FromMinutes(10.0), + MaxRespawn = TimeSpan.FromMinutes(20.0), + Skill = SkillName.Fishing, + Tiles = m_WaterTiles, + RangedTiles = true, + MaxRange = 4, + ConsumedPerHarvest = 1, + ConsumedPerFeluccaHarvest = 1, + EffectActions = new[] { 12 }, + EffectSounds = new int[0], + EffectCounts = new[] { 1 }, + EffectDelay = TimeSpan.Zero, + EffectSoundDelay = TimeSpan.FromSeconds(8.0), + NoResourcesMessage = 503172, // The fish don't seem to be biting here. + FailMessage = 503171, // You fish a while, but fail to catch anything. + TimedOutOfRangeMessage = 500976, // You need to be closer to the water to fish! + OutOfRangeMessage = 500976, // You need to be closer to the water to fish! + PackFullMessage = 503176, // You do not have room in your backpack for a fish. + ToolBrokeMessage = 503174 // You broke your fishing pole. + }; + + HarvestResource[] res = { new HarvestResource(00.0, 00.0, 100.0, 1043297, typeof(Fish)) }; - veins = new[] - { + HarvestVein[] veins = { new HarvestVein(100.0, 0.0, res[0], null) }; @@ -107,20 +85,9 @@ namespace Server.Engines.Harvest Definition = fish; Definitions.Add(fish); - - #endregion } - public static Fishing System - { - get - { - if (m_System == null) - m_System = new Fishing(); - - return m_System; - } - } + public static Fishing System => m_System ?? (m_System = new Fishing()); public HarvestDefinition Definition{ get; } @@ -191,10 +158,7 @@ namespace Server.Engines.Harvest private static Map SafeMap(Map map) { - if (map == null || map == Map.Internal) - return Map.Trammel; - - return map; + return map == null || map == Map.Internal ? Map.Trammel : map; } public override bool CheckResources(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed) @@ -324,10 +288,7 @@ namespace Server.Engines.Harvest TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(4, sos.Level))); - if (sos.IsAncient) - chest.DropItem(new FabledFishingNet()); - else - chest.DropItem(new SpecialFishingNet()); + chest.DropItem(sos.IsAncient ? new FabledFishingNet() : new SpecialFishingNet()); chest.Movable = true; chest.Locked = false; @@ -388,10 +349,7 @@ namespace Server.Engines.Harvest return true; // we don't want to give the item to the player, it's on the serpent } - if (item is BigFish || item is WoodenChest || item is MetalGoldenChest) - placeAtFeet = true; - - return base.Give(m, item, placeAtFeet); + return base.Give(m, item, placeAtFeet || item is BigFish || item is WoodenChest || item is MetalGoldenChest); } public override void SendSuccessTo(Mobile from, Item item, HarvestResource resource) @@ -547,4 +505,4 @@ namespace Server.Engines.Harvest } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Harvest/Lumberjacking.cs b/Scripts/Engines/Harvest/Lumberjacking.cs index 4219a96e5..c66eead6c 100644 --- a/Scripts/Engines/Harvest/Lumberjacking.cs +++ b/Scripts/Engines/Harvest/Lumberjacking.cs @@ -43,47 +43,30 @@ namespace Server.Engines.Harvest HarvestResource[] res; HarvestVein[] veins; - #region Lumberjacking - - HarvestDefinition lumber = new HarvestDefinition(); - - // Resource banks are every 4x3 tiles - lumber.BankWidth = 4; - lumber.BankHeight = 3; - - // Every bank holds from 20 to 45 logs - lumber.MinTotal = 20; - lumber.MaxTotal = 45; - - // A resource bank will respawn its content every 20 to 30 minutes - lumber.MinRespawn = TimeSpan.FromMinutes(20.0); - lumber.MaxRespawn = TimeSpan.FromMinutes(30.0); - - // Skill checking is done on the Lumberjacking skill - lumber.Skill = SkillName.Lumberjacking; - - // Set the list of harvestable tiles - lumber.Tiles = m_TreeTiles; - - // Players must be within 2 tiles to harvest - lumber.MaxRange = 2; - - // Ten logs per harvest action - lumber.ConsumedPerHarvest = 10; - lumber.ConsumedPerFeluccaHarvest = 20; - - // The chopping effect - lumber.EffectActions = new[] { 13 }; - lumber.EffectSounds = new[] { 0x13E }; - lumber.EffectCounts = Core.AOS ? new[] { 1 } : new[] { 1, 2, 2, 2, 3 }; - lumber.EffectDelay = TimeSpan.FromSeconds(1.6); - lumber.EffectSoundDelay = TimeSpan.FromSeconds(0.9); - - lumber.NoResourcesMessage = 500493; // There's not enough wood here to harvest. - lumber.FailMessage = 500495; // You hack at the tree for a while, but fail to produce any useable wood. - lumber.OutOfRangeMessage = 500446; // That is too far away. - lumber.PackFullMessage = 500497; // You can't place any wood into your backpack! - lumber.ToolBrokeMessage = 500499; // You broke your axe. + HarvestDefinition lumber = new HarvestDefinition + { + BankWidth = 4, + BankHeight = 3, + MinTotal = 20, + MaxTotal = 45, + MinRespawn = TimeSpan.FromMinutes(20.0), + MaxRespawn = TimeSpan.FromMinutes(30.0), + Skill = SkillName.Lumberjacking, + Tiles = m_TreeTiles, + MaxRange = 2, + ConsumedPerHarvest = 10, + ConsumedPerFeluccaHarvest = 20, + EffectActions = new[] { 13 }, + EffectSounds = new[] { 0x13E }, + EffectCounts = Core.AOS ? new[] { 1 } : new[] { 1, 2, 2, 2, 3 }, + EffectDelay = TimeSpan.FromSeconds(1.6), + EffectSoundDelay = TimeSpan.FromSeconds(0.9), + NoResourcesMessage = 500493, // There's not enough wood here to harvest. + FailMessage = 500495, // You hack at the tree for a while, but fail to produce any useable wood. + OutOfRangeMessage = 500446, // That is too far away. + PackFullMessage = 500497, // You can't place any wood into your backpack! + ToolBrokeMessage = 500499 // You broke your axe. + }; if (Core.ML) { @@ -141,20 +124,9 @@ namespace Server.Engines.Harvest Definition = lumber; Definitions.Add(lumber); - - #endregion } - public static Lumberjacking System - { - get - { - if (m_System == null) - m_System = new Lumberjacking(); - - return m_System; - } - } + public static Lumberjacking System => m_System ?? (m_System = new Lumberjacking()); public HarvestDefinition Definition{ get; } @@ -212,4 +184,4 @@ namespace Server.Engines.Harvest Array.Sort(m_TreeTiles); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Harvest/Mining.cs b/Scripts/Engines/Harvest/Mining.cs index a06ddf046..043ebbc52 100644 --- a/Scripts/Engines/Harvest/Mining.cs +++ b/Scripts/Engines/Harvest/Mining.cs @@ -23,55 +23,36 @@ namespace Server.Engines.Harvest private Mining() { - HarvestResource[] res; - HarvestVein[] veins; - #region Mining for ore and stone - HarvestDefinition oreAndStone = OreAndStone = new HarvestDefinition(); - - // Resource banks are every 8x8 tiles - oreAndStone.BankWidth = 8; - oreAndStone.BankHeight = 8; - - // Every bank holds from 10 to 34 ore - oreAndStone.MinTotal = 10; - oreAndStone.MaxTotal = 34; - - // A resource bank will respawn its content every 10 to 20 minutes - oreAndStone.MinRespawn = TimeSpan.FromMinutes(10.0); - oreAndStone.MaxRespawn = TimeSpan.FromMinutes(20.0); - - // Skill checking is done on the Mining skill - oreAndStone.Skill = SkillName.Mining; - - // Set the list of harvestable tiles - oreAndStone.Tiles = m_MountainAndCaveTiles; - - // Players must be within 2 tiles to harvest - oreAndStone.MaxRange = 2; - - // One ore per harvest action - oreAndStone.ConsumedPerHarvest = 1; - oreAndStone.ConsumedPerFeluccaHarvest = 2; - - // The digging effect - oreAndStone.EffectActions = new[] { 11 }; - oreAndStone.EffectSounds = new[] { 0x125, 0x126 }; - oreAndStone.EffectCounts = new[] { 1 }; - oreAndStone.EffectDelay = TimeSpan.FromSeconds(1.6); - oreAndStone.EffectSoundDelay = TimeSpan.FromSeconds(0.9); - - oreAndStone.NoResourcesMessage = 503040; // There is no metal here to mine. - oreAndStone.DoubleHarvestMessage = 503042; // Someone has gotten to the metal before you. - oreAndStone.TimedOutOfRangeMessage = 503041; // You have moved too far away to continue mining. - oreAndStone.OutOfRangeMessage = 500446; // That is too far away. - oreAndStone.FailMessage = 503043; // You loosen some rocks but fail to find any useable ore. - oreAndStone.PackFullMessage = 1010481; // Your backpack is full, so the ore you mined is lost. - oreAndStone.ToolBrokeMessage = 1044038; // You have worn out your tool! - - res = new[] + OreAndStone = new HarvestDefinition { + BankWidth = 8, + BankHeight = 8, + MinTotal = 10, + MaxTotal = 34, + MinRespawn = TimeSpan.FromMinutes(10.0), + MaxRespawn = TimeSpan.FromMinutes(20.0), + Skill = SkillName.Mining, + Tiles = m_MountainAndCaveTiles, + MaxRange = 2, + ConsumedPerHarvest = 1, + ConsumedPerFeluccaHarvest = 2, + EffectActions = new[] { 11 }, + EffectSounds = new[] { 0x125, 0x126 }, + EffectCounts = new[] { 1 }, + EffectDelay = TimeSpan.FromSeconds(1.6), + EffectSoundDelay = TimeSpan.FromSeconds(0.9), + NoResourcesMessage = 503040, // There is no metal here to mine. + DoubleHarvestMessage = 503042, // Someone has gotten to the metal before you. + TimedOutOfRangeMessage = 503041, // You have moved too far away to continue mining. + OutOfRangeMessage = 500446, // That is too far away. + FailMessage = 503043, // You loosen some rocks but fail to find any useable ore. + PackFullMessage = 1010481, // Your backpack is full, so the ore you mined is lost. + ToolBrokeMessage = 1044038 // You have worn out your tool! + }; + + HarvestResource[] res = { new HarvestResource(00.0, 00.0, 100.0, 1007072, typeof(IronOre), typeof(Granite)), new HarvestResource(65.0, 25.0, 105.0, 1007073, typeof(DullCopperOre), typeof(DullCopperGranite), typeof(DullCopperElemental)), @@ -91,8 +72,7 @@ namespace Server.Engines.Harvest typeof(ValoriteElemental)) }; - veins = new[] - { + HarvestVein[] veins = { new HarvestVein(49.6, 0.0, res[0], null), // Iron new HarvestVein(11.2, 0.5, res[1], res[0]), // Dull Copper new HarvestVein(09.8, 0.5, res[2], res[0]), // Shadow Iron @@ -104,11 +84,11 @@ namespace Server.Engines.Harvest new HarvestVein(01.4, 0.5, res[8], res[0]) // Valorite }; - oreAndStone.Resources = res; - oreAndStone.Veins = veins; + OreAndStone.Resources = res; + OreAndStone.Veins = veins; if (Core.ML) - oreAndStone.BonusResources = new[] + OreAndStone.BonusResources = new[] { new BonusHarvestResource(0, 99.4, null, null), //Nothing new BonusHarvestResource(100, .1, 1072562, typeof(BlueDiamond)), @@ -119,56 +99,41 @@ namespace Server.Engines.Harvest new BonusHarvestResource(100, .1, 1072568, typeof(Turquoise)) }; - oreAndStone.RaceBonus = Core.ML; - oreAndStone.RandomizeVeins = Core.ML; + OreAndStone.RaceBonus = Core.ML; + OreAndStone.RandomizeVeins = Core.ML; - Definitions.Add(oreAndStone); + Definitions.Add(OreAndStone); #endregion #region Mining for sand - HarvestDefinition sand = Sand = new HarvestDefinition(); - - // Resource banks are every 8x8 tiles - sand.BankWidth = 8; - sand.BankHeight = 8; - - // Every bank holds from 6 to 12 sand - sand.MinTotal = 6; - sand.MaxTotal = 12; - - // A resource bank will respawn its content every 10 to 20 minutes - sand.MinRespawn = TimeSpan.FromMinutes(10.0); - sand.MaxRespawn = TimeSpan.FromMinutes(20.0); - - // Skill checking is done on the Mining skill - sand.Skill = SkillName.Mining; - - // Set the list of harvestable tiles - sand.Tiles = m_SandTiles; - - // Players must be within 2 tiles to harvest - sand.MaxRange = 2; - - // One sand per harvest action - sand.ConsumedPerHarvest = 1; - sand.ConsumedPerFeluccaHarvest = 1; - - // The digging effect - sand.EffectActions = new[] { 11 }; - sand.EffectSounds = new[] { 0x125, 0x126 }; - sand.EffectCounts = new[] { 6 }; - sand.EffectDelay = TimeSpan.FromSeconds(1.6); - sand.EffectSoundDelay = TimeSpan.FromSeconds(0.9); - - sand.NoResourcesMessage = 1044629; // There is no sand here to mine. - sand.DoubleHarvestMessage = 1044629; // There is no sand here to mine. - sand.TimedOutOfRangeMessage = 503041; // You have moved too far away to continue mining. - sand.OutOfRangeMessage = 500446; // That is too far away. - sand.FailMessage = 1044630; // You dig for a while but fail to find any of sufficient quality for glassblowing. - sand.PackFullMessage = 1044632; // Your backpack can't hold the sand, and it is lost! - sand.ToolBrokeMessage = 1044038; // You have worn out your tool! + Sand = new HarvestDefinition + { + BankWidth = 8, + BankHeight = 8, + MinTotal = 6, + MaxTotal = 12, + MinRespawn = TimeSpan.FromMinutes(10.0), + MaxRespawn = TimeSpan.FromMinutes(20.0), + Skill = SkillName.Mining, + Tiles = m_SandTiles, + MaxRange = 2, + ConsumedPerHarvest = 1, + ConsumedPerFeluccaHarvest = 1, + EffectActions = new[] { 11 }, + EffectSounds = new[] { 0x125, 0x126 }, + EffectCounts = new[] { 6 }, + EffectDelay = TimeSpan.FromSeconds(1.6), + EffectSoundDelay = TimeSpan.FromSeconds(0.9), + NoResourcesMessage = 1044629, // There is no sand here to mine. + DoubleHarvestMessage = 1044629, // There is no sand here to mine. + TimedOutOfRangeMessage = 503041, // You have moved too far away to continue mining. + OutOfRangeMessage = 500446, // That is too far away. + FailMessage = 1044630, // You dig for a while but fail to find any of sufficient quality for glassblowing. + PackFullMessage = 1044632, // Your backpack can't hold the sand, and it is lost! + ToolBrokeMessage = 1044038 // You have worn out your tool! + }; res = new[] { @@ -180,24 +145,15 @@ namespace Server.Engines.Harvest new HarvestVein(100.0, 0.0, res[0], null) }; - sand.Resources = res; - sand.Veins = veins; + Sand.Resources = res; + Sand.Veins = veins; - Definitions.Add(sand); + Definitions.Add(Sand); #endregion } - public static Mining System - { - get - { - if (m_System == null) - m_System = new Mining(); - - return m_System; - } - } + public static Mining System => m_System ?? (m_System = new Mining()); public HarvestDefinition OreAndStone{ get; } @@ -206,16 +162,16 @@ namespace Server.Engines.Harvest public override Type GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource) { - if (def == OreAndStone) - { - if (from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone && - from.Skills.Mining.Base >= 100.0 && 0.1 > Utility.RandomDouble()) - return resource.Types[1]; + if (def != OreAndStone) + return base.GetResourceType(from, tool, def, map, loc, resource); - return resource.Types[0]; - } - return base.GetResourceType(from, tool, def, map, loc, resource); + if (from.Skills.Mining.Base >= 100.0 && from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone + && 0.1 > Utility.RandomDouble()) + return resource.Types[1]; + + return resource.Types[0]; + } public override bool CheckHarvest(Mobile from, Item tool) @@ -337,6 +293,7 @@ namespace Server.Engines.Harvest } catch { + // ignored } } } @@ -434,4 +391,4 @@ namespace Server.Engines.Harvest #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Help/HelpGump.cs b/Scripts/Engines/Help/HelpGump.cs index 3ceb40308..7833dbb0e 100644 --- a/Scripts/Engines/Help/HelpGump.cs +++ b/Scripts/Engines/Help/HelpGump.cs @@ -62,8 +62,8 @@ namespace Server.Engines.Help AddPage(0); - AddHtmlLocalized(150, 50, 360, 40, 1001002, false, false); //
Ultima Online Help Menu
- AddButton(425, 415, 2073, 2072, 0, GumpButtonType.Reply, 0); // Close + AddHtmlLocalized(150, 50, 360, 40, 1001002); //
Ultima Online Help Menu
+ AddButton(425, 415, 2073, 2072, 0); // Close AddPage(1); @@ -79,7 +79,7 @@ namespace Server.Engines.Help @"General question about Ultima Online. Select this option if you have a general gameplay question, need help learning to use a skill, or if you would like to search the UO Knowledge Base.", true, true); - AddButton(80, 205, 5540, 5541, 2, GumpButtonType.Reply, 0); + AddButton(80, 205, 5540, 5541, 2); AddHtml(110, 205, 450, 58, @"My character is physically stuck in the game. This choice only covers cases where your character is physically stuck in a location they cannot move out of. This option will only work two times in 24 hours.", true, true); @@ -101,7 +101,7 @@ namespace Server.Engines.Help @"General question about Ultima Online. Select this option if you have a general gameplay question, need help learning to use a skill, or if you would like to search the UO Knowledge Base.", true, true); - AddButton(80, 170, 5540, 5541, 2, GumpButtonType.Reply, 0); + AddButton(80, 170, 5540, 5541, 2); AddHtml(110, 170, 450, 74, @"My character is physically stuck in the game. This choice only covers cases where your character is physically stuck in a location they cannot move out of. This option will only work two times in 24 hours.", true, true); @@ -119,29 +119,29 @@ namespace Server.Engines.Help AddPage(2); - AddButton(80, 90, 5540, 5541, 3, GumpButtonType.Reply, 0); + AddButton(80, 90, 5540, 5541, 3); AddHtml(110, 90, 450, 74, @"Report a bug or contact Origin. Use this option to launch your web browser and mail in a bug report. Your report will be read by our Quality Assurance Staff. We apologize for not being able to reply to individual reports. ", true, true); - AddButton(80, 170, 5540, 5541, 4, GumpButtonType.Reply, 0); + AddButton(80, 170, 5540, 5541, 4); AddHtml(110, 170, 450, 74, @"Suggestion for the Game. If you'd like to make a suggestion for the game, it should be directed to the Development Team Members who participate in the discussion forums on the UO.Com web site. Choosing this option will take you to the Discussion Forums. ", true, true); - AddButton(80, 250, 5540, 5541, 5, GumpButtonType.Reply, 0); + AddButton(80, 250, 5540, 5541, 5); AddHtml(110, 250, 450, 74, @"Account Management For questions regarding your account such as forgotten passwords, payment options, account activation, and account transfer, please choose this option.", true, true); - AddButton(80, 330, 5540, 5541, 6, GumpButtonType.Reply, 0); + AddButton(80, 330, 5540, 5541, 6); AddHtml(110, 330, 450, 74, @"Other. If you are experiencing a problem in the game that does not fall into one of the other categories or is not addressed on the Support web page (located at http://support.uo.com), and requires in-game assistance, use this option. ", true, true); AddPage(3); - AddButton(80, 90, 5540, 5541, 7, GumpButtonType.Reply, 0); + AddButton(80, 90, 5540, 5541, 7); AddHtmlLocalized(110, 90, 450, 145, 1062572, true, true); /*
Another player is harassing me (or Exploiting).

* VERBAL HARASSMENT
@@ -165,7 +165,7 @@ namespace Server.Engines.Help * � What constitutes an exploit? */ - AddButton(80, 240, 5540, 5541, 8, GumpButtonType.Reply, 0); + AddButton(80, 240, 5540, 5541, 8); AddHtmlLocalized(110, 240, 450, 145, 1062573, true, true); /*
Another player is harassing me using game mechanics.

*
@@ -188,7 +188,7 @@ namespace Server.Engines.Help */ AddButton(150, 390, 5540, 5541, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(180, 390, 335, 40, 1001015, false, false); // NO - I meant to ask for help with another matter. + AddHtmlLocalized(180, 390, 335, 40, 1001015); // NO - I meant to ask for help with another matter. } public static void Initialize() @@ -252,7 +252,7 @@ namespace Server.Engines.Help { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsAosRules && !from.Region.IsPartOf()) // Dueling + if (house?.IsAosRules == true && !from.Region.IsPartOf()) // Dueling { from.Location = house.BanLocation; } @@ -331,4 +331,4 @@ namespace Server.Engines.Help from.SendGump(new PagePromptGump(from, type)); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Help/PagePromptGump.cs b/Scripts/Engines/Help/PagePromptGump.cs index 9e8e1a2a4..40e5ab934 100644 --- a/Scripts/Engines/Help/PagePromptGump.cs +++ b/Scripts/Engines/Help/PagePromptGump.cs @@ -19,15 +19,14 @@ namespace Server.Engines.Help AddPage(0); - AddHtmlLocalized(264, 80, 200, 24, 1062524, false, false); // Enter Description - AddHtmlLocalized(120, 108, 420, 48, 1062638, false, - false); // Please enter a brief description (up to 200 characters) of your problem: + AddHtmlLocalized(264, 80, 200, 24, 1062524); // Enter Description + AddHtmlLocalized(120, 108, 420, 48, 1062638); // Please enter a brief description (up to 200 characters) of your problem: AddBackground(100, 148, 440, 200, 3500); AddTextEntry(120, 168, 400, 200, 1153, 0, ""); - AddButton(175, 355, 2074, 2075, 1, GumpButtonType.Reply, 0); // Okay - AddButton(405, 355, 2073, 2072, 0, GumpButtonType.Reply, 0); // Cancel + AddButton(175, 355, 2074, 2075, 1); // Okay + AddButton(405, 355, 2073, 2072, 0); // Cancel } public override void OnResponse(NetState sender, RelayInfo info) @@ -58,4 +57,4 @@ namespace Server.Engines.Help } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Help/PageQueue.cs b/Scripts/Engines/Help/PageQueue.cs index 3e6029d04..522d4aa8d 100644 --- a/Scripts/Engines/Help/PageQueue.cs +++ b/Scripts/Engines/Help/PageQueue.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Net.Mail; @@ -258,10 +257,10 @@ namespace Server.Engines.Help { Mobile m = ns.Mobile; - if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m)) + if (m?.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m)) m.SendMessage("A new page has been placed in the queue."); - if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && + if (m?.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && Core.TickCount - m.LastMoveTime < 600000) isStaffOnline = true; } diff --git a/Scripts/Engines/Help/PageQueueGump.cs b/Scripts/Engines/Help/PageQueueGump.cs index 9c24b15ae..876d981d3 100644 --- a/Scripts/Engines/Help/PageQueueGump.cs +++ b/Scripts/Engines/Help/PageQueueGump.cs @@ -28,8 +28,8 @@ namespace Server.Engines.Help AddImageTiled(9, 11, 21, 53, 0xBBC); - AddButton(10, 12, 0x7D2, 0x7D2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(34, 28, 65, 24, 3001002, 0xFFFFFF, false, false); // Message + AddButton(10, 12, 0x7D2, 0x7D2, 0); + AddHtmlLocalized(34, 28, 65, 24, 3001002, 0xFFFFFF); // Message } public override void OnResponse(NetState state, RelayInfo info) @@ -55,7 +55,7 @@ namespace Server.Engines.Help Add(new GumpLabel(180, 12, 2100, "Page Queue")); List list = PageQueue.List; - + for (int i = 0;i < list.Count;) { PageEntry e = list[i]; @@ -98,7 +98,7 @@ namespace Server.Engines.Help $"[{typeString}] {e.Message} [{(e.Handler == null ? "Unhandled" : "Handling")}]"; Add(new GumpHtml(12, 44 + i % 5 * 80, 350, 70, html, true, true)); - Add(new GumpButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0)); + Add(new GumpButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, i + 1)); } } @@ -176,9 +176,9 @@ namespace Server.Engines.Help if (!File.Exists(path)) return new List(); - + List list = new List(); - + try { using (StreamReader ip = new StreamReader(path)) @@ -229,7 +229,7 @@ namespace Server.Engines.Help AddImageTiled(0, 0, 410, 448, 0xA40); AddAlphaRegion(1, 1, 408, 446); - AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32), false, false); + AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32)); List list = PredefinedResponse.List; @@ -256,16 +256,15 @@ namespace Server.Engines.Help if (canEdit) { - AddButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, 2 + i * 3, GumpButtonType.Reply, 0); + 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, GumpButtonType.Reply, 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, GumpButtonType.Reply, - 0); + 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); } @@ -282,8 +281,8 @@ namespace Server.Engines.Help AddLabel(48, 10, 2100, "Previous Page"); } - AddButton(12, 44 + i % 5 * 80, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0); - AddHtml(45, 44 + i % 5 * 80, 200, 20, Color("New Response", LabelColor32), false, false); + AddButton(12, 44 + i % 5 * 80, 0xFAB, 0xFAD, 1); + AddHtml(45, 44 + i % 5 * 80, 200, 20, Color("New Response", LabelColor32)); } } else if (canEdit) @@ -291,17 +290,17 @@ namespace Server.Engines.Help AddImageTiled(0, 0, 410, 250, 0xA40); AddAlphaRegion(1, 1, 408, 248); - AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32), false, false); + AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32)); - AddButton(10, 40, 0xFB1, 0xFB3, 1, GumpButtonType.Reply, 0); - AddHtml(45, 40, 200, 20, Color("Remove", LabelColor32), false, false); + AddButton(10, 40, 0xFB1, 0xFB3, 1); + AddHtml(45, 40, 200, 20, Color("Remove", LabelColor32)); - AddButton(10, 70, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); - AddHtml(45, 70, 200, 20, Color("Title:", LabelColor32), false, false); + AddButton(10, 70, 0xFA5, 0xFA7, 2); + AddHtml(45, 70, 200, 20, Color("Title:", LabelColor32)); AddTextInput(10, 90, 300, 20, 0, response.Title); - AddButton(10, 120, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); - AddHtml(45, 120, 200, 20, Color("Message:", LabelColor32), false, false); + AddButton(10, 120, 0xFA5, 0xFA7, 3); + AddHtml(45, 120, 200, 20, Color("Message:", LabelColor32)); AddTextInput(10, 140, 390, 100, 1, response.Message); } } @@ -473,7 +472,7 @@ namespace Server.Engines.Help AddLabelCropped(128, 38, 264, 20, 2100, $"{entry.Sender.RawName} {entry.Sender.Location} [{entry.Sender.Map}]"); - AddButton(18, bottom - buttons * 22, 0xFAB, 0xFAD, 8, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFAB, 0xFAD, 8); AddImageTiled(52, bottom - buttons * 22 + 1, 340, 80, 0xA40 /*0xBBC*/ /*0x2458*/); AddImageTiled(53, bottom - buttons * 22 + 2, 338, 78, 0xBBC /*0x2426*/); AddTextEntry(55, bottom - buttons++ * 22 + 2, 336, 78, 0x480, 0, ""); @@ -483,7 +482,7 @@ namespace Server.Engines.Help if (entry.Sender != m) { - AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 1); AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Sender"); } @@ -493,10 +492,10 @@ namespace Server.Engines.Help { AddLabelCropped(128, 58, 264, 20, 2100, "Unhandled"); - AddButton(18, bottom - buttons * 22, 0xFB1, 0xFB3, 5, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFB1, 0xFB3, 5); AddLabel(52, bottom - buttons++ * 22, 2100, "Delete Page"); - AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 4, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 4); AddLabel(52, bottom - buttons++ * 22, 2100, "Handle Page"); } else @@ -505,15 +504,15 @@ namespace Server.Engines.Help if (entry.Handler != m) { - AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 2); AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Handler"); } else { - AddButton(18, bottom - buttons * 22, 0xFA2, 0xFA4, 6, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFA2, 0xFA4, 6); AddLabel(52, bottom - buttons++ * 22, 2100, "Abandon Page"); - AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 7, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFB7, 0xFB9, 7); AddLabel(52, bottom - buttons++ * 22, 2100, "Page Handled"); } } @@ -521,12 +520,12 @@ namespace Server.Engines.Help AddLabel(18, 78, 2100, "Page Location:"); AddLabelCropped(128, 78, 264, 20, 2100, $"{entry.PageLocation} [{entry.PageMap}]"); - AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 3); AddLabel(52, bottom - buttons++ * 22, 2100, "Go to Page Location"); if (entry.SpeechLog != null) { - AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0); + AddButton(18, bottom - buttons * 22, 0xFA5, 0xFA7, 10); AddLabel(52, bottom - buttons * 22, 2100, "View Speech Log"); } @@ -541,7 +540,7 @@ namespace Server.Engines.Help List preresp = PredefinedResponse.List; AddButton(18, 18, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1); - AddButton(410 - 18 - 32, 18, 0xFAB, 0xFAC, 9, GumpButtonType.Reply, 0); + AddButton(410 - 18 - 32, 18, 0xFAB, 0xFAC, 9); if (preresp.Count == 0) { @@ -553,7 +552,7 @@ namespace Server.Engines.Help for (int i = 0; i < preresp.Count; ++i) { - AddButton(18, 40 + i * 22, 0xFA5, 0xFA7, 100 + i, GumpButtonType.Reply, 0); + AddButton(18, 40 + i * 22, 0xFA5, 0xFA7, 100 + i); AddLabel(52, 40 + i * 22, 2100, preresp[i].Title); } } @@ -799,4 +798,4 @@ namespace Server.Engines.Help } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Help/PageResponseGump.cs b/Scripts/Engines/Help/PageResponseGump.cs index c7a272b74..c3c6a6a80 100644 --- a/Scripts/Engines/Help/PageResponseGump.cs +++ b/Scripts/Engines/Help/PageResponseGump.cs @@ -18,15 +18,14 @@ namespace Server.Engines.Help AddPage(0); - AddHtmlLocalized(150, 40, 360, 40, 1062610, false, false); //
Ultima Online Help Response
+ AddHtmlLocalized(150, 40, 360, 40, 1062610); //
Ultima Online Help Response
AddHtml(80, 90, 480, 290, $"{name} tells {from.Name}: {text}", true, true); - AddHtmlLocalized(80, 390, 480, 40, 1062611, false, - false); // Clicking the OKAY button will remove the reponse you have received. - AddButton(400, 417, 2074, 2075, 1, GumpButtonType.Reply, 0); // OKAY + AddHtmlLocalized(80, 390, 480, 40, 1062611); // Clicking the OKAY button will remove the reponse you have received. + AddButton(400, 417, 2074, 2075, 1); // OKAY - AddButton(475, 417, 2073, 2072, 0, GumpButtonType.Reply, 0); // CANCEL + AddButton(475, 417, 2073, 2072, 0); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -35,4 +34,4 @@ namespace Server.Engines.Help m_From.SendGump(new MessageSentGump(m_From, m_Name, m_Text)); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Help/SpeechLogGump.cs b/Scripts/Engines/Help/SpeechLogGump.cs index 959a9a8c0..7996e18f7 100644 --- a/Scripts/Engines/Help/SpeechLogGump.cs +++ b/Scripts/Engines/Help/SpeechLogGump.cs @@ -39,8 +39,7 @@ namespace Server.Engines.Help string playerAccount = player.Account is Account ? player.Account.Username : "???"; AddHtml(10, 10, 280, 20, - $"
SPEECH LOG - {playerName} ({Utility.FixHtml(playerAccount)})
", - false, false); + $"
SPEECH LOG - {playerName} ({Utility.FixHtml(playerAccount)})
"); int lastPage = (log.Count - 1) / MaxEntriesPerPage; @@ -80,12 +79,12 @@ namespace Server.Engines.Help AddHtml(10, 40, 280, 350, sLog, false, true); if (page > 0) - AddButton(10, 395, 0xFAE, 0xFB0, 1, GumpButtonType.Reply, 0); // Previous page + 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, GumpButtonType.Reply, 0); // Next page + AddButton(261, 395, 0xFA5, 0xFA7, 2); // Next page } public override void OnResponse(NetState sender, RelayInfo info) @@ -111,4 +110,4 @@ namespace Server.Engines.Help } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Help/StuckMenu.cs b/Scripts/Engines/Help/StuckMenu.cs index fa1358c50..229cb815b 100644 --- a/Scripts/Engines/Help/StuckMenu.cs +++ b/Scripts/Engines/Help/StuckMenu.cs @@ -125,7 +125,7 @@ namespace Server.Menus.Questions AddBackground(0, 0, 270, 320, 2600); - AddHtmlLocalized(50, 20, 250, 35, 1011027, false, false); // Chose a town: + AddHtmlLocalized(50, 20, 250, 35, 1011027); // Chose a town: StuckMenuEntry[] entries = IsInSecondAgeArea(beheld) ? m_T2AEntries : m_Entries; @@ -133,26 +133,18 @@ namespace Server.Menus.Questions { StuckMenuEntry entry = entries[i]; - AddButton(50, 55 + 35 * i, 208, 209, i + 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(75, 55 + 35 * i, 335, 40, entry.Name, false, false); + AddButton(50, 55 + 35 * i, 208, 209, i + 1); + AddHtmlLocalized(75, 55 + 35 * i, 335, 40, entry.Name); } - AddButton(55, 263, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(90, 265, 200, 35, 1011012, false, false); // CANCEL + AddButton(55, 263, 4005, 4007, 0); + AddHtmlLocalized(90, 265, 200, 35, 1011012); // CANCEL } private static bool IsInSecondAgeArea(Mobile m) { - if (m.Map != Map.Trammel && m.Map != Map.Felucca) - return false; - - if (m.X >= 5120 && m.Y >= 2304) - return true; - - if (m.Region.IsPartOf("Terathan Keep")) - return true; - - return false; + return (m.Map == Map.Trammel || m.Map == Map.Felucca) && + (m.X >= 5120 && m.Y >= 2304 || m.Region.IsPartOf("Terathan Keep")); } public void BeginClose() @@ -289,4 +281,4 @@ namespace Server.Menus.Questions } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Khaldun/KhaldunGen.cs b/Scripts/Engines/Khaldun/KhaldunGen.cs index e247f8da0..8370bfe64 100644 --- a/Scripts/Engines/Khaldun/KhaldunGen.cs +++ b/Scripts/Engines/Khaldun/KhaldunGen.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Items; namespace Server.Commands @@ -16,46 +17,33 @@ namespace Server.Commands { IPooledEnumerable eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0); - foreach (Item item in eable) - if (item is MorphItem morphItem && morphItem.Z == z && morphItem.InactiveItemID == inactiveItemID && - morphItem.ActiveItemID == activeItemID) - { - eable.Free(); - return true; - } - + bool found = eable.Any(item => item is MorphItem morphItem && morphItem.Z == z && + morphItem.InactiveItemID == inactiveItemID && + morphItem.ActiveItemID == activeItemID); eable.Free(); - return false; + return found; } public static bool FindEffectController(int x, int y, int z) { - IPooledEnumerable eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0); - - foreach (Item item in eable) - if (item is EffectController && item.Z == z) - { - eable.Free(); - return true; - } + IPooledEnumerable eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0); + bool found = eable.Any(item => item is EffectController && item.Z == z); eable.Free(); - return false; + return found; } public static T TryCreateItem(int x, int y, int z, T srcItem) where T : Item { IPooledEnumerable eable = Map.Felucca.GetItemsInBounds(new Rectangle2D(x, y, 1, 1)); - - foreach (T item in eable) - if (item.GetType() == srcItem.GetType()) - { - eable.Free(); - srcItem.Delete(); - return item; - } - + T t = eable.FirstOrDefault(item => item.GetType() == srcItem.GetType()); eable.Free(); + if (t != null) + { + srcItem.Delete(); + return t; + } + srcItem.MoveToWorld(new Point3D(x, y, z), Map.Felucca); m_Count++; @@ -205,4 +193,4 @@ namespace Server.Commands e.Mobile.SendMessage($"{m_Count} dynamic Khaldun item{(m_Count == 1 ? "" : "s")} generated."); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Khaldun/PuzzleChest.cs b/Scripts/Engines/Khaldun/PuzzleChest.cs index 9b4eeac6d..633fd951a 100644 --- a/Scripts/Engines/Khaldun/PuzzleChest.cs +++ b/Scripts/Engines/Khaldun/PuzzleChest.cs @@ -408,7 +408,7 @@ namespace Server.Items DropItem(gem); if (0.2 > Utility.RandomDouble()) - DropItem(new BagOfReagents(50)); + DropItem(new BagOfReagents()); for (int i = 0; i < 2; i++) { @@ -557,7 +557,7 @@ namespace Server.Items AddImage(62, 20, 0x67); - AddHtmlLocalized(80, 36, 110, 70, 1018309, true, false); // A Puzzle Lock + AddHtmlLocalized(80, 36, 110, 70, 1018309, true); // A Puzzle Lock /* Correctly choose the sequence of cylinders needed to open the latch. Each cylinder * may potentially be used more than once. Beware! A false attempt could be deadly! @@ -577,16 +577,16 @@ namespace Server.Items double lockpicking = from.Skills.Lockpicking.Base; if (lockpicking >= 60.0) { - AddHtmlLocalized(160, 125, 230, 24, 1018308, false, false); // Lockpicking hint: + AddHtmlLocalized(160, 125, 230, 24, 1018308); // Lockpicking hint: AddBackground(159, 150, 230, 95, 0x13EC); if (lockpicking >= 80.0) { - AddHtmlLocalized(165, 157, 200, 40, 1018312, false, false); // In the first slot: + AddHtmlLocalized(165, 157, 200, 40, 1018312); // In the first slot: AddCylinder(350, 165, chest.Solution.First); - AddHtmlLocalized(165, 197, 200, 40, 1018313, false, false); // Used in unknown slot: + AddHtmlLocalized(165, 197, 200, 40, 1018313); // Used in unknown slot: AddCylinder(350, 200, chest.FirstHint); if (lockpicking >= 90.0) @@ -597,7 +597,7 @@ namespace Server.Items } else { - AddHtmlLocalized(165, 157, 200, 40, 1018313, false, false); // Used in unknown slot: + AddHtmlLocalized(165, 157, 200, 40, 1018313); // Used in unknown slot: AddCylinder(350, 160, chest.FirstHint); if (lockpicking >= 70.0) @@ -608,7 +608,7 @@ namespace Server.Items PuzzleChestSolution lastGuess = chest.GetLastGuess(from); if (lastGuess != null) { - AddHtmlLocalized(127, 249, 170, 20, 1018311, false, false); // Thy previous guess: + AddHtmlLocalized(127, 249, 170, 20, 1018311); // Thy previous guess: AddBackground(290, 247, 115, 25, 0x13EC); @@ -625,21 +625,21 @@ namespace Server.Items AddPedestal(305, 270, solution.Fourth, 3, check == 3); AddPedestal(360, 270, solution.Fifth, 4, check == 4); - AddButton(258, 370, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); + AddButton(258, 370, 0xFA5, 0xFA7, 1); } private void AddLeftCylinderButton(int x, int y, PuzzleChestCylinder cylinder, int buttonID) { AddBackground(x, y, 30, 30, 0x13EC); AddCylinder(x - 7, y + 10, cylinder); - AddButton(x + 38, y + 9, 0x13A8, 0x4B9, buttonID, GumpButtonType.Reply, 0); + AddButton(x + 38, y + 9, 0x13A8, 0x4B9, buttonID); } private void AddRightCylinderButton(int x, int y, PuzzleChestCylinder cylinder, int buttonID) { AddBackground(x, y, 30, 30, 0x13EC); AddCylinder(x - 7, y + 10, cylinder); - AddButton(x - 26, y + 9, 0x13A8, 0x4B9, buttonID, GumpButtonType.Reply, 0); + AddButton(x - 26, y + 9, 0x13A8, 0x4B9, buttonID); } private void AddPedestal(int x, int y, PuzzleChestCylinder cylinder, int switchID, bool initialState) @@ -739,15 +739,15 @@ namespace Server.Items AddBackground(15, 250, 305, 163, 0x53); AddBackground(28, 265, 280, 133, 0xBB8); - AddHtmlLocalized(35, 271, 270, 24, 1018314, false, false); // Thou hast failed to solve the puzzle! + AddHtmlLocalized(35, 271, 270, 24, 1018314); // Thou hast failed to solve the puzzle! - AddHtmlLocalized(35, 297, 250, 24, 1018315, false, false); // Correctly placed colors: + AddHtmlLocalized(35, 297, 250, 24, 1018315); // Correctly placed colors: AddLabel(285, 297, 0x44, correctCylinders.ToString()); - AddHtmlLocalized(35, 323, 250, 24, 1018316, false, false); // Used colors in wrong slots: + AddHtmlLocalized(35, 323, 250, 24, 1018316); // Used colors in wrong slots: AddLabel(285, 323, 0x44, correctColors.ToString()); - AddButton(152, 369, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); + AddButton(152, 369, 0xFA5, 0xFA7, 0); } } } @@ -805,4 +805,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Khaldun/RaiseSwitch.cs b/Scripts/Engines/Khaldun/RaiseSwitch.cs index 213d167e2..2cf814499 100644 --- a/Scripts/Engines/Khaldun/RaiseSwitch.cs +++ b/Scripts/Engines/Khaldun/RaiseSwitch.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Network; namespace Server.Items @@ -7,12 +8,7 @@ namespace Server.Items { private ResetTimer m_ResetTimer; - [Constructible] - public RaiseSwitch() : this(0x1093) - { - } - - protected RaiseSwitch(int itemID) : base(itemID) + public RaiseSwitch(int itemID = 0x1093) : base(itemID) { Movable = false; } @@ -32,24 +28,24 @@ namespace Server.Items return; } - if (RaisableItem != null && RaisableItem.Deleted) + if (RaisableItem?.Deleted == true) RaisableItem = null; Flip(); - if (RaisableItem != null) + if (RaisableItem == null) + return; + + if (RaisableItem.IsRaisable) { - if (RaisableItem.IsRaisable) - { - RaisableItem.Raise(); - m.LocalOverheadMessage(MessageType.Regular, 0x5A, true, - "You hear a grinding noise echoing in the distance."); - } - else - { - m.LocalOverheadMessage(MessageType.Regular, 0x5A, true, - "You flip the switch again, but nothing happens."); - } + RaisableItem.Raise(); + m.LocalOverheadMessage(MessageType.Regular, 0x5A, true, + "You hear a grinding noise echoing in the distance."); + } + else + { + m.LocalOverheadMessage(MessageType.Regular, 0x5A, true, + "You flip the switch again, but nothing happens."); } } @@ -65,10 +61,7 @@ namespace Server.Items { ItemID = 0x1095; - if (RaisableItem != null && RaisableItem.CloseDelay >= TimeSpan.Zero) - StartResetTimer(RaisableItem.CloseDelay); - else - StartResetTimer(TimeSpan.FromMinutes(2.0)); + StartResetTimer(RaisableItem?.CloseDelay >= TimeSpan.Zero ? RaisableItem.CloseDelay : TimeSpan.FromMinutes(2.0)); } Effects.PlaySound(Location, Map, 0x3E8); @@ -183,22 +176,12 @@ namespace Server.Items public void Refresh() { - bool found = false; - foreach (Mobile mob in GetMobilesInRange(CurrentRange)) - { - if (mob.Hidden && mob.AccessLevel > AccessLevel.Player) - continue; - - found = true; - break; - } - - Visible = found; + Visible = GetMobilesInRange(CurrentRange).Any(mob => !mob.Hidden || mob.AccessLevel <= AccessLevel.Player); } public override void Serialize(GenericWriter writer) { - if (RaisableItem != null && RaisableItem.Deleted) + if (RaisableItem?.Deleted == true) RaisableItem = null; base.Serialize(writer); @@ -215,4 +198,4 @@ namespace Server.Items Timer.DelayCall(TimeSpan.Zero, Refresh); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs b/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs index 8425f10cd..a44779f24 100644 Binary files a/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs and b/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs differ diff --git a/Scripts/Engines/MLQuests/Definitions/Bedlam.cs b/Scripts/Engines/MLQuests/Definitions/Bedlam.cs index 95b0c47d6..73b8985b3 100644 --- a/Scripts/Engines/MLQuests/Definitions/Bedlam.cs +++ b/Scripts/Engines/MLQuests/Definitions/Bedlam.cs @@ -100,7 +100,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Sandals(0x709)); @@ -144,7 +144,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Sandals(Utility.RandomNeutralHue())); @@ -196,7 +196,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Shoes(Utility.RandomNeutralHue())); @@ -227,4 +227,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/Britannia.cs b/Scripts/Engines/MLQuests/Definitions/Britannia.cs index 632e95a57..62f071960 100644 --- a/Scripts/Engines/MLQuests/Definitions/Britannia.cs +++ b/Scripts/Engines/MLQuests/Definitions/Britannia.cs @@ -128,7 +128,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Sandals(Utility.RandomPinkHue())); @@ -201,4 +201,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/Heartwood.cs b/Scripts/Engines/MLQuests/Definitions/Heartwood.cs index 7e958a886..26225b9ae 100644 --- a/Scripts/Engines/MLQuests/Definitions/Heartwood.cs +++ b/Scripts/Engines/MLQuests/Definitions/Heartwood.cs @@ -1952,7 +1952,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2014,7 +2014,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2077,7 +2077,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2138,7 +2138,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2200,7 +2200,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2261,7 +2261,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2320,7 +2320,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2383,7 +2383,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2442,7 +2442,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2515,7 +2515,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots()); AddItem(new FemaleLeafChest()); @@ -2570,7 +2570,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2629,7 +2629,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2686,7 +2686,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2758,7 +2758,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2837,7 +2837,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2900,7 +2900,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -2965,7 +2965,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3023,7 +3023,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3088,7 +3088,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3147,7 +3147,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3205,7 +3205,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3254,7 +3254,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3322,7 +3322,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3380,7 +3380,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3445,7 +3445,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3505,7 +3505,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3564,7 +3564,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -3622,7 +3622,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x1BB)); @@ -3685,7 +3685,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x901)); AddItem(new WoodlandBelt()); @@ -3746,7 +3746,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ThighBoots(0x127)); AddItem(new FemaleElvenRobe(Utility.RandomBrightHue())); @@ -3790,7 +3790,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x1BB)); AddItem(new Cloak(0x3B2)); @@ -3847,7 +3847,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x72C)); AddItem(new FemaleElvenRobe(0x8B0)); @@ -3890,7 +3890,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots()); AddItem(new Tunic(0x732)); @@ -3938,7 +3938,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ThighBoots()); AddItem(new ElvenPants(0x58D)); @@ -3983,7 +3983,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots()); AddItem(new HidePants()); @@ -4028,7 +4028,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Sandals(0x715)); AddItem(new FemaleElvenRobe(0x742)); @@ -4071,7 +4071,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x1BB)); AddItem(new MaleElvenRobe(0x47E)); @@ -4114,7 +4114,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Shoes(0x75A)); AddItem(new FemaleElvenRobe(0x13)); @@ -4158,7 +4158,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x3B2)); AddItem(new RoyalCirclet()); @@ -4208,7 +4208,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Sandals(0x1BB)); AddItem(new MaleElvenRobe(0x48F)); @@ -4251,7 +4251,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x901)); AddItem(new ElvenPants(0x8AB)); @@ -4303,7 +4303,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots(0x1BB)); @@ -4359,7 +4359,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -4410,7 +4410,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -4470,7 +4470,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -4525,7 +4525,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -4579,7 +4579,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -4634,7 +4634,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -4677,4 +4677,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/Heritage.cs b/Scripts/Engines/MLQuests/Definitions/Heritage.cs index 6ea3053b0..d87389985 100644 --- a/Scripts/Engines/MLQuests/Definitions/Heritage.cs +++ b/Scripts/Engines/MLQuests/Definitions/Heritage.cs @@ -789,7 +789,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new FancyShirt(Utility.RandomBlueHue())); AddItem(new LongPants(Utility.RandomNondyedHue())); @@ -830,4 +830,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs b/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs index add1244f7..f6e3cbd6a 100644 --- a/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs +++ b/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs @@ -87,7 +87,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Doublet()); @@ -130,7 +130,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new GildedDress()); @@ -161,4 +161,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs b/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs index d9c3a8919..8b54fab17 100644 --- a/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs +++ b/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs @@ -258,7 +258,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Shoes(Utility.RandomNeutralHue())); AddItem(new Skirt(Utility.RandomBlueHue())); @@ -308,7 +308,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Shoes(Utility.RandomNeutralHue())); AddItem(new LongPants(Utility.RandomBlueHue())); @@ -344,4 +344,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs b/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs index 175a51992..ec44695a1 100644 --- a/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs +++ b/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs @@ -208,7 +208,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Sandals(Utility.RandomNeutralHue())); @@ -353,4 +353,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs b/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs index e8200317d..626bc25ba 100644 --- a/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs +++ b/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs @@ -365,7 +365,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Archery, 60.0, 80.0); @@ -439,7 +439,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); @@ -501,7 +501,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Boots(0x901)); @@ -557,7 +557,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Shoes(Utility.RandomNeutralHue())); @@ -609,7 +609,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Blacksmith, 60.0, 80.0); @@ -673,7 +673,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Boots(0x901)); @@ -726,7 +726,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Boots(0x543)); @@ -780,7 +780,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Robe(0x2FD)); @@ -832,7 +832,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Boots(0x591)); @@ -877,7 +877,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new ThighBoots()); @@ -931,7 +931,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Boots(0x901)); @@ -987,7 +987,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Boots(0x901)); @@ -1036,4 +1036,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs b/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs index ccfcd5fd3..8183968ee 100644 --- a/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs +++ b/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs @@ -738,7 +738,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -801,7 +801,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -859,7 +859,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -916,7 +916,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -984,7 +984,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -1041,7 +1041,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -1105,7 +1105,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -1164,7 +1164,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -1221,7 +1221,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new ElvenBoots()); AddItem(new LeafTonlet()); @@ -1267,7 +1267,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -1311,4 +1311,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs b/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs index f4df926c5..9d89456c8 100644 --- a/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs +++ b/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs @@ -495,7 +495,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -553,7 +553,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -620,7 +620,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -680,7 +680,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -724,4 +724,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs b/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs index affbc8551..1902d85f7 100644 --- a/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs +++ b/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs @@ -122,7 +122,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); SetSkill(SkillName.Meditation, 60.0, 80.0); SetSkill(SkillName.Focus, 60.0, 80.0); @@ -163,4 +163,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs b/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs index 1bfdff0ab..1b48c0eed 100644 --- a/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs +++ b/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs @@ -115,7 +115,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Sandals(0x72B)); @@ -162,7 +162,7 @@ namespace Server.Engines.MLQuests.Definitions Hue = Race.RandomSkinHue(); InitStats(100, 100, 25); - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); AddItem(new Backpack()); AddItem(new Sandals(0x8FD)); @@ -193,4 +193,4 @@ namespace Server.Engines.MLQuests.Definitions } #endregion -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs b/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs index 984d6adff..593c9a89b 100644 --- a/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs +++ b/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs @@ -93,7 +93,7 @@ namespace Server.Engines.MLQuests.Gumps AddButton( 275, 430, (int)ButtonGraphic.Continue, (int)ButtonGraphic.Continue + 2, 0, GumpButtonType.Page, m_Page + 1 ); foreach ( ButtonInfo button in m_Buttons ) - AddButton( button.Position == ButtonPosition.Left ? 95 : 313, 455, (int)button.Graphic, (int)button.Graphic + 2, button.ButtonID, GumpButtonType.Reply, 0 ); + AddButton( button.Position == ButtonPosition.Left ? 95 : 313, 455, (int)button.Graphic, (int)button.Graphic + 2, button.ButtonID, ); if ( m_Title != null ) AddHtmlLocalized( 130, 68, 220, 48, 1114513, m_Title, 0x2710, false, false ); //
~1_TOKEN~
@@ -131,7 +131,7 @@ namespace Server.Engines.MLQuests.Gumps AddImage(379, 60, 0x15A9); AddImage(425, 0, 0x28C9); AddImage(90, 33, 0x232D); - AddHtmlLocalized(130, 45, 270, 16, label, 0xFFFFFF, false, false); + AddHtmlLocalized(130, 45, 270, 16, label, 0xFFFFFF); AddImageTiled(130, 65, 175, 1, 0x238D); } @@ -149,11 +149,10 @@ namespace Server.Engines.MLQuests.Gumps foreach (ButtonInfo button in m_Buttons) AddButton(button.Position == ButtonPosition.Left ? 95 : 313, 455, (int)button.Graphic, - (int)button.Graphic + 2, button.ButtonID, GumpButtonType.Reply, 0); + (int)button.Graphic + 2, button.ButtonID); if (m_Title != null) - AddHtmlLocalized(130, 68, 220, 48, 1114513, m_Title, 0x2710, false, - false); //
~1_TOKEN~
+ AddHtmlLocalized(130, 68, 220, 48, 1114513, m_Title, 0x2710); //
~1_TOKEN~
} #endif @@ -179,16 +178,14 @@ namespace Server.Engines.MLQuests.Gumps public void AddDescription(MLQuest quest) { - AddHtmlLocalized(98, 140, 312, 16, quest.IsChainTriggered || quest.NextQuest != null ? 1075024 : 1072202, 0x2710, - false, false); // Description [(quest chain)] + AddHtmlLocalized(98, 140, 312, 16, quest.IsChainTriggered || quest.NextQuest != null ? 1075024 : 1072202, 0x2710); // Description [(quest chain)] TextDefinition.AddHtmlText(this, 98, 156, 312, 240, quest.Description, false, true, 0x15F90, 0xBDE784); } public void AddObjectives(MLQuest quest) { - AddHtmlLocalized(98, 140, 312, 16, 1049073, 0x2710, false, false); // Objective: - AddHtmlLocalized(98, 156, 312, 16, quest.ObjectiveType == ObjectiveType.All ? 1072208 : 1072209, 0x2710, false, - false); // All of the following / Only one of the following + AddHtmlLocalized(98, 140, 312, 16, 1049073, 0x2710); // Objective: + AddHtmlLocalized(98, 156, 312, 16, quest.ObjectiveType == ObjectiveType.All ? 1072208 : 1072209, 0x2710); // All of the following / Only one of the following int y = 172; @@ -210,9 +207,8 @@ namespace Server.Engines.MLQuests.Gumps { MLQuest quest = instance.Quest; - AddHtmlLocalized(98, 140, 312, 16, 1049073, 0x2710, false, false); // Objective: - AddHtmlLocalized(98, 156, 312, 16, quest.ObjectiveType == ObjectiveType.All ? 1072208 : 1072209, 0x2710, false, - false); // All of the following / Only one of the following + AddHtmlLocalized(98, 140, 312, 16, 1049073, 0x2710); // Objective: + AddHtmlLocalized(98, 156, 312, 16, quest.ObjectiveType == ObjectiveType.All ? 1072208 : 1072209, 0x2710); // All of the following / Only one of the following int y = 172; @@ -222,14 +218,14 @@ namespace Server.Engines.MLQuests.Gumps public void AddRewardsPage(MLQuest quest) // For the quest log/offer gumps { - AddHtmlLocalized(98, 140, 312, 16, 1072201, 0x2710, false, false); // Reward + AddHtmlLocalized(98, 140, 312, 16, 1072201, 0x2710); // Reward int y = 162; if (quest.Rewards.Count > 1) { // TODO: Is this what this is for? Does "Only one of the following" occur? - AddHtmlLocalized(98, 156, 312, 16, 1072208, 0x2710, false, false); // All of the following + AddHtmlLocalized(98, 156, 312, 16, 1072208, 0x2710); // All of the following y += 16; } @@ -243,7 +239,7 @@ namespace Server.Engines.MLQuests.Gumps if (quest.Rewards.Count > 1) { // TODO: Is this what this is for? Does "Only one of the following" occur? - AddHtmlLocalized(100, 140, 312, 16, 1072208, 0x2710, false, false); // All of the following + AddHtmlLocalized(100, 140, 312, 16, 1072208, 0x2710); // All of the following y += 16; } @@ -292,4 +288,4 @@ namespace Server.Engines.MLQuests.Gumps pm.CloseGump(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs b/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs index 708f68268..8dbdde61c 100644 --- a/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs +++ b/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs @@ -8,12 +8,7 @@ namespace Server.Engines.MLQuests.Gumps private bool m_CloseGumps; private MLQuestInstance m_Instance; - public QuestCancelConfirmGump(MLQuestInstance instance) - : this(instance, true) - { - } - - public QuestCancelConfirmGump(MLQuestInstance instance, bool closeGumps) + public QuestCancelConfirmGump(MLQuestInstance instance, bool closeGumps = true) : base(120, 50) { m_Instance = instance; @@ -50,7 +45,7 @@ namespace Server.Engines.MLQuests.Gumps AddImage(2, 248, 0x2716); AddImage(2, 2, 0x2716); - AddHtmlLocalized(25, 22, 200, 20, 1049000, 0x7D00, false, false); // Confirm Quest Cancellation + AddHtmlLocalized(25, 22, 200, 20, 1049000, 0x7D00); // Confirm Quest Cancellation AddImage(25, 40, 0xBBF); /* @@ -60,24 +55,23 @@ namespace Server.Engines.MLQuests.Gumps *
* Are you certain you wish to cancel at this time? */ - AddHtmlLocalized(25, 55, 300, 120, 1060836, 0xFFFFFF, false, false); + AddHtmlLocalized(25, 55, 300, 120, 1060836, 0xFFFFFF); MLQuest quest = instance.Quest; if (quest.IsChainTriggered || quest.NextQuest != null) { AddRadio(25, 145, 0x25F8, 0x25FB, false, 2); - AddHtmlLocalized(60, 150, 280, 20, 1075023, 0xFFFFFF, false, - false); // Yes, I want to quit this entire chain! + AddHtmlLocalized(60, 150, 280, 20, 1075023, 0xFFFFFF); // Yes, I want to quit this entire chain! } AddRadio(25, 180, 0x25F8, 0x25FB, true, 1); - AddHtmlLocalized(60, 185, 280, 20, 1049005, 0xFFFFFF, false, false); // Yes, I really want to quit this quest! + AddHtmlLocalized(60, 185, 280, 20, 1049005, 0xFFFFFF); // Yes, I really want to quit this quest! AddRadio(25, 215, 0x25F8, 0x25FB, false, 0); - AddHtmlLocalized(60, 220, 280, 20, 1049006, 0xFFFFFF, false, false); // No, I don't want to quit. + AddHtmlLocalized(60, 220, 280, 20, 1049006, 0xFFFFFF); // No, I don't want to quit. - AddButton(265, 220, 0xF7, 0xF8, 7, GumpButtonType.Reply, 0); + AddButton(265, 220, 0xF7, 0xF8, 7); } public override void OnResponse(NetState sender, RelayInfo info) @@ -100,4 +94,4 @@ namespace Server.Engines.MLQuests.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs b/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs index 1829c8de9..5a74e17bc 100644 --- a/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs +++ b/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs @@ -9,12 +9,7 @@ namespace Server.Engines.MLQuests.Gumps private bool m_CloseGumps; private MLQuestInstance m_Instance; - public QuestLogDetailedGump(MLQuestInstance instance) - : this(instance, true) - { - } - - public QuestLogDetailedGump(MLQuestInstance instance, bool closeGumps) + public QuestLogDetailedGump(MLQuestInstance instance, bool closeGumps = true) : base(1046026) // Quest Log { m_Instance = instance; @@ -39,7 +34,7 @@ namespace Server.Engines.MLQuests.Gumps AddDescription(quest); if (instance.Failed) // only displayed on the first page - AddHtmlLocalized(160, 80, 250, 16, 500039, 0x3C00, false, false); // Failed! + AddHtmlLocalized(160, 80, 250, 16, 500039, 0x3C00); // Failed! BuildPage(); AddObjectivesProgress(instance); diff --git a/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs b/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs index efbcc89ba..84f13cdcf 100644 --- a/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs +++ b/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs @@ -10,12 +10,7 @@ namespace Server.Engines.MLQuests.Gumps private bool m_CloseGumps; private PlayerMobile m_Owner; - public QuestLogGump(PlayerMobile pm) - : this(pm, true) - { - } - - public QuestLogGump(PlayerMobile pm, bool closeGumps) + public QuestLogGump(PlayerMobile pm, bool closeGumps = true) : base(1046026) // Quest Log { m_Owner = pm; diff --git a/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs b/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs index 1d919bde9..11ae33826 100644 --- a/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs +++ b/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs @@ -38,16 +38,14 @@ namespace Server.Engines.MLQuests.Gumps AddBackground(0, 0, 240, 135, 0x2422); if (targetRace == Race.Human) - AddHtmlLocalized(15, 15, 210, 75, 1073643, 0, false, - false); // Are you sure you wish to embrace your humanity? + 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, false, - false); // Are you sure you want to follow the elven ways? + 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}?", false, false); + AddHtml(15, 15, 210, 75, $"Are you sure you want to change your race to {targetRace.Name}?"); - AddButton(160, 95, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0); - AddButton(90, 95, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0); + AddButton(160, 95, 0xF7, 0xF8, 1); + AddButton(90, 95, 0xF2, 0xF1, 0); } public override void OnResponse(NetState sender, RelayInfo info) @@ -186,7 +184,7 @@ namespace Server.Engines.MLQuests.Gumps return; } - if (!CanChange(pm, targetRace) || owner != null && !owner.CheckComplete(pm)) + if (!CanChange(pm, targetRace) || owner?.CheckComplete(pm) == false) return; int hue = pvSrc.ReadUInt16(); diff --git a/Scripts/Engines/MLQuests/Items/Bleach.cs b/Scripts/Engines/MLQuests/Items/Bleach.cs index 43512c436..da0e7446f 100644 --- a/Scripts/Engines/MLQuests/Items/Bleach.cs +++ b/Scripts/Engines/MLQuests/Items/Bleach.cs @@ -3,7 +3,7 @@ namespace Server.Items public class Bleach : PigmentsOfTokuno { [Constructible] - public Bleach() : base(PigmentType.None) + public Bleach() { LootType = LootType.Blessed; } diff --git a/Scripts/Engines/MLQuests/Items/GamanHorns.cs b/Scripts/Engines/MLQuests/Items/GamanHorns.cs index 59372017f..34243625e 100644 --- a/Scripts/Engines/MLQuests/Items/GamanHorns.cs +++ b/Scripts/Engines/MLQuests/Items/GamanHorns.cs @@ -3,12 +3,7 @@ namespace Server.Items public class GamanHorns : Item { [Constructible] - public GamanHorns() : this(1) - { - } - - [Constructible] - public GamanHorns(int amount) : base(0x1084) + public GamanHorns(int amount = 1) : base(0x1084) { LootType = LootType.Blessed; Stackable = true; @@ -36,4 +31,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/PixieLeg.cs b/Scripts/Engines/MLQuests/Items/PixieLeg.cs index 3b546ab4c..44f0d7313 100644 --- a/Scripts/Engines/MLQuests/Items/PixieLeg.cs +++ b/Scripts/Engines/MLQuests/Items/PixieLeg.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PixieLeg : ChickenLeg { [Constructible] - public PixieLeg() : this(1) - { - } - - [Constructible] - public PixieLeg(int amount) : base(amount) + public PixieLeg(int amount = 1) : base(amount) { LootType = LootType.Blessed; Hue = 0x1C2; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs b/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs index 75f2bf189..6617302fa 100644 --- a/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs +++ b/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs @@ -24,21 +24,8 @@ namespace Server.Engines.MLQuests.Items public override bool Nontransferable => true; - public List MLQuests - { - get - { - if (m_MLQuests == null) - { - m_MLQuests = MLQuestSystem.FindQuestList(GetType()); - - if (m_MLQuests == null) - m_MLQuests = MLQuestSystem.EmptyList; - } - - return m_MLQuests; - } - } + public List MLQuests => m_MLQuests ?? + (m_MLQuests = MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList); public override void AddNameProperties(ObjectPropertyList list) { @@ -101,21 +88,8 @@ namespace Server.Engines.MLQuests.Items public override bool Nontransferable => true; - public List MLQuests - { - get - { - if (m_MLQuests == null) - { - m_MLQuests = MLQuestSystem.FindQuestList(GetType()); - - if (m_MLQuests == null) - m_MLQuests = MLQuestSystem.EmptyList; - } - - return m_MLQuests; - } - } + public List MLQuests => m_MLQuests ?? + (m_MLQuests = MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList); public override void HandleInvalidTransfer(Mobile from) { @@ -163,4 +137,4 @@ namespace Server.Engines.MLQuests.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/SapOfSosaria.cs b/Scripts/Engines/MLQuests/Items/SapOfSosaria.cs index 8b5551c42..2b1356beb 100644 --- a/Scripts/Engines/MLQuests/Items/SapOfSosaria.cs +++ b/Scripts/Engines/MLQuests/Items/SapOfSosaria.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SapOfSosaria : Item { [Constructible] - public SapOfSosaria() : this(1) - { - } - - [Constructible] - public SapOfSosaria(int amount) : base(0x1848) + public SapOfSosaria(int amount = 1) : base(0x1848) { LootType = LootType.Blessed; Stackable = true; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/SeveredElfEars.cs b/Scripts/Engines/MLQuests/Items/SeveredElfEars.cs index 6b2681d0c..9c8870433 100644 --- a/Scripts/Engines/MLQuests/Items/SeveredElfEars.cs +++ b/Scripts/Engines/MLQuests/Items/SeveredElfEars.cs @@ -4,12 +4,7 @@ namespace Server.Items public class SeveredElfEars : Item { [Constructible] - public SeveredElfEars() : this(1) - { - } - - [Constructible] - public SeveredElfEars(int amount) : base(Utility.RandomList(0x312D, 0x312E)) + public SeveredElfEars(int amount = 1) : base(Utility.RandomList(0x312D, 0x312E)) { Stackable = true; Amount = amount; @@ -33,4 +28,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/SeveredHumanEars.cs b/Scripts/Engines/MLQuests/Items/SeveredHumanEars.cs index 756ee85cf..f2a3f0711 100644 --- a/Scripts/Engines/MLQuests/Items/SeveredHumanEars.cs +++ b/Scripts/Engines/MLQuests/Items/SeveredHumanEars.cs @@ -4,12 +4,7 @@ namespace Server.Items public class SeveredHumanEars : Item { [Constructible] - public SeveredHumanEars() : this(1) - { - } - - [Constructible] - public SeveredHumanEars(int amount) : base(Utility.RandomList(0x312F, 0x3130)) + public SeveredHumanEars(int amount = 1) : base(Utility.RandomList(0x312F, 0x3130)) { Stackable = true; Amount = amount; @@ -33,4 +28,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/Teleporters.cs b/Scripts/Engines/MLQuests/Items/Teleporters.cs index 8ebc8b5e5..dbd38a210 100644 --- a/Scripts/Engines/MLQuests/Items/Teleporters.cs +++ b/Scripts/Engines/MLQuests/Items/Teleporters.cs @@ -10,18 +10,13 @@ namespace Server.Engines.MLQuests.Items [Constructible] public MLQuestTeleporter() - : this(Point3D.Zero, null, null, null) + : this(Point3D.Zero) { } [Constructible] - public MLQuestTeleporter(Point3D pointDest, Map mapDest) - : this(pointDest, mapDest, null, null) - { - } - - [Constructible] - public MLQuestTeleporter(Point3D pointDest, Map mapDest, Type questType, TextDefinition message) + public MLQuestTeleporter( + Point3D pointDest, Map mapDest = null, Type questType = null, TextDefinition message = null) : base(pointDest, mapDest) { m_QuestType = questType; @@ -110,18 +105,13 @@ namespace Server.Engines.MLQuests.Items [Constructible] public TicketTeleporter() - : this(Point3D.Zero, null, null, null) + : this(Point3D.Zero) { } [Constructible] - public TicketTeleporter(Point3D pointDest, Map mapDest) - : this(pointDest, mapDest, null, null) - { - } - - [Constructible] - public TicketTeleporter(Point3D pointDest, Map mapDest, Type ticketType, TextDefinition message) + public TicketTeleporter( + Point3D pointDest, Map mapDest = null, Type ticketType = null, TextDefinition message = null) : base(pointDest, mapDest) { m_TicketType = ticketType; @@ -154,7 +144,7 @@ namespace Server.Engines.MLQuests.Items if (m_TicketType == null) return true; - + Container pack = m.Backpack; Item ticket = pack?.FindItemByType(m_TicketType, false) ?? m.Items.Find(item => m_TicketType.IsInstanceOfType(item)); @@ -201,4 +191,4 @@ namespace Server.Engines.MLQuests.Items Message = TextDefinition.Deserialize(reader); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Items/UnicornRibs.cs b/Scripts/Engines/MLQuests/Items/UnicornRibs.cs index 77de253b8..534c8cf76 100644 --- a/Scripts/Engines/MLQuests/Items/UnicornRibs.cs +++ b/Scripts/Engines/MLQuests/Items/UnicornRibs.cs @@ -3,12 +3,7 @@ namespace Server.Items public class UnicornRibs : Item { [Constructible] - public UnicornRibs() : this(1) - { - } - - [Constructible] - public UnicornRibs(int amount) : base(0x9F1) + public UnicornRibs(int amount = 1) : base(0x9F1) { LootType = LootType.Blessed; Hue = 0x14B; @@ -36,4 +31,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/MLQuest.cs b/Scripts/Engines/MLQuests/MLQuest.cs index f5432a3d4..f466e82f9 100644 --- a/Scripts/Engines/MLQuests/MLQuest.cs +++ b/Scripts/Engines/MLQuests/MLQuest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Engines.MLQuests.Gumps; using Server.Engines.MLQuests.Objectives; using Server.Engines.MLQuests.Rewards; @@ -247,12 +248,7 @@ namespace Server.Engines.MLQuests { string name = $"MLQS-{GetType().Name}"; - // Auto cleanup on regeneration - List toDelete = new List(); - - foreach (Item item in map.GetItemsInRange(loc, 0)) - if (item is Spawner && item.Name == name) - toDelete.Add(item); + IEnumerable toDelete = map.GetItemsInRange(loc, 0).Where(item => item is Spawner && item.Name == name); foreach (Item item in toDelete) item.Delete(); @@ -264,11 +260,7 @@ namespace Server.Engines.MLQuests public void PutDeco(Item deco, Point3D loc, Map map) { // Auto cleanup on regeneration - List toDelete = new List(); - - foreach (Item item in map.GetItemsInRange(loc, 0)) - if (item.ItemID == deco.ItemID && item.Z == loc.Z) - toDelete.Add(item); + IEnumerable toDelete = map.GetItemsInRange(loc, 0).Where(item => item.ItemID == deco.ItemID && item.Z == loc.Z); foreach (Item item in toDelete) item.Delete(); @@ -278,4 +270,4 @@ namespace Server.Engines.MLQuests #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/MLQuestContext.cs b/Scripts/Engines/MLQuests/MLQuestContext.cs index c28136897..23e7a6071 100644 --- a/Scripts/Engines/MLQuests/MLQuestContext.cs +++ b/Scripts/Engines/MLQuests/MLQuestContext.cs @@ -62,7 +62,7 @@ namespace Server.Engines.MLQuests { MLQuest quest = MLQuestSystem.ReadQuestRef(reader); - if (quest != null && quest.IsChainTriggered) + if (quest?.IsChainTriggered == true) ChainOffers.Add(quest); } @@ -272,4 +272,4 @@ namespace Server.Engines.MLQuests } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/MLQuestEntry.cs b/Scripts/Engines/MLQuests/MLQuestEntry.cs index 560ad1375..262672cd5 100644 --- a/Scripts/Engines/MLQuests/MLQuestEntry.cs +++ b/Scripts/Engines/MLQuests/MLQuestEntry.cs @@ -302,7 +302,7 @@ namespace Server.Engines.MLQuests public void ClaimRewards() { - if (Quest == null || Player == null || Player.Deleted || !ClaimReward || Removed) + if (Quest == null || Player?.Deleted != false || !ClaimReward || Removed) return; List rewards = new List(); @@ -400,11 +400,10 @@ namespace Server.Engines.MLQuests private void StopTimer() { - if (m_Timer != null) - { - m_Timer.Stop(); - m_Timer = null; - } + if (m_Timer == null) + return; + m_Timer.Stop(); + m_Timer = null; } public void OnQuesterDeleted() @@ -442,10 +441,7 @@ namespace Server.Engines.MLQuests MLQuestSystem.WriteQuestRef(writer, Quest); - if (m_Quester == null || m_Quester.Deleted) - writer.Write(Serial.MinusOne); - else - writer.Write(m_Quester.Serial); + writer.Write(m_Quester?.Deleted != false ? Serial.MinusOne : m_Quester.Serial); writer.Write(ClaimReward); writer.Write(Objectives.Length); @@ -485,4 +481,4 @@ namespace Server.Engines.MLQuests return instance; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/MLQuestSystem.cs b/Scripts/Engines/MLQuests/MLQuestSystem.cs index f9a4177dc..67f02bb59 100644 --- a/Scripts/Engines/MLQuests/MLQuestSystem.cs +++ b/Scripts/Engines/MLQuests/MLQuestSystem.cs @@ -66,6 +66,7 @@ namespace Server.Engines.MLQuests } catch { + // ignored } if (quest == null) @@ -128,7 +129,7 @@ namespace Server.Engines.MLQuests if (AutoGenerateNew) foreach (MLQuest quest in Quests.Values) - if (quest != null && !quest.Deserialized) + if (quest?.Deserialized == false) quest.Generate(); MLQuestPersistence.EnsureExistence(); @@ -555,7 +556,7 @@ namespace Server.Engines.MLQuests foreach (MLQuest quest in quests) { - if (quest.IsChainTriggered || context != null && context.IsDoingQuest(quest)) + if (quest.IsChainTriggered || context?.IsDoingQuest(quest) == true) continue; /* @@ -569,10 +570,7 @@ namespace Server.Engines.MLQuests m_EligiblePool.Add(quest); } - if (m_EligiblePool.Count == 0) - return fallback; - - return m_EligiblePool[Utility.Random(m_EligiblePool.Count)]; + return m_EligiblePool.Count == 0 ? fallback : m_EligiblePool[Utility.Random(m_EligiblePool.Count)]; } public static void TurnToFace(IQuestGiver quester, Mobile mob) @@ -590,7 +588,7 @@ namespace Server.Engines.MLQuests else if (quester is Item item) MessageHelper.SendLocalizedMessageTo(item, pm, cliloc, SpeechColor); else - pm.SendLocalizedMessage(cliloc, "", SpeechColor); + pm.SendLocalizedMessage(cliloc); } public static void Tell(IQuestGiver quester, PlayerMobile pm, int cliloc, string args) @@ -602,7 +600,7 @@ namespace Server.Engines.MLQuests else if (quester is Item item) MessageHelper.SendLocalizedMessageTo(item, pm, cliloc, args, SpeechColor); else - pm.SendLocalizedMessage(cliloc, args, SpeechColor); + pm.SendLocalizedMessage(cliloc, args); } public static void Tell(IQuestGiver quester, PlayerMobile pm, string message) @@ -630,7 +628,7 @@ namespace Server.Engines.MLQuests public static void WriteQuestRef(GenericWriter writer, MLQuest quest) { - writer.Write(quest != null && quest.SaveEnabled ? quest.GetType().FullName : null); + writer.Write(quest?.SaveEnabled == true ? quest.GetType().FullName : null); } public static MLQuest ReadQuestRef(GenericReader reader) @@ -709,4 +707,4 @@ namespace Server.Engines.MLQuests } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs b/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs index 8036381fd..7c8f81bd2 100644 --- a/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs +++ b/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs @@ -97,7 +97,7 @@ namespace Server.Engines.MLQuests.Mobiles public void TalkTo(PlayerMobile pm) { - if (pm == null || m_Timer != null && m_Timer.Running) + if (pm == null || m_Timer?.Running == true) return; int completed = CompletedCount(pm); @@ -423,4 +423,4 @@ namespace Server.Engines.MLQuests.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs b/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs index f229a9a71..044867b60 100644 --- a/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs +++ b/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs @@ -58,7 +58,7 @@ namespace Server.Engines.MLQuests.Objectives public static void WriteTimeRemaining(Gump g, ref int y, TimeSpan timeRemaining) { - g.AddHtmlLocalized(103, y, 120, 16, 1062379, 0x15F90, false, false); // Est. time remaining: + g.AddHtmlLocalized(103, y, 120, 16, 1062379, 0x15F90); // Est. time remaining: g.AddLabel(223, y, 0x481, timeRemaining.TotalSeconds.ToString("F0")); y += 16; } diff --git a/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs b/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs index bc87f5ba6..cccf92fc7 100644 --- a/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs +++ b/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Gumps; using Server.Items; using Server.Mobiles; @@ -7,12 +8,7 @@ namespace Server.Engines.MLQuests.Objectives { public class CollectObjective : BaseObjective { - public CollectObjective() - : this(0, null, null) - { - } - - public CollectObjective(int amount, Type type, TextDefinition name) + public CollectObjective(int amount = 0, Type type = null, TextDefinition name = null) { DesiredAmount = amount; AcceptedType = type; @@ -37,7 +33,7 @@ namespace Server.Engines.MLQuests.Objectives public bool CheckType(Type type) { - return AcceptedType != null && AcceptedType.IsAssignableFrom(type); + return AcceptedType?.IsAssignableFrom(type) == true; } public virtual bool CheckItem(Item item) @@ -58,12 +54,12 @@ namespace Server.Engines.MLQuests.Objectives { string amount = DesiredAmount.ToString(); - g.AddHtmlLocalized(98, y, 350, 16, 1072205, 0x15F90, false, false); // Obtain + g.AddHtmlLocalized(98, y, 350, 16, 1072205, 0x15F90); // Obtain g.AddLabel(143, y, 0x481, amount); if (Name.Number > 0) { - g.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF, false, false); + g.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF); g.AddItem(350, y, LabelToItemID(Name.Number)); } else if (Name.String != null) @@ -74,7 +70,7 @@ namespace Server.Engines.MLQuests.Objectives else { if (Name.Number > 0) - g.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x15F90, false, false); + g.AddHtmlLocalized(98, y, 312, 32, Name.Number, 0x15F90); else if (Name.String != null) g.AddLabel(98, y, 0x481, Name.String); } @@ -122,13 +118,7 @@ namespace Server.Engines.MLQuests.Objectives return 0; Item[] items = pack.FindItemsByType(Objective.AcceptedType, false); // Note: subclasses are included - int total = 0; - - foreach (Item item in items) - if (item.QuestItem && Objective.CheckItem(item)) - total += item.Amount; - - return total; + return items.Where(item => item.QuestItem && Objective.CheckItem(item)).Sum(item => item.Amount); } public override bool AllowsQuestItem(Item item, Type type) @@ -211,14 +201,14 @@ namespace Server.Engines.MLQuests.Objectives { base.WriteToGump(g, ref y); - g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x15F90, false, false); // Total + g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x15F90); // Total g.AddLabel(223, y, 0x481, GetCurrentTotal().ToString()); y += 16; - g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x15F90, false, false); // Return to + g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x15F90); // Return to g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType)); y += 16; } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs b/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs index 27604a68d..cd36d49c5 100644 --- a/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs +++ b/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Gumps; using Server.Items; using Server.Mobiles; @@ -8,12 +9,7 @@ namespace Server.Engines.MLQuests.Objectives { public class DeliverObjective : BaseObjective { - public DeliverObjective(Type delivery, int amount, TextDefinition name, Type destination) - : this(delivery, amount, name, destination, true) - { - } - - public DeliverObjective(Type delivery, int amount, TextDefinition name, Type destination, bool spawnsDelivery) + public DeliverObjective(Type delivery, int amount, TextDefinition name, Type destination, bool spawnsDelivery = true) { Delivery = delivery; Amount = amount; @@ -69,12 +65,12 @@ namespace Server.Engines.MLQuests.Objectives { string amount = Amount.ToString(); - g.AddHtmlLocalized(98, y, 312, 16, 1072207, 0x15F90, false, false); // Deliver + g.AddHtmlLocalized(98, y, 312, 16, 1072207, 0x15F90); // Deliver g.AddLabel(143, y, 0x481, amount); if (Name.Number > 0) { - g.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF, false, false); + g.AddHtmlLocalized(143 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF); g.AddItem(350, y, CollectObjective.LabelToItemID(Name.Number)); } else if (Name.String != null) @@ -84,7 +80,7 @@ namespace Server.Engines.MLQuests.Objectives y += 32; - g.AddHtmlLocalized(103, y, 120, 16, 1072379, 0x15F90, false, false); // Deliver to + g.AddHtmlLocalized(103, y, 120, 16, 1072379, 0x15F90); // Deliver to g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Destination)); y += 16; @@ -100,13 +96,8 @@ namespace Server.Engines.MLQuests.Objectives public class TimedDeliverObjective : DeliverObjective { - public TimedDeliverObjective(TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination) - : this(duration, delivery, amount, name, destination, true) - { - } - public TimedDeliverObjective(TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination, - bool spawnsDelivery) + bool spawnsDelivery = true) : base(delivery, amount, name, destination, spawnsDelivery) { Duration = duration; @@ -158,12 +149,7 @@ namespace Server.Engines.MLQuests.Objectives return 0; Item[] items = pack.FindItemsByType(Objective.Delivery, false); // Note: subclasses are included - int total = 0; - - foreach (Item item in items) - total += item.Amount; - - return total; + return items.Sum(item => item.Amount); } public override bool OnBeforeClaimReward() @@ -240,4 +226,4 @@ namespace Server.Engines.MLQuests.Objectives writer.Write(HasCompleted); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs b/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs index 24d794829..05814e1a5 100644 --- a/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs +++ b/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs @@ -7,12 +7,7 @@ namespace Server.Engines.MLQuests.Objectives { public class EscortObjective : BaseObjective { - public EscortObjective() - : this(null) - { - } - - public EscortObjective(QuestArea destination) + public EscortObjective(QuestArea destination = null) { Destination = destination; } @@ -60,10 +55,10 @@ namespace Server.Engines.MLQuests.Objectives public override void WriteToGump(Gump g, ref int y) { - g.AddHtmlLocalized(98, y, 312, 16, 1072206, 0x15F90, false, false); // Escort to + 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, false, false); + g.AddHtmlLocalized(173, y, 312, 20, Destination.Name.Number, 0xFFFFFF); else if (Destination.Name.String != null) g.AddLabel(173, y, 0x481, Destination.Name.String); @@ -212,7 +207,7 @@ namespace Server.Engines.MLQuests.Objectives MLQuestInstance instance = Instance; PlayerMobile pm = instance.Player; - if (m_Escort != null && !m_Escort.Deleted) + if (m_Escort?.Deleted == false) { if (!pm.Alive) m_Escort.Say(500901); // Ack! My escort has come to haunt me! @@ -268,4 +263,4 @@ namespace Server.Engines.MLQuests.Objectives writer.Write(HasCompleted); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs b/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs index 1c4af0638..692e922cf 100644 --- a/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs +++ b/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs @@ -67,7 +67,7 @@ namespace Server.Engines.MLQuests.Objectives args = ThresholdFixed % 10 == 0 ? $"#{skillLabel}\t{ThresholdFixed / 10}" : $"#{skillLabel}\t{(double)ThresholdFixed / 10:0.0}"; - g.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x15F90, false, false); // Increase ~1_SKILL~ to ~2_VALUE~ + g.AddHtmlLocalized(98, y, 312, 16, 1077485, args, 0x15F90); // Increase ~1_SKILL~ to ~2_VALUE~ y += 16; } @@ -154,7 +154,7 @@ namespace Server.Engines.MLQuests.Objectives if (IsCompleted()) { - g.AddHtmlLocalized(113, y, 312, 20, 1055121, 0xFFFFFF, false, false); // Complete + g.AddHtmlLocalized(113, y, 312, 20, 1055121, 0xFFFFFF); // Complete y += 16; } } diff --git a/Scripts/Engines/MLQuests/Objectives/KillObjective.cs b/Scripts/Engines/MLQuests/Objectives/KillObjective.cs index 729ac13c1..af75f1660 100644 --- a/Scripts/Engines/MLQuests/Objectives/KillObjective.cs +++ b/Scripts/Engines/MLQuests/Objectives/KillObjective.cs @@ -6,17 +6,9 @@ namespace Server.Engines.MLQuests.Objectives { public class KillObjective : BaseObjective { - public KillObjective() - : this(0, null, null, null) - { - } - public KillObjective(int amount, Type[] types, TextDefinition name) - : this(amount, types, name, null) - { - } - - public KillObjective(int amount, Type[] types, TextDefinition name, QuestArea area) + public KillObjective( + int amount = 0, Type[] types = null, TextDefinition name = null, QuestArea area = null) { DesiredAmount = amount; AcceptedTypes = types; @@ -36,11 +28,11 @@ namespace Server.Engines.MLQuests.Objectives { string amount = DesiredAmount.ToString(); - g.AddHtmlLocalized(98, y, 312, 16, 1072204, 0x15F90, false, false); // Slay + g.AddHtmlLocalized(98, y, 312, 16, 1072204, 0x15F90); // Slay g.AddLabel(133, y, 0x481, amount); if (Name.Number > 0) - g.AddHtmlLocalized(133 + amount.Length * 15, y, 190, 18, Name.Number, 0x77BF, false, false); + 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); @@ -50,10 +42,10 @@ namespace Server.Engines.MLQuests.Objectives if (Area != null) { - g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x15F90, false, false); // Location + g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x15F90); // Location if (Area.Name.Number > 0) - g.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0xFFFFFF, false, false); + g.AddHtmlLocalized(223, y, 312, 20, Area.Name.Number, 0xFFFFFF); else if (Area.Name.String != null) g.AddLabel(223, y, 0x481, Area.Name.String); @@ -73,12 +65,7 @@ namespace Server.Engines.MLQuests.Objectives public class TimedKillObjective : KillObjective { - public TimedKillObjective(TimeSpan duration, int amount, Type[] types, TextDefinition name) - : this(duration, amount, types, name, null) - { - } - - public TimedKillObjective(TimeSpan duration, int amount, Type[] types, TextDefinition name, QuestArea area) + public TimedKillObjective(TimeSpan duration, int amount, Type[] types, TextDefinition name, QuestArea area = null) : base(amount, types, name, area) { Duration = duration; @@ -112,7 +99,7 @@ namespace Server.Engines.MLQuests.Objectives foreach (Type acceptedType in Objective.AcceptedTypes) if (acceptedType.IsAssignableFrom(type)) { - if (Objective.Area != null && !Objective.Area.Contains(mob)) + if (Objective.Area?.Contains(mob) == false) return false; PlayerMobile pm = Instance.Player; @@ -140,11 +127,11 @@ namespace Server.Engines.MLQuests.Objectives base.WriteToGump(g, ref y); - g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x15F90, false, false); // Total + g.AddHtmlLocalized(103, y, 120, 16, 3000087, 0x15F90); // Total g.AddLabel(223, y, 0x481, Slain.ToString()); y += 16; - g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x15F90, false, false); // Return to + g.AddHtmlLocalized(103, y, 120, 16, 1074782, 0x15F90); // Return to g.AddLabel(223, y, 0x481, QuesterNameAttribute.GetQuesterNameFor(Instance.QuesterType)); y += 16; } @@ -156,4 +143,4 @@ namespace Server.Engines.MLQuests.Objectives writer.Write(Slain); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/QuestArea.cs b/Scripts/Engines/MLQuests/QuestArea.cs index a2ef83e38..929c058e3 100644 --- a/Scripts/Engines/MLQuests/QuestArea.cs +++ b/Scripts/Engines/MLQuests/QuestArea.cs @@ -4,12 +4,8 @@ namespace Server.Engines.MLQuests { public class QuestArea { - public QuestArea(TextDefinition name, string region) - : this(name, region, null) - { - } - public QuestArea(TextDefinition name, string region, Map forceMap) + public QuestArea(TextDefinition name, string region, Map forceMap = null) { Name = name; RegionName = region; @@ -55,4 +51,4 @@ namespace Server.Engines.MLQuests ForceMap == null ? "-null-" : ForceMap.ToString()); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MLQuests/Rewards/ItemReward.cs b/Scripts/Engines/MLQuests/Rewards/ItemReward.cs index 0f4cb50e8..27c2a0bd5 100644 --- a/Scripts/Engines/MLQuests/Rewards/ItemReward.cs +++ b/Scripts/Engines/MLQuests/Rewards/ItemReward.cs @@ -40,17 +40,7 @@ namespace Server.Engines.MLQuests.Rewards private Type m_Type; - public ItemReward() - : this(null, null) - { - } - - public ItemReward(TextDefinition name, Type type) - : this(name, type, 1) - { - } - - public ItemReward(TextDefinition name, Type type, int amount) + public ItemReward(TextDefinition name = null, Type type = null, int amount = 1) : base(name) { m_Type = type; @@ -105,4 +95,4 @@ namespace Server.Engines.MLQuests.Rewards } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MyRunUO/MyRunUO.cs b/Scripts/Engines/MyRunUO/MyRunUO.cs index 7983144ac..efce89134 100644 --- a/Scripts/Engines/MyRunUO/MyRunUO.cs +++ b/Scripts/Engines/MyRunUO/MyRunUO.cs @@ -107,7 +107,7 @@ namespace Server.Engines.MyRunUO [Description("Initially creates the database schema.")] public static void InitMyRunUO_OnCommand(CommandEventArgs e) { - if (m_Command != null && m_Command.HasCompleted) + if (m_Command?.HasCompleted == true) { TableCreation(); e.Mobile.SendMessage("MyRunUO table creation process has been started."); @@ -120,7 +120,7 @@ namespace Server.Engines.MyRunUO public static void TableCreation() { - if (m_Command != null && !m_Command.HasCompleted) + if (m_Command?.HasCompleted == false) return; // DateTime start = DateTime.Now; Console.WriteLine("MyRunUO: Creating tables"); @@ -154,7 +154,7 @@ namespace Server.Engines.MyRunUO [Description("Starts the process of updating the MyRunUO character and guild database.")] public static void UpdateMyRunUO_OnCommand(CommandEventArgs e) { - if (m_Command != null && m_Command.HasCompleted) + if (m_Command?.HasCompleted == true) m_Command = null; if (m_Timer == null && m_Command == null) @@ -170,7 +170,7 @@ namespace Server.Engines.MyRunUO public static void Begin() { - if (m_Command != null && m_Command.HasCompleted) + if (m_Command?.HasCompleted == true) m_Command = null; if (m_Timer != null || m_Command != null) @@ -252,7 +252,7 @@ namespace Server.Engines.MyRunUO { Mobile mob = acct[j]; - if (mob != null && mob.AccessLevel < Config.HiddenAccessLevel) + if (mob?.AccessLevel < Config.HiddenAccessLevel) m_List.Add(mob); } @@ -713,4 +713,4 @@ namespace Server.Engines.MyRunUO Complete } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/MyRunUO/MyRunUOStatus.cs b/Scripts/Engines/MyRunUO/MyRunUOStatus.cs index 1dfc107df..727b3a440 100644 --- a/Scripts/Engines/MyRunUO/MyRunUOStatus.cs +++ b/Scripts/Engines/MyRunUO/MyRunUOStatus.cs @@ -36,7 +36,7 @@ namespace Server.Engines.MyRunUO public static void Begin() { - if (m_Command != null && !m_Command.HasCompleted) + if (m_Command?.HasCompleted == false) return; Console.WriteLine("MyRunUO: Updating status database"); @@ -69,4 +69,4 @@ namespace Server.Engines.MyRunUO m_Command?.Enqueue(null); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Party/DeclineTimer.cs b/Scripts/Engines/Party/DeclineTimer.cs index 85613ea4c..4d714b5c7 100644 --- a/Scripts/Engines/Party/DeclineTimer.cs +++ b/Scripts/Engines/Party/DeclineTimer.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Engines.PartySystem diff --git a/Scripts/Engines/Party/Party.cs b/Scripts/Engines/Party/Party.cs index 060a9b16d..74e9c4cd8 100644 --- a/Scripts/Engines/Party/Party.cs +++ b/Scripts/Engines/Party/Party.cs @@ -391,7 +391,7 @@ namespace Server.Engines.PartySystem { Mobile mob = ns.Mobile; - if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel && + if (mob?.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel && mob.Party != this && !m_Listeners.Contains(mob)) { if (p == null) @@ -471,4 +471,4 @@ namespace Server.Engines.PartySystem } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Party/PartyCommands.cs b/Scripts/Engines/Party/PartyCommands.cs index a7b090b02..5ffc4e249 100644 --- a/Scripts/Engines/Party/PartyCommands.cs +++ b/Scripts/Engines/Party/PartyCommands.cs @@ -47,7 +47,7 @@ namespace Server.Engines.PartySystem Party p = Party.Get(from); - if (p != null && p.Contains(target)) + if (p?.Contains(target) == true) p.SendPrivateMessage(from, target, text); else from.SendLocalizedMessage(3000211); // You are not in a party. @@ -117,4 +117,4 @@ namespace Server.Engines.PartySystem p.OnDecline(from, leader); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Pathing/FastAStarAlgorithm.cs b/Scripts/Engines/Pathing/FastAStarAlgorithm.cs index d0ecc65b2..2b31ef552 100644 --- a/Scripts/Engines/Pathing/FastAStarAlgorithm.cs +++ b/Scripts/Engines/Pathing/FastAStarAlgorithm.cs @@ -124,7 +124,6 @@ namespace Server.PathAlgorithms.FastAStar BaseCreature bc = m as BaseCreature; - int pathCount, parent; int backtrack = 0, depth = 0; Direction[] path = m_Path; @@ -182,8 +181,8 @@ namespace Server.PathAlgorithms.FastAStar if (newNode != destNode) continue; - pathCount = 0; - parent = m_Nodes[newNode].parent; + int pathCount = 0; + int parent = m_Nodes[newNode].parent; while (parent != -1) { diff --git a/Scripts/Engines/Pathing/FastMovement.cs b/Scripts/Engines/Pathing/FastMovement.cs index 5c764a4ae..6630e8b65 100644 --- a/Scripts/Engines/Pathing/FastMovement.cs +++ b/Scripts/Engines/Pathing/FastMovement.cs @@ -132,10 +132,9 @@ namespace Server.Movement public bool CheckMovement(Mobile m, Direction d, out int newZ) { - if (!Enabled && _Successor != null) - return _Successor.CheckMovement(m, d, out newZ); - - return CheckMovement(m, m.Map, m.Location, d, out newZ); + return !Enabled && _Successor != null + ? _Successor.CheckMovement(m, d, out newZ) + : CheckMovement(m, m.Map, m.Location, d, out newZ); } public static void Initialize() @@ -235,7 +234,7 @@ namespace Server.Movement } // Stygian Dragon - if (m.Body == 826 && map != null && map.MapID == 5) + if (m.Body == 826 && map?.MapID == 5) { if (x >= 307 && x <= 354 && y >= 126 && y <= 192) { @@ -384,20 +383,13 @@ namespace Server.Movement private static bool Verify(Item item, int x, int y) { - return item != null && item.AtWorldPoint(x, y); + return item.AtWorldPoint(x, y); } private static bool Verify(Item item, TileFlag reqFlags, bool ignoreMovableImpassables) { - if (item == null) return false; - - if (ignoreMovableImpassables && item.Movable && item.ItemData.Impassable) return false; - - if ((item.ItemData.Flags & reqFlags) == 0) return false; - - if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) return false; - - return true; + return item != null && (!ignoreMovableImpassables || !item.Movable || !item.ItemData.Impassable) && + (item.ItemData.Flags & reqFlags) != 0 && !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue; } private static bool Verify(Item item, TileFlag reqFlags, bool ignoreMovableImpassables, int x, int y) @@ -460,11 +452,9 @@ namespace Server.Movement isSet = true; } - ItemData itemData; - foreach (Item item in itemList) { - itemData = item.ItemData; + ItemData itemData = item.ItemData; int calcTop = item.Z + itemData.CalcHeight; @@ -489,7 +479,8 @@ namespace Server.Movement 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) @@ -560,4 +551,4 @@ namespace Server.Movement } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Pathing/Movement.cs b/Scripts/Engines/Pathing/Movement.cs index 4c84e8eb5..8c954f4a4 100644 --- a/Scripts/Engines/Pathing/Movement.cs +++ b/Scripts/Engines/Pathing/Movement.cs @@ -77,7 +77,9 @@ namespace Server.Movement List mobsLeft = m_MobPools[1]; List mobsRight = m_MobPools[2]; - bool checkMobs = m is BaseCreature creature && !creature.Controlled && + BaseCreature bc = m as BaseCreature; + + bool checkMobs = bc?.Controlled == false && (xForward != Goal.X || yForward != Goal.Y); if (checkDiagonals) @@ -114,18 +116,21 @@ namespace Server.Movement if ((item.ItemData.Flags & reqFlags) == 0) continue; - if (sector == sectorStart && item.AtWorldPoint(xStart, yStart) && !(item is BaseMulti) && - item.ItemID <= TileData.MaxItemValue) - itemsStart.Add(item); - else if (sector == sectorForward && item.AtWorldPoint(xForward, yForward) && !(item is BaseMulti) && - item.ItemID <= TileData.MaxItemValue) - itemsForward.Add(item); - else if (sector == sectorLeft && item.AtWorldPoint(xLeft, yLeft) && !(item is BaseMulti) && - item.ItemID <= TileData.MaxItemValue) - itemsLeft.Add(item); - else if (sector == sectorRight && item.AtWorldPoint(xRight, yRight) && !(item is BaseMulti) && - item.ItemID <= TileData.MaxItemValue) - itemsRight.Add(item); + if (!(item is BaseMulti)) + { + if (sector == sectorStart && item.AtWorldPoint(xStart, yStart) && + item.ItemID <= TileData.MaxItemValue) + itemsStart.Add(item); + else if (sector == sectorForward && item.AtWorldPoint(xForward, yForward) && + item.ItemID <= TileData.MaxItemValue) + itemsForward.Add(item); + else if (sector == sectorLeft && item.AtWorldPoint(xLeft, yLeft) && + item.ItemID <= TileData.MaxItemValue) + itemsLeft.Add(item); + else if (sector == sectorRight && item.AtWorldPoint(xRight, yRight) && + item.ItemID <= TileData.MaxItemValue) + itemsRight.Add(item); + } } if (checkMobs) @@ -162,12 +167,15 @@ namespace Server.Movement if ((item.ItemData.Flags & reqFlags) == 0) continue; - if (item.AtWorldPoint(xStart, yStart) && !(item is BaseMulti) && - item.ItemID <= TileData.MaxItemValue) - itemsStart.Add(item); - else if (item.AtWorldPoint(xForward, yForward) && !(item is BaseMulti) && - item.ItemID <= TileData.MaxItemValue) - itemsForward.Add(item); + if (!(item is BaseMulti)) + { + if (item.AtWorldPoint(xStart, yStart) && + item.ItemID <= TileData.MaxItemValue) + itemsStart.Add(item); + else if (item.AtWorldPoint(xForward, yForward) && + item.ItemID <= TileData.MaxItemValue) + itemsForward.Add(item); + } } } else @@ -215,25 +223,31 @@ namespace Server.Movement GetStartZ(m, map, loc, itemsStart, out int startZ, out int startTop); + bc?.DebugSay("My Z/Top is {0} {1}", startZ, startTop); + bool moveIsOk = Check(map, m, itemsForward, mobsForward, xForward, yForward, startTop, startZ, m.CanSwim, m.CantWalk, out newZ); + bc?.DebugSay("Can I move? {0} {1}", moveIsOk, newZ); + if (moveIsOk && checkDiagonals) { if (m.Player && m.AccessLevel < AccessLevel.GameMaster) { - if (!Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, - out _) || !Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, - m.CantWalk, out _)) + if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, + out _) && Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, + m.CantWalk, out _))) moveIsOk = false; } else { - if (!Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, - out _) && !Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, - m.CantWalk, out _)) + if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk, + out _) || Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim, + m.CantWalk, out _))) moveIsOk = false; } + + bc?.DebugSay("Can I still move? {0} {1}", moveIsOk, newZ); } for (int i = 0; i < (checkDiagonals ? 4 : 2); ++i) @@ -336,56 +350,55 @@ namespace Server.Movement bool ignoreSpellFields = m is PlayerMobile && map != Map.Felucca; #region Tiles - for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; ItemData itemData = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; TileFlag flags = itemData.Flags; - if ((flags & ImpassableSurface) == TileFlag.Surface || canSwim && (flags & TileFlag.Wet) != 0 - ) // Surface && !Impassable + // Surface && !Impassable + if ((flags & ImpassableSurface) != TileFlag.Surface && (!canSwim || (flags & TileFlag.Wet) == 0)) + continue; + + if (cantWalk && (flags & TileFlag.Wet) == 0) + continue; + + int itemZ = tile.Z; + int itemTop = itemZ; + int ourZ = itemZ + itemData.CalcHeight; + int testTop = checkTop; + + if (moveIsOk) { - if (cantWalk && (flags & TileFlag.Wet) == 0) + int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); + + if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + } - int itemZ = tile.Z; - int itemTop = itemZ; - int ourZ = itemZ + itemData.CalcHeight; - int testTop = checkTop; + if (ourZ + PersonHeight > testTop) + testTop = ourZ + PersonHeight; - if (moveIsOk) - { - int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); + if (!itemData.Bridge) + itemTop += itemData.Height; - if (cmp > 0 || cmp == 0 && ourZ > newZ) - continue; - } + if (stepTop < itemTop) + continue; - if (ourZ + PersonHeight > testTop) - testTop = ourZ + PersonHeight; + int landCheck = itemZ; - if (!itemData.Bridge) - itemTop += itemData.Height; + if (itemData.Height >= StepHeight) + landCheck += StepHeight; + else + landCheck += itemData.Height; - if (stepTop >= itemTop) - { - int landCheck = itemZ; + if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) + continue; - if (itemData.Height >= StepHeight) - landCheck += StepHeight; - else - landCheck += itemData.Height; - - if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) - continue; - - if (IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) - { - newZ = ourZ; - moveIsOk = true; - } - } + if (IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) + { + newZ = ourZ; + moveIsOk = true; } } @@ -474,15 +487,13 @@ namespace Server.Movement #region Mobiles - if (moveIsOk) - for (int i = 0; moveIsOk && i < mobiles.Count; ++i) - { - Mobile mob = mobiles[i]; - - if (mob != m && mob.Z + 15 > newZ && newZ + 15 > mob.Z && !CanMoveOver(m, mob)) - moveIsOk = false; - } + for (int i = 0; moveIsOk && i < mobiles.Count; ++i) + { + Mobile mob = mobiles[i]; + if (mob != m && mob.Z + 15 > newZ && newZ + 15 > mob.Z && !CanMoveOver(m, mob)) + moveIsOk = false; + } #endregion return moveIsOk; @@ -543,11 +554,7 @@ namespace Server.Movement zLow = tile.Z; zCenter = calcTop; - - int top = tile.Z + id.Height; - - if (!isSet || top > zTop) - zTop = top; + zTop = tile.Z + id.Height; isSet = true; } @@ -620,4 +627,4 @@ namespace Server.Movement } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Pathing/MovementPath.cs b/Scripts/Engines/Pathing/MovementPath.cs index cf70fd71c..a7baebebf 100644 --- a/Scripts/Engines/Pathing/MovementPath.cs +++ b/Scripts/Engines/Pathing/MovementPath.cs @@ -28,11 +28,9 @@ namespace Server try { - PathAlgorithm alg = OverrideAlgorithm; + PathAlgorithm alg = OverrideAlgorithm ?? FastAStarAlgorithm.Instance; - if (alg == null) alg = FastAStarAlgorithm.Instance; - - if (alg != null && alg.CheckCondition(m, map, start, goal)) + if (alg?.CheckCondition(m, map, start, goal) == true) Directions = alg.Find(m, map, start, goal); } catch (Exception e) @@ -49,7 +47,7 @@ namespace Server public Direction[] Directions{ get; } - public bool Success => Directions != null && Directions.Length > 0; + public bool Success => Directions?.Length > 0; public static PathAlgorithm OverrideAlgorithm{ get; set; } @@ -106,4 +104,4 @@ namespace Server OverrideAlgorithm = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Pathing/PathFollower.cs b/Scripts/Engines/Pathing/PathFollower.cs index 3a49cd028..73fbd46e5 100644 --- a/Scripts/Engines/Pathing/PathFollower.cs +++ b/Scripts/Engines/Pathing/PathFollower.cs @@ -44,7 +44,7 @@ namespace Server public void Advance(ref Point3D p, int index) { - if (m_Path != null && m_Path.Success) + if (m_Path?.Success == true) { Direction[] dirs = m_Path.Directions; @@ -70,18 +70,10 @@ namespace Server if (!Enabled) return false; - bool repath = false; - Point3D goal = GetGoalLocation(); - if (m_Path == null) - repath = true; - else if ((!m_Path.Success || goal != m_LastGoalLoc) && m_LastPathTime + RepathDelay <= DateTime.UtcNow) - repath = true; - else if (m_Path.Success && Check(m_From.Location, m_LastGoalLoc, 0)) - repath = true; - - if (!repath) + 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; @@ -95,17 +87,12 @@ namespace Server Advance(ref m_Next, m_Index); return true; + } public bool Check(Point3D loc, Point3D goal, int range) { - if (!Utility.InRange(loc, goal, range)) - return false; - - if (range <= 1 && Math.Abs(loc.Z - goal.Z) >= 16) - return false; - - return true; + return Utility.InRange(loc, goal, range) && (range > 1 || Math.Abs(loc.Z - goal.Z) < 16); } public bool Follow(bool run, int range) @@ -118,7 +105,7 @@ namespace Server bool repathed = CheckPath(); - if (!Enabled || !m_Path.Success) + if (!(Enabled && m_Path.Success)) { d = m_From.GetDirectionTo(goal); @@ -190,4 +177,4 @@ namespace Server return Check(m_From.Location, goal, range); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/EmptyTheBowlGump.cs b/Scripts/Engines/Plants/EmptyTheBowlGump.cs index 04d364f0f..fdd97d00e 100644 --- a/Scripts/Engines/Plants/EmptyTheBowlGump.cs +++ b/Scripts/Engines/Plants/EmptyTheBowlGump.cs @@ -17,12 +17,12 @@ namespace Server.Engines.Plants DrawPicture(); - AddButton(98, 150, 0x47E, 0x480, 1, GumpButtonType.Reply, 0); // Cancel + AddButton(98, 150, 0x47E, 0x480, 1); // Cancel - AddButton(138, 151, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0); // Help + AddButton(138, 151, 0xD2, 0xD2, 2); // Help AddLabel(143, 151, 0x835, "?"); - AddButton(168, 150, 0x481, 0x483, 3, GumpButtonType.Reply, 0); // Ok + AddButton(168, 150, 0x481, 0x483, 3); // Ok } private void DrawBackground() @@ -118,4 +118,4 @@ namespace Server.Engines.Plants } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/MainPlantGump.cs b/Scripts/Engines/Plants/MainPlantGump.cs index dfb8bf22c..f4db3fe4e 100644 --- a/Scripts/Engines/Plants/MainPlantGump.cs +++ b/Scripts/Engines/Plants/MainPlantGump.cs @@ -17,44 +17,44 @@ namespace Server.Engines.Plants DrawPlant(); - AddButton(71, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0); // Reproduction menu + AddButton(71, 67, 0xD4, 0xD4, 1); // Reproduction menu AddItem(59, 68, 0xD08); PlantSystem system = plant.PlantSystem; - AddButton(71, 91, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0); // Infestation + AddButton(71, 91, 0xD4, 0xD4, 2); // Infestation AddItem(8, 96, 0x372); AddPlus(95, 92, system.Infestation); - AddButton(71, 115, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0); // Fungus + AddButton(71, 115, 0xD4, 0xD4, 3); // Fungus AddItem(58, 115, 0xD16); AddPlus(95, 116, system.Fungus); - AddButton(71, 139, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0); // Poison + AddButton(71, 139, 0xD4, 0xD4, 4); // Poison AddItem(59, 143, 0x1AE4); AddPlus(95, 140, system.Poison); - AddButton(71, 163, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0); // Disease + AddButton(71, 163, 0xD4, 0xD4, 5); // Disease AddItem(55, 167, 0x1727); AddPlus(95, 164, system.Disease); - AddButton(209, 67, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0); // Water + AddButton(209, 67, 0xD2, 0xD2, 6); // Water AddItem(193, 67, 0x1F9D); AddPlusMinus(196, 67, system.Water); - AddButton(209, 91, 0xD4, 0xD4, 7, GumpButtonType.Reply, 0); // Poison potion + AddButton(209, 91, 0xD4, 0xD4, 7); // Poison potion AddItem(201, 91, 0xF0A); AddLevel(196, 91, system.PoisonPotion); - AddButton(209, 115, 0xD4, 0xD4, 8, GumpButtonType.Reply, 0); // Cure potion + AddButton(209, 115, 0xD4, 0xD4, 8); // Cure potion AddItem(201, 115, 0xF07); AddLevel(196, 115, system.CurePotion); - AddButton(209, 139, 0xD4, 0xD4, 9, GumpButtonType.Reply, 0); // Heal potion + AddButton(209, 139, 0xD4, 0xD4, 9); // Heal potion AddItem(201, 139, 0xF0C); AddLevel(196, 139, system.HealPotion); - AddButton(209, 163, 0xD4, 0xD4, 10, GumpButtonType.Reply, 0); // Strength potion + AddButton(209, 163, 0xD4, 0xD4, 10); // Strength potion AddItem(201, 163, 0xF09); AddLevel(196, 163, system.StrengthPotion); @@ -64,10 +64,10 @@ namespace Server.Engines.Plants AddImage(232, 47, 0xD2); AddGrowthIndicator(239, 47); - AddButton(48, 183, 0xD2, 0xD2, 11, GumpButtonType.Reply, 0); // Help + AddButton(48, 183, 0xD2, 0xD2, 11); // Help AddLabel(54, 183, 0x835, "?"); - AddButton(232, 183, 0xD4, 0xD4, 12, GumpButtonType.Reply, 0); // Empty the bowl + AddButton(232, 183, 0xD4, 0xD4, 12); // Empty the bowl AddItem(219, 180, 0x15FD); } @@ -142,7 +142,7 @@ namespace Server.Engines.Plants AddItem(92, 167, 0x1B9D); AddItem(161, 167, 0x1B9D); - AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00, false, false); + AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00); break; } @@ -151,7 +151,7 @@ namespace Server.Engines.Plants AddItem(91, 164, 0x18E6); AddItem(161, 164, 0x18E6); - AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207, false, false); + AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207); break; } @@ -160,7 +160,7 @@ namespace Server.Engines.Plants AddItem(96, 168, 0xC61); AddItem(162, 168, 0xC61); - AddHtmlLocalized(129, 167, 42, 20, message, 0x008200, false, false); + AddHtmlLocalized(129, 167, 42, 20, message, 0x008200); break; } @@ -169,7 +169,7 @@ namespace Server.Engines.Plants AddItem(93, 162, 0x1A99); AddItem(162, 162, 0x1A99); - AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0, false, false); + AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0); break; } @@ -422,4 +422,4 @@ namespace Server.Engines.Plants return null; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/MiscItems/FertileDirt.cs b/Scripts/Engines/Plants/MiscItems/FertileDirt.cs index e98e30b34..9bed07de7 100644 --- a/Scripts/Engines/Plants/MiscItems/FertileDirt.cs +++ b/Scripts/Engines/Plants/MiscItems/FertileDirt.cs @@ -3,12 +3,7 @@ namespace Server.Items public class FertileDirt : Item { [Constructible] - public FertileDirt() : this(1) - { - } - - [Constructible] - public FertileDirt(int amount) : base(0xF81) + public FertileDirt(int amount = 1) : base(0xF81) { Stackable = true; Weight = 1.0; @@ -33,4 +28,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/MiscItems/GreenThorns.cs b/Scripts/Engines/Plants/MiscItems/GreenThorns.cs index 39b335a81..be37f5f78 100644 --- a/Scripts/Engines/Plants/MiscItems/GreenThorns.cs +++ b/Scripts/Engines/Plants/MiscItems/GreenThorns.cs @@ -8,12 +8,7 @@ namespace Server.Items public class GreenThorns : Item { [Constructible] - public GreenThorns() : this(1) - { - } - - [Constructible] - public GreenThorns(int amount) : base(0xF42) + public GreenThorns(int amount = 1) : base(0xF42) { Stackable = true; Weight = 1.0; @@ -752,4 +747,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/MiscItems/OrangePetals.cs b/Scripts/Engines/Plants/MiscItems/OrangePetals.cs index 580f98aea..f2e30e623 100644 --- a/Scripts/Engines/Plants/MiscItems/OrangePetals.cs +++ b/Scripts/Engines/Plants/MiscItems/OrangePetals.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Network; @@ -10,12 +9,7 @@ namespace Server.Items private static Dictionary m_Table = new Dictionary(); [Constructible] - public OrangePetals() : this(1) - { - } - - [Constructible] - public OrangePetals(int amount) : base(0x1021) + public OrangePetals(int amount = 1) : base(0x1021) { Stackable = true; Hue = 0x2B; diff --git a/Scripts/Engines/Plants/MiscItems/RedLeaves.cs b/Scripts/Engines/Plants/MiscItems/RedLeaves.cs index 7c1a2bf75..b95ef96b9 100644 --- a/Scripts/Engines/Plants/MiscItems/RedLeaves.cs +++ b/Scripts/Engines/Plants/MiscItems/RedLeaves.cs @@ -5,12 +5,7 @@ namespace Server.Items public class RedLeaves : Item { [Constructible] - public RedLeaves() : this(1) - { - } - - [Constructible] - public RedLeaves(int amount) : base(0x1E85) + public RedLeaves(int amount = 1) : base(0x1E85) { Stackable = true; Hue = 0x21; @@ -98,4 +93,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/PlantBowl.cs b/Scripts/Engines/Plants/PlantBowl.cs index 6e517adde..8a328a3ce 100644 --- a/Scripts/Engines/Plants/PlantBowl.cs +++ b/Scripts/Engines/Plants/PlantBowl.cs @@ -162,7 +162,7 @@ namespace Server.Engines.Plants } else if (IsDirtPatch(targeted)) { - PlantItem fullBowl = new PlantItem(false); + PlantItem fullBowl = new PlantItem(); if (from.PlaceInBackpack(fullBowl)) { diff --git a/Scripts/Engines/Plants/PlantItem.cs b/Scripts/Engines/Plants/PlantItem.cs index e65d970a4..0a34d1837 100644 --- a/Scripts/Engines/Plants/PlantItem.cs +++ b/Scripts/Engines/Plants/PlantItem.cs @@ -42,12 +42,7 @@ namespace Server.Engines.Plants private bool m_ShowType; [Constructible] - public PlantItem() : this(false) - { - } - - [Constructible] - public PlantItem(bool fertileDirt) : base(0x1602) + public PlantItem(bool fertileDirt = false) : base(0x1602) { Weight = 1.0; @@ -560,4 +555,4 @@ namespace Server.Engines.Plants Plants.Remove(this); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/ReproductionGump.cs b/Scripts/Engines/Plants/ReproductionGump.cs index cc0391a6f..ead5ca625 100644 --- a/Scripts/Engines/Plants/ReproductionGump.cs +++ b/Scripts/Engines/Plants/ReproductionGump.cs @@ -13,37 +13,37 @@ namespace Server.Engines.Plants DrawBackground(); - AddButton(70, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0); // Main menu + AddButton(70, 67, 0xD4, 0xD4, 1); // Main menu AddItem(57, 65, 0x1600); AddLabel(108, 67, 0x835, "Reproduction"); if (m_Plant.PlantStatus == PlantStatus.Stage9) { - AddButton(212, 67, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0); // Set to decorative + AddButton(212, 67, 0xD4, 0xD4, 2); // Set to decorative AddItem(202, 68, 0xC61); AddLabel(216, 66, 0x21, "/"); } - AddButton(80, 116, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0); // Pollination + AddButton(80, 116, 0xD4, 0xD4, 3); // Pollination AddItem(66, 117, 0x1AA2); AddPollinationState(106, 116); - AddButton(128, 116, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0); // Resources + AddButton(128, 116, 0xD4, 0xD4, 4); // Resources AddItem(113, 120, 0x1021); AddResourcesState(149, 116); - AddButton(177, 116, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0); // Seeds + AddButton(177, 116, 0xD4, 0xD4, 5); // Seeds AddItem(160, 121, 0xDCF); AddSeedsState(199, 116); - AddButton(70, 163, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0); // Gather pollen + AddButton(70, 163, 0xD2, 0xD2, 6); // Gather pollen AddItem(56, 164, 0x1AA2); - AddButton(138, 163, 0xD2, 0xD2, 7, GumpButtonType.Reply, 0); // Gather resources + AddButton(138, 163, 0xD2, 0xD2, 7); // Gather resources AddItem(123, 167, 0x1021); - AddButton(212, 163, 0xD2, 0xD2, 8, GumpButtonType.Reply, 0); // Gather seeds + AddButton(212, 163, 0xD2, 0xD2, 8); // Gather seeds AddItem(195, 168, 0xDCF); } @@ -260,4 +260,4 @@ namespace Server.Engines.Plants } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/Seed.cs b/Scripts/Engines/Plants/Seed.cs index cd3dc4430..b3578477a 100644 --- a/Scripts/Engines/Plants/Seed.cs +++ b/Scripts/Engines/Plants/Seed.cs @@ -9,12 +9,12 @@ namespace Server.Engines.Plants private bool m_ShowType; [Constructible] - public Seed() : this(PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration(), false) + public Seed() : this(PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration()) { } [Constructible] - public Seed(PlantType plantType, PlantHue plantHue, bool showType) : base(0xDCF) + public Seed(PlantType plantType, PlantHue plantHue, bool showType = false) : base(0xDCF) { Weight = 1.0; Stackable = Core.SA; @@ -75,17 +75,17 @@ namespace Server.Engines.Plants public static Seed RandomBonsaiSeed(double increaseRatio) { - return new Seed(PlantTypeInfo.RandomBonsai(increaseRatio), PlantHue.Plain, false); + return new Seed(PlantTypeInfo.RandomBonsai(increaseRatio), PlantHue.Plain); } public static Seed RandomPeculiarSeed(int group) { switch (group) { - case 1: return new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain, false); - case 2: return new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain, false); - case 3: return new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain, false); - default: return new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain, false); + case 1: return new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain); + case 2: return new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain); + case 3: return new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain); + default: return new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain); } } @@ -125,14 +125,12 @@ namespace Server.Engines.Plants public override void AddNameProperty(ObjectPropertyList list) { - string args; - list.Add(GetLabel(out args), args); + list.Add(GetLabel(out string args), args); } public override void OnSingleClick(Mobile from) { - string args; - LabelTo(from, GetLabel(out args), args); + LabelTo(from, GetLabel(out string args), args); } public override void OnDoubleClick(Mobile from) @@ -224,4 +222,4 @@ namespace Server.Engines.Plants } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Plants/SetToDecorativeGump.cs b/Scripts/Engines/Plants/SetToDecorativeGump.cs index 29af96088..5b3a60bce 100644 --- a/Scripts/Engines/Plants/SetToDecorativeGump.cs +++ b/Scripts/Engines/Plants/SetToDecorativeGump.cs @@ -16,12 +16,12 @@ namespace Server.Engines.Plants AddLabel(115, 85, 0x44, "Set plant"); AddLabel(82, 105, 0x44, "to decorative mode?"); - AddButton(98, 140, 0x47E, 0x480, 1, GumpButtonType.Reply, 0); // Cancel + AddButton(98, 140, 0x47E, 0x480, 1); // Cancel - AddButton(138, 141, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0); // Help + AddButton(138, 141, 0xD2, 0xD2, 2); // Help AddLabel(143, 141, 0x835, "?"); - AddButton(168, 140, 0x481, 0x483, 3, GumpButtonType.Reply, 0); // Ok + AddButton(168, 140, 0x481, 0x483, 3); // Ok } private void DrawBackground() @@ -81,4 +81,4 @@ namespace Server.Engines.Plants } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs b/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs index 088517716..766ca6fd4 100644 --- a/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs +++ b/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs @@ -15,7 +15,7 @@ namespace Server.Engines.Quests.Ambitious { // Red/Black Solen Queens killed: gump.AddHtmlLocalized(70, 260, 270, 100, ((AmbitiousQueenQuest)System).RedSolen ? 1054064 : 1054065, - BaseQuestGump.Blue, false, false); + BaseQuestGump.Blue); gump.AddLabel(70, 280, 0x64, CurProgress.ToString()); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, MaxProgress.ToString()); diff --git a/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs b/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs index 30d9de6f6..eba7233ba 100644 --- a/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs +++ b/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs @@ -102,7 +102,7 @@ namespace Server.Engines.Quests.Collector AddImageTiled(35, 150, 120, 100, 0x24B1); AddImage(35, 300, 0x24B4); - AddHtmlLocalized(110, 60, 200, 20, 1049069, White, false, false); // Conversation Event + AddHtmlLocalized(110, 60, 200, 20, 1049069, White); // Conversation Event AddImage(65, 14, 0x2776); AddImageTiled(81, 14, 349, 17, 0x2775); @@ -121,12 +121,12 @@ namespace Server.Engines.Quests.Collector true); // Sure, I have some sheet music for a Gabriel Piete song. I'd be happy to sell you a copy for 10 gold. AddRadio(85, 350, 0x25F8, 0x25FB, true, 1); - AddHtmlLocalized(120, 356, 280, 20, 1014088, White, false, false); // I accept. + AddHtmlLocalized(120, 356, 280, 20, 1014088, White); // I accept. AddRadio(85, 385, 0x25F8, 0x25FB, false, 0); - AddHtmlLocalized(120, 391, 280, 20, 1049012, White, false, false); // No thanks, I decline. + AddHtmlLocalized(120, 391, 280, 20, 1049012, White); // No thanks, I decline. - AddButton(340, 390, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0); + AddButton(340, 390, 0xF7, 0xF8, 1); } public override void OnResponse(NetState sender, RelayInfo info) @@ -143,15 +143,14 @@ namespace Server.Engines.Quests.Collector if (obj?.Completed != false) return; - - if (player.Backpack != null && player.Backpack.ConsumeTotal(typeof(Gold), 10)) + + if (player.Backpack?.ConsumeTotal(typeof(Gold), 10) == true) { obj.Complete(); } else { - BankBox bank = player.FindBankNoCreate(); - if (bank != null && bank.ConsumeTotal(typeof(Gold), 10)) + if (player.FindBankNoCreate()?.ConsumeTotal(typeof(Gold), 10) == true) obj.Complete(); else @@ -161,4 +160,4 @@ namespace Server.Engines.Quests.Collector } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Core/BaseQuester.cs b/Scripts/Engines/Quests/Core/BaseQuester.cs index 1b1a56cc6..c6f4cc259 100644 --- a/Scripts/Engines/Quests/Core/BaseQuester.cs +++ b/Scripts/Engines/Quests/Core/BaseQuester.cs @@ -27,11 +27,7 @@ namespace Server.Engines.Quests { protected List m_SBInfos = new List(); - public BaseQuester() : this(null) - { - } - - public BaseQuester(string title) : base(title) + public BaseQuester(string title = null) : base(title) { } @@ -122,4 +118,4 @@ namespace Server.Engines.Quests int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs b/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs index cd62993e9..8b5245974 100644 --- a/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs +++ b/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs @@ -4,11 +4,7 @@ namespace Server.Engines.Quests { public abstract class DynamicTeleporter : Item { - public DynamicTeleporter() : this(0x1822, 0x482) - { - } - - public DynamicTeleporter(int itemID, int hue) : base(itemID) + public DynamicTeleporter(int itemID = 0x1822, int hue = 0x482) : base(itemID) { Movable = false; Hue = hue; @@ -62,4 +58,4 @@ namespace Server.Engines.Quests int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Core/QuestConversation.cs b/Scripts/Engines/Quests/Core/QuestConversation.cs index ee69935ec..7c128ec20 100644 --- a/Scripts/Engines/Quests/Core/QuestConversation.cs +++ b/Scripts/Engines/Quests/Core/QuestConversation.cs @@ -81,7 +81,7 @@ namespace Server.Engines.Quests AddImageTiled(35, 150, 120, 100, 9393); AddImage(35, 250, 9396); - AddHtmlLocalized(110, 60, 200, 20, 1049069, White, false, false); // Conversation Event + AddHtmlLocalized(110, 60, 200, 20, 1049069, White); // Conversation Event AddImage(65, 14, 10102); AddImageTiled(81, 14, 349, 17, 10101); @@ -94,7 +94,7 @@ namespace Server.Engines.Quests AddImage(75, 58, 9781); AddImage(380, 45, 223); - AddButton(220, 335, 2313, 2312, 1, GumpButtonType.Reply, 0); + AddButton(220, 335, 2313, 2312, 1); AddImage(0, 0, 10440); AddPage(1); @@ -106,7 +106,7 @@ namespace Server.Engines.Quests if (i > 0) { AddButton(65, 366, 9909, 9911, 0, GumpButtonType.Page, 1 + i); - AddHtmlLocalized(90, 367, 50, 20, 1043354, Black, false, false); // Previous + AddHtmlLocalized(90, 367, 50, 20, 1043354, Black); // Previous AddPage(1 + i); } @@ -116,7 +116,7 @@ namespace Server.Engines.Quests if (i > 0) { AddButton(420, 366, 9903, 9905, 0, GumpButtonType.Page, i); - AddHtmlLocalized(370, 367, 50, 20, 1043353, Black, false, false); // Next + AddHtmlLocalized(370, 367, 50, 20, 1043353, Black); // Next } } } @@ -135,4 +135,4 @@ namespace Server.Engines.Quests } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Core/QuestItemInfo.cs b/Scripts/Engines/Quests/Core/QuestItemInfo.cs index d0300d444..22f0066c1 100644 --- a/Scripts/Engines/Quests/Core/QuestItemInfo.cs +++ b/Scripts/Engines/Quests/Core/QuestItemInfo.cs @@ -1,5 +1,3 @@ -using Server.Gumps; - namespace Server.Engines.Quests { public class QuestItemInfo @@ -37,13 +35,13 @@ namespace Server.Engines.Quests AddImageTiled(131, 20, 10, height - 30, 2624); AddAlphaRegion(131, 20, 10, height - 30); - AddHtmlLocalized(67, 35, 120, 20, 1011233, White, false, false); // INFO + AddHtmlLocalized(67, 35, 120, 20, 1011233, White); // INFO AddImage(62, 52, 9157); AddImage(72, 52, 9157); AddImage(82, 52, 9157); - AddButton(25, 31, 1209, 1210, 777, GumpButtonType.Reply, 0); + AddButton(25, 31, 1209, 1210, 777); AddPage(1); @@ -56,4 +54,4 @@ namespace Server.Engines.Quests } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Core/QuestObjective.cs b/Scripts/Engines/Quests/Core/QuestObjective.cs index b8d5b24e5..1c8db7a96 100644 --- a/Scripts/Engines/Quests/Core/QuestObjective.cs +++ b/Scripts/Engines/Quests/Core/QuestObjective.cs @@ -147,12 +147,12 @@ namespace Server.Engines.Quests AddImage(20, 5, 1417); - AddHtmlLocalized(0, 78, 120, 40, 1049079, White, false, false); // Quest Log Updated + AddHtmlLocalized(0, 78, 120, 40, 1049079, White); // Quest Log Updated AddImageTiled(0, 78, 120, 40, 2624); AddAlphaRegion(0, 78, 120, 40); - AddButton(30, 15, 5575, 5576, 1, GumpButtonType.Reply, 0); + AddButton(30, 15, 5575, 5576, 1); } public override void OnResponse(NetState sender, RelayInfo info) @@ -193,20 +193,20 @@ namespace Server.Engines.Quests AddImage(20, 87, 1231); AddImage(75, 62, 9307); - AddHtmlLocalized(117, 35, 230, 20, 1046026, Blue, false, false); // Quest Log + AddHtmlLocalized(117, 35, 230, 20, 1046026, Blue); // Quest Log AddImage(77, 33, 9781); AddImage(65, 110, 2104); - AddHtmlLocalized(79, 106, 230, 20, 1049073, Blue, false, false); // Objective: + AddHtmlLocalized(79, 106, 230, 20, 1049073, Blue); // Objective: AddImageTiled(68, 125, 120, 1, 9101); AddImage(65, 240, 2104); - AddHtmlLocalized(79, 237, 230, 20, 1049076, Blue, false, false); // Progress details: + AddHtmlLocalized(79, 237, 230, 20, 1049076, Blue); // Progress details: AddImageTiled(68, 255, 120, 1, 9101); - AddButton(175, 355, 2313, 2312, 1, GumpButtonType.Reply, 0); + AddButton(175, 355, 2313, 2312, 1); AddImage(341, 15, 10450); AddImage(341, 330, 10450); @@ -222,7 +222,7 @@ namespace Server.Engines.Quests if (i > 0) { AddButton(55, 346, 9909, 9911, 0, GumpButtonType.Page, 1 + i); - AddHtmlLocalized(82, 347, 50, 20, 1043354, White, false, false); // Previous + AddHtmlLocalized(82, 347, 50, 20, 1043354, White); // Previous AddPage(1 + i); } @@ -233,7 +233,7 @@ namespace Server.Engines.Quests if (i > 0) { AddButton(317, 346, 9903, 9905, 0, GumpButtonType.Page, i); - AddHtmlLocalized(278, 347, 50, 20, 1043353, White, false, false); // Next + AddHtmlLocalized(278, 347, 50, 20, 1043353, White); // Next } } } @@ -252,4 +252,4 @@ namespace Server.Engines.Quests } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Core/QuestSystem.cs b/Scripts/Engines/Quests/Core/QuestSystem.cs index 975a08b40..8e644ffaa 100644 --- a/Scripts/Engines/Quests/Core/QuestSystem.cs +++ b/Scripts/Engines/Quests/Core/QuestSystem.cs @@ -512,34 +512,31 @@ namespace Server.Engines.Quests AddImage(2, 248, 10006); AddImage(2, 2, 10006); - AddHtmlLocalized(25, 22, 200, 20, 1049000, 32000, false, false); // Confirm Quest Cancellation + AddHtmlLocalized(25, 22, 200, 20, 1049000, 32000); // Confirm Quest Cancellation AddImage(25, 40, 3007); if (system.IsTutorial) { - AddHtmlLocalized(25, 55, 300, 120, 1060836, White, false, - false); // This quest will give you valuable information, skills and equipment that will help you advance in the game at a quicker pace.

Are you certain you wish to cancel at this time? + AddHtmlLocalized(25, 55, 300, 120, 1060836, White); // This quest will give you valuable information, skills and equipment that will help you advance in the game at a quicker pace.

Are you certain you wish to cancel at this time? } else { - AddHtmlLocalized(25, 60, 300, 20, 1049001, White, false, false); // You have chosen to abort your quest: + AddHtmlLocalized(25, 60, 300, 20, 1049001, White); // You have chosen to abort your quest: AddImage(25, 81, 0x25E7); AddHtmlObject(48, 80, 280, 20, system.Name, DarkGreen, false, false); - AddHtmlLocalized(25, 120, 280, 20, 1049002, White, false, - false); // Can this quest be restarted after quitting? + AddHtmlLocalized(25, 120, 280, 20, 1049002, White); // Can this quest be restarted after quitting? AddImage(25, 141, 0x25E7); - AddHtmlLocalized(48, 140, 280, 20, system.RestartDelay < TimeSpan.MaxValue ? 1049016 : 1049017, DarkGreen, - false, false); // Yes/No + AddHtmlLocalized(48, 140, 280, 20, system.RestartDelay < TimeSpan.MaxValue ? 1049016 : 1049017, DarkGreen); // Yes/No } AddRadio(25, 175, 9720, 9723, true, 1); - AddHtmlLocalized(60, 180, 280, 20, 1049005, White, false, false); // Yes, I really want to quit! + AddHtmlLocalized(60, 180, 280, 20, 1049005, White); // Yes, I really want to quit! AddRadio(25, 210, 9720, 9723, false, 0); - AddHtmlLocalized(60, 215, 280, 20, 1049006, White, false, false); // No, I don't want to quit. + AddHtmlLocalized(60, 215, 280, 20, 1049006, White); // No, I don't want to quit. - AddButton(265, 220, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(265, 220, 247, 248, 1); } public override void OnResponse(NetState sender, RelayInfo info) @@ -565,7 +562,7 @@ namespace Server.Engines.Quests AddAlphaRegion(50, 20, 400, 400); AddImage(90, 33, 9005); - AddHtmlLocalized(130, 45, 270, 20, 1049010, White, false, false); // Quest Offer + AddHtmlLocalized(130, 45, 270, 20, 1049010, White); // Quest Offer AddImageTiled(130, 65, 175, 1, 9101); AddImage(140, 110, 1209); @@ -574,12 +571,12 @@ namespace Server.Engines.Quests AddHtmlObject(98, 140, 312, 200, system.OfferMessage, LightGreen, false, true); AddRadio(85, 350, 9720, 9723, true, 1); - AddHtmlLocalized(120, 356, 280, 20, 1049011, White, false, false); // I accept! + AddHtmlLocalized(120, 356, 280, 20, 1049011, White); // I accept! AddRadio(85, 385, 9720, 9723, false, 0); - AddHtmlLocalized(120, 391, 280, 20, 1049012, White, false, false); // No thanks, I decline. + AddHtmlLocalized(120, 391, 280, 20, 1049012, White); // No thanks, I decline. - AddButton(340, 390, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(340, 390, 247, 248, 1); AddImageTiled(50, 29, 30, 390, 10460); AddImageTiled(34, 140, 17, 279, 9263); diff --git a/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs b/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs index 667cd1421..f6d561fc6 100644 --- a/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs +++ b/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs @@ -19,33 +19,31 @@ namespace Server.Engines.Quests.Necro if (m.AccessLevel > AccessLevel.Player) return true; - bool sendMessage = m.Player; + Mobile mob = m; - if (m is BaseCreature) - m = ((BaseCreature)m).ControlMaster; + if (m is BaseCreature creature) + mob = creature.ControlMaster; - if (m is PlayerMobile pm) + if (!(mob is PlayerMobile pm)) + return false; + + QuestSystem qs = pm.Quest; + + if (qs is DarkTidesQuest) { - QuestSystem qs = pm.Quest; + QuestObjective obj = qs.FindObjective(); - if (qs is DarkTidesQuest) + if (obj?.Completed == true) { - QuestObjective obj = qs.FindObjective(); + m.SendLocalizedMessage( + 1060648); // With Horus' permission, you are able to pass through the barrier. - if (obj != null && obj.Completed) - { - if (sendMessage) - m.SendLocalizedMessage( - 1060648); // With Horus' permission, you are able to pass through the barrier. - - return true; - } + return true; } } - if (sendMessage) - m.SendLocalizedMessage(1060649, "", - 0x66D); // Without the permission of the guardian Horus, the magic of the barrier prevents your passage. + m.SendLocalizedMessage(1060649, "", + 0x66D); // Without the permission of the guardian Horus, the magic of the barrier prevents your passage. return false; } @@ -64,4 +62,4 @@ namespace Server.Engines.Quests.Necro int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs b/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs index adf7eec48..c2115086e 100644 --- a/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs +++ b/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs @@ -65,7 +65,7 @@ namespace Server.Engines.Quests.Necro { if (!m_ToDelete && !Frozen) { - if (m_Necromancer == null || m_Necromancer.Deleted || m_Necromancer.Map == Map.Internal) + if (m_Necromancer?.Deleted != false || m_Necromancer.Map == Map.Internal) { Delete(); return; @@ -240,4 +240,4 @@ namespace Server.Engines.Quests.Necro Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs b/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs index ebbba836c..c3fcfb93b 100644 --- a/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs +++ b/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs @@ -184,7 +184,7 @@ namespace Server.Engines.Quests.Ninja if (!Completed) { // Henchmen killed: - gump.AddHtmlLocalized(70, 260, 270, 100, 1063207, BaseQuestGump.Blue, false, false); + gump.AddHtmlLocalized(70, 260, 270, 100, 1063207, BaseQuestGump.Blue); gump.AddLabel(70, 280, 0x64, CurProgress.ToString()); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, MaxProgress.ToString()); diff --git a/Scripts/Engines/Quests/Solen Matriarch/Objectives.cs b/Scripts/Engines/Quests/Solen Matriarch/Objectives.cs index 87f35e880..e1a81eb52 100644 --- a/Scripts/Engines/Quests/Solen Matriarch/Objectives.cs +++ b/Scripts/Engines/Quests/Solen Matriarch/Objectives.cs @@ -15,7 +15,7 @@ namespace Server.Engines.Quests.Matriarch { // Black/Red Solen Infiltrators killed: gump.AddHtmlLocalized(70, 260, 270, 100, ((SolenMatriarchQuest)System).RedSolen ? 1054088 : 1054087, - BaseQuestGump.Blue, false, false); + BaseQuestGump.Blue); gump.AddLabel(70, 280, 0x64, CurProgress.ToString()); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, MaxProgress.ToString()); @@ -80,8 +80,7 @@ namespace Server.Engines.Quests.Matriarch { if (!Completed) { - gump.AddHtmlLocalized(70, 260, 270, 100, 1054093, BaseQuestGump.Blue, false, - false); // Gallons of Water gathered: + gump.AddHtmlLocalized(70, 260, 270, 100, 1054093, BaseQuestGump.Blue); // Gallons of Water gathered: gump.AddLabel(70, 280, 0x64, (CurProgress / 5).ToString()); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, (MaxProgress / 5).ToString()); diff --git a/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs b/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs index 3b1a5c347..0e1776fde 100644 --- a/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs +++ b/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs @@ -116,7 +116,7 @@ namespace Server.Engines.Quests.Naturalist if (study.StudiedSpecialNest) { - reward = new Seed(type, PlantHue.FireRed, false); + reward = new Seed(type, PlantHue.FireRed); } else { @@ -134,7 +134,7 @@ namespace Server.Engines.Quests.Naturalist break; } - reward = new Seed(type, hue, false); + reward = new Seed(type, hue); } if (player.PlaceInBackpack(reward)) diff --git a/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs b/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs index d62936d6d..1e50d6c2b 100644 --- a/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs +++ b/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs @@ -1,3 +1,5 @@ +using System.Linq; + namespace Server.Engines.Quests.Naturalist { public class NestArea @@ -27,17 +29,7 @@ namespace Server.Engines.Quests.Naturalist m_Rects = rects; } - public static int NonSpecialCount - { - get - { - int n = 0; - foreach (NestArea area in m_Areas) - if (!area.Special) - n++; - return n; - } - } + public static int NonSpecialCount => m_Areas.Count(area => !area.Special); public bool Special{ get; } @@ -54,10 +46,7 @@ namespace Server.Engines.Quests.Naturalist public static NestArea Find(IPoint2D p) { - foreach (NestArea area in m_Areas) - if (area.Contains(p)) - return area; - return null; + return m_Areas.FirstOrDefault(area => area.Contains(p)); } public static NestArea GetByID(int id) @@ -69,10 +58,7 @@ namespace Server.Engines.Quests.Naturalist public bool Contains(IPoint2D p) { - foreach (Rectangle2D rect in m_Rects) - if (rect.Contains(p)) - return true; - return false; + return m_Rects.Any(rect => rect.Contains(p)); } } } \ No newline at end of file diff --git a/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs b/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs index f949f97f5..21b4a56d2 100644 --- a/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs +++ b/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs @@ -114,7 +114,7 @@ namespace Server.Engines.Quests.Naturalist { if (!Completed) { - gump.AddHtmlLocalized(70, 260, 270, 100, 1054055, BaseQuestGump.Blue, false, false); // Solen Nests Studied : + gump.AddHtmlLocalized(70, 260, 270, 100, 1054055, BaseQuestGump.Blue); // Solen Nests Studied : gump.AddLabel(70, 280, 0x64, CurProgress.ToString()); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, MaxProgress.ToString()); @@ -171,7 +171,7 @@ namespace Server.Engines.Quests.Naturalist { string count = NestArea.NonSpecialCount.ToString(); - gump.AddHtmlLocalized(70, 260, 270, 100, 1054055, BaseQuestGump.Blue, false, false); // Solen Nests Studied : + gump.AddHtmlLocalized(70, 260, 270, 100, 1054055, BaseQuestGump.Blue); // Solen Nests Studied : gump.AddLabel(70, 280, 0x64, count); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, count); diff --git a/Scripts/Engines/Quests/Terrible Hatchlings/Objectives.cs b/Scripts/Engines/Quests/Terrible Hatchlings/Objectives.cs index 345c25265..6ea5f6ad8 100644 --- a/Scripts/Engines/Quests/Terrible Hatchlings/Objectives.cs +++ b/Scripts/Engines/Quests/Terrible Hatchlings/Objectives.cs @@ -12,7 +12,7 @@ namespace Server.Engines.Quests.Zento if (!Completed) { // Deathwatch Beetle Hatchlings killed: - gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF, false, false); + gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF); gump.AddLabel(70, 280, 0x64, "0"); gump.AddLabel(100, 280, 0x64, "/"); @@ -45,7 +45,7 @@ namespace Server.Engines.Quests.Zento if (!Completed) { // Deathwatch Beetle Hatchlings killed: - gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF, false, false); + gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF); gump.AddLabel(70, 280, 0x64, "1"); gump.AddLabel(100, 280, 0x64, "/"); @@ -96,7 +96,7 @@ namespace Server.Engines.Quests.Zento if (!Completed) { // Deathwatch Beetle Hatchlings killed: - gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF, false, false); + gump.AddHtmlLocalized(70, 260, 270, 100, 1063318, 0x12DC6BF); gump.AddLabel(70, 280, 0x64, CurProgress.ToString()); gump.AddLabel(100, 280, 0x64, "/"); diff --git a/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs b/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs index 2fadd414d..dceef8b76 100644 --- a/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs +++ b/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs @@ -39,12 +39,12 @@ namespace Server.Engines.Quests.Doom public virtual void BeginSummon(Mobile from) { - if (Chyloth != null && !Chyloth.Deleted) + if (Chyloth?.Deleted == false) { from.SendLocalizedMessage( 1050010); // The ferry man has already been summoned. There is no need to ring for him again. } - else if (Dragon != null && !Dragon.Deleted) + else if (Dragon?.Deleted == false) { from.SendLocalizedMessage( 1050017); // The ferryman has recently been summoned already. You decide against ringing the bell again so soon. @@ -83,9 +83,8 @@ namespace Server.Engines.Quests.Doom 2023, 0); Effects.PlaySound(loc, Map, 0x1FE); - Chyloth = new Chyloth(); + Chyloth = new Chyloth { Direction = (Direction)(7 & (4 + (int)from.GetDirectionTo(loc))) }; - Chyloth.Direction = (Direction)(7 & (4 + (int)from.GetDirectionTo(loc))); Chyloth.MoveToWorld(loc, Map); Chyloth.Bell = this; @@ -117,4 +116,4 @@ namespace Server.Engines.Quests.Doom Chyloth?.Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs b/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs index 0db94c93e..ccd8d1598 100644 --- a/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs +++ b/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs @@ -177,21 +177,20 @@ namespace Server.Engines.Quests.Doom Party p = PartySystem.Party.Get(from); - if (p != null) - for (int i = 0; i < p.Members.Count; ++i) + for (int i = 0; i < p?.Members.Count; ++i) + { + PartyMemberInfo pmi = p.Members[i]; + Mobile member = pmi.Mobile; + + if (member != from && member.Map == Map.Malas && member.Region.IsPartOf("Doom")) { - PartyMemberInfo pmi = p.Members[i]; - Mobile member = pmi.Mobile; + if (AngryAt == member) + AngryAt = null; - if (member != from && member.Map == Map.Malas && member.Region.IsPartOf("Doom")) - { - if (AngryAt == member) - AngryAt = null; - - member.CloseGump(); - member.SendGump(new ChylothPartyGump(from, member)); - } + member.CloseGump(); + member.SendGump(new ChylothPartyGump(from, member)); } + } if (AngryAt == from) AngryAt = null; @@ -254,16 +253,14 @@ namespace Server.Engines.Quests.Doom AddImageTiled(15, 15, 365, 190, 2624); AddRadio(30, 140, 9727, 9730, true, 1); - AddHtmlLocalized(65, 145, 300, 25, 1050050, 0x7FFF, false, false); // Yes, let's go! + AddHtmlLocalized(65, 145, 300, 25, 1050050, 0x7FFF); // Yes, let's go! AddRadio(30, 175, 9727, 9730, false, 0); - AddHtmlLocalized(65, 178, 300, 25, 1050049, 0x7FFF, false, false); // No thanks, I'd rather stay here. + AddHtmlLocalized(65, 178, 300, 25, 1050049, 0x7FFF); // No thanks, I'd rather stay here. - AddHtmlLocalized(30, 20, 360, 35, 1050047, 0x7FFF, false, - false); // Another player has paid Chyloth for your passage across lake Mortis: + AddHtmlLocalized(30, 20, 360, 35, 1050047, 0x7FFF); // Another player has paid Chyloth for your passage across lake Mortis: - AddHtmlLocalized(30, 105, 345, 40, 1050048, 0x5B2D, false, - false); // Do you wish to accept their invitation at this time? + AddHtmlLocalized(30, 105, 345, 40, 1050048, 0x5B2D); // Do you wish to accept their invitation at this time? AddImage(65, 72, 5605); @@ -272,7 +269,7 @@ namespace Server.Engines.Quests.Doom AddLabel(90, 70, 1645, leader.Name); - AddButton(290, 175, 247, 248, 2, GumpButtonType.Reply, 0); + AddButton(290, 175, 247, 248, 2); AddImageTiled(15, 14, 365, 1, 9107); AddImageTiled(380, 14, 1, 190, 9105); @@ -308,4 +305,4 @@ namespace Server.Engines.Quests.Doom } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/The Summoning/Mobiles/Victoria.cs b/Scripts/Engines/Quests/The Summoning/Mobiles/Victoria.cs index 85fdeec52..3eed0c1f7 100644 --- a/Scripts/Engines/Quests/The Summoning/Mobiles/Victoria.cs +++ b/Scripts/Engines/Quests/The Summoning/Mobiles/Victoria.cs @@ -28,7 +28,7 @@ namespace Server.Engines.Quests.Doom { get { - if (m_Altar == null || m_Altar.Deleted || m_Altar.Map != Map || + if (m_Altar?.Deleted != false || m_Altar.Map != Map || !Utility.InRange(m_Altar.Location, Location, AltarRange)) foreach (Item item in GetItemsInRange(AltarRange)) if (item is SummoningAltar altar) @@ -143,4 +143,4 @@ namespace Server.Engines.Quests.Doom int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs b/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs index b83a0697c..c41924f7d 100644 --- a/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs +++ b/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs @@ -77,7 +77,7 @@ namespace Server.Engines.Quests.Doom QuestObjective obj = FindObjective(); - if (obj != null && obj.CurProgress > 0) + if (obj?.CurProgress > 0) { From.BankBox.DropItem(new DaemonBone(obj.CurProgress)); @@ -109,4 +109,4 @@ namespace Server.Engines.Quests.Doom writer.Write(WaitForSummon); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs b/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs index 87432363e..07563d0ac 100644 --- a/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs +++ b/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs @@ -64,7 +64,7 @@ namespace Server.Engines.Quests.Haven [CommandProperty(AccessLevel.GameMaster)] public MilitiaCanoneer Canoneer{ get; set; } - public override bool HandlesOnMovement => Canoneer != null && !Canoneer.Deleted && Canoneer.Active; + public override bool HandlesOnMovement => Canoneer?.Deleted == false && Canoneer.Active; public void DoFireEffect(IPoint3D target) { @@ -101,7 +101,7 @@ namespace Server.Engines.Quests.Haven public override void OnMovement(Mobile m, Point3D oldLocation) { - if (Canoneer == null || Canoneer.Deleted || !Canoneer.Active) + if (!(Canoneer?.Deleted == false && Canoneer.Active)) return; bool canFire; @@ -127,7 +127,7 @@ namespace Server.Engines.Quests.Haven public override void Serialize(GenericWriter writer) { - if (Canoneer != null && Canoneer.Deleted) + if (Canoneer?.Deleted == true) Canoneer = null; base.Serialize(writer); @@ -183,4 +183,4 @@ namespace Server.Engines.Quests.Haven int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs b/Scripts/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs index 85c2f043f..0f0904646 100644 --- a/Scripts/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs +++ b/Scripts/Engines/Quests/Uzeraan Turmoil/Items/SchmendrickApprenticeCorpse.cs @@ -133,13 +133,13 @@ namespace Server.Engines.Quests.Haven public override void OnLocationChange(Point3D oldLoc) { - if (m_Lantern != null && !m_Lantern.Deleted) + if (m_Lantern?.Deleted == false) m_Lantern.Location = new Point3D(X, Y + 1, Z); } public override void OnMapChange() { - if (m_Lantern != null && !m_Lantern.Deleted) + if (m_Lantern?.Deleted == false) m_Lantern.Map = Map; } @@ -147,13 +147,13 @@ namespace Server.Engines.Quests.Haven { base.OnAfterDelete(); - if (m_Lantern != null && !m_Lantern.Deleted) + if (m_Lantern?.Deleted == false) m_Lantern.Delete(); } public override void Serialize(GenericWriter writer) { - if (m_Lantern != null && m_Lantern.Deleted) + if (m_Lantern?.Deleted == true) m_Lantern = null; base.Serialize(writer); @@ -172,4 +172,4 @@ namespace Server.Engines.Quests.Haven m_Lantern = (Lantern)reader.ReadItem(); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs index a73c46285..09aef695b 100644 --- a/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs +++ b/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs @@ -404,7 +404,7 @@ namespace Server.Engines.Quests.Haven public override void ChildSerialize(GenericWriter writer) { - if (CorpseWithBone != null && CorpseWithBone.Deleted) + if (CorpseWithBone?.Deleted == true) CorpseWithBone = null; writer.WriteEncodedInt(0); // version @@ -432,4 +432,4 @@ namespace Server.Engines.Quests.Haven System.AddConversation(new BankerConversation()); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs b/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs index 584c00ac3..8bea12987 100644 --- a/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs +++ b/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs @@ -43,23 +43,23 @@ namespace Server.Engines.Quests.Hag PlayerMobile player = System.From; Map map = player.Map; - if ((Corpse == null || Corpse.Deleted) && (map == Map.Trammel || map == Map.Felucca) && - player.InRange(m_CorpseLocation, 8)) - { - Corpse = new HagApprenticeCorpse(); - Corpse.MoveToWorld(m_CorpseLocation, map); + if (Corpse?.Deleted == false || map != Map.Trammel && map != Map.Felucca || + !player.InRange(m_CorpseLocation, 8)) + return; - Effects.SendLocationEffect(m_CorpseLocation, map, 0x3728, 10, 10); - Effects.PlaySound(m_CorpseLocation, map, 0x1FE); + Corpse = new HagApprenticeCorpse(); + Corpse.MoveToWorld(m_CorpseLocation, map); - Mobile imp = new Zeefzorpul(); - imp.MoveToWorld(m_CorpseLocation, map); + Effects.SendLocationEffect(m_CorpseLocation, map, 0x3728, 10, 10); + Effects.PlaySound(m_CorpseLocation, map, 0x1FE); - // * You see a strange imp stealing a scrap of paper from the bloodied corpse * - Corpse.SendLocalizedMessageTo(player, 1055049); + Mobile imp = new Zeefzorpul(); + imp.MoveToWorld(m_CorpseLocation, map); - Timer.DelayCall(TimeSpan.FromSeconds(3.0), () => DeleteImp(imp)); - } + // * You see a strange imp stealing a scrap of paper from the bloodied corpse * + Corpse.SendLocalizedMessageTo(player, 1055049); + + Timer.DelayCall(TimeSpan.FromSeconds(3.0), () => DeleteImp(imp)); } private void DeleteImp(Mobile m) @@ -102,7 +102,7 @@ namespace Server.Engines.Quests.Hag public override void ChildSerialize(GenericWriter writer) { - if (Corpse != null && Corpse.Deleted) + if (Corpse?.Deleted == true) Corpse = null; writer.WriteEncodedInt(1); // version @@ -260,11 +260,7 @@ namespace Server.Engines.Quests.Hag public class FindIngredientObjective : QuestObjective { - public FindIngredientObjective(Ingredient[] oldIngredients) : this(oldIngredients, false) - { - } - - public FindIngredientObjective(Ingredient[] oldIngredients, bool blackheartMet) + public FindIngredientObjective(Ingredient[] oldIngredients, bool blackheartMet = false) { if (!blackheartMet) { @@ -345,7 +341,7 @@ namespace Server.Engines.Quests.Hag { IngredientInfo info = IngredientInfo.Get(Ingredient); - gump.AddHtmlLocalized(70, 260, 270, 100, info.Name, BaseQuestGump.Blue, false, false); + gump.AddHtmlLocalized(70, 260, 270, 100, info.Name, BaseQuestGump.Blue); gump.AddLabel(70, 280, 0x64, CurProgress.ToString()); gump.AddLabel(100, 280, 0x64, "/"); gump.AddLabel(130, 280, 0x64, info.Quantity.ToString()); @@ -439,4 +435,4 @@ namespace Server.Engines.Quests.Hag System.AddConversation(new EndConversation()); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/RemoteAdmin/Network.cs b/Scripts/Engines/RemoteAdmin/Network.cs index 16ee46cc3..09e9cd300 100644 --- a/Scripts/Engines/RemoteAdmin/Network.cs +++ b/Scripts/Engines/RemoteAdmin/Network.cs @@ -22,10 +22,7 @@ namespace Server.RemoteAdmin public static void Configure() { PacketHandlers.Register(0xF1, 0, false, OnReceive); - -#if !MONO Core.MultiConsoleOut.Add(new EventTextWriter(OnConsoleChar, OnConsoleLine, OnConsoleString)); -#endif Timer.DelayCall(TimeSpan.FromMinutes(2.5), TimeSpan.FromMinutes(2.5), CleanUp); } @@ -279,4 +276,4 @@ namespace Server.RemoteAdmin m_OnLine?.Invoke(line); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/RemoteAdmin/Packets.cs b/Scripts/Engines/RemoteAdmin/Packets.cs index 5125686e0..0697c1f30 100644 --- a/Scripts/Engines/RemoteAdmin/Packets.cs +++ b/Scripts/Engines/RemoteAdmin/Packets.cs @@ -99,12 +99,7 @@ namespace Server.RemoteAdmin { m_Stream.WriteAsciiNull(a.Username); - string pwToSend = a.PlainPassword; - - if (pwToSend == null) - pwToSend = "(hidden)"; - - m_Stream.WriteAsciiNull(pwToSend); + m_Stream.WriteAsciiNull(a.PlainPassword ?? "(hidden)"); m_Stream.Write((byte)a.AccessLevel); m_Stream.Write(a.Banned); unchecked @@ -159,4 +154,4 @@ namespace Server.RemoteAdmin m_Stream.WriteAsciiNull(caption); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs b/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs index d020c8e72..a2340f191 100644 --- a/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs +++ b/Scripts/Engines/RemoteAdmin/RemoteAdminLogging.cs @@ -34,9 +34,8 @@ namespace Server.RemoteAdmin { Output = new StreamWriter( Path.Combine(directory, - string.Format(LogSubDirectory + "{0}.log", DateTime.UtcNow.ToString("yyyyMMdd"))), true); + string.Format(LogSubDirectory + "{0}.log", DateTime.UtcNow.ToString("yyyyMMdd"))), true) { AutoFlush = true }; - Output.AutoFlush = true; Output.WriteLine("##############################"); Output.WriteLine("Log started on {0}", DateTime.UtcNow); diff --git a/Scripts/Engines/Reports/Objects/Staffing/Info.cs b/Scripts/Engines/Reports/Objects/Staffing/Info.cs index 9bcbd5813..5f7d395d3 100644 --- a/Scripts/Engines/Reports/Objects/Staffing/Info.cs +++ b/Scripts/Engines/Reports/Objects/Staffing/Info.cs @@ -3,7 +3,7 @@ using Server.Accounting; namespace Server.Engines.Reports { - public abstract class BaseInfo : IComparable + public abstract class BaseInfo : IComparable { private string m_Display; @@ -51,19 +51,14 @@ namespace Server.Engines.Reports } } - public int CompareTo(object obj) + public int CompareTo(BaseInfo cmp) { - BaseInfo cmp = obj as BaseInfo; - - int v = cmp.GetPageCount(cmp is StaffInfo ? PageResolution.Handled : PageResolution.None, - DateTime.UtcNow - SortRange, DateTime.UtcNow) + int v = cmp?.GetPageCount(cmp is StaffInfo ? PageResolution.Handled : PageResolution.None, + DateTime.UtcNow - SortRange, DateTime.UtcNow) ?? 0 - GetPageCount(this is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - SortRange, DateTime.UtcNow); - if (v == 0) - v = string.Compare(Display, cmp.Display); - - return v; + return v == 0 ? string.Compare(Display, cmp.Display) : v; } public int GetPageCount(PageResolution res, DateTime min, DateTime max) @@ -95,4 +90,4 @@ namespace Server.Engines.Reports { } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Reports/Objects/Staffing/StaffHistory.cs b/Scripts/Engines/Reports/Objects/Staffing/StaffHistory.cs index 38bd54370..9352c4303 100644 --- a/Scripts/Engines/Reports/Objects/Staffing/StaffHistory.cs +++ b/Scripts/Engines/Reports/Objects/Staffing/StaffHistory.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; diff --git a/Scripts/Engines/Reports/Persistance/PersistableType.cs b/Scripts/Engines/Reports/Persistance/PersistableType.cs index 352112dac..4d985e5c0 100644 --- a/Scripts/Engines/Reports/Persistance/PersistableType.cs +++ b/Scripts/Engines/Reports/Persistance/PersistableType.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Engines.Reports diff --git a/Scripts/Engines/Reports/Reports.cs b/Scripts/Engines/Reports/Reports.cs index 6031133b4..2b7d08eaf 100644 --- a/Scripts/Engines/Reports/Reports.cs +++ b/Scripts/Engines/Reports/Reports.cs @@ -133,7 +133,7 @@ namespace Server.Engines.Reports if (ladder == null) return chart; - + List entries = ladder.Entries; for (int i = entries.Count - 1; i >= 0; --i) @@ -205,7 +205,7 @@ namespace Server.Engines.Reports if (prefs == null) return chart; - + List arenas = Arena.Arenas; for (int i = 0; i < arenas.Count; ++i) @@ -528,7 +528,7 @@ namespace Server.Engines.Reports return report; } - public class SkillDistribution : IComparable + public class SkillDistribution : IComparable { public int m_NumberOfGMs; public SkillInfo m_Skill; @@ -538,10 +538,10 @@ namespace Server.Engines.Reports m_Skill = skill; } - public int CompareTo(object obj) + public int CompareTo(SkillDistribution sd) { - return ((SkillDistribution)obj).m_NumberOfGMs - m_NumberOfGMs; + return sd?.m_NumberOfGMs ?? 0 - m_NumberOfGMs; } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Spawner/Spawner.cs b/Scripts/Engines/Spawner/Spawner.cs index 122b9f79e..3d6229d53 100644 --- a/Scripts/Engines/Spawner/Spawner.cs +++ b/Scripts/Engines/Spawner/Spawner.cs @@ -55,8 +55,8 @@ namespace Server.Mobiles } public override string DefaultName => "Spawner"; - public bool IsFull => Spawned != null && Spawned.Count >= m_Count; - public bool IsEmpty => Spawned != null && Spawned.Count == 0; + public bool IsFull => Spawned?.Count >= m_Count; + public bool IsEmpty => Spawned?.Count == 0; public DateTime End{ get; set; } public List Entries{ get; private set; } @@ -144,12 +144,7 @@ namespace Server.Mobiles [CommandProperty(AccessLevel.Developer)] public TimeSpan NextSpawn { - get - { - if (m_Running && m_Timer != null && m_Timer.Running) - return End - DateTime.UtcNow; - return TimeSpan.FromSeconds(0); - } + get => m_Running && m_Timer?.Running == true ? End - DateTime.UtcNow : TimeSpan.FromSeconds(0); set { Start(); @@ -197,7 +192,7 @@ namespace Server.Mobiles Spawned.Remove(spawn); } - if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running) + if (m_Running && !IsFull && m_Timer?.Running == false) DoTimer(); } @@ -209,7 +204,7 @@ namespace Server.Mobiles false); } - public SpawnerEntry AddEntry(string creaturename, int probability, int amount, bool dotimer = true) + public SpawnerEntry AddEntry(string creaturename, int probability = 100, int amount = 1, bool dotimer = true) { SpawnerEntry entry = new SpawnerEntry(creaturename, probability, amount); Entries.Add(entry); @@ -520,8 +515,7 @@ namespace Server.Mobiles { flags = EntryFlags.InvalidProps; - if (o is ISpawnable spawnable) - spawnable.Delete(); + (o as ISpawnable)?.Delete(); return false; } @@ -549,11 +543,7 @@ namespace Server.Mobiles { int walkrange = GetWalkingRange(); - if (walkrange >= 0) - c.RangeHome = walkrange; - else - c.RangeHome = m_HomeRange; - + c.RangeHome = walkrange >= 0 ? walkrange : m_HomeRange; c.CurrentWayPoint = GetWayPoint(); if (m_Team > 0) @@ -732,7 +722,7 @@ namespace Server.Mobiles Entries.Remove(entry); - if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running) + if (m_Running && !IsFull && m_Timer?.Running == false) DoTimer(); InvalidateProperties(); @@ -781,7 +771,7 @@ namespace Server.Mobiles } } - if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running) + if (m_Running && !IsFull && m_Timer?.Running == false) DoTimer(); InvalidateProperties(); @@ -1050,6 +1040,7 @@ namespace Server.Mobiles } catch { + // ignored } } diff --git a/Scripts/Engines/Spawner/SpawnerGump.cs b/Scripts/Engines/Spawner/SpawnerGump.cs index 7c23807cf..9be3687b3 100644 --- a/Scripts/Engines/Spawner/SpawnerGump.cs +++ b/Scripts/Engines/Spawner/SpawnerGump.cs @@ -21,9 +21,9 @@ namespace Server.Mobiles AddBackground(0, 0, 343, 371 + (m_Entry != null ? 44 : 0), 5054); - AddHtml(95, 1, 250, 20, "Creatures List", false, false); - AddHtml(245, 1, 250, 20, "#", false, false); - AddHtml(282, 1, 250, 20, "Prb", false, false); + AddHtml(95, 1, 250, 20, "Creatures List"); + AddHtml(245, 1, 250, 20, "#"); + AddHtml(282, 1, 250, 20, "Prb"); //AddLabel( 95, 1, 0, "Creatures List" ); @@ -41,13 +41,12 @@ namespace Server.Mobiles if (entry == null || m_Entry != entry) AddButton(5, 22 * i + 21 + offset, entry != null ? 0xFBA : 0xFA5, entry != null ? 0xFBC : 0xFA7, - GetButtonID(2, i * 2), GumpButtonType.Reply, 0); //Expand + GetButtonID(2, i * 2)); //Expand else AddButton(5, 22 * i + 21 + offset, 0xFBB, 0xFBC, - GetButtonID(2, i * 2), GumpButtonType.Reply, 0); //Unexpand + GetButtonID(2, i * 2)); //Unexpand - AddButton(38, 22 * i + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + i * 2), GumpButtonType.Reply, - 0); //Delete + AddButton(38, 22 * i + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + i * 2)); //Delete AddImageTiled(71, 22 * i + 20 + offset, 161, 23, 0xA40); //creature text box AddImageTiled(72, 22 * i + 21 + offset, 159, 21, 0xBBC); //creature text box @@ -97,28 +96,28 @@ namespace Server.Mobiles } } - AddButton(5, 347 + offset, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0); + AddButton(5, 347 + offset, 0xFB1, 0xFB3, 0); AddLabel(38, 347 + offset, 0x384, "Cancel"); - AddButton(5, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 2), GumpButtonType.Reply, 0); + AddButton(5, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 2)); AddLabel(38, 325 + offset, 0x384, "Okay"); - AddButton(110, 325 + offset, 0xFB4, 0xFB6, GetButtonID(1, 3), GumpButtonType.Reply, 0); + AddButton(110, 325 + offset, 0xFB4, 0xFB6, GetButtonID(1, 3)); AddLabel(143, 325 + offset, 0x384, "Bring to Home"); - AddButton(110, 347 + offset, 0xFA8, 0xFAA, GetButtonID(1, 4), GumpButtonType.Reply, 0); + AddButton(110, 347 + offset, 0xFA8, 0xFAA, GetButtonID(1, 4)); AddLabel(143, 347 + offset, 0x384, "Total Respawn"); - AddButton(253, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 5), GumpButtonType.Reply, 0); + AddButton(253, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 5)); AddLabel(286, 325 + offset, 0x384, "Apply"); if (m_Page > 0) - AddButton(276, 308 + offset, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 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), GumpButtonType.Reply, 0); + AddButton(293, 308 + offset, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(293, 308 + offset, 0x25E6); } @@ -145,64 +144,63 @@ namespace Server.Mobiles TextRelay parmte = info.GetTextEntry(index + 3); TextRelay propte = info.GetTextEntry(index + 4); - if (cte != null) + if (cte == null) + continue; + + string str = cte.Text.Trim().ToLower(); + + if (str.Length > 0) { - string str = cte.Text.Trim().ToLower(); + Type type = SpawnerType.GetType(str); - if (str.Length > 0) + if (type != null) { - Type type = SpawnerType.GetType(str); + SpawnerEntry entry; - if (type != null) + if (entryindex < ocount) { - SpawnerEntry entry; + entry = spawner.Entries[entryindex]; + entry.SpawnedName = str; - if (entryindex < ocount) - { - entry = spawner.Entries[entryindex]; - entry.SpawnedName = str; + if (mte != null) + entry.SpawnedMaxCount = Utility.ToInt32(mte.Text.Trim()); - if (mte != null) - entry.SpawnedMaxCount = Utility.ToInt32(mte.Text.Trim()); - - if (poste != null) - entry.SpawnedProbability = Utility.ToInt32(poste.Text.Trim()); - } - else - { - int maxcount = 1; - int 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(); + if (poste != null) + entry.SpawnedProbability = Utility.ToInt32(poste.Text.Trim()); } else { - from.SendMessage("{0} is not a valid type name for entry #{1}.", str, i); + int maxcount = 1; + int 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) + else { - rementries.Add(spawner.Entries[entryindex]); + from.SendMessage("{0} is not a valid type name for entry #{1}.", str, i); } } + else if (entryindex < ocount && spawner.Entries[entryindex] != null) + { + rementries.Add(spawner.Entries[entryindex]); + } } - if (rementries.Count > 0) - for (int i = 0; i < rementries.Count; i++) - spawner.RemoveEntry(rementries[i]); + for (int i = 0; i < rementries.Count; i++) + spawner.RemoveEntry(rementries[i]); if (ocount == 0 && spawner.Entries.Count > 0) spawner.Start(); @@ -241,7 +239,7 @@ namespace Server.Mobiles } case 1: { - if (m_Spawner.Entries != null && (m_Page + 1) * 13 <= m_Spawner.Entries.Count) + if ((m_Page + 1) * 13 <= m_Spawner.Entries?.Count) { m_Page++; m_Entry = null; @@ -282,16 +280,9 @@ namespace Server.Mobiles { SpawnerEntry entry = m_Spawner.Entries[entryindex]; if (buttontype == 0) // Spawn creature - { - if (m_Entry != null && m_Entry == entry) - m_Entry = null; - else - m_Entry = entry; - } + m_Entry = m_Entry != entry ? entry : null; else // Remove creatures - { m_Spawner.RemoveSpawn(entryindex); - } } CreateArray(info, state.Mobile, m_Spawner); @@ -305,4 +296,4 @@ namespace Server.Mobiles state.Mobile.SendGump(new SpawnerGump(m_Spawner, null, m_Page)); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs b/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs index 37e5fb6b5..e020b5cc4 100644 --- a/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs +++ b/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs @@ -479,12 +479,7 @@ namespace Server.Items private PigmentType m_Type; [Constructible] - public PigmentsOfTokuno() : this(PigmentType.None, 10) - { - } - - [Constructible] - public PigmentsOfTokuno(PigmentType type) : this(type, + public PigmentsOfTokuno(PigmentType type = PigmentType.None) : this(type, type == PigmentType.None || type >= PigmentType.FadedCoal ? 10 : 50) { } @@ -559,4 +554,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs b/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs index 992033bb1..6d831932e 100644 --- a/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs +++ b/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs @@ -628,6 +628,11 @@ namespace Server.Items { private string m_UrnName; + [Constructible] + public AncientUrn() : this(Names[Utility.Random(Names.Length)]) + { + } + [Constructible] public AncientUrn(string urnName) : base(0x241D) { @@ -635,11 +640,6 @@ namespace Server.Items Weight = 1.0; } - [Constructible] - public AncientUrn() : this(Names[Utility.Random(Names.Length)]) - { - } - public AncientUrn(Serial serial) : base(serial) { } @@ -725,6 +725,11 @@ namespace Server.Items { private string m_SwordsName; + [Constructible] + public HonorableSwords() : this(AncientUrn.Names[Utility.Random(AncientUrn.Names.Length)]) + { + } + [Constructible] public HonorableSwords(string swordsName) : base(0x2853) { @@ -733,11 +738,6 @@ namespace Server.Items Weight = 5.0; } - [Constructible] - public HonorableSwords() : this(AncientUrn.Names[Utility.Random(AncientUrn.Names.Length)]) - { - } - public HonorableSwords(Serial serial) : base(serial) { } @@ -1080,4 +1080,4 @@ namespace Server.Items int version = InheritsItem ? 0 : reader.ReadInt(); // Required for BasePigmentsOfTokuno insertion } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs b/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs index 730d50ae6..d9f9e95d7 100644 --- a/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs +++ b/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs @@ -169,7 +169,7 @@ namespace Server.Misc if (!pm.PlaceInBackpack(i)) { - if (pm.BankBox != null && pm.BankBox.TryDropItem(killer, i, false)) + if (pm.BankBox?.TryDropItem(killer, i, false) == true) { pm.SendLocalizedMessage(1079730); // The item has been placed into your bank box. } @@ -331,7 +331,7 @@ namespace Server.Gumps List buttons = new List(); Item[] items = pack.FindItemsByType(TreasuresOfTokuno.LesserArtifactsTotal); - + for (int i = 0; i < items.Length; i++) { Item item = items[i]; @@ -582,21 +582,17 @@ namespace Server.Gumps public class TypeTileButtonInfo : ImageTileButtonInfo { - public TypeTileButtonInfo(Type type, int itemID, int hue, TextDefinition label, int localizedToolTip) : base( + public TypeTileButtonInfo(Type type, int itemID, TextDefinition label, int localizedToolTip = -1) : this(type, itemID, + 0, label, localizedToolTip) + { + } + + public TypeTileButtonInfo(Type type, int itemID, int hue, TextDefinition label, int localizedToolTip = -1) : base( itemID, hue, label, localizedToolTip) { Type = type; } - public TypeTileButtonInfo(Type type, int itemID, TextDefinition label) : this(type, itemID, 0, label, -1) - { - } - - public TypeTileButtonInfo(Type type, int itemID, TextDefinition label, int localizedToolTip) : this(type, itemID, - 0, label, localizedToolTip) - { - } - public Type Type{ get; } } @@ -628,4 +624,4 @@ Pigments of tokuno do NOT check for if item is already hued 0; APPARENTLY he st Chest of Heirlooms don't show if unlocked. Chest of heirlooms, locked, HARD to pick at 100 lock picking but not impossible. had 95 health to 0, cause it's trapped >< (explosion i think) -*/ \ No newline at end of file +*/ diff --git a/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs b/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs index 74f50b64a..309b3e8ef 100644 --- a/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs +++ b/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs @@ -6,7 +6,7 @@ namespace Server.Misc { Movable = false; - if (Instance == null || Instance.Deleted) + if (Instance?.Deleted != false) Instance = this; else base.Delete(); @@ -59,4 +59,4 @@ namespace Server.Misc { } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs b/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs index 33e3dfd8d..3e2de9eba 100644 --- a/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs +++ b/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs @@ -150,7 +150,7 @@ namespace Server.Mobiles { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsCoOwner(from) || (int)from.AccessLevel > (int)AccessLevel.Counselor) + if (house?.IsCoOwner(from) == true || from.AccessLevel > AccessLevel.Counselor) list.Add(new DemolishEntry(this)); } } @@ -159,7 +159,7 @@ namespace Server.Mobiles { base.OnAfterDelete(); - if (Plinth != null && !Plinth.Deleted) + if (Plinth?.Deleted == false) Plinth.Delete(); } @@ -309,12 +309,14 @@ namespace Server.Mobiles public Item CloneItem(Item item) { - Item cloned = new Item(item.ItemID); - cloned.Layer = item.Layer; - cloned.Name = item.Name; - cloned.Hue = item.Hue; - cloned.Weight = item.Weight; - cloned.Movable = false; + Item cloned = new Item(item.ItemID) + { + Layer = item.Layer, + Name = item.Name, + Hue = item.Hue, + Weight = item.Weight, + Movable = false + }; return cloned; } @@ -569,7 +571,7 @@ namespace Server.Mobiles IPoint3D p = targeted as IPoint3D; Map map = from.Map; - if (p == null || map == null || m_Maker == null || m_Maker.Deleted) + if (p == null || map == null || m_Maker?.Deleted != false) return; if (m_Maker.IsChildOf(from.Backpack)) @@ -666,4 +668,4 @@ namespace Server.Mobiles return AddonFitResult.Valid; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs b/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs index f35f30a94..8353e5a0d 100644 --- a/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs +++ b/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs @@ -47,7 +47,7 @@ namespace Server.Items { base.OnAfterDelete(); - if (m_Statue != null && !m_Statue.Deleted) + if (m_Statue?.Deleted == false) m_Statue.Delete(); } @@ -106,9 +106,9 @@ namespace Server.Items AddPage(0); AddImage(0, 0, 0x24F4); - AddHtml(55, 50, 150, 20, statue.Name, false, false); - AddHtml(55, 75, 150, 20, statue.SculptedOn.ToString(), false, false); - AddHtmlLocalized(55, 100, 150, 20, GetTypeNumber(statue.StatueType), 0, false, false); + AddHtml(55, 50, 150, 20, statue.Name); + AddHtml(55, 75, 150, 20, statue.SculptedOn.ToString()); + AddHtmlLocalized(55, 100, 150, 20, GetTypeNumber(statue.StatueType), 0); } public int GetTypeNumber(StatueType type) @@ -123,4 +123,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs b/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs index 4d163d145..4d719b32e 100644 --- a/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs +++ b/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs @@ -30,40 +30,39 @@ namespace Server.Gumps AddImageTiled(10, 40, 307, 244, 0xA40); AddImageTiled(10, 294, 307, 20, 0xA40); AddAlphaRegion(10, 10, 307, 304); - AddHtmlLocalized(14, 12, 327, 20, 1076156, 0x7FFF, false, false); // Character Statue Maker + AddHtmlLocalized(14, 12, 327, 20, 1076156, 0x7FFF); // Character Statue Maker // pose - AddHtmlLocalized(133, 41, 120, 20, 1076168, 0x7FFF, false, false); // Choose Pose - AddHtmlLocalized(133, 61, 120, 20, 1076208 + (int)m_Statue.Pose, 0x77E, false, false); - AddButton(163, 81, 0xFA5, 0xFA7, (int)Buttons.PoseNext, GumpButtonType.Reply, 0); - AddButton(133, 81, 0xFAE, 0xFB0, (int)Buttons.PosePrev, GumpButtonType.Reply, 0); + AddHtmlLocalized(133, 41, 120, 20, 1076168, 0x7FFF); // Choose Pose + AddHtmlLocalized(133, 61, 120, 20, 1076208 + (int)m_Statue.Pose, 0x77E); + AddButton(163, 81, 0xFA5, 0xFA7, (int)Buttons.PoseNext); + AddButton(133, 81, 0xFAE, 0xFB0, (int)Buttons.PosePrev); // direction - AddHtmlLocalized(133, 126, 120, 20, 1076170, 0x7FFF, false, false); // Choose Direction - AddHtmlLocalized(133, 146, 120, 20, GetDirectionNumber(m_Statue.Direction), 0x77E, false, false); - AddButton(163, 167, 0xFA5, 0xFA7, (int)Buttons.DirNext, GumpButtonType.Reply, 0); - AddButton(133, 167, 0xFAE, 0xFB0, (int)Buttons.DirPrev, GumpButtonType.Reply, 0); + AddHtmlLocalized(133, 126, 120, 20, 1076170, 0x7FFF); // Choose Direction + AddHtmlLocalized(133, 146, 120, 20, GetDirectionNumber(m_Statue.Direction), 0x77E); + AddButton(163, 167, 0xFA5, 0xFA7, (int)Buttons.DirNext); + AddButton(133, 167, 0xFAE, 0xFB0, (int)Buttons.DirPrev); // material - AddHtmlLocalized(133, 211, 120, 20, 1076171, 0x7FFF, false, false); // Choose Material - AddHtmlLocalized(133, 231, 120, 20, GetMaterialNumber(m_Statue.StatueType, m_Statue.Material), 0x77E, false, - false); - AddButton(163, 253, 0xFA5, 0xFA7, (int)Buttons.MatNext, GumpButtonType.Reply, 0); - AddButton(133, 253, 0xFAE, 0xFB0, (int)Buttons.MatPrev, GumpButtonType.Reply, 0); + AddHtmlLocalized(133, 211, 120, 20, 1076171, 0x7FFF); // Choose Material + AddHtmlLocalized(133, 231, 120, 20, GetMaterialNumber(m_Statue.StatueType, m_Statue.Material), 0x77E); + AddButton(163, 253, 0xFA5, 0xFA7, (int)Buttons.MatNext); + AddButton(133, 253, 0xFAE, 0xFB0, (int)Buttons.MatPrev); // cancel - AddButton(10, 294, 0xFB1, 0xFB2, (int)Buttons.Close, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 294, 80, 20, 1006045, 0x7FFF, false, false); // Cancel + AddButton(10, 294, 0xFB1, 0xFB2, (int)Buttons.Close); + AddHtmlLocalized(45, 294, 80, 20, 1006045, 0x7FFF); // Cancel // sculpt - AddButton(234, 294, 0xFB7, 0xFB9, (int)Buttons.Sculpt, GumpButtonType.Reply, 0); - AddHtmlLocalized(269, 294, 80, 20, 1076174, 0x7FFF, false, false); // Sculpt + AddButton(234, 294, 0xFB7, 0xFB9, (int)Buttons.Sculpt); + AddHtmlLocalized(269, 294, 80, 20, 1076174, 0x7FFF); // Sculpt // restore if (m_Maker is CharacterStatueDeed) { - AddButton(107, 294, 0xFAB, 0xFAD, (int)Buttons.Restore, GumpButtonType.Reply, 0); - AddHtmlLocalized(142, 294, 80, 20, 1076193, 0x7FFF, false, false); // Restore + AddButton(107, 294, 0xFAB, 0xFAD, (int)Buttons.Restore); + AddHtmlLocalized(142, 294, 80, 20, 1076193, 0x7FFF); // Restore } } @@ -111,7 +110,7 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { - if (m_Statue == null || m_Statue.Deleted) + if (m_Statue?.Deleted != false) return; bool sendGump = false; @@ -195,4 +194,4 @@ namespace Server.Gumps Restore } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs b/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs index f2d2fb499..238ebfc94 100644 --- a/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs +++ b/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs @@ -25,10 +25,10 @@ namespace Server.Engines.VeteranRewards AddBackground(10, 10, 600, 450, 2600); - AddButton(530, 415, 4017, 4019, 0, GumpButtonType.Reply, 0); + AddButton(530, 415, 4017, 4019, 0); AddButton(60, 415, 4014, 4016, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(95, 415, 200, 20, 1049755, false, false); // Main Menu + AddHtmlLocalized(95, 415, 200, 20, 1049755); // Main Menu } private void RenderCategories() @@ -61,10 +61,10 @@ namespace Server.Engines.VeteranRewards RewardSystem.ComputeRewardInfo(m_From, out int cur, out int max); - AddHtmlLocalized(60, 105, 300, 35, 1006006, false, false); // Your current total of rewards to choose: + AddHtmlLocalized(60, 105, 300, 35, 1006006); // Your current total of rewards to choose: AddLabel(370, 107, 50, (max - cur).ToString()); - AddHtmlLocalized(60, 140, 300, 35, 1006007, false, false); // You have already chosen: + AddHtmlLocalized(60, 140, 300, 35, 1006007); // You have already chosen: AddLabel(370, 142, 50, cur.ToString()); RewardCategory[] categories = RewardSystem.Categories; @@ -84,9 +84,9 @@ namespace Server.Engines.VeteranRewards page += PagesPerCategory(categories[i]); if (categories[i].NameString != null) - AddHtml(135, 180 + i * 40, 300, 20, categories[i].NameString, false, false); + AddHtml(135, 180 + i * 40, 300, 20, categories[i].NameString); else - AddHtmlLocalized(135, 180 + i * 40, 300, 20, categories[i].Name, false, false); + AddHtmlLocalized(135, 180 + i * 40, 300, 20, categories[i].Name); } page = 2; @@ -130,22 +130,22 @@ namespace Server.Engines.VeteranRewards if (i == 24) { AddButton(305, 415, 0xFA5, 0xFA7, 0, GumpButtonType.Page, ++page); - AddHtmlLocalized(340, 415, 200, 20, 1011066, false, false); // Next page + AddHtmlLocalized(340, 415, 200, 20, 1011066); // Next page AddPage(page); AddButton(270, 415, 0xFAE, 0xFB0, 0, GumpButtonType.Page, page - 1); - AddHtmlLocalized(185, 415, 200, 20, 1011067, false, false); // Previous page + AddHtmlLocalized(185, 415, 200, 20, 1011067); // Previous page i = 0; } - AddButton(55 + i / 12 * 250, 80 + i % 12 * 25, 5540, 5541, GetButtonID(index, j), GumpButtonType.Reply, 0); + 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, false, false); + 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, false, false); + AddHtmlLocalized(80 + i / 12 * 250, 80 + i % 12 * 25, 250, 20, entry.Name); ++i; } @@ -189,4 +189,4 @@ namespace Server.Engines.VeteranRewards } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs b/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs index 046692279..bd4410893 100644 --- a/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs +++ b/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs @@ -20,24 +20,24 @@ namespace Server.Engines.VeteranRewards AddBackground(10, 10, 500, 300, 2600); - AddHtmlLocalized(30, 55, 300, 35, 1006000, false, false); // You have selected: + AddHtmlLocalized(30, 55, 300, 35, 1006000); // You have selected: if (entry.NameString != null) - AddHtml(335, 55, 150, 35, entry.NameString, false, false); + AddHtml(335, 55, 150, 35, entry.NameString); else - AddHtmlLocalized(335, 55, 150, 35, entry.Name, false, false); + AddHtmlLocalized(335, 55, 150, 35, entry.Name); - AddHtmlLocalized(30, 95, 300, 35, 1006001, false, false); // This will be assigned to this character: + AddHtmlLocalized(30, 95, 300, 35, 1006001); // This will be assigned to this character: AddLabel(335, 95, 0, from.Name); AddHtmlLocalized(35, 160, 450, 90, 1006002, true, true); // Are you sure you wish to select this reward for this character? You will not be able to transfer this reward to another character on another shard. Click 'ok' below to confirm your selection or 'cancel' to go back to the selection screen. - AddButton(60, 265, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(95, 266, 150, 35, 1006044, false, false); // Ok + AddButton(60, 265, 4005, 4007, 1); + AddHtmlLocalized(95, 266, 150, 35, 1006044); // Ok - AddButton(295, 265, 4017, 4019, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(330, 266, 150, 35, 1006045, false, false); // Cancel + AddButton(295, 265, 4017, 4019, 0); + AddHtmlLocalized(330, 266, 150, 35, 1006045); // Cancel } public override void OnResponse(NetState sender, RelayInfo info) @@ -67,4 +67,4 @@ namespace Server.Engines.VeteranRewards m_From.SendGump(new RewardNoticeGump(m_From)); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs b/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs index e434ad546..70dea01f2 100644 --- a/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs +++ b/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs @@ -20,13 +20,13 @@ namespace Server.Gumps AddBackground(0, 0, 220, 170, 0x13BE); AddBackground(10, 10, 200, 150, 0xBB8); - AddHtmlLocalized(20, 30, 180, 60, question, false, false); // Do you wish to re-deed this decoration? + AddHtmlLocalized(20, 30, 180, 60, question); // Do you wish to re-deed this decoration? - AddHtmlLocalized(55, 100, 150, 25, 1011011, false, false); // CONTINUE - AddButton(20, 100, 0xFA5, 0xFA7, (int)Buttons.Confirm, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 100, 150, 25, 1011011); // CONTINUE + AddButton(20, 100, 0xFA5, 0xFA7, (int)Buttons.Confirm); - AddHtmlLocalized(55, 125, 150, 25, 1011012, false, false); // CANCEL - AddButton(20, 125, 0xFA5, 0xFA7, (int)Buttons.Cancel, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 125, 150, 25, 1011012); // CANCEL + AddButton(20, 125, 0xFA5, 0xFA7, (int)Buttons.Cancel); } public override void OnResponse(NetState sender, RelayInfo info) @@ -71,4 +71,4 @@ namespace Server.Gumps Confirm } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs b/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs index 14e1d085a..3e9a8aac9 100644 --- a/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs +++ b/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs @@ -22,11 +22,11 @@ namespace Server.Engines.VeteranRewards */ AddHtmlLocalized(52, 35, 420, 55, 1006046, true, true); - AddButton(60, 95, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(95, 96, 150, 35, 1006044, false, false); // Ok + AddButton(60, 95, 4005, 4007, 1); + AddHtmlLocalized(95, 96, 150, 35, 1006044); // Ok - AddButton(285, 95, 4017, 4019, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(320, 96, 150, 35, 1006045, false, false); // Cancel + AddButton(285, 95, 4017, 4019, 0); + AddHtmlLocalized(320, 96, 150, 35, 1006045); // Cancel } public override void OnResponse(NetState sender, RelayInfo info) @@ -35,4 +35,4 @@ namespace Server.Engines.VeteranRewards m_From.SendGump(new RewardChoiceGump(m_From)); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/RewardOptionGump.cs b/Scripts/Engines/VeteranRewards/RewardOptionGump.cs index 14e7c12b1..4bdd1b2c9 100644 --- a/Scripts/Engines/VeteranRewards/RewardOptionGump.cs +++ b/Scripts/Engines/VeteranRewards/RewardOptionGump.cs @@ -14,11 +14,7 @@ namespace Server.Gumps private IRewardOption m_Option; private RewardOptionList m_Options = new RewardOptionList(); - public RewardOptionGump(IRewardOption option) : this(option, 0) - { - } - - public RewardOptionGump(IRewardOption option, int title) : base(60, 36) + public RewardOptionGump(IRewardOption option, int title = 0) : base(60, 36) { m_Option = option; @@ -32,20 +28,20 @@ namespace Server.Gumps AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL if (title > 0) - AddHtmlLocalized(14, 12, 273, 20, title, 0x7FFF, false, false); + AddHtmlLocalized(14, 12, 273, 20, title, 0x7FFF); else - AddHtmlLocalized(14, 12, 273, 20, 1080392, 0x7FFF, false, false); // Select your choice from the menu below. + AddHtmlLocalized(14, 12, 273, 20, 1080392, 0x7FFF); // Select your choice from the menu below. AddPage(1); for (int i = 0; i < m_Options.Count; i++) { - AddButton(19, 49 + i * 24, 0x845, 0x846, m_Options[i].ID, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47 + i * 24, 213, 20, m_Options[i].Cliloc, 0x7FFF, false, false); + AddButton(19, 49 + i * 24, 0x845, 0x846, m_Options[i].ID); + AddHtmlLocalized(44, 47 + i * 24, 213, 20, m_Options[i].Cliloc, 0x7FFF); } } @@ -88,4 +84,4 @@ namespace Server.Gumps Add(new RewardOption(id, cliloc)); } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/VeteranRewards/RewardSystem.cs b/Scripts/Engines/VeteranRewards/RewardSystem.cs index 0be464dc8..504b72e71 100644 --- a/Scripts/Engines/VeteranRewards/RewardSystem.cs +++ b/Scripts/Engines/VeteranRewards/RewardSystem.cs @@ -171,7 +171,7 @@ namespace Server.Engines.VeteranRewards max = 2 + level; } - public static bool CheckIsUsableBy(Mobile from, Item item, object[] args) + public static bool CheckIsUsableBy(Mobile from, Item item, object[] args = null) { if (m_Lists == null) SetupRewardTables(); @@ -189,12 +189,12 @@ namespace Server.Engines.VeteranRewards { if (entries[j].ItemType != type) continue; - + if (args == null && entries[j].Args.Length == 0) { if (isRelaxedRules && i <= 0 || HasAccess(from, list, out TimeSpan ts)) return true; - + from.SendLocalizedMessage(1008126, true, Math.Ceiling(ts.TotalDays / 30.0) .ToString()); // Your account is not old enough to use this item. Months until you can use this item : @@ -204,7 +204,7 @@ namespace Server.Engines.VeteranRewards if (args?.Length != entries[j].Args.Length) continue; - + bool match = true; for (int k = 0; match && k < args.Length; ++k) @@ -214,7 +214,7 @@ namespace Server.Engines.VeteranRewards { if (isRelaxedRules && i <= 0 || HasAccess(from, list, out TimeSpan ts)) return true; - + from.SendLocalizedMessage(1008126, true, Math.Ceiling(ts.TotalDays / 30.0) .ToString()); // Your account is not old enough to use this item. Months until you can use this item : @@ -503,4 +503,4 @@ namespace Server.Engines.VeteranRewards { bool IsRewardItem{ get; set; } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Virtues/Honor.cs b/Scripts/Engines/Virtues/Honor.cs index 908561a7c..2583a48f6 100644 --- a/Scripts/Engines/Virtues/Honor.cs +++ b/Scripts/Engines/Virtues/Honor.cs @@ -119,11 +119,11 @@ namespace Server if (target.Body.IsHuman && (!(target is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer)) { - if (reg == null || reg.IsDisabled()) + if (reg?.IsDisabled() != true) { //Allow honor on blue if Out of guardzone } - else if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0) + else if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) { //Allow honor on blue if in Fel } @@ -406,4 +406,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Virtues/Justice.cs b/Scripts/Engines/Virtues/Justice.cs index c726b790a..259ab4598 100644 --- a/Scripts/Engines/Virtues/Justice.cs +++ b/Scripts/Engines/Virtues/Justice.cs @@ -194,8 +194,7 @@ namespace Server AddImageTiled(15, 15, 365, 190, 2624); AddAlphaRegion(15, 15, 365, 190); - AddHtmlLocalized(30, 20, 360, 25, 1049365, 0x7FFF, false, - false); // Another player is offering you their protection: + AddHtmlLocalized(30, 20, 360, 25, 1049365, 0x7FFF); // Another player is offering you their protection: AddLabel(90, 55, 1153, protector.Name); AddImage(50, 45, 9005); @@ -203,12 +202,12 @@ namespace Server AddImageTiled(95, 82, 200, 1, 9157); AddRadio(30, 110, 9727, 9730, true, 1); - AddHtmlLocalized(65, 115, 300, 25, 1049444, 0x7FFF, false, false); // Yes, I would like their protection. + AddHtmlLocalized(65, 115, 300, 25, 1049444, 0x7FFF); // Yes, I would like their protection. AddRadio(30, 145, 9727, 9730, false, 0); - AddHtmlLocalized(65, 148, 300, 25, 1049445, 0x7FFF, false, false); // No thanks, I can take care of myself. + AddHtmlLocalized(65, 148, 300, 25, 1049445, 0x7FFF); // No thanks, I can take care of myself. - AddButton(160, 175, 247, 248, 2, GumpButtonType.Reply, 0); + AddButton(160, 175, 247, 248, 2); AddImage(215, 0, 50581); @@ -235,4 +234,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Virtues/Valor.cs b/Scripts/Engines/Virtues/Valor.cs index 20ad8e050..87c6a0da0 100644 --- a/Scripts/Engines/Virtues/Valor.cs +++ b/Scripts/Engines/Virtues/Valor.cs @@ -47,7 +47,7 @@ namespace Server public static void Valor(Mobile from, object targ) { - if (!(targ is IdolOfTheChampion idol) || idol.Deleted || idol.Spawn == null || idol.Spawn.Deleted) + if (!(targ is IdolOfTheChampion idol) || idol.Deleted || idol.Spawn?.Deleted != false) { from.SendLocalizedMessage(1054035); // You must target a Champion Idol to challenge the Champion's spawn! } @@ -139,4 +139,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Virtues/VirtueGump.cs b/Scripts/Engines/Virtues/VirtueGump.cs index a9cbb50e0..98a6765ef 100644 --- a/Scripts/Engines/Virtues/VirtueGump.cs +++ b/Scripts/Engines/Virtues/VirtueGump.cs @@ -47,8 +47,8 @@ namespace Server if (m_Beholder == m_Beheld) { - AddButton(57, 269, 2027, 2027, 1, GumpButtonType.Reply, 0); - AddButton(186, 269, 2071, 2071, 2, GumpButtonType.Reply, 0); + AddButton(57, 269, 2027, 2027, 1); + AddButton(186, 269, 2071, 2071, 2); } } diff --git a/Scripts/Engines/Virtues/VirtueInfoGump.cs b/Scripts/Engines/Virtues/VirtueInfoGump.cs index e93041f2d..f642321a9 100644 --- a/Scripts/Engines/Virtues/VirtueInfoGump.cs +++ b/Scripts/Engines/Virtues/VirtueInfoGump.cs @@ -10,12 +10,7 @@ namespace Server private string m_Page; private VirtueName m_Virtue; - public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description) : this(beholder, virtue, description, - null) - { - } - - public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description, string webPage) : base(0, 0) + public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description, string webPage = null) : base(0, 0) { m_Beholder = beholder; m_Virtue = virtue; @@ -73,16 +68,15 @@ namespace Server valueDesc = 1052050; // You have achieved the highest path in this Virtue. - AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue, false, false); - AddHtmlLocalized(75, 95, 220, 140, description, false, false); - AddHtmlLocalized(70, 224, 229, 60, valueDesc, false, false); + AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue); + AddHtmlLocalized(75, 95, 220, 140, description); + AddHtmlLocalized(70, 224, 229, 60, valueDesc); - AddButton(65, 277, 1209, 1209, 1, GumpButtonType.Reply, 0); + AddButton(65, 277, 1209, 1209, 1); - AddButton(280, 43, 4014, 4014, 2, GumpButtonType.Reply, 0); + AddButton(280, 43, 4014, 4014, 2); - AddHtmlLocalized(83, 275, 400, 40, webPage == null ? 1052055 : 1052052, false, - false); // This virtue is not yet defined. OR -click to learn more (opens webpage) + AddHtmlLocalized(83, 275, 400, 40, webPage == null ? 1052055 : 1052052); // This virtue is not yet defined. OR -click to learn more (opens webpage) } public override void OnResponse(NetState state, RelayInfo info) @@ -105,4 +99,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Scripts/Engines/Virtues/VirtueStatusGump.cs b/Scripts/Engines/Virtues/VirtueStatusGump.cs index 854c8271a..911cc7774 100644 --- a/Scripts/Engines/Virtues/VirtueStatusGump.cs +++ b/Scripts/Engines/Virtues/VirtueStatusGump.cs @@ -22,30 +22,29 @@ namespace Server AddPage(1); - AddHtml(140, 73, 200, 20, "The Virtues", false, false); + AddHtml(140, 73, 200, 20, "The Virtues"); - AddHtmlLocalized(80, 100, 100, 40, 1051000, false, false); // Humility - AddHtmlLocalized(80, 129, 100, 40, 1051001, false, false); // Sacrifice - AddHtmlLocalized(80, 159, 100, 40, 1051002, false, false); // Compassion - AddHtmlLocalized(80, 189, 100, 40, 1051003, false, false); // Spirituality - AddHtmlLocalized(200, 100, 200, 40, 1051004, false, false); // Valor - AddHtmlLocalized(200, 129, 200, 40, 1051005, false, false); // Honor - AddHtmlLocalized(200, 159, 200, 40, 1051006, false, false); // Justice - AddHtmlLocalized(200, 189, 200, 40, 1051007, false, false); // Honesty + AddHtmlLocalized(80, 100, 100, 40, 1051000); // Humility + AddHtmlLocalized(80, 129, 100, 40, 1051001); // Sacrifice + AddHtmlLocalized(80, 159, 100, 40, 1051002); // Compassion + AddHtmlLocalized(80, 189, 100, 40, 1051003); // Spirituality + AddHtmlLocalized(200, 100, 200, 40, 1051004); // Valor + AddHtmlLocalized(200, 129, 200, 40, 1051005); // Honor + AddHtmlLocalized(200, 159, 200, 40, 1051006); // Justice + AddHtmlLocalized(200, 189, 200, 40, 1051007); // Honesty - AddHtmlLocalized(75, 224, 220, 60, 1052062, false, - false); // Click on a blue gem to view your status in that virtue. + AddHtmlLocalized(75, 224, 220, 60, 1052062); // Click on a blue gem to view your status in that virtue. - AddButton(60, 100, 1210, 1210, 1, GumpButtonType.Reply, 0); - AddButton(60, 129, 1210, 1210, 2, GumpButtonType.Reply, 0); - AddButton(60, 159, 1210, 1210, 3, GumpButtonType.Reply, 0); - AddButton(60, 189, 1210, 1210, 4, GumpButtonType.Reply, 0); - AddButton(180, 100, 1210, 1210, 5, GumpButtonType.Reply, 0); - AddButton(180, 129, 1210, 1210, 6, GumpButtonType.Reply, 0); - AddButton(180, 159, 1210, 1210, 7, GumpButtonType.Reply, 0); - AddButton(180, 189, 1210, 1210, 8, GumpButtonType.Reply, 0); + AddButton(60, 100, 1210, 1210, 1); + AddButton(60, 129, 1210, 1210, 2); + AddButton(60, 159, 1210, 1210, 3); + AddButton(60, 189, 1210, 1210, 4); + AddButton(180, 100, 1210, 1210, 5); + AddButton(180, 129, 1210, 1210, 6); + AddButton(180, 159, 1210, 1210, 7); + AddButton(180, 189, 1210, 1210, 8); - AddButton(280, 43, 4014, 4014, 9, GumpButtonType.Reply, 0); + AddButton(280, 43, 4014, 4014, 9); } public override void OnResponse(NetState state, RelayInfo info) @@ -105,4 +104,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/AddDoorGump.cs b/Scripts/Gumps/AddDoorGump.cs index da1daa181..178b1cb1d 100644 --- a/Scripts/Gumps/AddDoorGump.cs +++ b/Scripts/Gumps/AddDoorGump.cs @@ -18,11 +18,7 @@ namespace Server.Gumps private int m_Type; - public AddDoorGump() : this(-1) - { - } - - public AddDoorGump(int type) : base(50, 40) + public AddDoorGump(int type = -1) : base(50, 40) { m_Type = type; @@ -35,18 +31,18 @@ namespace Server.Gumps int baseID = m_Types[m_Type].m_BaseID; AddItem(25, 24, baseID); - AddButton(26, 37, 0x5782, 0x5782, 1, GumpButtonType.Reply, 0); + AddButton(26, 37, 0x5782, 0x5782, 1); AddItem(47, 45, baseID + 2); - AddButton(43, 57, 0x5783, 0x5783, 2, GumpButtonType.Reply, 0); + AddButton(43, 57, 0x5783, 0x5783, 2); AddItem(87, 22, baseID + 10); - AddButton(116, 35, 0x5785, 0x5785, 6, GumpButtonType.Reply, 0); + AddButton(116, 35, 0x5785, 0x5785, 6); AddItem(65, 45, baseID + 8); - AddButton(96, 55, 0x5784, 0x5784, 5, GumpButtonType.Reply, 0); + AddButton(96, 55, 0x5784, 0x5784, 5); - AddButton(73, 36, 0x2716, 0x2716, 9, GumpButtonType.Reply, 0); + AddButton(73, 36, 0x2716, 0x2716, 9); } else { @@ -54,7 +50,7 @@ namespace Server.Gumps for (int i = 0; i < m_Types.Length; ++i) { - AddButton(30 + i * 49, 13, 0x2624, 0x2625, i + 1, GumpButtonType.Reply, 0); + AddButton(30 + i * 49, 13, 0x2624, 0x2625, i + 1); AddItem(22 + i * 49, 20, m_Types[i].m_BaseID); } } @@ -122,4 +118,4 @@ namespace Server.Gumps m_BaseID = baseID; } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/AddGump.cs b/Scripts/Gumps/AddGump.cs index b253721e5..118456163 100644 --- a/Scripts/Gumps/AddGump.cs +++ b/Scripts/Gumps/AddGump.cs @@ -32,10 +32,10 @@ namespace Server.Gumps AddImageTiled(42, 12, 182, 16, 2624); AddAlphaRegion(42, 12, 182, 16); - AddButton(10, 9, 4011, 4013, 1, GumpButtonType.Reply, 0); + AddButton(10, 9, 4011, 4013, 1); AddTextEntry(44, 10, 180, 20, 0x480, 0, searchString); - AddHtmlLocalized(230, 10, 100, 20, 3010005, 0x7FFF, false, false); + AddHtmlLocalized(230, 10, 100, 20, 3010005, 0x7FFF); AddImageTiled(10, 40, 400, 200, 2624); AddAlphaRegion(10, 40, 400, 200); @@ -46,7 +46,7 @@ namespace Server.Gumps int index = i % 10; AddLabel(44, 39 + index * 20, 0x480, searchResults[i].Name); - AddButton(10, 39 + index * 20, 4023, 4025, 4 + i, GumpButtonType.Reply, 0); + AddButton(10, 39 + index * 20, 4023, 4025, 4 + i); } else AddLabel(15, 44, 0x480, explicitSearch ? "Nothing matched your search terms." : "No results to display."); @@ -55,19 +55,18 @@ namespace Server.Gumps AddAlphaRegion(10, 250, 400, 20); if (m_Page > 0) - AddButton(10, 249, 4014, 4016, 2, GumpButtonType.Reply, 0); + AddButton(10, 249, 4014, 4016, 2); else AddImage(10, 249, 4014); - AddHtmlLocalized(44, 250, 170, 20, 1061028, m_Page > 0 ? 0x7FFF : 0x5EF7, false, false); // Previous page + 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, GumpButtonType.Reply, 0); + AddButton(210, 249, 4005, 4007, 3); else AddImage(210, 249, 4005); - AddHtmlLocalized(244, 250, 170, 20, 1061027, (m_Page + 1) * 10 < searchResults.Length ? 0x7FFF : 0x5EF7, false, - false); // Next page + AddHtmlLocalized(244, 250, 170, 20, 1061027, (m_Page + 1) * 10 < searchResults.Length ? 0x7FFF : 0x5EF7); // Next page } public static void Initialize() @@ -248,4 +247,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/AdminGump.cs b/Scripts/Gumps/AdminGump.cs index cb384470b..a7ad3b44f 100644 --- a/Scripts/Gumps/AdminGump.cs +++ b/Scripts/Gumps/AdminGump.cs @@ -109,7 +109,7 @@ namespace Server.Gumps AddPageButton(10, 90, GetButtonID(0, 4), "FIREWALL", AdminGumpPage.Firewall, AdminGumpPage.FirewallInfo); if (notice != null) - AddHtml(12, 392, 396, 36, Color(notice, LabelColor32), false, false); + AddHtml(12, 392, 396, 36, Color(notice, LabelColor32)); switch (pageType) { @@ -251,7 +251,7 @@ namespace Server.Gumps } case AdminGumpPage.Administer_WorldBuilding: { - AddHtml(10, 125, 400, 20, Color(Center("Generating"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Generating"), LabelColor32)); AddButtonLabeled(20, 150, GetButtonID(3, 100), "Documentation"); AddButtonLabeled(220, 150, GetButtonID(3, 107), "Rebuild Categorization"); @@ -265,7 +265,7 @@ namespace Server.Gumps AddButtonLabeled(20, 225, GetButtonID(3, 104), "Doors"); AddButtonLabeled(220, 225, GetButtonID(3, 105), "Signs"); - AddHtml(20, 275, 400, 30, Color(Center("Statics"), LabelColor32), false, false); + AddHtml(20, 275, 400, 30, Color(Center("Statics"), LabelColor32)); AddButtonLabeled(20, 300, GetButtonID(3, 110), "Freeze (Target)"); AddButtonLabeled(20, 325, GetButtonID(3, 111), "Freeze (World)"); @@ -279,7 +279,7 @@ namespace Server.Gumps } case AdminGumpPage.Administer_Server: { - AddHtml(10, 125, 400, 20, Color(Center("Server"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Server"), LabelColor32)); AddButtonLabeled(20, 150, GetButtonID(3, 200), "Save"); @@ -296,7 +296,7 @@ namespace Server.Gumps AddLabel( 20, 215, LabelHue, "Shutdown/Restart not available." ); }*/ - AddHtml(10, 295, 400, 20, Color(Center("Broadcast"), LabelColor32), false, false); + AddHtml(10, 295, 400, 20, Color(Center("Broadcast"), LabelColor32)); AddTextField(20, 320, 380, 20, 0); AddButtonLabeled(20, 350, GetButtonID(3, 210), "To Everyone"); @@ -306,12 +306,12 @@ namespace Server.Gumps } case AdminGumpPage.Administer_Access_Lockdown: { - AddHtml(10, 125, 400, 20, Color(Center("Server Lockdown"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Server Lockdown"), LabelColor32)); AddHtml(20, 150, 380, 80, Color( "When enabled, only clients with an access level equal to or greater than the specified lockdown level may access the server. After setting a lockdown level, use the Purge Invalid Clients button to disconnect those clients without access.", - LabelColor32), false, false); + LabelColor32)); AccessLevel level = AccountHandler.LockdownLevel; bool isLockedDown = level > AccessLevel.Player; @@ -331,9 +331,9 @@ namespace Server.Gumps } case AdminGumpPage.Administer_Access: { - AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32)); - AddHtml(10, 155, 400, 20, Color(Center("Connectivity"), LabelColor32), false, false); + AddHtml(10, 155, 400, 20, Color(Center("Connectivity"), LabelColor32)); AddButtonLabeled(20, 180, GetButtonID(3, 300), "Kick"); AddButtonLabeled(220, 180, GetButtonID(3, 301), "Ban"); @@ -341,7 +341,7 @@ namespace Server.Gumps AddButtonLabeled(20, 210, GetButtonID(3, 302), "Firewall"); AddButtonLabeled(220, 210, GetButtonID(3, 303), "Lockdown"); - AddHtml(10, 245, 400, 20, Color(Center("Staff"), LabelColor32), false, false); + AddHtml(10, 245, 400, 20, Color(Center("Staff"), LabelColor32)); AddButtonLabeled(20, 270, GetButtonID(3, 310), "Make Player"); AddButtonLabeled(20, 290, GetButtonID(3, 311), "Make Counselor"); @@ -365,7 +365,7 @@ namespace Server.Gumps } case AdminGumpPage.Administer_Commands: { - AddHtml(10, 125, 400, 20, Color(Center("Commands"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Commands"), LabelColor32)); AddButtonLabeled(20, 150, GetButtonID(3, 400), "Add"); AddButtonLabeled(220, 150, GetButtonID(3, 401), "Remove"); @@ -427,12 +427,12 @@ namespace Server.Gumps AddLabelCropped(273, 120, 109, 20, LabelHue, "IP Address"); if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(375, 122, 0x25EA); if ((listPage + 1) * 12 < m_List.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(392, 122, 0x25E6); @@ -461,7 +461,7 @@ namespace Server.Gumps AddLabelCropped(273, offset, 109, 20, LabelHue, ns.ToString()); if (a != null || m != null) - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2), GumpButtonType.Reply, 0); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2)); } break; @@ -473,7 +473,7 @@ namespace Server.Gumps AddClientHeader(); - AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32)); int y = 146; @@ -485,7 +485,7 @@ namespace Server.Gumps AddLabel(20, y, LabelHue, "Account:"); AddLabel(200, y, a != null && a.Banned ? RedHue : LabelHue, a == null ? "(no account)" : a.Username); - AddButton(380, y, 0xFA5, 0xFA7, GetButtonID(7, 14), GumpButtonType.Reply, 0); + AddButton(380, y, 0xFA5, 0xFA7, GetButtonID(7, 14)); y += 20; NetState ns = m.NetState; @@ -565,12 +565,12 @@ namespace Server.Gumps AddLabelCropped(192, 120, 180, 20, LabelHue, "Accounts"); if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(375, 122, 0x25EA); if ((listPage + 1) * 12 < sharedAccounts.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(392, 122, 0x25E6); @@ -614,7 +614,7 @@ namespace Server.Gumps AddLabelCropped(192, offset, 180, 20, LabelHue, sb.ToString()); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56), GumpButtonType.Reply, 0); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); } break; @@ -637,12 +637,12 @@ namespace Server.Gumps AddLabelCropped(252, 120, 120, 20, LabelHue, "Status"); if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(375, 122, 0x25EA); if ((listPage + 1) * 12 < m_List.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(392, 122, 0x25E6); @@ -686,7 +686,7 @@ namespace Server.Gumps else AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56), GumpButtonType.Reply, 0); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); } break; @@ -707,7 +707,7 @@ namespace Server.Gumps if (!(state is Account a)) break; - AddHtml(10, 125, 400, 20, Color(Center("Change Password"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Change Password"), LabelColor32)); AddLabel(20, 150, LabelHue, "Username:"); AddLabel(200, 150, LabelHue, a.Username); @@ -727,7 +727,7 @@ namespace Server.Gumps if (!(state is Account a)) break; - AddHtml(10, 125, 400, 20, Color(Center("Change Access Level"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Change Access Level"), LabelColor32)); AddLabel(20, 150, LabelHue, "Username:"); AddLabel(200, 150, LabelHue, a.Username); @@ -766,7 +766,7 @@ namespace Server.Gumps if (a[i] != null) ++charCount; - AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32)); AddLabel(20, 150, LabelHue, "Username:"); AddLabel(200, 150, LabelHue, a.Username); @@ -841,7 +841,7 @@ namespace Server.Gumps if (!(state is Account a)) break; - AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32)); AddPageButton(20, 150, GetButtonID(5, 14), "View client addresses", AdminGumpPage.AccountDetails_Access_ClientIPs); @@ -865,41 +865,39 @@ namespace Server.Gumps else ipAddresses = Utility.CastListCovariant(m_List); - AddHtml(10, 195, 400, 20, Color(Center("Client Addresses"), LabelColor32), false, false); + AddHtml(10, 195, 400, 20, Color(Center("Client Addresses"), LabelColor32)); AddButtonLabeled(227, 225, GetButtonID(5, 16), "View all shared accounts"); AddButtonLabeled(227, 245, GetButtonID(5, 17), "Ban all shared accounts"); AddButtonLabeled(227, 265, GetButtonID(5, 18), "Firewall all addresses"); AddButtonLabeled(227, 285, GetButtonID(5, 36), "Clear all addresses"); - AddHtml(225, 315, 180, 80, Color("List of IP addresses which have accessed this account.", LabelColor32), - false, false); + AddHtml(225, 315, 180, 80, Color("List of IP addresses which have accessed this account.", LabelColor32)); AddImageTiled(15, 219, 206, 156, 0xBBC); AddBlackAlpha(16, 220, 204, 154); - AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32), false, false); + AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32)); if (listPage > 0) - AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(184, 223, 0x25EA); if ((listPage + 1) * 6 < ipAddresses.Count) - AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(201, 223, 0x25E6); if (ipAddresses.Count == 0) - AddHtml(18, 243, 200, 60, Color("This account has not yet been accessed.", LabelColor32), false, - false); + AddHtml(18, 243, 200, 60, Color("This account has not yet been accessed.", LabelColor32)); for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipAddresses.Count; ++i, ++index) { - AddHtml(18, 243 + i * 22, 114, 20, Color(ipAddresses[index].ToString(), LabelColor32), false, false); - AddButton(130, 242 + i * 22, 0xFA2, 0xFA4, GetButtonID(8, index), GumpButtonType.Reply, 0); - AddButton(160, 242 + i * 22, 0xFA8, 0xFAA, GetButtonID(9, index), GumpButtonType.Reply, 0); - AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(10, index), GumpButtonType.Reply, 0); + AddHtml(18, 243 + i * 22, 114, 20, Color(ipAddresses[index].ToString(), LabelColor32)); + AddButton(130, 242 + i * 22, 0xFA2, 0xFA4, GetButtonID(8, index)); + AddButton(160, 242 + i * 22, 0xFA8, 0xFAA, GetButtonID(9, index)); + AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(10, index)); } goto case AdminGumpPage.AccountDetails_Access; @@ -919,7 +917,7 @@ namespace Server.Gumps else ipRestrictions = Utility.CastListCovariant(m_List); - AddHtml(10, 195, 400, 20, Color(Center("Address Restrictions"), LabelColor32), false, false); + AddHtml(10, 195, 400, 20, Color(Center("Address Restrictions"), LabelColor32)); AddTextField(227, 225, 120, 20, 0); @@ -928,30 +926,30 @@ namespace Server.Gumps AddHtml(225, 255, 180, 120, Color( "Any clients connecting from an address not in this list will be rejected. Or, if the list is empty, any client may connect.", - LabelColor32), false, false); + LabelColor32)); AddImageTiled(15, 219, 206, 156, 0xBBC); AddBlackAlpha(16, 220, 204, 154); - AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32), false, false); + AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32)); if (listPage > 0) - AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(184, 223, 0x25EA); if ((listPage + 1) * 6 < ipRestrictions.Count) - AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(201, 223, 0x25E6); if (ipRestrictions.Count == 0) - AddHtml(18, 243, 200, 60, Color("There are no addresses in this list.", LabelColor32), false, false); + AddHtml(18, 243, 200, 60, Color("There are no addresses in this list.", LabelColor32)); for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipRestrictions.Count; ++i, ++index) { - AddHtml(18, 243 + i * 22, 114, 20, Color(ipRestrictions[index].ToString(), LabelColor32), false, false); - AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(8, index), GumpButtonType.Reply, 0); + AddHtml(18, 243 + i * 22, 114, 20, Color(ipRestrictions[index], LabelColor32)); + AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(8, index)); } goto case AdminGumpPage.AccountDetails_Access; @@ -961,7 +959,7 @@ namespace Server.Gumps if (!(state is Account a)) break; - AddHtml(10, 125, 400, 20, Color(Center("Characters"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Characters"), LabelColor32)); AddLabelCropped(12, 150, 120, 20, LabelHue, "Name"); AddLabelCropped(132, 150, 120, 20, LabelHue, "Access Level"); @@ -986,7 +984,7 @@ namespace Server.Gumps else AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, i + 50), GumpButtonType.Reply, 0); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, i + 50)); ++index; } @@ -1001,7 +999,7 @@ namespace Server.Gumps if (!(state is Account a)) break; - AddHtml(10, 125, 400, 20, Color(Center("Comments"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Comments"), LabelColor32)); AddButtonLabeled(20, 150, GetButtonID(5, 4), "Add Comment"); @@ -1029,7 +1027,7 @@ namespace Server.Gumps if (!(state is Account a)) break; - AddHtml(10, 125, 400, 20, Color(Center("Tags"), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center("Tags"), LabelColor32)); AddButtonLabeled(20, 150, GetButtonID(5, 5), "Add Tag"); @@ -1069,12 +1067,12 @@ namespace Server.Gumps AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address"); if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(375, 122, 0x25EA); if ((listPage + 1) * 12 < firewallEntries.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(392, 122, 0x25E6); @@ -1088,7 +1086,7 @@ namespace Server.Gumps int offset = 140 + i * 20; AddLabelCropped(12, offset, 358, 20, LabelHue, firewallEntry.ToString()); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(6, index + 4), GumpButtonType.Reply, 0); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(6, index + 4)); } break; @@ -1100,11 +1098,11 @@ namespace Server.Gumps if (!(state is Firewall.IFirewallEntry firewallEntry)) break; - AddHtml(10, 125, 400, 20, Color(Center(firewallEntry.ToString()), LabelColor32), false, false); + AddHtml(10, 125, 400, 20, Color(Center(firewallEntry.ToString()), LabelColor32)); AddButtonLabeled(20, 150, GetButtonID(6, 3), "Remove"); - AddHtml(10, 175, 400, 20, Color(Center("Potentially Affected Accounts"), LabelColor32), false, false); + AddHtml(10, 175, 400, 20, Color(Center("Potentially Affected Accounts"), LabelColor32)); List blockedAccts; @@ -1135,12 +1133,12 @@ namespace Server.Gumps blockedAccts = Utility.CastListCovariant(m_List); if (listPage > 0) - AddButton(375, 177, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); + AddButton(375, 177, 0x15E3, 0x15E7, GetButtonID(1, 0)); else AddImage(375, 177, 0x25EA); if ((listPage + 1) * 12 < blockedAccts.Count) - AddButton(392, 177, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); + AddButton(392, 177, 0x15E1, 0x15E5, GetButtonID(1, 1)); else AddImage(392, 177, 0x25E6); @@ -1165,7 +1163,7 @@ namespace Server.Gumps else AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56), GumpButtonType.Reply, 0); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); } break; @@ -1186,14 +1184,14 @@ namespace Server.Gumps public void AddSelectedButton(int x, int y, int buttonID, string text, bool isSelection) { - AddButton(x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0); - AddHtml(x + 35, y, 200, 20, Color(text, isSelection ? SelectedColor32 : LabelColor32), false, false); + AddButton(x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID); + AddHtml(x + 35, y, 200, 20, Color(text, isSelection ? SelectedColor32 : LabelColor32)); } public void AddButtonLabeled(int x, int y, int buttonID, string text) { - AddButton(x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0); - AddHtml(x + 35, y, 240, 20, Color(text, LabelColor32), false, false); + AddButton(x, y - 1, 4005, 4007, buttonID); + AddHtml(x + 35, y, 240, 20, Color(text, LabelColor32)); } public string Center(string text) @@ -1342,7 +1340,7 @@ namespace Server.Gumps for (int i = 0; i < theirAddresses.Length; ++i) { if (!table.ContainsKey(theirAddresses[i])) - table[theirAddresses[i]] = new List{ acct }; + table[theirAddresses[i]] = new List{ acct }; } } @@ -1352,7 +1350,7 @@ namespace Server.Gumps { KeyValuePair> kvp = tableEntries[i]; List list = kvp.Value; - + if (kvp.Value.Count == 1) list.RemoveAt(i--); else @@ -1372,7 +1370,7 @@ namespace Server.Gumps foreach (IAccount account in Accounts.GetAccounts()) { Account acct = (Account)account; - + IPAddress[] theirAddresses = acct.LoginIPs; bool contains = false; @@ -2004,7 +2002,7 @@ namespace Server.Gumps { Mobile m = a[j]; - if (m != null && m.AccessLevel >= level) + if (m?.AccessLevel >= level) hasAccess = true; } @@ -2085,8 +2083,8 @@ namespace Server.Gumps Mobile m = ns.Mobile; IAccount a = ns.Account; - isMatch = m != null && m.Name.ToLower().IndexOf(match) >= 0 - || a != null && a.Username.ToLower().IndexOf(match) >= 0; + isMatch = m?.Name.ToLower().IndexOf(match) >= 0 + || a?.Username.ToLower().IndexOf(match) >= 0; } else { @@ -2103,10 +2101,7 @@ namespace Server.Gumps if (results.Count == 1) { NetState ns = results[0]; - object state = ns.Mobile; - - if (state == null) - state = ns.Account; + object state = ns.Mobile ?? (object)ns.Account; if (state is Mobile) from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, "One match found.", @@ -2327,7 +2322,7 @@ namespace Server.Gumps List list = GetSharedAccounts(a.LoginIPs); if (list.Count > 1 || list.Count == 1 && !list.Contains(a)) - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, Utility.CastListContravariant(list), null, new List())); else if (a.LoginIPs.Length > 0) from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, @@ -3183,9 +3178,9 @@ namespace Server.Gumps return 1; if (aLevel > bLevel) return -1; - + return aLevel < bLevel ? 1 : Insensitive.Compare(x.Username, y.Username); } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/BanDurationGump.cs b/Scripts/Gumps/BanDurationGump.cs index 55852e64d..a59b762ba 100644 --- a/Scripts/Gumps/BanDurationGump.cs +++ b/Scripts/Gumps/BanDurationGump.cs @@ -26,7 +26,7 @@ namespace Server.Gumps //AddImageTiled( 10, 10, width - 20, 20, 2624 ); //AddAlphaRegion( 10, 10, width - 20, 20 ); - AddHtml(10, 10, width - 20, 20, "
Ban Duration
", false, false); + AddHtml(10, 10, width - 20, 20, "
Ban Duration
"); //AddImageTiled( 10, 40, width - 20, height - 50, 2624 ); //AddAlphaRegion( 10, 40, width - 20, height - 50 ); @@ -39,14 +39,14 @@ namespace Server.Gumps AddInput(5, 2, "Minutes"); AddInput(6, 3, "Seconds"); - AddHtml(170, 45, 240, 20, "Comments:", false, false); + AddHtml(170, 45, 240, 20, "Comments:"); AddTextField(170, 65, 315, height - 80, 10); } public void AddButtonLabeled(int x, int y, int buttonID, string text) { - AddButton(x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0); - AddHtml(x + 35, y, 240, 20, text, false, false); + AddButton(x, y - 1, 4005, 4007, buttonID); + AddHtml(x + 35, y, 240, 20, text); } public void AddTextField(int x, int y, int width, int height, int index) @@ -240,4 +240,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/BaseConfirmGump.cs b/Scripts/Gumps/BaseConfirmGump.cs index 08278b122..eeb878c96 100644 --- a/Scripts/Gumps/BaseConfirmGump.cs +++ b/Scripts/Gumps/BaseConfirmGump.cs @@ -31,17 +31,17 @@ namespace Server.Gumps AddImage(315, 248, 0x2716); AddImage(2, 248, 0x2716); AddImage(2, 2, 0x2716); - AddHtmlLocalized(25, 25, 200, 20, TitleNumber, 0x7D00, false, false); + AddHtmlLocalized(25, 25, 200, 20, TitleNumber, 0x7D00); AddImage(25, 40, 0xBBF); - AddHtmlLocalized(25, 55, 300, 120, LabelNumber, 0xFFFFFF, false, false); + AddHtmlLocalized(25, 55, 300, 120, LabelNumber, 0xFFFFFF); AddRadio(25, 175, 0x25F8, 0x25FB, true, (int)Buttons.Break); AddRadio(25, 210, 0x25F8, 0x25FB, false, (int)Buttons.Close); - AddHtmlLocalized(60, 180, 280, 20, 1074976, 0xFFFFFF, false, false); - AddHtmlLocalized(60, 215, 280, 20, 1074977, 0xFFFFFF, false, false); + AddHtmlLocalized(60, 180, 280, 20, 1074976, 0xFFFFFF); + AddHtmlLocalized(60, 215, 280, 20, 1074977, 0xFFFFFF); - AddButton(265, 220, 0xF7, 0xF8, (int)Buttons.Confirm, GumpButtonType.Reply, 0); + AddButton(265, 220, 0xF7, 0xF8, (int)Buttons.Confirm); } public virtual int TitleNumber //
Warning!
@@ -76,4 +76,4 @@ namespace Server.Gumps Confirm } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/BaseGridGump.cs b/Scripts/Gumps/BaseGridGump.cs index 0c96b98b2..40fd596c3 100644 --- a/Scripts/Gumps/BaseGridGump.cs +++ b/Scripts/Gumps/BaseGridGump.cs @@ -126,7 +126,7 @@ namespace Server.Gumps public void AddEntryHtml(int width, string text) { AddImageTiled(CurrentX, CurrentY, width, EntryHeight, EntryGumpID); - AddHtml(CurrentX + TextOffsetX, CurrentY, width - TextOffsetX, EntryHeight, text, false, false); + AddHtml(CurrentX + TextOffsetX, CurrentY, width - TextOffsetX, EntryHeight, text); IncreaseX(width); } @@ -163,7 +163,7 @@ namespace Server.Gumps HeaderGumpID); AddButton(CurrentX + (width - buttonWidth) / 2, CurrentY + (EntryHeight * spannedEntries + OffsetSize * (spannedEntries - 1) - buttonHeight) / 2, normalID, - pressedID, buttonID, GumpButtonType.Reply, 0); + pressedID, buttonID); IncreaseX(width); } @@ -185,4 +185,4 @@ namespace Server.Gumps IncreaseX(width); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/BaseImageTileButtonsGump.cs b/Scripts/Gumps/BaseImageTileButtonsGump.cs index 207934f07..a72944a45 100644 --- a/Scripts/Gumps/BaseImageTileButtonsGump.cs +++ b/Scripts/Gumps/BaseImageTileButtonsGump.cs @@ -11,7 +11,7 @@ namespace Server.Gumps private TextDefinition m_Label; private int m_LocalizedTooltip; - public ImageTileButtonInfo(int itemID, int hue, TextDefinition label, int localizedTooltip) + public ImageTileButtonInfo(int itemID, int hue, TextDefinition label, int localizedTooltip = -1) { m_Hue = hue; m_ItemID = itemID; @@ -19,10 +19,6 @@ namespace Server.Gumps m_LocalizedTooltip = localizedTooltip; } - public ImageTileButtonInfo(int itemID, int hue, TextDefinition label) : this(itemID, hue, label, -1) - { - } - public virtual int ItemID { get => m_ItemID; @@ -69,8 +65,8 @@ namespace Server.Gumps AddImageTiled(10, y + 54, x, 20, 0xA40); AddAlphaRegion(10, 10, x, y + 64); - AddButton(10, y + 54, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); //Cancel Button - AddHtmlLocalized(45, y + 56, x - 50, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, y + 54, 0xFB1, 0xFB2, 0); //Cancel Button + AddHtmlLocalized(45, y + 56, x - 50, 20, 1060051, 0x7FFF); // CANCEL TextDefinition.AddHtmlText(this, 14, 12, x, 20, header, false, false, 0x7FFF, 0xFFFFFF); AddPage(1); @@ -89,12 +85,12 @@ namespace Server.Gumps if (position == 0 && i != 0) { AddButton(x - 100, y + 54, 0xFA5, 0xFA7, 0, GumpButtonType.Page, pageNum); - AddHtmlLocalized(x - 60, y + 56, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(x - 60, y + 56, 60, 20, 1043353, 0x7FFF); // Next AddPage(pageNum); AddButton(x - 200, y + 54, 0xFAE, 0xFB0, 0, GumpButtonType.Page, pageNum - 1); - AddHtmlLocalized(x - 160, y + 56, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(x - 160, y + 56, 60, 20, 1011393, 0x7FFF); // Back } ImageTileButtonInfo b = buttons[i]; @@ -128,4 +124,4 @@ namespace Server.Gumps { } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/CategorizedAddGump.cs b/Scripts/Gumps/CategorizedAddGump.cs index 8fb342971..8a5b5ce50 100644 --- a/Scripts/Gumps/CategorizedAddGump.cs +++ b/Scripts/Gumps/CategorizedAddGump.cs @@ -111,20 +111,11 @@ namespace Server.Gumps public override string Caption => Title; - public static CAGCategory Root - { - get - { - if (m_Root == null) - m_Root = Load("Data/objects.xml"); - - return m_Root; - } - } + public static CAGCategory Root => m_Root ?? (m_Root = Load("Data/objects.xml")); public override void OnClick(Mobile from, int page) { - from.SendGump(new CategorizedAddGump(from, this, 0)); + from.SendGump(new CategorizedAddGump(from, this)); } public static CAGCategory Load(string path) @@ -215,11 +206,11 @@ namespace Server.Gumps private Mobile m_Owner; private int m_Page; - public CategorizedAddGump(Mobile owner) : this(owner, CAGCategory.Root, 0) + public CategorizedAddGump(Mobile owner) : this(owner, CAGCategory.Root) { } - public CategorizedAddGump(Mobile owner, CAGCategory category, int page) : base(GumpOffsetX, GumpOffsetY) + public CategorizedAddGump(Mobile owner, CAGCategory category, int page = 0) : base(GumpOffsetX, GumpOffsetY) { owner.CloseGump(); @@ -260,7 +251,7 @@ namespace Server.Gumps if (m_Category.Parent != null) { - AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); if (PrevLabel) AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); @@ -276,7 +267,7 @@ namespace Server.Gumps EntryGumpID); AddHtml(x + TextOffsetX, y + (EntryHeight - 20) / 2, emptyWidth - TextOffsetX, EntryHeight, - $"
{m_Category.Caption}
", false, false); + $"
{m_Category.Caption}
"); x += emptyWidth + OffsetSize; @@ -287,7 +278,7 @@ namespace Server.Gumps if (page > 0) { - AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2, GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2); if (PrevLabel) AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); @@ -322,7 +313,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4); if (node is CAGObject obj) { @@ -393,4 +384,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ClientGump.cs b/Scripts/Gumps/ClientGump.cs index 6b58e0bda..956f4b70c 100644 --- a/Scripts/Gumps/ClientGump.cs +++ b/Scripts/Gumps/ClientGump.cs @@ -12,11 +12,7 @@ namespace Server.Gumps private const int LabelColor32 = 0xFFFFFF; private NetState m_State; - public ClientGump(Mobile from, NetState state) : this(from, state, "") - { - } - - public ClientGump(Mobile from, NetState state, string initialText) : base(30, 20) + public ClientGump(Mobile from, NetState state, string initialText = "") : base(30, 20) { if (state == null) return; @@ -33,44 +29,43 @@ namespace Server.Gumps AddImageTiled(10, 32, 380, 232, 0xA40); AddAlphaRegion(10, 32, 380, 232); - AddHtml(10, 10, 380, 20, Color(Center("User Information"), LabelColor32), false, false); + AddHtml(10, 10, 380, 20, Color(Center("User Information"), LabelColor32)); int line = 0; - AddHtml(14, 36 + line * 20, 200, 20, Color("Address:", LabelColor32), false, false); - AddHtml(70, 36 + line++ * 20, 200, 20, Color(state.ToString(), LabelColor32), false, false); + AddHtml(14, 36 + line * 20, 200, 20, Color("Address:", LabelColor32)); + AddHtml(70, 36 + line++ * 20, 200, 20, Color(state.ToString(), LabelColor32)); - AddHtml(14, 36 + line * 20, 200, 20, Color("Client:", LabelColor32), false, false); + AddHtml(14, 36 + line * 20, 200, 20, Color("Client:", LabelColor32)); AddHtml(70, 36 + line++ * 20, 200, 20, - Color(state.Version == null ? "(null)" : state.Version.ToString(), LabelColor32), false, false); + Color(state.Version == null ? "(null)" : state.Version.ToString(), LabelColor32)); - AddHtml(14, 36 + line * 20, 200, 20, Color("Version:", LabelColor32), false, false); + AddHtml(14, 36 + line * 20, 200, 20, Color("Version:", LabelColor32)); ExpansionInfo info = state.ExpansionInfo; string expansionName = info.Name; - AddHtml(70, 36 + line++ * 20, 200, 20, Color(expansionName, LabelColor32), false, false); + AddHtml(70, 36 + line++ * 20, 200, 20, Color(expansionName, LabelColor32)); Account a = state.Account as Account; Mobile m = state.Mobile; if (from.AccessLevel >= AccessLevel.GameMaster && a != null) { - AddHtml(14, 36 + line * 20, 200, 20, Color("Account:", LabelColor32), false, false); - AddHtml(70, 36 + line++ * 20, 200, 20, Color(a.Username, LabelColor32), false, false); + AddHtml(14, 36 + line * 20, 200, 20, Color("Account:", LabelColor32)); + AddHtml(70, 36 + line++ * 20, 200, 20, Color(a.Username, LabelColor32)); } if (m != null) { - AddHtml(14, 36 + line * 20, 200, 20, Color("Mobile:", LabelColor32), false, false); - AddHtml(70, 36 + line++ * 20, 200, 20, Color($"{m.Name} (0x{m.Serial.Value:X})", LabelColor32), false, - false); + AddHtml(14, 36 + line * 20, 200, 20, Color("Mobile:", LabelColor32)); + AddHtml(70, 36 + line++ * 20, 200, 20, Color($"{m.Name} (0x{m.Serial.Value:X})", LabelColor32)); - AddHtml(14, 36 + line * 20, 200, 20, Color("Location:", LabelColor32), false, false); - AddHtml(70, 36 + line++ * 20, 200, 20, Color($"{m.Location} [{m.Map}]", LabelColor32), false, false); + AddHtml(14, 36 + line * 20, 200, 20, Color("Location:", LabelColor32)); + AddHtml(70, 36 + line++ * 20, 200, 20, Color($"{m.Location} [{m.Map}]", LabelColor32)); - AddButton(13, 157, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0); - AddHtml(48, 158, 200, 20, Color("Send Message", LabelColor32), false, false); + AddButton(13, 157, 0xFAB, 0xFAD, 1); + AddHtml(48, 158, 200, 20, Color("Send Message", LabelColor32)); AddImageTiled(12, 182, 376, 80, 0xA40); AddImageTiled(13, 183, 374, 78, 0xBBC); @@ -85,43 +80,43 @@ namespace Server.Gumps if (BaseCommand.IsAccessible(from, m)) { - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Properties", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 4); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Properties", LabelColor32)); } if (from != m) { - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Go to them", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 5); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Go to them", LabelColor32)); - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Bring them here", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 6); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Bring them here", LabelColor32)); } - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 7, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Move to target", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 7); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Move to target", LabelColor32)); if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel) { - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 8, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Disconnect", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 8); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Disconnect", LabelColor32)); if (m.Alive) { - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 9, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Kill", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 9); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Kill", LabelColor32)); } else { - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Resurrect", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 10); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Resurrect", LabelColor32)); } } if (from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel) { - AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 11, GumpButtonType.Reply, 0); - AddHtml(280, 38 + line++ * 20, 100, 20, Color("Skills browser", LabelColor32), false, false); + AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 11); + AddHtml(280, 38 + line++ * 20, 100, 20, Color("Skills browser", LabelColor32)); } } } @@ -307,4 +302,4 @@ namespace Server.Gumps return $"{text}"; } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/CommentsGump.cs b/Scripts/Gumps/CommentsGump.cs index 588ac6d58..897a5d370 100644 --- a/Scripts/Gumps/CommentsGump.cs +++ b/Scripts/Gumps/CommentsGump.cs @@ -26,7 +26,7 @@ namespace Server.Gumps AddLabel(x, 12, 2100, title); AddPage(1); - AddButton(12, 12, 0xFA8, 0xFAA, 0x7F, GumpButtonType.Reply, 0); + AddButton(12, 12, 0xFA8, 0xFAA, 0x7F); AddLabel(48, 12, 2100, "Add Comment"); List list = acct.Comments; @@ -115,4 +115,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ConfirmBreakCrystalGump.cs b/Scripts/Gumps/ConfirmBreakCrystalGump.cs index c7522b881..4a22984ba 100644 --- a/Scripts/Gumps/ConfirmBreakCrystalGump.cs +++ b/Scripts/Gumps/ConfirmBreakCrystalGump.cs @@ -17,37 +17,37 @@ namespace Server.Gumps public override void Confirm(Mobile from) { - if (m_Item == null || m_Item.Deleted) + if (m_Item?.Deleted != false) return; BaseCreature summon = m_Item.Summon; - if (summon != null) + if (summon == null) + return; + + if (!summon.SetControlMaster(from)) { - if (!summon.SetControlMaster(from)) - { - summon.Delete(); - } - else - { - from.SendLocalizedMessage(1049666); // Your pet has bonded with you! + summon.Delete(); + } + else + { + from.SendLocalizedMessage(1049666); // Your pet has bonded with you! - summon.MoveToWorld(from.Location, from.Map); - summon.IsBonded = true; + summon.MoveToWorld(from.Location, from.Map); + summon.IsBonded = true; - summon.Skills.Wrestling.Base = 100; - summon.Skills.Tactics.Base = 100; - summon.Skills.MagicResist.Base = 100; - summon.Skills.Anatomy.Base = 100; + summon.Skills.Wrestling.Base = 100; + summon.Skills.Tactics.Base = 100; + summon.Skills.MagicResist.Base = 100; + summon.Skills.Anatomy.Base = 100; - Effects.PlaySound(summon.Location, summon.Map, summon.BaseSoundID); - Effects.SendLocationParticles(EffectItem.Create(summon.Location, summon.Map, EffectItem.DefaultDuration), - 0x3728, 1, 10, 0x26B6); + Effects.PlaySound(summon.Location, summon.Map, summon.BaseSoundID); + Effects.SendLocationParticles(EffectItem.Create(summon.Location, summon.Map, EffectItem.DefaultDuration), + 0x3728, 1, 10, 0x26B6); - m_Item.Release(from, summon); - m_Item.Delete(); - } + m_Item.Release(from, summon); + m_Item.Delete(); } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ConfirmHeritageGump.cs b/Scripts/Gumps/ConfirmHeritageGump.cs index c801aa941..0de56fec5 100644 --- a/Scripts/Gumps/ConfirmHeritageGump.cs +++ b/Scripts/Gumps/ConfirmHeritageGump.cs @@ -18,19 +18,18 @@ namespace Server.Gumps AddBackground(0, 0, 291, 99, 0x13BE); AddImageTiled(5, 6, 280, 20, 0xA40); - AddHtmlLocalized(9, 8, 280, 20, 1070972, 0x7FFF, false, - false); // Click "OKAY" to redeem the following promotional item: + AddHtmlLocalized(9, 8, 280, 20, 1070972, 0x7FFF); // Click "OKAY" to redeem the following promotional item: AddImageTiled(5, 31, 280, 40, 0xA40); - AddHtmlLocalized(9, 35, 272, 40, cliloc, 0x7FFF, false, false); - AddButton(180, 73, 0xFB7, 0xFB8, (int)Buttons.Okay, GumpButtonType.Reply, 0); - AddHtmlLocalized(215, 75, 100, 20, 1011036, 0x7FFF, false, false); // OKAY - AddButton(5, 73, 0xFB1, 0xFB2, (int)Buttons.Cancel, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 75, 100, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddHtmlLocalized(9, 35, 272, 40, cliloc, 0x7FFF); + AddButton(180, 73, 0xFB7, 0xFB8, (int)Buttons.Okay); + AddHtmlLocalized(215, 75, 100, 20, 1011036, 0x7FFF); // OKAY + AddButton(5, 73, 0xFB1, 0xFB2, (int)Buttons.Cancel); + AddHtmlLocalized(40, 75, 100, 20, 1060051, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Token == null || m_Token.Deleted) + if (m_Token?.Deleted != false) return; switch (info.ButtonID) @@ -71,4 +70,4 @@ namespace Server.Gumps Okay } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ConfirmHouseResize.cs b/Scripts/Gumps/ConfirmHouseResize.cs index 6667026c9..c572e08e6 100644 --- a/Scripts/Gumps/ConfirmHouseResize.cs +++ b/Scripts/Gumps/ConfirmHouseResize.cs @@ -24,7 +24,7 @@ namespace Server.Gumps AddBackground(0, 0, 420, 280, 0x13BE); AddImageTiled(10, 10, 400, 20, 0xA40); AddAlphaRegion(10, 10, 400, 20); - AddHtmlLocalized(10, 10, 400, 20, 1060635, 0x7800, false, false); //
WARNING
+ AddHtmlLocalized(10, 10, 400, 20, 1060635, 0x7800); //
WARNING
AddImageTiled(10, 40, 400, 200, 0xA40); AddAlphaRegion(10, 40, 400, 200); @@ -40,10 +40,10 @@ namespace Server.Gumps AddImageTiled(10, 250, 400, 20, 0xA40); AddAlphaRegion(10, 250, 400, 20); - AddButton(10, 250, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddButton(210, 250, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 250, 170, 20, 1011036, 0x7FFF, false, false); // OKAY - AddHtmlLocalized(240, 250, 170, 20, 1011012, 0x7FFF, false, false); // CANCEL + AddButton(10, 250, 0xFA5, 0xFA7, 1); + AddButton(210, 250, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(40, 250, 170, 20, 1011036, 0x7FFF); // OKAY + AddHtmlLocalized(240, 250, 170, 20, 1011012, 0x7FFF); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -155,4 +155,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ConfirmReleaseGump.cs b/Scripts/Gumps/ConfirmReleaseGump.cs index 7369a5013..a045fef0e 100644 --- a/Scripts/Gumps/ConfirmReleaseGump.cs +++ b/Scripts/Gumps/ConfirmReleaseGump.cs @@ -22,23 +22,20 @@ namespace Server.Gumps AddHtmlLocalized(20, 15, 230, 60, 1046257, true, true); // Are you sure you want to release your pet? - AddButton(20, 80, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 80, 75, 20, 1011011, false, false); // CONTINUE + AddButton(20, 80, 4005, 4007, 2); + AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE - AddButton(135, 80, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(170, 80, 75, 20, 1011012, false, false); // CANCEL + AddButton(135, 80, 4005, 4007, 1); + AddHtmlLocalized(170, 80, 75, 20, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) { - if (info.ButtonID == 2) - if (!m_Pet.Deleted && m_Pet.Controlled && m_From == m_Pet.ControlMaster && - m_From.CheckAlive() /*&& m_Pet.CheckControlChance( m_From )*/) - if (m_Pet.Map == m_From.Map && m_Pet.InRange(m_From, 14)) - { - m_Pet.ControlTarget = null; - m_Pet.ControlOrder = OrderType.Release; - } + 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; } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/DawnsMusicBoxGump.cs b/Scripts/Gumps/DawnsMusicBoxGump.cs index dedc9c20d..498642551 100644 --- a/Scripts/Gumps/DawnsMusicBoxGump.cs +++ b/Scripts/Gumps/DawnsMusicBoxGump.cs @@ -19,9 +19,9 @@ namespace Server.Gumps AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1075130, 0x7FFF, false, false); // Choose a track to play + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1075130, 0x7FFF); // Choose a track to play int page = 1; int i, y = 49; @@ -47,8 +47,8 @@ namespace Server.Gumps if (info == null) continue; - AddButton(19, y, 0x845, 0x846, 100 + i, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, y - 2, 213, 20, info.Name, 0x7FFF, false, false); + AddButton(19, y, 0x845, 0x846, 100 + i); + AddHtmlLocalized(44, y - 2, 213, 20, info.Name, 0x7FFF); } if (i % 10 == 0) @@ -61,13 +61,13 @@ namespace Server.Gumps AddButton(193, 294, 0xFAE, 0xFAF, 0, GumpButtonType.Page, page); } - AddButton(19, y, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, y - 2, 213, 20, 1075207, 0x7FFF, false, false); // Stop Song + AddButton(19, y, 0x845, 0x846, 1); + AddHtmlLocalized(44, y - 2, 213, 20, 1075207, 0x7FFF); // Stop Song } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Box == null || m_Box.Deleted) + if (m_Box?.Deleted != false) return; Mobile m = sender.Mobile; @@ -83,4 +83,4 @@ namespace Server.Gumps m_Box.PlayMusic(m, m_Box.Tracks[info.ButtonID - 100]); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Go/GoGump.cs b/Scripts/Gumps/Go/GoGump.cs index dfebaf843..ec26774c9 100644 --- a/Scripts/Gumps/Go/GoGump.cs +++ b/Scripts/Gumps/Go/GoGump.cs @@ -100,7 +100,7 @@ namespace Server.Gumps if (node.Parent != null) { - AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); if (PrevLabel) AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); @@ -115,8 +115,7 @@ namespace Server.Gumps AddImageTiled(x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID); - AddHtml(x + TextOffsetX, y, emptyWidth - TextOffsetX, EntryHeight, $"
{node.Name}
", false, - false); + AddHtml(x + TextOffsetX, y, emptyWidth - TextOffsetX, EntryHeight, $"
{node.Name}
"); x += emptyWidth + OffsetSize; @@ -127,7 +126,7 @@ namespace Server.Gumps if (page > 0) { - AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2, GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2); if (PrevLabel) AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); @@ -162,7 +161,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, index + 4, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, index + 4); } } diff --git a/Scripts/Gumps/Guilds/DeclareFealtyGump.cs b/Scripts/Gumps/Guilds/DeclareFealtyGump.cs index b18b07efb..b6ade1cfa 100644 --- a/Scripts/Gumps/Guilds/DeclareFealtyGump.cs +++ b/Scripts/Gumps/Guilds/DeclareFealtyGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011097, false, false); // Declare your fealty + AddHtmlLocalized(20, 10, 400, 35, 1011097); // Declare your fealty - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 250, 35, 1011098, false, false); // I have selected my new lord. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 250, 35, 1011098); // I have selected my new lord. - AddButton(300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 0); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -37,7 +37,8 @@ namespace Server.Gumps { Mobile m = m_List[index]; - if (m != null && !m.Deleted) state.Mobile.GuildFealty = m; + if (m?.Deleted == false) + state.Mobile.GuildFealty = m; } } } @@ -46,4 +47,4 @@ namespace Server.Gumps m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GrantGuildTitleGump.cs b/Scripts/Gumps/Guilds/GrantGuildTitleGump.cs index 8e6c50732..1af757d3b 100644 --- a/Scripts/Gumps/Guilds/GrantGuildTitleGump.cs +++ b/Scripts/Gumps/Guilds/GrantGuildTitleGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011118, false, false); // Grant a title to another member. + AddHtmlLocalized(20, 10, 400, 35, 1011118); // Grant a title to another member. - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011127, false, false); // I dub thee... + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011127); // I dub thee... - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -37,7 +37,7 @@ namespace Server.Gumps { Mobile m = m_List[index]; - if (m != null && !m.Deleted) + if (m?.Deleted == false) { m_Mobile.SendLocalizedMessage(1013074); // New title (20 characters max): m_Mobile.Prompt = new GuildTitlePrompt(m_Mobile, m, m_Guild); @@ -52,4 +52,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildAcceptWarGump.cs b/Scripts/Gumps/Guilds/GuildAcceptWarGump.cs index aa3dfbadf..021acd651 100644 --- a/Scripts/Gumps/Guilds/GuildAcceptWarGump.cs +++ b/Scripts/Gumps/Guilds/GuildAcceptWarGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011147, false, false); // Select the guild to accept the invitations: + AddHtmlLocalized(20, 10, 400, 35, 1011147); // Select the guild to accept the invitations: - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011100, false, false); // Accept war invitations. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011100); // Accept war invitations. - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -62,4 +62,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs b/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs index ec1218527..018f390ef 100644 --- a/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs +++ b/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs @@ -12,13 +12,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1013075, false, false); // Accept or Refuse candidates for membership + AddHtmlLocalized(20, 10, 400, 35, 1013075); // Accept or Refuse candidates for membership - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1013076, false, false); // Accept + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1013076); // Accept - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1013077, false, false); // Refuse + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1013077); // Refuse } public override void OnResponse(NetState state, RelayInfo info) @@ -47,7 +47,7 @@ namespace Server.Gumps { Mobile m = m_List[index]; - if (m != null && !m.Deleted) + if (m?.Deleted == false) { #region Factions @@ -72,7 +72,7 @@ namespace Server.Gumps break; } - if (targetState != null && targetState.IsLeaving) + if (targetState?.IsLeaving == true) { // OSI does this quite strangely, so we'll just do it this way m_Mobile.SendMessage( @@ -109,7 +109,7 @@ namespace Server.Gumps { Mobile m = m_List[index]; - if (m != null && !m.Deleted) + if (m?.Deleted == false) { m_Guild.Candidates.Remove(m); @@ -128,4 +128,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildCandidatesGump.cs b/Scripts/Gumps/Guilds/GuildCandidatesGump.cs index 92103b735..60ce45109 100644 --- a/Scripts/Gumps/Guilds/GuildCandidatesGump.cs +++ b/Scripts/Gumps/Guilds/GuildCandidatesGump.cs @@ -11,10 +11,10 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 500, 35, 1013030, false, false); //
Candidates
+ AddHtmlLocalized(20, 10, 500, 35, 1013030); //
Candidates
- AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 300, 35, 1011120, false, false); // Return to the main menu. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 300, 35, 1011120); // Return to the main menu. } public override void OnResponse(NetState state, RelayInfo info) @@ -29,4 +29,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs b/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs index 79211a6dd..c4bb0d5e1 100644 --- a/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs +++ b/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs @@ -22,24 +22,23 @@ namespace Server.Gumps AddBackground(0, 0, 550, 400, 5054); AddBackground(10, 10, 530, 380, 3000); - AddHtmlLocalized(20, 15, 510, 30, 1013062, false, false); //
Change Guild Type Menu
+ AddHtmlLocalized(20, 15, 510, 30, 1013062); //
Change Guild Type Menu
- AddHtmlLocalized(50, 50, 450, 30, 1013066, false, - false); // Please select the type of guild you would like to change to + AddHtmlLocalized(50, 50, 450, 30, 1013066); // Please select the type of guild you would like to change to - AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(85, 100, 300, 30, 1013063, false, false); // Standard guild + AddButton(20, 100, 4005, 4007, 1); + AddHtmlLocalized(85, 100, 300, 30, 1013063); // Standard guild - AddButton(20, 150, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddButton(20, 150, 4005, 4007, 2); AddItem(50, 143, 7109); - AddHtmlLocalized(85, 150, 300, 300, 1013064, false, false); // Order guild + AddHtmlLocalized(85, 150, 300, 300, 1013064); // Order guild - AddButton(20, 200, 4005, 4007, 3, GumpButtonType.Reply, 0); + AddButton(20, 200, 4005, 4007, 3); AddItem(45, 200, 7107); - AddHtmlLocalized(85, 200, 300, 300, 1013065, false, false); // Chaos guild + AddHtmlLocalized(85, 200, 300, 300, 1013065); // Chaos guild - AddButton(300, 360, 4005, 4007, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 360, 150, 30, 1011012, false, false); // CANCEL + AddButton(300, 360, 4005, 4007, 4); + AddHtmlLocalized(335, 360, 150, 30, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -98,4 +97,4 @@ namespace Server.Gumps m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildCharterGump.cs b/Scripts/Gumps/Guilds/GuildCharterGump.cs index 6615bd15f..16662a04f 100644 --- a/Scripts/Gumps/Guilds/GuildCharterGump.cs +++ b/Scripts/Gumps/Guilds/GuildCharterGump.cs @@ -20,25 +20,25 @@ namespace Server.Gumps AddBackground(0, 0, 550, 400, 5054); AddBackground(10, 10, 530, 380, 3000); - AddButton(20, 360, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 360, 300, 35, 1011120, false, false); // Return to the main menu. + AddButton(20, 360, 4005, 4007, 1); + AddHtmlLocalized(55, 360, 300, 35, 1011120); // Return to the main menu. string charter; if ((charter = guild.Charter) == null || (charter = charter.Trim()).Length <= 0) - AddHtmlLocalized(20, 20, 400, 35, 1013032, false, false); // No charter has been defined. + 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, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 200, 300, 20, 1011122, false, false); // Visit the guild website : + AddButton(20, 200, 4005, 4007, 2); + AddHtmlLocalized(55, 200, 300, 20, 1011122); // Visit the guild website : string website; if ((website = guild.Website) == null || (website = website.Trim()).Length <= 0) website = DefaultWebsite; - AddHtml(55, 220, 300, 20, website, false, false); + AddHtml(55, 220, 300, 20, website); } public override void OnResponse(NetState state, RelayInfo info) @@ -66,4 +66,4 @@ namespace Server.Gumps m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildDeclarePeaceGump.cs b/Scripts/Gumps/Guilds/GuildDeclarePeaceGump.cs index ffc0b12ab..00370e69d 100644 --- a/Scripts/Gumps/Guilds/GuildDeclarePeaceGump.cs +++ b/Scripts/Gumps/Guilds/GuildDeclarePeaceGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011137, false, false); // Select the guild you wish to declare peace with. + AddHtmlLocalized(20, 10, 400, 35, 1011137); // Select the guild you wish to declare peace with. - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011138, false, false); // Send the olive branch. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011138); // Send the olive branch. - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -60,4 +60,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs b/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs index 079299d99..c60b6096c 100644 --- a/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs +++ b/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs @@ -14,13 +14,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011065, false, false); // Select the guild you wish to declare war on. + AddHtmlLocalized(20, 10, 400, 35, 1011065); // Select the guild you wish to declare war on. - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011068, false, false); // Send the challenge! + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011068); // Send the challenge! - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -86,4 +86,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildDismissGump.cs b/Scripts/Gumps/Guilds/GuildDismissGump.cs index 23e79990b..f86a03209 100644 --- a/Scripts/Gumps/Guilds/GuildDismissGump.cs +++ b/Scripts/Gumps/Guilds/GuildDismissGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011124, false, false); // Whom do you wish to dismiss? + AddHtmlLocalized(20, 10, 400, 35, 1011124); // Whom do you wish to dismiss? - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011125, false, false); // Kick them out! + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011125); // Kick them out! - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -37,7 +37,7 @@ namespace Server.Gumps { Mobile m = m_List[index]; - if (m != null && !m.Deleted) + if (m?.Deleted == false) { m_Guild.RemoveMember(m); @@ -57,4 +57,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildGump.cs b/Scripts/Gumps/Guilds/GuildGump.cs index 8adeb835f..a4a884096 100644 --- a/Scripts/Gumps/Guilds/GuildGump.cs +++ b/Scripts/Gumps/Guilds/GuildGump.cs @@ -19,7 +19,7 @@ namespace Server.Gumps AddBackground(0, 0, 550, 400, 5054); AddBackground(10, 10, 530, 380, 3000); - AddHtml(20, 15, 200, 35, guild.Name, false, false); + AddHtml(20, 15, 200, 35, guild.Name); Mobile leader = guild.Leader; @@ -37,11 +37,11 @@ namespace Server.Gumps if ((leadName = leader.Name) == null || (leadName = leadName.Trim()).Length <= 0) leadName = "(empty)"; - AddHtml(220, 15, 250, 35, leadTitle + leadName, false, false); + AddHtml(220, 15, 250, 35, leadTitle + leadName); } - AddButton(20, 50, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 50, 100, 20, 1013022, false, false); // Loyal to + AddButton(20, 50, 4005, 4007, 1); + AddHtmlLocalized(55, 50, 100, 20, 1013022); // Loyal to Mobile fealty = beholder.GuildFealty; @@ -57,55 +57,53 @@ namespace Server.Gumps fealtyName = "(empty)"; if (beholder == fealty) - AddHtmlLocalized(55, 70, 470, 20, 1018002, false, false); // yourself + AddHtmlLocalized(55, 70, 470, 20, 1018002); // yourself else - AddHtml(55, 70, 470, 20, fealtyName, false, false); + AddHtml(55, 70, 470, 20, fealtyName); - AddButton(215, 50, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(250, 50, 170, 20, 1013023, false, false); // Display guild abbreviation - AddHtmlLocalized(250, 70, 50, 20, beholder.DisplayGuildTitle ? 1011262 : 1011263, false, false); // on/off + AddButton(215, 50, 4005, 4007, 2); + AddHtmlLocalized(250, 50, 170, 20, 1013023); // Display guild abbreviation + AddHtmlLocalized(250, 70, 50, 20, beholder.DisplayGuildTitle ? 1011262 : 1011263); // on/off - AddButton(20, 100, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 100, 470, 30, 1011086, false, false); // View the current roster. + AddButton(20, 100, 4005, 4007, 3); + AddHtmlLocalized(55, 100, 470, 30, 1011086); // View the current roster. - AddButton(20, 130, 4005, 4007, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 130, 470, 30, 1011085, false, false); // Recruit someone into the guild. + AddButton(20, 130, 4005, 4007, 4); + AddHtmlLocalized(55, 130, 470, 30, 1011085); // Recruit someone into the guild. if (guild.Candidates.Count > 0) { - AddButton(20, 160, 4005, 4007, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 160, 470, 30, 1011093, false, - false); // View list of candidates who have been sponsored to the guild. + AddButton(20, 160, 4005, 4007, 5); + AddHtmlLocalized(55, 160, 470, 30, 1011093); // View list of candidates who have been sponsored to the guild. } else { AddImage(20, 160, 4020); - AddHtmlLocalized(55, 160, 470, 30, 1013031, false, - false); // There are currently no candidates for membership. + AddHtmlLocalized(55, 160, 470, 30, 1013031); // There are currently no candidates for membership. } - AddButton(20, 220, 4005, 4007, 6, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 220, 470, 30, 1011087, false, false); // View the guild's charter. + AddButton(20, 220, 4005, 4007, 6); + AddHtmlLocalized(55, 220, 470, 30, 1011087); // View the guild's charter. - AddButton(20, 250, 4005, 4007, 7, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 250, 470, 30, 1011092, false, false); // Resign from the guild. + AddButton(20, 250, 4005, 4007, 7); + AddHtmlLocalized(55, 250, 470, 30, 1011092); // Resign from the guild. - AddButton(20, 280, 4005, 4007, 8, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 280, 470, 30, 1011095, false, false); // View list of guilds you are at war with. + AddButton(20, 280, 4005, 4007, 8); + AddHtmlLocalized(55, 280, 470, 30, 1011095); // View list of guilds you are at war with. if (beholder.AccessLevel >= AccessLevel.GameMaster || beholder == leader) { - AddButton(20, 310, 4005, 4007, 9, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 310, 470, 30, 1011094, false, false); // Access guildmaster functions. + AddButton(20, 310, 4005, 4007, 9); + AddHtmlLocalized(55, 310, 470, 30, 1011094); // Access guildmaster functions. } else { AddImage(20, 310, 4020); - AddHtmlLocalized(55, 310, 470, 30, 1018013, false, false); // Reserved for guildmaster + AddHtmlLocalized(55, 310, 470, 30, 1018013); // Reserved for guildmaster } - AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 360, 470, 30, 1011441, false, false); // EXIT + AddButton(20, 360, 4005, 4007, 0); + AddHtmlLocalized(55, 360, 470, 30, 1011441); // EXIT } public static void EnsureClosed(Mobile m) @@ -130,7 +128,7 @@ namespace Server.Gumps Item stone = g.Guildstone; - return stone == null || stone.Deleted || !m.InRange(stone.GetWorldLocation(), 2); + return stone?.Deleted != false || !m.InRange(stone.GetWorldLocation(), 2); } public static bool BadMember(Mobile m, Guild g) @@ -140,7 +138,7 @@ namespace Server.Gumps Item stone = g.Guildstone; - return stone == null || stone.Deleted || !m.InRange(stone.GetWorldLocation(), 2); + return stone?.Deleted != false || !m.InRange(stone.GetWorldLocation(), 2); } public override void OnResponse(NetState sender, RelayInfo info) @@ -219,4 +217,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildListGump.cs b/Scripts/Gumps/Guilds/GuildListGump.cs index aa1cd119e..abde1ff9f 100644 --- a/Scripts/Gumps/Guilds/GuildListGump.cs +++ b/Scripts/Gumps/Guilds/GuildListGump.cs @@ -31,7 +31,7 @@ namespace Server.Gumps if (i != 0) { AddButton(300, 370, 4005, 4007, 0, GumpButtonType.Page, i / 11 + 1); - AddHtmlLocalized(335, 370, 300, 35, 1011066, false, false); // Next page + AddHtmlLocalized(335, 370, 300, 35, 1011066); // Next page } AddPage(i / 11 + 1); @@ -39,7 +39,7 @@ namespace Server.Gumps if (i != 0) { AddButton(20, 370, 4014, 4016, 0, GumpButtonType.Page, i / 11); - AddHtmlLocalized(55, 370, 300, 35, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 370, 300, 35, 1011067); // Previous page } } diff --git a/Scripts/Gumps/Guilds/GuildMobileListGump.cs b/Scripts/Gumps/Guilds/GuildMobileListGump.cs index 59158549c..4179ee663 100644 --- a/Scripts/Gumps/Guilds/GuildMobileListGump.cs +++ b/Scripts/Gumps/Guilds/GuildMobileListGump.cs @@ -32,7 +32,7 @@ namespace Server.Gumps if (i != 0) { AddButton(300, 370, 4005, 4007, 0, GumpButtonType.Page, i / 11 + 1); - AddHtmlLocalized(335, 370, 300, 35, 1011066, false, false); // Next page + AddHtmlLocalized(335, 370, 300, 35, 1011066); // Next page } AddPage(i / 11 + 1); @@ -40,7 +40,7 @@ namespace Server.Gumps if (i != 0) { AddButton(20, 370, 4014, 4016, 0, GumpButtonType.Page, i / 11); - AddHtmlLocalized(55, 370, 300, 35, 1011067, false, false); // Previous page + AddHtmlLocalized(55, 370, 300, 35, 1011067); // Previous page } } diff --git a/Scripts/Gumps/Guilds/GuildRejectWarGump.cs b/Scripts/Gumps/Guilds/GuildRejectWarGump.cs index 2a1f36bcd..16761e975 100644 --- a/Scripts/Gumps/Guilds/GuildRejectWarGump.cs +++ b/Scripts/Gumps/Guilds/GuildRejectWarGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011148, false, false); // Select the guild to reject their invitations: + AddHtmlLocalized(20, 10, 400, 35, 1011148); // Select the guild to reject their invitations: - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011101, false, false); // Reject war invitations. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011101); // Reject war invitations. - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -59,4 +59,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildRescindDeclarationGump.cs b/Scripts/Gumps/Guilds/GuildRescindDeclarationGump.cs index 8a55ef7bc..2a648b5d4 100644 --- a/Scripts/Gumps/Guilds/GuildRescindDeclarationGump.cs +++ b/Scripts/Gumps/Guilds/GuildRescindDeclarationGump.cs @@ -11,13 +11,13 @@ namespace Server.Gumps protected override void Design() { - AddHtmlLocalized(20, 10, 400, 35, 1011150, false, false); // Select the guild to rescind our invitations: + AddHtmlLocalized(20, 10, 400, 35, 1011150); // Select the guild to rescind our invitations: - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 245, 30, 1011102, false, false); // Rescind your war declarations. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 245, 30, 1011102); // Rescind your war declarations. - AddButton(300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 400, 100, 35, 1011012, false, false); // CANCEL + AddButton(300, 400, 4005, 4007, 2); + AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -59,4 +59,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildRosterGump.cs b/Scripts/Gumps/Guilds/GuildRosterGump.cs index e363fa33e..5588678a3 100644 --- a/Scripts/Gumps/Guilds/GuildRosterGump.cs +++ b/Scripts/Gumps/Guilds/GuildRosterGump.cs @@ -11,10 +11,10 @@ namespace Server.Gumps protected override void Design() { - AddHtml(20, 10, 500, 35, $"
{m_Guild.Name}
", false, false); + AddHtml(20, 10, 500, 35, $"
{m_Guild.Name}
"); - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 300, 35, 1011120, false, false); // Return to the main menu. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 300, 35, 1011120); // Return to the main menu. } public override void OnResponse(NetState state, RelayInfo info) @@ -29,4 +29,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildWarAdminGump.cs b/Scripts/Gumps/Guilds/GuildWarAdminGump.cs index 116649a0a..64d284013 100644 --- a/Scripts/Gumps/Guilds/GuildWarAdminGump.cs +++ b/Scripts/Gumps/Guilds/GuildWarAdminGump.cs @@ -19,49 +19,48 @@ namespace Server.Gumps AddBackground(0, 0, 550, 440, 5054); AddBackground(10, 10, 530, 420, 3000); - AddHtmlLocalized(20, 10, 510, 35, 1011105, false, false); //
WAR FUNCTIONS
+ AddHtmlLocalized(20, 10, 510, 35, 1011105); //
WAR FUNCTIONS
- AddButton(20, 40, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 40, 400, 30, 1011099, false, false); // Declare war through guild name search. + AddButton(20, 40, 4005, 4007, 1); + AddHtmlLocalized(55, 40, 400, 30, 1011099); // Declare war through guild name search. int count = 0; if (guild.Enemies.Count > 0) { - AddButton(20, 160 + count * 30, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011103, false, false); // Declare peace. + AddButton(20, 160 + count * 30, 4005, 4007, 2); + AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011103); // Declare peace. } else { - AddHtmlLocalized(20, 160 + count++ * 30, 400, 30, 1013033, false, false); // No current wars + AddHtmlLocalized(20, 160 + count++ * 30, 400, 30, 1013033); // No current wars } if (guild.WarInvitations.Count > 0) { - AddButton(20, 160 + count * 30, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011100, false, false); // Accept war invitations. + AddButton(20, 160 + count * 30, 4005, 4007, 3); + AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011100); // Accept war invitations. - AddButton(20, 160 + count * 30, 4005, 4007, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011101, false, false); // Reject war invitations. + AddButton(20, 160 + count * 30, 4005, 4007, 4); + AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011101); // Reject war invitations. } else { - AddHtmlLocalized(20, 160 + count++ * 30, 400, 30, 1018012, false, - false); // No current invitations received for war. + AddHtmlLocalized(20, 160 + count++ * 30, 400, 30, 1018012); // No current invitations received for war. } if (guild.WarDeclarations.Count > 0) { - AddButton(20, 160 + count * 30, 4005, 4007, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011102, false, false); // Rescind your war declarations. + AddButton(20, 160 + count * 30, 4005, 4007, 5); + AddHtmlLocalized(55, 160 + count++ * 30, 400, 30, 1011102); // Rescind your war declarations. } else { - AddHtmlLocalized(20, 160 + count++ * 30, 400, 30, 1013055, false, false); // No current war declarations + AddHtmlLocalized(20, 160 + count++ * 30, 400, 30, 1013055); // No current war declarations } - AddButton(20, 400, 4005, 4007, 6, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 400, 35, 1011104, false, false); // Return to the previous menu. + AddButton(20, 400, 4005, 4007, 6); + AddHtmlLocalized(55, 400, 400, 35, 1011104); // Return to the previous menu. } public override void OnResponse(NetState state, RelayInfo info) @@ -73,7 +72,7 @@ namespace Server.Gumps { case 1: // Declare war { - m_Mobile.SendLocalizedMessage(1018001); // Declare war through search - Enter Guild Name: + m_Mobile.SendLocalizedMessage(1018001); // Declare war through search - Enter Guild Name: m_Mobile.Prompt = new GuildDeclareWarPrompt(m_Mobile, m_Guild); break; @@ -116,4 +115,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildWarGump.cs b/Scripts/Gumps/Guilds/GuildWarGump.cs index eb7bd2ae6..d2304dc45 100644 --- a/Scripts/Gumps/Guilds/GuildWarGump.cs +++ b/Scripts/Gumps/Guilds/GuildWarGump.cs @@ -20,69 +20,69 @@ namespace Server.Gumps AddBackground(0, 0, 550, 440, 5054); AddBackground(10, 10, 530, 420, 3000); - AddHtmlLocalized(20, 10, 500, 35, 1011133, false, false); //
WARFARE STATUS
+ AddHtmlLocalized(20, 10, 500, 35, 1011133); //
WARFARE STATUS
- AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 300, 35, 1011120, false, false); // Return to the main menu. + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 300, 35, 1011120); // Return to the main menu. AddPage(1); AddButton(375, 375, 5224, 5224, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(410, 373, 100, 25, 1011066, false, false); // Next page + AddHtmlLocalized(410, 373, 100, 25, 1011066); // Next page - AddHtmlLocalized(20, 45, 400, 20, 1011134, false, false); // We are at war with: + AddHtmlLocalized(20, 45, 400, 20, 1011134); // We are at war with: List enemies = guild.Enemies; if (enemies.Count == 0) - AddHtmlLocalized(20, 65, 400, 20, 1013033, false, false); // No current wars + AddHtmlLocalized(20, 65, 400, 20, 1013033); // No current wars else for (int i = 0; i < enemies.Count; ++i) { Guild g = enemies[i]; - AddHtml(20, 65 + i * 20, 300, 20, g.Name, false, false); + AddHtml(20, 65 + i * 20, 300, 20, g.Name); } AddPage(2); AddButton(375, 375, 5224, 5224, 0, GumpButtonType.Page, 3); - AddHtmlLocalized(410, 373, 100, 25, 1011066, false, false); // Next page + AddHtmlLocalized(410, 373, 100, 25, 1011066); // Next page AddButton(30, 375, 5223, 5223, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(65, 373, 150, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(65, 373, 150, 25, 1011067); // Previous page - AddHtmlLocalized(20, 45, 400, 20, 1011136, false, false); // Guilds that we have declared war on: + AddHtmlLocalized(20, 45, 400, 20, 1011136); // Guilds that we have declared war on: List declared = guild.WarDeclarations; if (declared.Count == 0) - AddHtmlLocalized(20, 65, 400, 20, 1018012, false, false); // No current invitations received for war. + AddHtmlLocalized(20, 65, 400, 20, 1018012); // No current invitations received for war. else for (int i = 0; i < declared.Count; ++i) { Guild g = declared[i]; - AddHtml(20, 65 + i * 20, 300, 20, g.Name, false, false); + AddHtml(20, 65 + i * 20, 300, 20, g.Name); } AddPage(3); AddButton(30, 375, 5223, 5223, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(65, 373, 150, 25, 1011067, false, false); // Previous page + AddHtmlLocalized(65, 373, 150, 25, 1011067); // Previous page - AddHtmlLocalized(20, 45, 400, 20, 1011135, false, false); // Guilds that have declared war on us: + AddHtmlLocalized(20, 45, 400, 20, 1011135); // Guilds that have declared war on us: List invites = guild.WarInvitations; if (invites.Count == 0) - AddHtmlLocalized(20, 65, 400, 20, 1013055, false, false); // No current war declarations + AddHtmlLocalized(20, 65, 400, 20, 1013055); // No current war declarations else for (int i = 0; i < invites.Count; ++i) { Guild g = invites[i]; - AddHtml(20, 65 + i * 20, 300, 20, g.Name, false, false); + AddHtml(20, 65 + i * 20, 300, 20, g.Name); } } @@ -98,4 +98,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/GuildmasterGump.cs b/Scripts/Gumps/Guilds/GuildmasterGump.cs index acefc2a13..29a7be63a 100644 --- a/Scripts/Gumps/Guilds/GuildmasterGump.cs +++ b/Scripts/Gumps/Guilds/GuildmasterGump.cs @@ -20,67 +20,66 @@ namespace Server.Gumps AddBackground(0, 0, 550, 400, 5054); AddBackground(10, 10, 530, 380, 3000); - AddHtmlLocalized(20, 15, 510, 35, 1011121, false, false); //
GUILDMASTER FUNCTIONS
+ AddHtmlLocalized(20, 15, 510, 35, 1011121); //
GUILDMASTER FUNCTIONS
- AddButton(20, 40, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 40, 470, 30, 1011107, false, false); // Set the guild name. + AddButton(20, 40, 4005, 4007, 2); + AddHtmlLocalized(55, 40, 470, 30, 1011107); // Set the guild name. - AddButton(20, 70, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 70, 470, 30, 1011109, false, false); // Set the guild's abbreviation. + AddButton(20, 70, 4005, 4007, 3); + AddHtmlLocalized(55, 70, 470, 30, 1011109); // Set the guild's abbreviation. if (Guild.OrderChaos) { - AddButton(20, 100, 4005, 4007, 4, GumpButtonType.Reply, 0); + AddButton(20, 100, 4005, 4007, 4); switch (m_Guild.Type) { case GuildType.Regular: - AddHtmlLocalized(55, 100, 470, 30, 1013059, false, false); // Change guild type: Currently Standard + AddHtmlLocalized(55, 100, 470, 30, 1013059); // Change guild type: Currently Standard break; case GuildType.Order: - AddHtmlLocalized(55, 100, 470, 30, 1013057, false, false); // Change guild type: Currently Order + AddHtmlLocalized(55, 100, 470, 30, 1013057); // Change guild type: Currently Order break; case GuildType.Chaos: - AddHtmlLocalized(55, 100, 470, 30, 1013058, false, false); // Change guild type: Currently Chaos + AddHtmlLocalized(55, 100, 470, 30, 1013058); // Change guild type: Currently Chaos break; } } - AddButton(20, 130, 4005, 4007, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 130, 470, 30, 1011112, false, false); // Set the guild's charter. + AddButton(20, 130, 4005, 4007, 5); + AddHtmlLocalized(55, 130, 470, 30, 1011112); // Set the guild's charter. - AddButton(20, 160, 4005, 4007, 6, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 160, 470, 30, 1011113, false, false); // Dismiss a member. + AddButton(20, 160, 4005, 4007, 6); + AddHtmlLocalized(55, 160, 470, 30, 1011113); // Dismiss a member. - AddButton(20, 190, 4005, 4007, 7, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 190, 470, 30, 1011114, false, false); // Go to the WAR menu. + AddButton(20, 190, 4005, 4007, 7); + AddHtmlLocalized(55, 190, 470, 30, 1011114); // Go to the WAR menu. if (m_Guild.Candidates.Count > 0) { - AddButton(20, 220, 4005, 4007, 8, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 220, 470, 30, 1013056, false, false); // Administer the list of candidates + AddButton(20, 220, 4005, 4007, 8); + AddHtmlLocalized(55, 220, 470, 30, 1013056); // Administer the list of candidates } else { AddImage(20, 220, 4020); - AddHtmlLocalized(55, 220, 470, 30, 1013031, false, - false); // There are currently no candidates for membership. + AddHtmlLocalized(55, 220, 470, 30, 1013031); // There are currently no candidates for membership. } - AddButton(20, 250, 4005, 4007, 9, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 250, 470, 30, 1011117, false, false); // Set the guildmaster's title. + AddButton(20, 250, 4005, 4007, 9); + AddHtmlLocalized(55, 250, 470, 30, 1011117); // Set the guildmaster's title. - AddButton(20, 280, 4005, 4007, 10, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 280, 470, 30, 1011118, false, false); // Grant a title to another member. + AddButton(20, 280, 4005, 4007, 10); + AddHtmlLocalized(55, 280, 470, 30, 1011118); // Grant a title to another member. - AddButton(20, 310, 4005, 4007, 11, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 310, 470, 30, 1011119, false, false); // Move this guildstone. + AddButton(20, 310, 4005, 4007, 11); + AddHtmlLocalized(55, 310, 470, 30, 1011119); // Move this guildstone. - AddButton(20, 360, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 360, 245, 30, 1011120, false, false); // Return to the main menu. + AddButton(20, 360, 4005, 4007, 1); + AddHtmlLocalized(55, 360, 245, 30, 1011120); // Return to the main menu. - AddButton(300, 360, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(335, 360, 100, 30, 1011441, false, false); // EXIT + AddButton(300, 360, 4005, 4007, 0); + AddHtmlLocalized(335, 360, 100, 30, 1011441); // EXIT } public override void OnResponse(NetState state, RelayInfo info) @@ -186,4 +185,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs b/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs index afc068a7d..07f9d736f 100644 --- a/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs +++ b/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs @@ -23,27 +23,26 @@ namespace Server.Guilds { base.PopulateGump(); - AddHtmlLocalized(431, 43, 110, 26, 1062978, 0xF, false, false); // Diplomacy + AddHtmlLocalized(431, 43, 110, 26, 1062978, 0xF); // Diplomacy - AddHtmlLocalized(65, 80, 480, 26, 1063124, 0xF, true, false); // Advanced Search Options + AddHtmlLocalized(65, 80, 480, 26, 1063124, 0xF, true); // Advanced Search Options - AddHtmlLocalized(65, 110, 480, 26, 1063136 + (int)m_Display, 0xF, false, - false); // Showing All Guilds/w/Relation/Waiting Relation + AddHtmlLocalized(65, 110, 480, 26, 1063136 + (int)m_Display, 0xF); // Showing All Guilds/w/Relation/Waiting Relation AddGroup(1); AddRadio(75, 140, 0xD2, 0xD3, false, 2); - AddHtmlLocalized(105, 140, 200, 26, 1063006, 0x0, false, false); // Show Guilds with Relationship + AddHtmlLocalized(105, 140, 200, 26, 1063006, 0x0); // Show Guilds with Relationship AddRadio(75, 170, 0xD2, 0xD3, false, 1); - AddHtmlLocalized(105, 170, 200, 26, 1063005, 0x0, false, false); // Show Guilds Awaiting Action + AddHtmlLocalized(105, 170, 200, 26, 1063005, 0x0); // Show Guilds Awaiting Action AddRadio(75, 200, 0xD2, 0xD3, false, 0); - AddHtmlLocalized(105, 200, 200, 26, 1063007, 0x0, false, false); // Show All Guilds + AddHtmlLocalized(105, 200, 200, 26, 1063007, 0x0); // Show All Guilds AddBackground(450, 370, 100, 26, 0x2486); - AddButton(455, 375, 0x845, 0x846, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(480, 373, 60, 26, 1006044, 0x0, false, false); // OK + AddButton(455, 375, 0x845, 0x846, 5); + AddHtmlLocalized(480, 373, 60, 26, 1006044, 0x0); // OK AddBackground(340, 370, 100, 26, 0x2486); - AddButton(345, 375, 0x845, 0x846, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(370, 373, 60, 26, 1006045, 0x0, false, false); // Cancel + AddButton(345, 375, 0x845, 0x846, 0); + AddHtmlLocalized(370, 373, 60, 26, 1006045, 0x0); // Cancel } @@ -66,4 +65,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs b/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs index 33bd4845c..81024b81c 100644 --- a/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs @@ -7,11 +7,7 @@ namespace Server.Guilds { public abstract class BaseGuildGump : Gump { - public BaseGuildGump(PlayerMobile pm, Guild g) : this(pm, g, 10, 10) - { - } - - public BaseGuildGump(PlayerMobile pm, Guild g, int x, int y) : base(x, y) + public BaseGuildGump(PlayerMobile pm, Guild g, int x = 10, int y = 10) : base(x, y) { guild = g; player = pm; @@ -31,14 +27,14 @@ namespace Server.Guilds AddBackground(0, 0, 600, 440, 0x24AE); AddBackground(66, 40, 150, 26, 0x2486); - AddButton(71, 45, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(96, 43, 110, 26, 1063014, 0x0, false, false); // My Guild + AddButton(71, 45, 0x845, 0x846, 1); + AddHtmlLocalized(96, 43, 110, 26, 1063014, 0x0); // My Guild AddBackground(236, 40, 150, 26, 0x2486); - AddButton(241, 45, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(266, 43, 110, 26, 1062974, 0x0, false, false); // Guild Roster + AddButton(241, 45, 0x845, 0x846, 2); + AddHtmlLocalized(266, 43, 110, 26, 1062974, 0x0); // Guild Roster AddBackground(401, 40, 150, 26, 0x2486); - AddButton(406, 45, 0x845, 0x846, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(431, 43, 110, 26, 1062978, 0x0, false, false); // Diplomacy + AddButton(406, 45, 0x845, 0x846, 3); + AddHtmlLocalized(431, 43, 110, 26, 1062978, 0x0); // Diplomacy AddPage(1); } @@ -81,12 +77,7 @@ namespace Server.Guilds m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m)); } - public static bool CheckProfanity(string s) - { - return CheckProfanity(s, 50); - } - - public static bool CheckProfanity(string s, int maxLength) + public static bool CheckProfanity(string s, int maxLength = 50) { //return NameVerification.Validate( s, 1, 50, true, true, false, int.MaxValue, ProfanityProtection.Exceptions, ProfanityProtection.Disallowed, ProfanityProtection.StartDisallowed ); //What am I doing wrong, this still allows chars like the <3 symbol... 3 AM. someone change this to use this @@ -126,7 +117,7 @@ namespace Server.Guilds public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll) { - if (text != null && text.Number > 0) + 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); @@ -137,4 +128,4 @@ namespace Server.Guilds return $"{text}"; } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs b/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs index e0f9a3c9c..2ad7bed1c 100644 --- a/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs @@ -54,7 +54,7 @@ namespace Server.Guilds AddBackground(130, 75, 385, 30, 0xBB8); AddTextEntry(135, 80, 375, 30, 0x481, 1, m_Filter); - AddButton(520, 75, 0x867, 0x868, 5, GumpButtonType.Reply, 0); //Filter Button + AddButton(520, 75, 0x867, 0x868, 5); //Filter Button int width = 0; for (int i = 0; i < m_Fields.Length; i++) @@ -69,21 +69,20 @@ namespace Server.Guilds int ButtonID = isComparer ? m_Ascending ? 0x983 : 0x985 : 0x2716; - AddButton(59 + width + f.Width, 117, ButtonID, ButtonID + (isComparer ? 1 : 0), 100 + i, - GumpButtonType.Reply, 0); + AddButton(59 + width + f.Width, 117, ButtonID, ButtonID + (isComparer ? 1 : 0), 100 + i); width += f.Width + 12; } if (m_StartNumber <= 0) - AddButton(65, 80, 0x15E3, 0x15E7, 0, GumpButtonType.Page, 0); + AddButton(65, 80, 0x15E3, 0x15E7, 0, GumpButtonType.Page); else - AddButton(65, 80, 0x15E3, 0x15E7, 6, GumpButtonType.Reply, 0); // Back + AddButton(65, 80, 0x15E3, 0x15E7, 6); // Back if (m_StartNumber + itemsPerPage > m_List.Count) - AddButton(95, 80, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 0); + AddButton(95, 80, 0x15E1, 0x15E5, 0, GumpButtonType.Page); else - AddButton(95, 80, 0x15E1, 0x15E5, 7, GumpButtonType.Reply, 0); // Forward + AddButton(95, 80, 0x15E1, 0x15E5, 7); // Forward int itemNumber = 0; @@ -125,9 +124,9 @@ namespace Server.Guilds } if (HasRelationship(o)) - AddButton(40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index, GumpButtonType.Reply, 0); //Info Button + AddButton(40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index); //Info Button else - AddButton(40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index, GumpButtonType.Reply, 0); //Info Button + AddButton(40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index); //Info Button } protected abstract TextDefinition[] GetValuesFor(T o, int aryLength); @@ -206,4 +205,4 @@ namespace Server.Guilds Comparer = comparer; } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs b/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs index bed1487c1..ac1407c5d 100644 --- a/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs @@ -14,26 +14,25 @@ namespace Server.Guilds AddPage(0); AddBackground(0, 0, 500, 300, 0x2422); - AddHtmlLocalized(25, 20, 450, 25, 1062939, 0x0, true, false); //
GUILD MENU
- AddHtmlLocalized(25, 60, 450, 60, 1062940, 0x0, false, - false); // As you are not a member of any guild, you can create your own by providing a unique guild name and paying the standard guild registration fee. - AddHtmlLocalized(25, 135, 120, 25, 1062941, 0x0, false, false); // Registration Fee: + AddHtmlLocalized(25, 20, 450, 25, 1062939, 0x0, true); //
GUILD MENU
+ AddHtmlLocalized(25, 60, 450, 60, 1062940, 0x0); // As you are not a member of any guild, you can create your own by providing a unique guild name and paying the standard guild registration fee. + AddHtmlLocalized(25, 135, 120, 25, 1062941, 0x0); // Registration Fee: AddLabel(155, 135, 0x481, Guild.RegistrationFee.ToString()); - AddHtmlLocalized(25, 165, 120, 25, 1011140, 0x0, false, false); // Enter Guild Name: + AddHtmlLocalized(25, 165, 120, 25, 1011140, 0x0); // Enter Guild Name: AddBackground(155, 160, 320, 26, 0xBB8); AddTextEntry(160, 163, 315, 21, 0x481, 5, guildName); - AddHtmlLocalized(25, 191, 120, 26, 1063035, 0x0, false, false); // Abbreviation: + AddHtmlLocalized(25, 191, 120, 26, 1063035, 0x0); // Abbreviation: AddBackground(155, 186, 320, 26, 0xBB8); AddTextEntry(160, 189, 315, 21, 0x481, 6, guildAbbrev); - AddButton(415, 217, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0); - AddButton(345, 217, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0); + AddButton(415, 217, 0xF7, 0xF8, 1); + AddButton(345, 217, 0xF2, 0xF1, 0); if (pm.AcceptGuildInvites) - AddButton(20, 260, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0); + AddButton(20, 260, 0xD2, 0xD3, 2); else - AddButton(20, 260, 0xD3, 0xD2, 2, GumpButtonType.Reply, 0); + AddButton(20, 260, 0xD3, 0xD2, 2); - AddHtmlLocalized(45, 260, 200, 30, 1062943, 0x0, false, false); // Ignore Guild Invites + AddHtmlLocalized(45, 260, 200, 30, 1062943, 0x0); // Ignore Guild Invites } public override void OnResponse(NetState sender, RelayInfo info) @@ -110,4 +109,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs b/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs index 12a3408ab..084fb59d6 100644 --- a/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs @@ -76,7 +76,7 @@ namespace Server.Guilds { base.PopulateGump(); - AddHtmlLocalized(431, 43, 110, 26, 1062978, 0xF, false, false); // Diplomacy + AddHtmlLocalized(431, 43, 110, 26, 1062978, 0xF); // Diplomacy } protected override TextDefinition[] GetValuesFor(Guild g, int aryLength) @@ -137,16 +137,16 @@ namespace Server.Guilds //AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/Awaiting Action/ w/Relation Ship //AddHtmlText( 66, 153 + itemNumber * 28, 280, 26, m_LowerText, false, false ); - if (m_LowerText != null && m_LowerText.Number > 0) - AddHtmlLocalized(66, 153 + itemNumber * 28, 280, 26, m_LowerText.Number, 0xF, 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), false, false); + AddHtml(66, 153 + itemNumber * 28, 280, 26, Color(m_LowerText.String, 0x99)); if (AllowAdvancedSearch) { AddBackground(350, 148 + itemNumber * 28, 200, 26, 0x2486); - AddButton(355, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0); - AddHtmlLocalized(380, 151 + itemNumber * 28, 160, 26, 1063083, 0x0, false, false); // Advanced Search + AddButton(355, 153 + itemNumber * 28, 0x845, 0x846, 8); + AddHtmlLocalized(380, 151 + itemNumber * 28, 160, 26, 1063083, 0x0); // Advanced Search } } @@ -290,4 +290,4 @@ namespace Server.Guilds #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs index 4d97213e6..b3039432e 100644 --- a/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs @@ -9,11 +9,7 @@ namespace Server.Guilds { private bool m_IsResigning; - public GuildInfoGump(PlayerMobile pm, Guild g) : this(pm, g, false) - { - } - - public GuildInfoGump(PlayerMobile pm, Guild g, bool isResigning) : base(pm, g) + public GuildInfoGump(PlayerMobile pm, Guild g, bool isResigning = false) : base(pm, g) { m_IsResigning = isResigning; PopulateGump(); @@ -24,37 +20,37 @@ namespace Server.Guilds bool isLeader = IsLeader(player, guild); base.PopulateGump(); - AddHtmlLocalized(96, 43, 110, 26, 1063014, 0xF, false, false); // My Guild + AddHtmlLocalized(96, 43, 110, 26, 1063014, 0xF); // My Guild AddImageTiled(65, 80, 160, 26, 0xA40); AddImageTiled(67, 82, 156, 22, 0xBBC); - AddHtmlLocalized(70, 83, 150, 20, 1062954, 0x0, false, false); // Guild Name - AddHtml(233, 84, 320, 26, guild.Name, false, false); + AddHtmlLocalized(70, 83, 150, 20, 1062954, 0x0); // Guild Name + AddHtml(233, 84, 320, 26, guild.Name); AddImageTiled(65, 114, 160, 26, 0xA40); AddImageTiled(67, 116, 156, 22, 0xBBC); - AddHtmlLocalized(70, 117, 150, 20, 1063025, 0x0, false, false); // Alliance + AddHtmlLocalized(70, 117, 150, 20, 1063025, 0x0); // Alliance if (guild.Alliance != null && guild.Alliance.IsMember(guild)) { - AddHtml(233, 118, 320, 26, guild.Alliance.Name, false, false); - AddButton(40, 120, 0x4B9, 0x4BA, 6, GumpButtonType.Reply, 0); //Alliance Roster + AddHtml(233, 118, 320, 26, guild.Alliance.Name); + AddButton(40, 120, 0x4B9, 0x4BA, 6); //Alliance Roster } if (Guild.OrderChaos && isLeader) - AddButton(40, 154, 0x4B9, 0x4BA, 100, GumpButtonType.Reply, 0); // Guild Faction + AddButton(40, 154, 0x4B9, 0x4BA, 100); // Guild Faction AddImageTiled(65, 148, 160, 26, 0xA40); AddImageTiled(67, 150, 156, 22, 0xBBC); - AddHtmlLocalized(70, 151, 150, 20, 1063084, 0x0, false, false); // Guild Faction + AddHtmlLocalized(70, 151, 150, 20, 1063084, 0x0); // Guild Faction GuildType gt; Faction f; if ((gt = guild.Type) != GuildType.Regular) - AddHtml(233, 152, 320, 26, gt.ToString(), false, false); + AddHtml(233, 152, 320, 26, gt.ToString()); else if ((f = Faction.Find(guild.Leader)) != null) - AddHtml(233, 152, 320, 26, f.ToString(), false, false); + AddHtml(233, 152, 320, 26, f.ToString()); AddImageTiled(65, 196, 480, 4, 0x238D); @@ -65,21 +61,21 @@ namespace Server.Guilds AddHtml(65, 216, 480, 80, s, true, true); if (isLeader) - AddButton(40, 251, 0x4B9, 0x4BA, 4, GumpButtonType.Reply, 0); //Charter Edit button + AddButton(40, 251, 0x4B9, 0x4BA, 4); //Charter Edit button s = guild.Website; if (string.IsNullOrEmpty(s)) s = "Guild website not yet set."; - AddHtml(65, 306, 480, 30, s, true, false); + AddHtml(65, 306, 480, 30, s, true); if (isLeader) - AddButton(40, 313, 0x4B9, 0x4BA, 5, GumpButtonType.Reply, 0); //Website Edit button + AddButton(40, 313, 0x4B9, 0x4BA, 5); //Website Edit button AddCheck(65, 370, 0xD2, 0xD3, player.DisplayGuildTitle, 0); - AddHtmlLocalized(95, 370, 150, 26, 1063085, 0x0, false, false); // Show Guild Title + AddHtmlLocalized(95, 370, 150, 26, 1063085, 0x0); // Show Guild Title AddBackground(450, 370, 100, 26, 0x2486); - AddButton(455, 375, 0x845, 0x846, 7, GumpButtonType.Reply, 0); - AddHtmlLocalized(480, 373, 60, 26, 3006115, m_IsResigning ? 0x5000 : 0, false, false); // Resign + AddButton(455, 375, 0x845, 0x846, 7); + AddHtmlLocalized(480, 373, 60, 26, 3006115, m_IsResigning ? 0x5000 : 0); // Resign } public override void OnResponse(NetState sender, RelayInfo info) @@ -193,4 +189,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs b/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs index 5d113f7ba..07fd68e4b 100644 --- a/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs +++ b/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs @@ -20,13 +20,12 @@ namespace Server.Guilds AddPage(0); AddBackground(0, 0, 350, 170, 0x2422); - AddHtmlLocalized(25, 20, 300, 45, 1062946, 0x0, true, - false); //
You have been invited to join a guild! (Warning: Accepting will make you attackable!)
- AddHtml(25, 75, 300, 25, $"
{guild.Name}
", true, false); - AddButton(265, 130, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0); - AddButton(195, 130, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0); - AddButton(20, 130, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 130, 150, 30, 1062943, 0x0, false, false); // Ignore Guild Invites + AddHtmlLocalized(25, 20, 300, 45, 1062946, 0x0, true); //
You have been invited to join a guild! (Warning: Accepting will make you attackable!)
+ AddHtml(25, 75, 300, 25, $"
{guild.Name}
", true); + AddButton(265, 130, 0xF7, 0xF8, 1); + AddButton(195, 130, 0xF2, 0xF1, 0); + AddButton(20, 130, 0xD2, 0xD3, 2); + AddHtmlLocalized(45, 130, 150, 30, 1062943, 0x0); // Ignore Guild Invites } @@ -62,4 +61,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs b/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs index abac3b2f4..5e547223d 100644 --- a/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs @@ -23,41 +23,39 @@ namespace Server.Guilds AddPage(0); AddBackground(0, 0, 350, 255, 0x242C); - AddHtmlLocalized(20, 15, 310, 26, 1063018, 0x0, false, - false); //
Guild Member Information
+ AddHtmlLocalized(20, 15, 310, 26, 1063018, 0x0); //
Guild Member Information
AddImageTiled(20, 40, 310, 2, 0x2711); - AddHtmlLocalized(20, 50, 150, 26, 1062955, 0x0, true, false); // Name - AddHtml(180, 53, 150, 26, m_Member.Name, false, false); + AddHtmlLocalized(20, 50, 150, 26, 1062955, 0x0, true); // Name + AddHtml(180, 53, 150, 26, m_Member.Name); - AddHtmlLocalized(20, 80, 150, 26, 1062956, 0x0, true, false); // Rank - AddHtmlLocalized(180, 83, 150, 26, m_Member.GuildRank.Name, 0x0, false, false); + AddHtmlLocalized(20, 80, 150, 26, 1062956, 0x0, true); // Rank + AddHtmlLocalized(180, 83, 150, 26, m_Member.GuildRank.Name, 0x0); - AddHtmlLocalized(20, 110, 150, 26, 1062953, 0x0, true, false); // Guild Title - AddHtml(180, 113, 150, 26, m_Member.GuildTitle, false, false); + AddHtmlLocalized(20, 110, 150, 26, 1062953, 0x0, true); // Guild Title + AddHtml(180, 113, 150, 26, m_Member.GuildTitle); AddImageTiled(20, 142, 310, 2, 0x2711); AddBackground(20, 150, 310, 26, 0x2486); - AddButton(25, 155, 0x845, 0x846, 4, GumpButtonType.Reply, 0); + AddButton(25, 155, 0x845, 0x846, 4); AddHtmlLocalized(50, 153, 270, 26, - m_Member == player.GuildFealty && guild.Leader != m_Member ? 1063082 : 1062996, 0x0, false, - false); // Clear/Cast Vote For This Member + m_Member == player.GuildFealty && guild.Leader != m_Member ? 1063082 : 1062996, 0x0); // Clear/Cast Vote For This Member AddBackground(20, 180, 150, 26, 0x2486); - AddButton(25, 185, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 183, 110, 26, 1062993, m_ToLeader ? 0x990000 : 0, false, false); // Promote + AddButton(25, 185, 0x845, 0x846, 1); + AddHtmlLocalized(50, 183, 110, 26, 1062993, m_ToLeader ? 0x990000 : 0); // Promote AddBackground(180, 180, 150, 26, 0x2486); - AddButton(185, 185, 0x845, 0x846, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(210, 183, 110, 26, 1062995, 0x0, false, false); // Set Guild Title + AddButton(185, 185, 0x845, 0x846, 3); + AddHtmlLocalized(210, 183, 110, 26, 1062995, 0x0); // Set Guild Title AddBackground(20, 210, 150, 26, 0x2486); - AddButton(25, 215, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 213, 110, 26, 1062994, 0x0, false, false); // Demote + AddButton(25, 215, 0x845, 0x846, 2); + AddHtmlLocalized(50, 213, 110, 26, 1062994, 0x0); // Demote AddBackground(180, 210, 150, 26, 0x2486); - AddButton(185, 215, 0x845, 0x846, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(210, 213, 110, 26, 1062997, m_toKick ? 0x5000 : 0, false, false); // Kick + AddButton(185, 215, 0x845, 0x846, 5); + AddHtmlLocalized(210, 213, 110, 26, 1062997, m_toKick ? 0x5000 : 0); // Kick } public override void OnResponse(NetState sender, RelayInfo info) @@ -252,4 +250,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs b/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs index 538a8e356..5a629ca71 100644 --- a/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs @@ -17,12 +17,12 @@ namespace Server.Guilds new InfoField(1062953, 150, TitleComparer.Instance) //Guild Title }; - public GuildRosterGump(PlayerMobile pm, Guild g) : this(pm, g, LastOnComparer.Instance, false, "", 0) + public GuildRosterGump(PlayerMobile pm, Guild g) : this(pm, g, LastOnComparer.Instance) { } - public GuildRosterGump(PlayerMobile pm, Guild g, IComparer currentComparer, bool ascending, - string filter, int startNumber) + public GuildRosterGump(PlayerMobile pm, Guild g, IComparer currentComparer, bool ascending = false, + string filter = "", int startNumber = 0) : base(pm, g, Utility.SafeConvertList(g.Members), currentComparer, ascending, filter, startNumber, m_Fields) { @@ -33,14 +33,14 @@ namespace Server.Guilds { base.PopulateGump(); - AddHtmlLocalized(266, 43, 110, 26, 1062974, 0xF, false, false); // Guild Roster + AddHtmlLocalized(266, 43, 110, 26, 1062974, 0xF); // Guild Roster } public override void DrawEndingEntry(int itemNumber) { AddBackground(225, 148 + itemNumber * 28, 150, 26, 0x2486); - AddButton(230, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0); - AddHtmlLocalized(255, 151 + itemNumber * 28, 110, 26, 1062992, 0x0, false, false); // Invite Player + AddButton(230, 153 + itemNumber * 28, 0x845, 0x846, 8); + AddHtmlLocalized(255, 151 + itemNumber * 28, 110, 26, 1062992, 0x0); // Invite Player } protected override TextDefinition[] GetValuesFor(PlayerMobile pm, int aryLength) @@ -156,7 +156,7 @@ namespace Server.Guilds else pm.SendLocalizedMessage(1013028); // That person has a different faction affiliation. } - else if (targetState != null && targetState.IsLeaving) + else if (targetState?.IsLeaving == true) { // OSI does this quite strangely, so we'll just do it this way pm.SendMessage("That person is quitting their faction and so you may not recruit them."); @@ -252,4 +252,4 @@ namespace Server.Guilds #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs index 953010c66..c5c79da11 100644 --- a/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs +++ b/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs @@ -22,8 +22,8 @@ namespace Server.Guilds public void AddButtonAndBackground(int x, int y, int buttonID, int locNum) { AddBackground(x, y, 225, 26, 0x2486); - AddButton(x + 5, y + 5, 0x845, 0x846, buttonID, GumpButtonType.Reply, 0); - AddHtmlLocalized(x + 30, y + 3, 185, 26, locNum, 0x0, false, false); + AddButton(x + 5, y + 5, 0x845, 0x846, buttonID); + AddHtmlLocalized(x + 30, y + 3, 185, 26, locNum, 0x0); } public override void PopulateGump() @@ -43,20 +43,19 @@ namespace Server.Guilds AddPage(0); AddBackground(0, 0, 520, 335, 0x242C); - AddHtmlLocalized(20, 15, 480, 26, 1062975, 0x0, false, - false); //
Guild Relationship
+ AddHtmlLocalized(20, 15, 480, 26, 1062975, 0x0); //
Guild Relationship
AddImageTiled(20, 40, 480, 2, 0x2711); - AddHtmlLocalized(20, 50, 120, 26, 1062954, 0x0, true, false); // Guild Name - AddHtml(150, 53, 360, 26, m_Other.Name, false, false); + AddHtmlLocalized(20, 50, 120, 26, 1062954, 0x0, true); // Guild Name + AddHtml(150, 53, 360, 26, m_Other.Name); - AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true, false); // Alliance + AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true); // Alliance if (otherAlliance != null) if (otherAlliance.IsMember(m_Other)) - AddHtml(150, 83, 360, 26, otherAlliance.Name, false, false); + AddHtml(150, 83, 360, 26, otherAlliance.Name); - AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true, false); // Abbreviation - AddHtml(150, 113, 120, 26, m_Other.Abbreviation, false, false); + AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true); // Abbreviation + AddHtml(150, 113, 120, 26, m_Other.Abbreviation); string kills = "0/0"; @@ -92,14 +91,14 @@ namespace Server.Guilds otherKills = Color($"{otherWar.Kills}/{otherWar.MaxKills}", 0x990000); } - AddHtmlLocalized(280, 110, 120, 26, 1062966, 0x0, true, false); // Your Kills - AddHtml(410, 113, 120, 26, kills, false, false); + AddHtmlLocalized(280, 110, 120, 26, 1062966, 0x0, true); // Your Kills + AddHtml(410, 113, 120, 26, kills); - AddHtmlLocalized(20, 140, 120, 26, 1062968, 0x0, true, false); // Time Remaining - AddHtml(150, 143, 120, 26, time, false, false); + AddHtmlLocalized(20, 140, 120, 26, 1062968, 0x0, true); // Time Remaining + AddHtml(150, 143, 120, 26, time); - AddHtmlLocalized(280, 140, 120, 26, 1062967, 0x0, true, false); // Their Kills - AddHtml(410, 143, 120, 26, otherKills, false, false); + AddHtmlLocalized(280, 140, 120, 26, 1062967, 0x0, true); // Their Kills + AddHtml(410, 143, 120, 26, otherKills); AddImageTiled(20, 172, 480, 2, 0x2711); @@ -155,7 +154,7 @@ namespace Server.Guilds //Withdraw Request AddButtonAndBackground(20, 290, 14, 1062986); // Withdraw Request - AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99), false, false); + AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99)); } else if (alliance.Leader == m_Other && alliance.IsPendingMember(guild)) { @@ -168,7 +167,7 @@ namespace Server.Guilds AddButtonAndBackground(20, 260, 15, 1062988); // Deny Request AddButtonAndBackground(20, 290, 16, 1062987); // Accept Request - AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99), false, false); + AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99)); } } else @@ -179,7 +178,7 @@ namespace Server.Guilds AddButtonAndBackground(275, 290, 0, 3000091); //Cancel - AddHtmlLocalized(20, 180, 480, 30, number, 0x0, true, false); + AddHtmlLocalized(20, 180, 480, 30, number, 0x0, true); AddImageTiled(20, 245, 480, 2, 0x2711); } @@ -209,7 +208,7 @@ namespace Server.Guilds case 5: //Accept the war { - if (war != null && !war.WarRequester && activeWar == null) + if (war?.WarRequester == false && activeWar == null) { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { @@ -229,7 +228,7 @@ namespace Server.Guilds war.WarBeginning = DateTime.UtcNow; guild.AcceptedWars.Add(war); - if (alliance != null && alliance.IsMember(guild)) + if (alliance?.IsMember(guild) == true) { alliance.AllianceMessage(1070769, otherAlliance != null @@ -274,7 +273,7 @@ namespace Server.Guilds } case 6: //Modify war terms { - if (war != null && !war.WarRequester && activeWar == null) + if (war?.WarRequester == false && activeWar == null) { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { @@ -338,7 +337,7 @@ namespace Server.Guilds { if (activeWar != null) { - if (alliance != null && alliance.IsMember(guild)) + if (alliance?.IsMember(guild) == true) { alliance.AllianceMessage(1070740, otherAlliance != null @@ -521,7 +520,7 @@ namespace Server.Guilds { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } - else if (alliance != null && alliance.IsMember(guild)) + else if (alliance?.IsMember(guild) == true) { guild.Alliance = null; //Calls alliance.Removeguild // alliance.RemoveGuild( guild ); @@ -544,7 +543,7 @@ namespace Server.Guilds pm.SendLocalizedMessage(1063239, $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. } - else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other)) + else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other)) { m_Other.Alliance = null; @@ -566,7 +565,7 @@ namespace Server.Guilds pm.SendLocalizedMessage(1063239, $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. } - else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other)) + else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other)) { pm.SendLocalizedMessage(1063434, $"{m_Other.Name}\t{alliance.Name}"); // ~1_val~ is now the leader of ~2_val~. @@ -700,4 +699,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs b/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs index 7ed859a53..e8bdad429 100644 --- a/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs @@ -18,23 +18,22 @@ namespace Server.Guilds AddBackground(0, 0, 500, 340, 0x24AE); AddBackground(65, 50, 370, 30, 0x2486); - AddHtmlLocalized(75, 55, 370, 26, 1062979, 0x3C00, false, - false); //
Declaration of War
+ AddHtmlLocalized(75, 55, 370, 26, 1062979, 0x3C00); //
Declaration of War
AddImage(410, 45, 0x232C); - AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF, false, false); // Duration of War - AddHtmlLocalized(65, 120, 400, 20, 1063010, 0x0, false, false); // Enter the number of hours the war will last. + AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF); // Duration of War + AddHtmlLocalized(65, 120, 400, 20, 1063010, 0x0); // Enter the number of hours the war will last. AddBackground(65, 150, 40, 30, 0x2486); AddTextEntry(70, 154, 50, 30, 0x481, 10, war != null ? war.WarLength.Hours.ToString() : "0"); - AddHtmlLocalized(65, 195, 200, 20, 1063011, 0x14AF, false, false); // Victory Condition - AddHtmlLocalized(65, 220, 400, 20, 1063012, 0x0, false, false); // Enter the winning number of kills. + AddHtmlLocalized(65, 195, 200, 20, 1063011, 0x14AF); // Victory Condition + AddHtmlLocalized(65, 220, 400, 20, 1063012, 0x0); // Enter the winning number of kills. AddBackground(65, 250, 40, 30, 0x2486); AddTextEntry(70, 254, 50, 30, 0x481, 11, war != null ? war.MaxKills.ToString() : "0"); AddBackground(190, 270, 130, 26, 0x2486); - AddButton(195, 275, 0x845, 0x846, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(220, 273, 90, 26, 1006045, 0x0, false, false); // Cancel + AddButton(195, 275, 0x845, 0x846, 0); + AddHtmlLocalized(220, 273, 90, 26, 1006045, 0x0); // Cancel AddBackground(330, 270, 130, 26, 0x2486); - AddButton(335, 275, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(360, 273, 90, 26, 1062989, 0x5000, false, false); // Declare War! + AddButton(335, 275, 0x845, 0x846, 1); + AddHtmlLocalized(360, 273, 90, 26, 1062989, 0x5000); // Declare War! } public override void OnResponse(NetState sender, RelayInfo info) @@ -137,4 +136,4 @@ namespace Server.Guilds } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Guilds/RecruitTarget.cs b/Scripts/Gumps/Guilds/RecruitTarget.cs index be878c9e7..3a03aa905 100644 --- a/Scripts/Gumps/Guilds/RecruitTarget.cs +++ b/Scripts/Gumps/Guilds/RecruitTarget.cs @@ -66,7 +66,7 @@ namespace Server.Gumps else m_Mobile.SendLocalizedMessage(1013028); // That person has a different faction affiliation. } - else if (targetState != null && targetState.IsLeaving) + else if (targetState?.IsLeaving == true) { // OSI does this quite strangely, so we'll just do it this way m_Mobile.SendMessage("That person is quitting their faction and so you may not recruit them."); @@ -94,4 +94,4 @@ namespace Server.Gumps m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/HeritageTokenGump.cs b/Scripts/Gumps/HeritageTokenGump.cs index a648af760..aca14cc31 100644 --- a/Scripts/Gumps/HeritageTokenGump.cs +++ b/Scripts/Gumps/HeritageTokenGump.cs @@ -20,260 +20,260 @@ namespace Server.Gumps AddImageTiled(10, 40, 500, 324, 0xA40); AddImageTiled(10, 374, 500, 20, 0xA40); AddAlphaRegion(10, 10, 500, 384); - AddButton(10, 374, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 376, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 500, 20, 1075576, 0x7FFF, false, false); // Choose your item from the following pages + AddButton(10, 374, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 376, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 500, 20, 1075576, 0x7FFF); // Choose your item from the following pages AddPage(1); AddImageTiledButton(14, 44, 0x918, 0x919, 0x64, GumpButtonType.Reply, 0, 0x1411, 0x2C, 18, 8); AddTooltip(1062912); - AddHtmlLocalized(98, 44, 250, 60, 1078147, 0x7FFF, false, false); // Royal Leggings of Embers + AddHtmlLocalized(98, 44, 250, 60, 1078147, 0x7FFF); // Royal Leggings of Embers AddImageTiledButton(264, 44, 0x918, 0x919, 0x65, GumpButtonType.Reply, 0, 0x234D, 0x0, 18, 12); AddTooltip(1062914); - AddHtmlLocalized(348, 44, 250, 60, 1062913, 0x7FFF, false, false); // Rose of Trinsic + AddHtmlLocalized(348, 44, 250, 60, 1062913, 0x7FFF); // Rose of Trinsic AddImageTiledButton(14, 108, 0x918, 0x919, 0x66, GumpButtonType.Reply, 0, 0x26C3, 0x504, 18, 8); AddTooltip(1062916); - AddHtmlLocalized(98, 108, 250, 60, 1062915, 0x7FFF, false, false); // Shamino’s Best Crossbow + AddHtmlLocalized(98, 108, 250, 60, 1062915, 0x7FFF); // Shamino’s Best Crossbow AddImageTiledButton(264, 108, 0x918, 0x919, 0x67, GumpButtonType.Reply, 0, 0x3F1D, 0x0, 18, 8); AddTooltip(1062918); - AddHtmlLocalized(348, 108, 250, 60, 1062917, 0x7FFF, false, false); // The Tapestry of Sosaria + AddHtmlLocalized(348, 108, 250, 60, 1062917, 0x7FFF); // The Tapestry of Sosaria AddImageTiledButton(14, 172, 0x918, 0x919, 0x68, GumpButtonType.Reply, 0, 0x3F14, 0x0, 18, 8); AddTooltip(1062920); - AddHtmlLocalized(98, 172, 250, 60, 1062919, 0x7FFF, false, false); // Hearth of the Home Fire + AddHtmlLocalized(98, 172, 250, 60, 1062919, 0x7FFF); // Hearth of the Home Fire AddImageTiledButton(264, 172, 0x918, 0x919, 0x69, GumpButtonType.Reply, 0, 0xF60, 0x482, -1, 10); AddTooltip(1062922); - AddHtmlLocalized(348, 172, 250, 60, 1062921, 0x7FFF, false, false); // The Holy Sword + AddHtmlLocalized(348, 172, 250, 60, 1062921, 0x7FFF); // The Holy Sword AddImageTiledButton(14, 236, 0x918, 0x919, 0x6A, GumpButtonType.Reply, 0, 0x236C, 0x0, 18, 6); AddTooltip(1062924); - AddHtmlLocalized(98, 236, 250, 60, 1062923, 0x7FFF, false, false); // Ancient Samurai Helm + AddHtmlLocalized(98, 236, 250, 60, 1062923, 0x7FFF); // Ancient Samurai Helm AddImageTiledButton(264, 236, 0x918, 0x919, 0x6B, GumpButtonType.Reply, 0, 0x2B10, 0x226, 18, 11); AddTooltip(1075223); - AddHtmlLocalized(348, 236, 250, 60, 1075188, 0x7FFF, false, false); // Helm of Spirituality + AddHtmlLocalized(348, 236, 250, 60, 1075188, 0x7FFF); // Helm of Spirituality AddImageTiledButton(14, 300, 0x918, 0x919, 0x6C, GumpButtonType.Reply, 0, 0x2B0C, 0x226, 18, 15); AddTooltip(1075224); - AddHtmlLocalized(98, 300, 250, 60, 1075192, 0x7FFF, false, false); // Gauntlets of Valor + AddHtmlLocalized(98, 300, 250, 60, 1075192, 0x7FFF); // Gauntlets of Valor AddImageTiledButton(264, 300, 0x918, 0x919, 0x6D, GumpButtonType.Reply, 0, 0x2B01, 0x0, 18, 9); AddTooltip(1075225); - AddHtmlLocalized(348, 300, 250, 60, 1075196, 0x7FFF, false, false); // Dupre’s Shield + AddHtmlLocalized(348, 300, 250, 60, 1075196, 0x7FFF); // Dupre’s Shield AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next AddPage(2); AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back AddImageTiledButton(14, 44, 0x918, 0x919, 0x6E, GumpButtonType.Reply, 0, 0x2AC6, 0x0, 29, 0); AddTooltip(1075226); - AddHtmlLocalized(98, 44, 250, 60, 1075197, 0x7FFF, false, false); // Fountain of Life + AddHtmlLocalized(98, 44, 250, 60, 1075197, 0x7FFF); // Fountain of Life AddImageTiledButton(264, 44, 0x918, 0x919, 0x6F, GumpButtonType.Reply, 0, 0x2AF9, 0x0, -4, -5); AddTooltip(1075227); - AddHtmlLocalized(348, 44, 250, 60, 1075198, 0x7FFF, false, false); // Dawn’s Music Box + AddHtmlLocalized(348, 44, 250, 60, 1075198, 0x7FFF); // Dawn’s Music Box AddImageTiledButton(14, 108, 0x918, 0x919, 0x70, GumpButtonType.Reply, 0, 0x2253, 0x0, 18, 12); AddTooltip(1075228); - AddHtmlLocalized(98, 108, 250, 60, 1078148, 0x7FFF, false, false); // Ossian Grimoire + AddHtmlLocalized(98, 108, 250, 60, 1078148, 0x7FFF); // Ossian Grimoire AddImageTiledButton(264, 108, 0x918, 0x919, 0x71, GumpButtonType.Reply, 0, 0x2D98, 0x0, 19, 13); AddTooltip(1078527); - AddHtmlLocalized(348, 108, 250, 60, 1078142, 0x7FFF, false, false); // Talisman of the Fey:
Ferret + AddHtmlLocalized(348, 108, 250, 60, 1078142, 0x7FFF); // Talisman of the Fey:
Ferret AddImageTiledButton(14, 172, 0x918, 0x919, 0x72, GumpButtonType.Reply, 0, 0x2D97, 0x0, 19, 13); AddTooltip(1078528); - AddHtmlLocalized(98, 172, 250, 60, 1078143, 0x7FFF, false, false); // Talisman of the Fey:
Squirrel + AddHtmlLocalized(98, 172, 250, 60, 1078143, 0x7FFF); // Talisman of the Fey:
Squirrel AddImageTiledButton(264, 172, 0x918, 0x919, 0x73, GumpButtonType.Reply, 0, 0x2D96, 0x0, 19, 8); AddTooltip(1078529); - AddHtmlLocalized(348, 172, 250, 60, 1078144, 0x7FFF, false, false); // Talisman of the Fey:
Cu Sidhe + AddHtmlLocalized(348, 172, 250, 60, 1078144, 0x7FFF); // Talisman of the Fey:
Cu Sidhe AddImageTiledButton(14, 236, 0x918, 0x919, 0x74, GumpButtonType.Reply, 0, 0x2D95, 0x0, -4, 2); AddTooltip(1078530); - AddHtmlLocalized(98, 236, 250, 60, 1078145, 0x7FFF, false, false); // Talisman of the Fey:
Reptalon + AddHtmlLocalized(98, 236, 250, 60, 1078145, 0x7FFF); // Talisman of the Fey:
Reptalon AddImageTiledButton(264, 236, 0x918, 0x919, 0x75, GumpButtonType.Reply, 0, 0x2B02, 0x0, -2, 9); AddTooltip(1078526); - AddHtmlLocalized(348, 236, 250, 60, 1075201, 0x7FFF, false, false); // Quiver of Infinity + AddHtmlLocalized(348, 236, 250, 60, 1075201, 0x7FFF); // Quiver of Infinity AddImageTiledButton(14, 300, 0x918, 0x919, 0x76, GumpButtonType.Reply, 0, 0x2A91, 0x0, 25, 5); AddTooltip(1075986); - AddHtmlLocalized(98, 300, 250, 60, 1074797, 0x7FFF, false, false); // Bone Throne, Bone Couch
and Bone Table + AddHtmlLocalized(98, 300, 250, 60, 1074797, 0x7FFF); // Bone Throne, Bone Couch
and Bone Table AddImageTiledButton(264, 300, 0x918, 0x919, 0x77, GumpButtonType.Reply, 0, 0x2A99, 0x0, 18, 1); AddTooltip(1075987); - AddHtmlLocalized(348, 300, 250, 60, 1078146, 0x7FFF, false, false); // Creepy Portraits + AddHtmlLocalized(348, 300, 250, 60, 1078146, 0x7FFF); // Creepy Portraits AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 3); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next AddPage(3); AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back AddImageTiledButton(14, 44, 0x918, 0x919, 0x78, GumpButtonType.Reply, 0, 0x2A71, 0x0, 13, 5); AddTooltip(1075988); - AddHtmlLocalized(98, 44, 250, 60, 1074799, 0x7FFF, false, false); // Mounted Pixies (5) + AddHtmlLocalized(98, 44, 250, 60, 1074799, 0x7FFF); // Mounted Pixies (5) AddImageTiledButton(264, 44, 0x918, 0x919, 0x79, GumpButtonType.Reply, 0, 0x2A98, 0x0, 26, 1); AddTooltip(1075990); - AddHtmlLocalized(348, 44, 250, 60, 1074800, 0x7FFF, false, false); // Haunted Mirror + AddHtmlLocalized(348, 44, 250, 60, 1074800, 0x7FFF); // Haunted Mirror AddImageTiledButton(14, 108, 0x918, 0x919, 0x7A, GumpButtonType.Reply, 0, 0x2A92, 0x0, 18, 1); AddTooltip(1075989); - AddHtmlLocalized(98, 108, 250, 60, 1074801, 0x7FFF, false, false); // Bed of Nails + AddHtmlLocalized(98, 108, 250, 60, 1074801, 0x7FFF); // Bed of Nails AddImageTiledButton(264, 108, 0x918, 0x919, 0x7B, GumpButtonType.Reply, 0, 0x2AB8, 0x0, 18, 1); AddTooltip(1075991); - AddHtmlLocalized(348, 108, 250, 60, 1074818, 0x7FFF, false, false); // Sacrificial Altar + AddHtmlLocalized(348, 108, 250, 60, 1074818, 0x7FFF); // Sacrificial Altar AddImageTiledButton(14, 172, 0x918, 0x919, 0x7C, GumpButtonType.Reply, 0, 0x3F26, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(98, 172, 250, 60, 1076257, 0x7FFF, false, false); // Broken Covered Chair + AddHtmlLocalized(98, 172, 250, 60, 1076257, 0x7FFF); // Broken Covered Chair AddImageTiledButton(264, 172, 0x918, 0x919, 0x7D, GumpButtonType.Reply, 0, 0x3F22, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(348, 172, 250, 60, 1076258, 0x7FFF, false, false); // Broken Bookcase + AddHtmlLocalized(348, 172, 250, 60, 1076258, 0x7FFF); // Broken Bookcase AddImageTiledButton(14, 236, 0x918, 0x919, 0x7E, GumpButtonType.Reply, 0, 0x3F24, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(98, 236, 250, 60, 1076259, 0x7FFF, false, false); // Standing Broken Chair + AddHtmlLocalized(98, 236, 250, 60, 1076259, 0x7FFF); // Standing Broken Chair AddImageTiledButton(264, 236, 0x918, 0x919, 0x7F, GumpButtonType.Reply, 0, 0x3F25, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(348, 236, 250, 60, 1076260, 0x7FFF, false, false); // Broken Vanity + AddHtmlLocalized(348, 236, 250, 60, 1076260, 0x7FFF); // Broken Vanity AddImageTiledButton(14, 300, 0x918, 0x919, 0x80, GumpButtonType.Reply, 0, 0x3F23, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(98, 300, 250, 60, 1076261, 0x7FFF, false, false); // Broken Chest of Drawers + AddHtmlLocalized(98, 300, 250, 60, 1076261, 0x7FFF); // Broken Chest of Drawers AddImageTiledButton(264, 300, 0x918, 0x919, 0x81, GumpButtonType.Reply, 0, 0x3F21, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(348, 300, 250, 60, 1076262, 0x7FFF, false, false); // Broken Armoire + AddHtmlLocalized(348, 300, 250, 60, 1076262, 0x7FFF); // Broken Armoire AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 4); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next AddPage(4); AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 3); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back AddImageTiledButton(14, 44, 0x918, 0x919, 0x82, GumpButtonType.Reply, 0, 0x3F0B, 0x0, 18, 8); AddTooltip(1076610); - AddHtmlLocalized(98, 44, 250, 60, 1076263, 0x7FFF, false, false); // Broken Bed + AddHtmlLocalized(98, 44, 250, 60, 1076263, 0x7FFF); // Broken Bed AddImageTiledButton(264, 44, 0x918, 0x919, 0x83, GumpButtonType.Reply, 0, 0xC19, 0x0, 13, 8); AddTooltip(1076610); - AddHtmlLocalized(348, 44, 250, 60, 1076264, 0x7FFF, false, false); // Broken Fallen Chair + AddHtmlLocalized(348, 44, 250, 60, 1076264, 0x7FFF); // Broken Fallen Chair AddImageTiledButton(14, 108, 0x918, 0x919, 0x84, GumpButtonType.Reply, 0, 0x3DAA, 0x0, 20, -3); AddTooltip(1076611); - AddHtmlLocalized(98, 108, 250, 60, 1076265, 0x7FFF, false, false); // Suit of Gold Armor + AddHtmlLocalized(98, 108, 250, 60, 1076265, 0x7FFF); // Suit of Gold Armor AddImageTiledButton(264, 108, 0x918, 0x919, 0x85, GumpButtonType.Reply, 0, 0x151C, 0x0, -20, -3); AddTooltip(1076612); - AddHtmlLocalized(348, 108, 250, 60, 1076266, 0x7FFF, false, false); // Suit of Silver Armor + AddHtmlLocalized(348, 108, 250, 60, 1076266, 0x7FFF); // Suit of Silver Armor AddImageTiledButton(14, 172, 0x918, 0x919, 0x86, GumpButtonType.Reply, 0, 0x3DB1, 0x0, 18, 8); AddTooltip(1076613); - AddHtmlLocalized(98, 172, 250, 60, 1076267, 0x7FFF, false, false); // Boiling Cauldron + AddHtmlLocalized(98, 172, 250, 60, 1076267, 0x7FFF); // Boiling Cauldron AddImageTiledButton(264, 172, 0x918, 0x919, 0x87, GumpButtonType.Reply, 0, 0x3F27, 0x0, 18, 8); AddTooltip(1076614); - AddHtmlLocalized(348, 172, 250, 60, 1024656, 0x7FFF, false, false); // Guillotine + AddHtmlLocalized(348, 172, 250, 60, 1024656, 0x7FFF); // Guillotine AddImageTiledButton(14, 236, 0x918, 0x919, 0x88, GumpButtonType.Reply, 0, 0x3F0C, 0x0, 18, 8); AddTooltip(1076615); - AddHtmlLocalized(98, 236, 250, 60, 1076268, 0x7FFF, false, false); // Cherry Blossom Tree + AddHtmlLocalized(98, 236, 250, 60, 1076268, 0x7FFF); // Cherry Blossom Tree AddImageTiledButton(264, 236, 0x918, 0x919, 0x89, GumpButtonType.Reply, 0, 0x3F07, 0x0, 18, 8); AddTooltip(1076616); - AddHtmlLocalized(348, 236, 250, 60, 1076269, 0x7FFF, false, false); // Apple Tree + AddHtmlLocalized(348, 236, 250, 60, 1076269, 0x7FFF); // Apple Tree AddImageTiledButton(14, 300, 0x918, 0x919, 0x8A, GumpButtonType.Reply, 0, 0x3F16, 0x0, 18, 8); AddTooltip(1076617); - AddHtmlLocalized(98, 300, 250, 60, 1076270, 0x7FFF, false, false); // Peach Tree + AddHtmlLocalized(98, 300, 250, 60, 1076270, 0x7FFF); // Peach Tree AddImageTiledButton(264, 300, 0x918, 0x919, 0x8B, GumpButtonType.Reply, 0, 0x3F12, 0x0, 18, 8); AddTooltip(1076618); - AddHtmlLocalized(348, 300, 250, 60, 1076271, 0x7FFF, false, false); // Hanging Axes + AddHtmlLocalized(348, 300, 250, 60, 1076271, 0x7FFF); // Hanging Axes AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 5); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next AddPage(5); AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 4); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back AddImageTiledButton(14, 44, 0x918, 0x919, 0x8C, GumpButtonType.Reply, 0, 0x3F13, 0x0, 18, 8); AddTooltip(1076619); - AddHtmlLocalized(98, 44, 250, 60, 1076272, 0x7FFF, false, false); // Hanging Swords + AddHtmlLocalized(98, 44, 250, 60, 1076272, 0x7FFF); // Hanging Swords AddImageTiledButton(264, 44, 0x918, 0x919, 0x8D, GumpButtonType.Reply, 0, 0x3F09, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(348, 44, 250, 60, 1076273, 0x7FFF, false, false); // Blue fancy rug + AddHtmlLocalized(348, 44, 250, 60, 1076273, 0x7FFF); // Blue fancy rug AddImageTiledButton(14, 108, 0x918, 0x919, 0x8E, GumpButtonType.Reply, 0, 0x3F0E, 0x0, 18, 8); AddTooltip(1076621); - AddHtmlLocalized(98, 108, 250, 60, 1076274, 0x7FFF, false, false); // Coffin + AddHtmlLocalized(98, 108, 250, 60, 1076274, 0x7FFF); // Coffin AddImageTiledButton(264, 108, 0x918, 0x919, 0x8F, GumpButtonType.Reply, 0, 0x3F1F, 0x0, 18, 8); AddTooltip(1076623); - AddHtmlLocalized(348, 108, 250, 60, 1074027, 0x7FFF, false, false); // Vanity + AddHtmlLocalized(348, 108, 250, 60, 1074027, 0x7FFF); // Vanity AddImageTiledButton(14, 172, 0x918, 0x919, 0x90, GumpButtonType.Reply, 0, 0x118B, 0x0, -4, -9); AddTooltip(1076624); - AddHtmlLocalized(98, 172, 250, 60, 1076635, 0x7FFF, false, false); // Table With A Purple
Tablecloth + AddHtmlLocalized(98, 172, 250, 60, 1076635, 0x7FFF); // Table With A Purple
Tablecloth AddImageTiledButton(264, 172, 0x918, 0x919, 0x91, GumpButtonType.Reply, 0, 0x118C, 0x0, -4, -9); AddTooltip(1076624); - AddHtmlLocalized(348, 172, 250, 60, 1076636, 0x7FFF, false, false); // Table With A Blue
Tablecloth + AddHtmlLocalized(348, 172, 250, 60, 1076636, 0x7FFF); // Table With A Blue
Tablecloth AddImageTiledButton(14, 236, 0x918, 0x919, 0x92, GumpButtonType.Reply, 0, 0x118D, 0x0, -4, -9); AddTooltip(1076624); - AddHtmlLocalized(98, 236, 250, 60, 1076637, 0x7FFF, false, false); // Table With A Red
Tablecloth + AddHtmlLocalized(98, 236, 250, 60, 1076637, 0x7FFF); // Table With A Red
Tablecloth AddImageTiledButton(264, 236, 0x918, 0x919, 0x93, GumpButtonType.Reply, 0, 0x118E, 0x0, -4, -9); AddTooltip(1076624); - AddHtmlLocalized(348, 236, 250, 60, 1076638, 0x7FFF, false, false); // Table With An Orange
Tablecloth + AddHtmlLocalized(348, 236, 250, 60, 1076638, 0x7FFF); // Table With An Orange
Tablecloth AddImageTiledButton(14, 300, 0x918, 0x919, 0x94, GumpButtonType.Reply, 0, 0x3F1E, 0x0, 18, 8); AddTooltip(1076625); - AddHtmlLocalized(98, 300, 250, 60, 1076279, 0x7FFF, false, false); // Unmade Bed + AddHtmlLocalized(98, 300, 250, 60, 1076279, 0x7FFF); // Unmade Bed AddImageTiledButton(264, 300, 0x918, 0x919, 0x95, GumpButtonType.Reply, 0, 0x3F0F, 0x0, 18, 8); AddTooltip(1076626); - AddHtmlLocalized(348, 300, 250, 60, 1076280, 0x7FFF, false, false); // Curtains + AddHtmlLocalized(348, 300, 250, 60, 1076280, 0x7FFF); // Curtains AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 6); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next AddPage(6); AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 5); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back AddImageTiledButton(14, 44, 0x918, 0x919, 0x96, GumpButtonType.Reply, 0, 0x1E34, 0x0, 18, -17); AddTooltip(1076627); - AddHtmlLocalized(98, 44, 250, 60, 1076281, 0x7FFF, false, false); // Scarecrow + AddHtmlLocalized(98, 44, 250, 60, 1076281, 0x7FFF); // Scarecrow AddImageTiledButton(264, 44, 0x918, 0x919, 0x97, GumpButtonType.Reply, 0, 0xA0C, 0x0, 18, 8); AddTooltip(1076628); - AddHtmlLocalized(348, 44, 250, 60, 1076282, 0x7FFF, false, false); // Wall Torch + AddHtmlLocalized(348, 44, 250, 60, 1076282, 0x7FFF); // Wall Torch AddImageTiledButton(14, 108, 0x918, 0x919, 0x98, GumpButtonType.Reply, 0, 0x3F10, 0x0, 18, 9); AddTooltip(1076629); - AddHtmlLocalized(98, 108, 250, 60, 1076283, 0x7FFF, false, false); // Fountain + AddHtmlLocalized(98, 108, 250, 60, 1076283, 0x7FFF); // Fountain AddImageTiledButton(264, 108, 0x918, 0x919, 0x99, GumpButtonType.Reply, 0, 0x3F19, 0x0, 18, 8); AddTooltip(1076630); - AddHtmlLocalized(348, 108, 250, 60, 1076284, 0x7FFF, false, false); // Statue + AddHtmlLocalized(348, 108, 250, 60, 1076284, 0x7FFF); // Statue AddImageTiledButton(14, 172, 0x918, 0x919, 0x9A, GumpButtonType.Reply, 0, 0x1EA5, 0x0, 5, -25); AddTooltip(1076631); - AddHtmlLocalized(98, 172, 250, 60, 1076285, 0x7FFF, false, false); // Large Fish Net + AddHtmlLocalized(98, 172, 250, 60, 1076285, 0x7FFF); // Large Fish Net AddImageTiledButton(264, 172, 0x918, 0x919, 0x9B, GumpButtonType.Reply, 0, 0x1EA3, 0x0, 18, -27); AddTooltip(1076632); - AddHtmlLocalized(348, 172, 250, 60, 1076286, 0x7FFF, false, false); // Small Fish Net + AddHtmlLocalized(348, 172, 250, 60, 1076286, 0x7FFF); // Small Fish Net AddImageTiledButton(14, 236, 0x918, 0x919, 0x9C, GumpButtonType.Reply, 0, 0x2FDF, 0x0, 18, -36); AddTooltip(1076633); - AddHtmlLocalized(98, 236, 250, 60, 1076287, 0x7FFF, false, false); // Ladder + AddHtmlLocalized(98, 236, 250, 60, 1076287, 0x7FFF); // Ladder AddImageTiledButton(264, 236, 0x918, 0x919, 0x9D, GumpButtonType.Reply, 0, 0x3F15, 0x0, 18, 8); AddTooltip(1076622); - AddHtmlLocalized(348, 236, 250, 60, 1076288, 0x7FFF, false, false); // Iron Maiden + AddHtmlLocalized(348, 236, 250, 60, 1076288, 0x7FFF); // Iron Maiden AddImageTiledButton(14, 300, 0x918, 0x919, 0x9E, GumpButtonType.Reply, 0, 0x3F0A, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(98, 300, 250, 60, 1076585, 0x7FFF, false, false); // Blue plain rug + AddHtmlLocalized(98, 300, 250, 60, 1076585, 0x7FFF); // Blue plain rug AddImageTiledButton(264, 300, 0x918, 0x919, 0x9F, GumpButtonType.Reply, 0, 0x3F11, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(348, 300, 250, 60, 1076586, 0x7FFF, false, false); // Golden decorative rug + AddHtmlLocalized(348, 300, 250, 60, 1076586, 0x7FFF); // Golden decorative rug AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 7); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next AddPage(7); AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 6); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back AddImageTiledButton(14, 44, 0x918, 0x919, 0xA0, GumpButtonType.Reply, 0, 0x3F0D, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(98, 44, 250, 60, 1076587, 0x7FFF, false, false); // Cinnamon fancy rug + AddHtmlLocalized(98, 44, 250, 60, 1076587, 0x7FFF); // Cinnamon fancy rug AddImageTiledButton(264, 44, 0x918, 0x919, 0xA1, GumpButtonType.Reply, 0, 0x3F18, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(348, 44, 250, 60, 1076588, 0x7FFF, false, false); // Red plain rug + AddHtmlLocalized(348, 44, 250, 60, 1076588, 0x7FFF); // Red plain rug AddImageTiledButton(14, 108, 0x918, 0x919, 0xA2, GumpButtonType.Reply, 0, 0x3F08, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(98, 108, 250, 60, 1076589, 0x7FFF, false, false); // Blue decorative rug + AddHtmlLocalized(98, 108, 250, 60, 1076589, 0x7FFF); // Blue decorative rug AddImageTiledButton(264, 108, 0x918, 0x919, 0xA3, GumpButtonType.Reply, 0, 0x3F17, 0x0, 18, 8); AddTooltip(1076620); - AddHtmlLocalized(348, 108, 250, 60, 1076590, 0x7FFF, false, false); // Pink fancy rug + AddHtmlLocalized(348, 108, 250, 60, 1076590, 0x7FFF); // Pink fancy rug AddImageTiledButton(14, 172, 0x918, 0x919, 0xA4, GumpButtonType.Reply, 0, 0x312A, 0x0, 18, 8); AddTooltip(1076615); - AddHtmlLocalized(98, 172, 250, 60, 1076784, 0x7FFF, false, false); // Cherry Blossom Trunk + AddHtmlLocalized(98, 172, 250, 60, 1076784, 0x7FFF); // Cherry Blossom Trunk AddImageTiledButton(264, 172, 0x918, 0x919, 0xA5, GumpButtonType.Reply, 0, 0x3128, 0x0, 18, 8); AddTooltip(1076616); - AddHtmlLocalized(348, 172, 250, 60, 1076785, 0x7FFF, false, false); // Apple Trunk + AddHtmlLocalized(348, 172, 250, 60, 1076785, 0x7FFF); // Apple Trunk AddImageTiledButton(14, 236, 0x918, 0x919, 0xA6, GumpButtonType.Reply, 0, 0x3129, 0x0, 18, 8); AddTooltip(1076617); - AddHtmlLocalized(98, 236, 250, 60, 1076786, 0x7FFF, false, false); // Peach Trunk + AddHtmlLocalized(98, 236, 250, 60, 1076786, 0x7FFF); // Peach Trunk } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Token == null || m_Token.Deleted || info.ButtonID == 0) + if (m_Token?.Deleted != false || info.ButtonID == 0) return; List types = new List(); @@ -575,4 +575,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/HonorSelf.cs b/Scripts/Gumps/HonorSelf.cs index 44f7b5f3f..cb7599b39 100644 --- a/Scripts/Gumps/HonorSelf.cs +++ b/Scripts/Gumps/HonorSelf.cs @@ -11,10 +11,10 @@ namespace Server.Gumps { m_from = from; AddBackground(0, 0, 245, 145, 9250); - AddButton(157, 101, 247, 248, 1, GumpButtonType.Reply, 0); - AddButton(81, 100, 241, 248, 0, GumpButtonType.Reply, 0); + AddButton(157, 101, 247, 248, 1); + AddButton(81, 100, 241, 248, 0); AddHtml(21, 20, 203, 70, @"Are you sure you want to use -honor points on yourself?", true, false); +honor points on yourself?", true); } public override void OnResponse(NetState sender, RelayInfo info) @@ -22,4 +22,4 @@ honor points on yourself?", true, false); if (info.ButtonID == 1) HonorVirtue.ActivateEmbrace(m_from); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/HouseDemolishGump.cs b/Scripts/Gumps/HouseDemolishGump.cs index 966df450a..5860a8b6c 100644 --- a/Scripts/Gumps/HouseDemolishGump.cs +++ b/Scripts/Gumps/HouseDemolishGump.cs @@ -27,7 +27,7 @@ namespace Server.Gumps AddImageTiled(10, 10, 400, 20, 2624); AddAlphaRegion(10, 10, 400, 20); - AddHtmlLocalized(10, 10, 400, 20, 1060635, 30720, false, false); //
WARNING
+ AddHtmlLocalized(10, 10, 400, 20, 1060635, 30720); //
WARNING
AddImageTiled(10, 40, 400, 200, 2624); AddAlphaRegion(10, 40, 400, 200); @@ -43,11 +43,11 @@ namespace Server.Gumps AddImageTiled(10, 250, 400, 20, 2624); AddAlphaRegion(10, 250, 400, 20); - AddButton(10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767, false, false); // OKAY + AddButton(10, 250, 4005, 4007, 1); + AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767); // OKAY - AddButton(210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767, false, false); // CANCEL + AddButton(210, 250, 4005, 4007, 0); + AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -167,4 +167,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/HouseGump.cs b/Scripts/Gumps/HouseGump.cs index 8d51777e0..0f914fa30 100644 --- a/Scripts/Gumps/HouseGump.cs +++ b/Scripts/Gumps/HouseGump.cs @@ -22,14 +22,14 @@ namespace Server.Gumps AddBackground(0, 0, 420, 430, 5054); AddBackground(10, 10, 400, 410, 3000); - AddButton(20, 388, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 388, 300, 20, 1011104, false, false); // Return to previous menu + AddButton(20, 388, 4005, 4007, 0); + AddHtmlLocalized(55, 388, 300, 20, 1011104); // Return to previous menu - AddHtmlLocalized(20, 20, 350, 20, number, false, false); + AddHtmlLocalized(20, 20, 350, 20, number); if (list == null) return; - + for (int i = 0; i < list.Count; ++i) { if (i % 16 == 0) @@ -87,17 +87,17 @@ namespace Server.Gumps AddBackground(0, 0, 420, 430, 5054); AddBackground(10, 10, 400, 410, 3000); - AddButton(20, 388, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 388, 300, 20, 1011104, false, false); // Return to previous menu + AddButton(20, 388, 4005, 4007, 0); + AddHtmlLocalized(55, 388, 300, 20, 1011104); // Return to previous menu - AddButton(20, 365, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 365, 300, 20, 1011270, false, false); // Remove now! + AddButton(20, 365, 4005, 4007, 1); + AddHtmlLocalized(55, 365, 300, 20, 1011270); // Remove now! - AddHtmlLocalized(20, 20, 350, 20, number, false, false); + AddHtmlLocalized(20, 20, 350, 20, number); if (list == null) return; - + m_Copy = new List(list); for (int i = 0; i < list.Count; ++i) @@ -210,114 +210,113 @@ namespace Server.Gumps if (!isFriend) return; - AddHtmlLocalized(55, 103, 75, 20, 1011233, false, false); // INFO + AddHtmlLocalized(55, 103, 75, 20, 1011233); // INFO AddButton(20, 103, 4005, 4007, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(170, 103, 75, 20, 1011234, false, false); // FRIENDS + AddHtmlLocalized(170, 103, 75, 20, 1011234); // FRIENDS AddButton(135, 103, 4005, 4007, 0, GumpButtonType.Page, 2); - AddHtmlLocalized(295, 103, 75, 20, 1011235, false, false); // OPTIONS + AddHtmlLocalized(295, 103, 75, 20, 1011235); // OPTIONS AddButton(260, 103, 4005, 4007, 0, GumpButtonType.Page, 3); - AddHtmlLocalized(295, 390, 75, 20, 1011441, false, false); // EXIT - AddButton(260, 390, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(295, 390, 75, 20, 1011441); // EXIT + AddButton(260, 390, 4005, 4007, 0); - AddHtmlLocalized(55, 390, 200, 20, 1011236, false, false); // Change this house's name! - AddButton(20, 390, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 390, 200, 20, 1011236); // Change this house's name! + AddButton(20, 390, 4005, 4007, 1); // Info page AddPage(1); - AddHtmlLocalized(20, 135, 100, 20, 1011242, false, false); // Owned by: - AddHtml(120, 135, 100, 20, GetOwnerName(), false, false); + AddHtmlLocalized(20, 135, 100, 20, 1011242); // Owned by: + AddHtml(120, 135, 100, 20, GetOwnerName()); - AddHtmlLocalized(20, 170, 275, 20, 1011237, false, false); // Number of locked down items: - AddHtml(320, 170, 50, 20, m_House.LockDownCount.ToString(), false, false); + AddHtmlLocalized(20, 170, 275, 20, 1011237); // Number of locked down items: + AddHtml(320, 170, 50, 20, m_House.LockDownCount.ToString()); - AddHtmlLocalized(20, 190, 275, 20, 1011238, false, false); // Maximum locked down items: - AddHtml(320, 190, 50, 20, m_House.MaxLockDowns.ToString(), false, false); + AddHtmlLocalized(20, 190, 275, 20, 1011238); // Maximum locked down items: + AddHtml(320, 190, 50, 20, m_House.MaxLockDowns.ToString()); - AddHtmlLocalized(20, 210, 275, 20, 1011239, false, false); // Number of secure containers: - AddHtml(320, 210, 50, 20, m_House.SecureCount.ToString(), false, false); + AddHtmlLocalized(20, 210, 275, 20, 1011239); // Number of secure containers: + AddHtml(320, 210, 50, 20, m_House.SecureCount.ToString()); - AddHtmlLocalized(20, 230, 275, 20, 1011240, false, false); // Maximum number of secure containers: - AddHtml(320, 230, 50, 20, m_House.MaxSecures.ToString(), false, false); + AddHtmlLocalized(20, 230, 275, 20, 1011240); // Maximum number of secure containers: + AddHtml(320, 230, 50, 20, m_House.MaxSecures.ToString()); - AddHtmlLocalized(20, 260, 400, 20, 1018032, false, false); // This house is properly placed. - AddHtmlLocalized(20, 280, 400, 20, 1018035, false, false); // This house is of modern design. + AddHtmlLocalized(20, 260, 400, 20, 1018032); // This house is properly placed. + AddHtmlLocalized(20, 280, 400, 20, 1018035); // This house is of modern design. if (m_House.Public) { // TODO: Validate exact placement - AddHtmlLocalized(20, 305, 275, 20, 1011241, false, false); // Number of visits this building has had - AddHtml(320, 305, 50, 20, m_House.Visits.ToString(), false, false); + AddHtmlLocalized(20, 305, 275, 20, 1011241); // Number of visits this building has had + AddHtml(320, 305, 50, 20, m_House.Visits.ToString()); } // Friends page AddPage(2); - AddHtmlLocalized(45, 130, 150, 20, 1011266, false, false); // List of co-owners - AddButton(20, 130, 2714, 2715, 2, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 130, 150, 20, 1011266); // List of co-owners + AddButton(20, 130, 2714, 2715, 2); - AddHtmlLocalized(45, 150, 150, 20, 1011267, false, false); // Add a co-owner - AddButton(20, 150, 2714, 2715, 3, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 150, 150, 20, 1011267); // Add a co-owner + AddButton(20, 150, 2714, 2715, 3); - AddHtmlLocalized(45, 170, 150, 20, 1018036, false, false); // Remove a co-owner - AddButton(20, 170, 2714, 2715, 4, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 170, 150, 20, 1018036); // Remove a co-owner + AddButton(20, 170, 2714, 2715, 4); - AddHtmlLocalized(45, 190, 150, 20, 1011268, false, false); // Clear co-owner list - AddButton(20, 190, 2714, 2715, 5, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 190, 150, 20, 1011268); // Clear co-owner list + AddButton(20, 190, 2714, 2715, 5); - AddHtmlLocalized(225, 130, 155, 20, 1011243, false, false); // List of Friends - AddButton(200, 130, 2714, 2715, 6, GumpButtonType.Reply, 0); + AddHtmlLocalized(225, 130, 155, 20, 1011243); // List of Friends + AddButton(200, 130, 2714, 2715, 6); - AddHtmlLocalized(225, 150, 155, 20, 1011244, false, false); // Add a Friend - AddButton(200, 150, 2714, 2715, 7, GumpButtonType.Reply, 0); + AddHtmlLocalized(225, 150, 155, 20, 1011244); // Add a Friend + AddButton(200, 150, 2714, 2715, 7); - AddHtmlLocalized(225, 170, 155, 20, 1018037, false, false); // Remove a Friend - AddButton(200, 170, 2714, 2715, 8, GumpButtonType.Reply, 0); + AddHtmlLocalized(225, 170, 155, 20, 1018037); // Remove a Friend + AddButton(200, 170, 2714, 2715, 8); - AddHtmlLocalized(225, 190, 155, 20, 1011245, false, false); // Clear Friends list - AddButton(200, 190, 2714, 2715, 9, GumpButtonType.Reply, 0); + AddHtmlLocalized(225, 190, 155, 20, 1011245); // Clear Friends list + AddButton(200, 190, 2714, 2715, 9); - AddHtmlLocalized(120, 215, 280, 20, 1011258, false, false); // Ban someone from the house - AddButton(95, 215, 2714, 2715, 10, GumpButtonType.Reply, 0); + AddHtmlLocalized(120, 215, 280, 20, 1011258); // Ban someone from the house + AddButton(95, 215, 2714, 2715, 10); - AddHtmlLocalized(120, 235, 280, 20, 1011259, false, false); // Eject someone from the house - AddButton(95, 235, 2714, 2715, 11, GumpButtonType.Reply, 0); + AddHtmlLocalized(120, 235, 280, 20, 1011259); // Eject someone from the house + AddButton(95, 235, 2714, 2715, 11); - AddHtmlLocalized(120, 255, 280, 20, 1011260, false, false); // View a list of banned people - AddButton(95, 255, 2714, 2715, 12, GumpButtonType.Reply, 0); + AddHtmlLocalized(120, 255, 280, 20, 1011260); // View a list of banned people + AddButton(95, 255, 2714, 2715, 12); - AddHtmlLocalized(120, 275, 280, 20, 1011261, false, false); // Lift a ban - AddButton(95, 275, 2714, 2715, 13, GumpButtonType.Reply, 0); + AddHtmlLocalized(120, 275, 280, 20, 1011261); // Lift a ban + AddButton(95, 275, 2714, 2715, 13); // Options page AddPage(3); - AddHtmlLocalized(45, 150, 355, 30, 1011248, false, false); // Transfer ownership of the house - AddButton(20, 150, 2714, 2715, 14, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 150, 355, 30, 1011248); // Transfer ownership of the house + AddButton(20, 150, 2714, 2715, 14); - AddHtmlLocalized(45, 180, 355, 30, 1011249, false, false); // Demolish house and get deed back - AddButton(20, 180, 2714, 2715, 15, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 180, 355, 30, 1011249); // Demolish house and get deed back + AddButton(20, 180, 2714, 2715, 15); if (!m_House.Public) { - AddHtmlLocalized(45, 210, 355, 30, 1011247, false, false); // Change the house locks - AddButton(20, 210, 2714, 2715, 16, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 210, 355, 30, 1011247); // Change the house locks + AddButton(20, 210, 2714, 2715, 16); - AddHtmlLocalized(45, 240, 350, 90, 1011253, false, - false); // Declare this building to be public. This will make your front door unlockable. - AddButton(20, 240, 2714, 2715, 17, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 240, 350, 90, 1011253); // Declare this building to be public. This will make your front door unlockable. + AddButton(20, 240, 2714, 2715, 17); } else { //AddHtmlLocalized( 45, 280, 350, 30, 1011250, false, false ); // Change the sign type - AddHtmlLocalized(45, 210, 350, 30, 1011250, false, false); // Change the sign type + AddHtmlLocalized(45, 210, 350, 30, 1011250); // Change the sign type AddButton(20, 210, 2714, 2715, 0, GumpButtonType.Page, 4); - AddHtmlLocalized(45, 240, 350, 30, 1011252, false, false); // Declare this building to be private. - AddButton(20, 240, 2714, 2715, 17, GumpButtonType.Reply, 0); + AddHtmlLocalized(45, 240, 350, 30, 1011252); // Declare this building to be private. + AddButton(20, 240, 2714, 2715, 17); // Change the sign type AddPage(4); @@ -328,11 +327,11 @@ namespace Server.Gumps AddItem(60 + i / 4 * 50, 130 + i % 4 * 35, 2980 + i * 2); } - AddHtmlLocalized(200, 305, 129, 20, 1011254, false, false); // Guild sign choices + AddHtmlLocalized(200, 305, 129, 20, 1011254); // Guild sign choices AddButton(350, 305, 252, 253, 0, GumpButtonType.Page, 5); - AddHtmlLocalized(200, 340, 355, 30, 1011277, false, false); // Okay that is fine. - AddButton(350, 340, 4005, 4007, 18, GumpButtonType.Reply, 0); + AddHtmlLocalized(200, 340, 355, 30, 1011277); // Okay that is fine. + AddButton(350, 340, 4005, 4007, 18); AddPage(5); @@ -342,11 +341,11 @@ namespace Server.Gumps AddItem(60 + i / 5 * 50, 130 + i % 5 * 35, 3028 + i * 2); } - AddHtmlLocalized(200, 305, 129, 20, 1011255, false, false); // Shop sign choices + AddHtmlLocalized(200, 305, 129, 20, 1011255); // Shop sign choices AddButton(350, 305, 250, 251, 0, GumpButtonType.Page, 4); - AddHtmlLocalized(200, 340, 355, 30, 1011277, false, false); // Okay that is fine. - AddButton(350, 340, 4005, 4007, 18, GumpButtonType.Reply, 0); + AddHtmlLocalized(200, 340, 355, 30, 1011277); // Okay that is fine. + AddButton(350, 340, 4005, 4007, 18); } } @@ -738,4 +737,4 @@ namespace Server.Prompts } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/HouseGumpAOS.cs b/Scripts/Gumps/HouseGumpAOS.cs index 104294f65..bce001852 100644 --- a/Scripts/Gumps/HouseGumpAOS.cs +++ b/Scripts/Gumps/HouseGumpAOS.cs @@ -118,7 +118,7 @@ namespace Server.Gumps for (int i = 0, y = (114 - lines.Count * 14) / 2; i < lines.Count; ++i, y += 14) { - string s = (string)lines[i]; + string s = lines[i]; AddLabel(10 + (160 - s.Length * 8) / 2, y, 0, s); } @@ -126,7 +126,7 @@ namespace Server.Gumps if (page == HouseGumpPageAOS.Vendors) { - AddHtmlLocalized(10, 120, 400, 20, 1062428, LabelColor, false, false); //
SHOPS
+ AddHtmlLocalized(10, 120, 400, 20, 1062428, LabelColor); //
SHOPS
AddList(house.AvailableVendorsFor(from), 1, false, false, from); return; @@ -156,52 +156,44 @@ namespace Server.Gumps { case HouseGumpPageAOS.Information: { - AddHtmlLocalized(20, 130, 200, 20, 1011242, LabelColor, false, false); // Owned By: + AddHtmlLocalized(20, 130, 200, 20, 1011242, LabelColor); // Owned By: AddLabel(210, 130, LabelHue, GetOwnerName()); - AddHtmlLocalized(20, 170, 380, 20, 1018032, SelectedColor, false, - false); // This house is properly placed. - AddHtmlLocalized(20, 190, 380, 20, 1018035, SelectedColor, false, - false); // This house is of modern design. - AddHtmlLocalized(20, 210, 380, 20, house is HouseFoundation ? 1060681 : 1060680, SelectedColor, false, - false); // This is a (pre | custom)-built house. - AddHtmlLocalized(20, 230, 380, 20, house.Public ? 1060678 : 1060679, SelectedColor, false, - false); // This house is (private | open to the public). + AddHtmlLocalized(20, 170, 380, 20, 1018032, SelectedColor); // This house is properly placed. + AddHtmlLocalized(20, 190, 380, 20, 1018035, SelectedColor); // This house is of modern design. + AddHtmlLocalized(20, 210, 380, 20, house is HouseFoundation ? 1060681 : 1060680, SelectedColor); // This is a (pre | custom)-built house. + AddHtmlLocalized(20, 230, 380, 20, house.Public ? 1060678 : 1060679, SelectedColor); // This house is (private | open to the public). switch (house.DecayType) { case DecayType.Ageless: case DecayType.AutoRefresh: { - AddHtmlLocalized(20, 250, 380, 20, 1062209, SelectedColor, false, - false); // This house is Automatically refreshed. + AddHtmlLocalized(20, 250, 380, 20, 1062209, SelectedColor); // This house is Automatically refreshed. break; } case DecayType.ManualRefresh: { - AddHtmlLocalized(20, 250, 380, 20, 1062208, SelectedColor, false, - false); // This house is Grandfathered. + AddHtmlLocalized(20, 250, 380, 20, 1062208, SelectedColor); // This house is Grandfathered. break; } case DecayType.Condemned: { - AddHtmlLocalized(20, 250, 380, 20, 1062207, WarningColor, false, - false); // This house is Condemned. + AddHtmlLocalized(20, 250, 380, 20, 1062207, WarningColor); // This house is Condemned. break; } } - AddHtmlLocalized(20, 290, 200, 20, 1060692, SelectedColor, false, false); // Built On: + AddHtmlLocalized(20, 290, 200, 20, 1060692, SelectedColor); // Built On: AddLabel(250, 290, LabelHue, GetDateTime(house.BuiltOn)); - AddHtmlLocalized(20, 310, 200, 20, 1060693, SelectedColor, false, false); // Last Traded: + AddHtmlLocalized(20, 310, 200, 20, 1060693, SelectedColor); // Last Traded: AddLabel(250, 310, LabelHue, GetDateTime(house.LastTraded)); - AddHtmlLocalized(20, 330, 200, 20, 1061793, SelectedColor, false, false); // House Value + AddHtmlLocalized(20, 330, 200, 20, 1061793, SelectedColor); // House Value AddLabel(250, 330, LabelHue, house.Price.ToString()); - AddHtmlLocalized(20, 360, 300, 20, 1011241, SelectedColor, false, - false); // Number of visits this building has had: + AddHtmlLocalized(20, 360, 300, 20, 1011241, SelectedColor); // Number of visits this building has had: AddLabel(350, 360, LabelHue, house.Visits.ToString()); break; @@ -225,14 +217,14 @@ namespace Server.Gumps AddButtonLabeled(210, 130, GetButtonID(3, 12), 1060695, isOwner); // Change to Private - AddHtmlLocalized(245, 150, 240, 20, 1060694, SelectedColor, false, false); // Change to Public + AddHtmlLocalized(245, 150, 240, 20, 1060694, SelectedColor); // Change to Public } else { AddButtonLabeled(10, 310, GetButtonID(3, 10), 1060699); // View Access List AddButtonLabeled(10, 330, GetButtonID(3, 11), 1060700); // Clear Access List - AddHtmlLocalized(245, 130, 240, 20, 1060695, SelectedColor, false, false); // Change to Private + AddHtmlLocalized(245, 130, 240, 20, 1060695, SelectedColor); // Change to Private AddButtonLabeled(210, 150, GetButtonID(3, 13), 1060694, isOwner); // Change to Public } @@ -241,8 +233,7 @@ namespace Server.Gumps } case HouseGumpPageAOS.Storage: { - AddHtmlLocalized(10, 130, 400, 20, 1060682, LabelColor, false, - false); //
HOUSE STORAGE SUMMARY
+ AddHtmlLocalized(10, 130, 400, 20, 1060682, LabelColor); //
HOUSE STORAGE SUMMARY
// This is not as OSI; storage changes not yet implemented @@ -258,11 +249,9 @@ namespace Server.Gumps AddHtmlLocalized( 10, 230, 275, 20, 1011240, LabelColor, false, false ); // Maximum number of secure containers: AddLabel( 310, 230, LabelHue, m_House.MaxSecures.ToString() );*/ - int fromSecures, fromVendors, fromLockdowns, fromMovingCrate; - int maxSecures = house.GetAosMaxSecures(); - int curSecures = house.GetAosCurSecures(out fromSecures, out fromVendors, out fromLockdowns, - out fromMovingCrate); + int curSecures = house.GetAosCurSecures(out int fromSecures, out int fromVendors, out int fromLockdowns, + out int fromMovingCrate); int maxLockdowns = house.GetAosMaxLockdowns(); int curLockdowns = house.GetAosCurLockdowns(); @@ -271,54 +260,54 @@ namespace Server.Gumps if (bonusStorage > 0) { - AddHtmlLocalized(10, 150, 300, 20, 1072519, LabelColor, false, false); // Increased Storage + AddHtmlLocalized(10, 150, 300, 20, 1072519, LabelColor); // Increased Storage AddLabel(310, 150, LabelHue, $"{bonusStorage}%"); } - AddHtmlLocalized(10, 170, 300, 20, 1060683, LabelColor, false, false); // Maximum Secure Storage + AddHtmlLocalized(10, 170, 300, 20, 1060683, LabelColor); // Maximum Secure Storage AddLabel(310, 170, LabelHue, maxSecures.ToString()); - AddHtmlLocalized(10, 190, 300, 20, 1060685, LabelColor, false, false); // Used by Moving Crate + AddHtmlLocalized(10, 190, 300, 20, 1060685, LabelColor); // Used by Moving Crate AddLabel(310, 190, LabelHue, fromMovingCrate.ToString()); - AddHtmlLocalized(10, 210, 300, 20, 1060686, LabelColor, false, false); // Used by Lockdowns + AddHtmlLocalized(10, 210, 300, 20, 1060686, LabelColor); // Used by Lockdowns AddLabel(310, 210, LabelHue, fromLockdowns.ToString()); if (BaseHouse.NewVendorSystem) { - AddHtmlLocalized(10, 230, 300, 20, 1060688, LabelColor, false, false); // Used by Secure Containers + AddHtmlLocalized(10, 230, 300, 20, 1060688, LabelColor); // Used by Secure Containers AddLabel(310, 230, LabelHue, fromSecures.ToString()); - AddHtmlLocalized(10, 250, 300, 20, 1060689, LabelColor, false, false); // Available Storage + AddHtmlLocalized(10, 250, 300, 20, 1060689, LabelColor); // Available Storage AddLabel(310, 250, LabelHue, Math.Max(maxSecures - curSecures, 0).ToString()); - AddHtmlLocalized(10, 290, 300, 20, 1060690, LabelColor, false, false); // Maximum Lockdowns + AddHtmlLocalized(10, 290, 300, 20, 1060690, LabelColor); // Maximum Lockdowns AddLabel(310, 290, LabelHue, maxLockdowns.ToString()); - AddHtmlLocalized(10, 310, 300, 20, 1060691, LabelColor, false, false); // Available Lockdowns + AddHtmlLocalized(10, 310, 300, 20, 1060691, LabelColor); // Available Lockdowns AddLabel(310, 310, LabelHue, Math.Max(maxLockdowns - curLockdowns, 0).ToString()); int maxVendors = house.GetNewVendorSystemMaxVendors(); int vendors = house.PlayerVendors.Count + house.VendorRentalContracts.Count; - AddHtmlLocalized(10, 350, 300, 20, 1062391, LabelColor, false, false); // Vendor Count + AddHtmlLocalized(10, 350, 300, 20, 1062391, LabelColor); // Vendor Count AddLabel(310, 350, LabelHue, vendors + " / " + maxVendors); } else { - AddHtmlLocalized(10, 230, 300, 20, 1060687, LabelColor, false, false); // Used by Vendors + AddHtmlLocalized(10, 230, 300, 20, 1060687, LabelColor); // Used by Vendors AddLabel(310, 230, LabelHue, fromVendors.ToString()); - AddHtmlLocalized(10, 250, 300, 20, 1060688, LabelColor, false, false); // Used by Secure Containers + AddHtmlLocalized(10, 250, 300, 20, 1060688, LabelColor); // Used by Secure Containers AddLabel(310, 250, LabelHue, fromSecures.ToString()); - AddHtmlLocalized(10, 270, 300, 20, 1060689, LabelColor, false, false); // Available Storage + AddHtmlLocalized(10, 270, 300, 20, 1060689, LabelColor); // Available Storage AddLabel(310, 270, LabelHue, Math.Max(maxSecures - curSecures, 0).ToString()); - AddHtmlLocalized(10, 330, 300, 20, 1060690, LabelColor, false, false); // Maximum Lockdowns + AddHtmlLocalized(10, 330, 300, 20, 1060690, LabelColor); // Maximum Lockdowns AddLabel(310, 330, LabelHue, maxLockdowns.ToString()); - AddHtmlLocalized(10, 350, 300, 20, 1060691, LabelColor, false, false); // Available Lockdowns + AddHtmlLocalized(10, 350, 300, 20, 1060691, LabelColor); // Available Lockdowns AddLabel(310, 350, LabelHue, Math.Max(maxLockdowns - curLockdowns, 0).ToString()); } @@ -360,7 +349,7 @@ namespace Server.Gumps int x = 50 + i % 3 * 100; int y = 180 + i / 3 * 80; - AddButton(x, y, 4005, 4007, GetButtonID(7, i), GumpButtonType.Reply, 0); + AddButton(x, y, 4005, 4007, GetButtonID(7, i)); AddItem(x + 20, y, m_HangerNumbers[i]); } @@ -373,7 +362,7 @@ namespace Server.Gumps int x = 15 + i % 5 * 80; int y = 180 + i / 5 * 100; - AddButton(x, y, 4005, 4007, GetButtonID(8, i), GumpButtonType.Reply, 0); + AddButton(x, y, 4005, 4007, GetButtonID(8, i)); AddItem(x + 25, y, m_FoundationNumbers[i]); } @@ -408,7 +397,7 @@ namespace Server.Gumps int x = 30 + j % 6 * 60; int y = 130 + j / 6 * 60; - AddButton(x, y, 4005, 4007, GetButtonID(9, index), GumpButtonType.Reply, 0); + AddButton(x, y, 4005, 4007, GetButtonID(9, index)); AddItem(x + 20, y, _HouseSigns[index++]); } } @@ -417,49 +406,49 @@ namespace Server.Gumps } case HouseGumpPageAOS.RemoveCoOwner: { - AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor, false, false); //
CO-OWNER LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor); //
CO-OWNER LIST
AddList(house.CoOwners, 10, false, true, from); break; } case HouseGumpPageAOS.ListCoOwner: { - AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor, false, false); //
CO-OWNER LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor); //
CO-OWNER LIST
AddList(house.CoOwners, -1, false, true, from); break; } case HouseGumpPageAOS.RemoveFriend: { - AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor, false, false); //
FRIENDS LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor); //
FRIENDS LIST
AddList(house.Friends, 11, false, true, from); break; } case HouseGumpPageAOS.ListFriend: { - AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor, false, false); //
FRIENDS LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor); //
FRIENDS LIST
AddList(house.Friends, -1, false, true, from); break; } case HouseGumpPageAOS.RemoveBan: { - AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor, false, false); //
BAN LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor); //
BAN LIST
AddList(house.Bans, 12, true, true, from); break; } case HouseGumpPageAOS.ListBan: { - AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor, false, false); //
BAN LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor); //
BAN LIST
AddList(house.Bans, -1, true, true, from); break; } case HouseGumpPageAOS.RemoveAccess: { - AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor, false, false); //
ACCESS LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor); //
ACCESS LIST
AddList(house.Access, 13, false, true, from); break; } case HouseGumpPageAOS.ListAccess: { - AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor, false, false); //
ACCESS LIST
+ AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor); //
ACCESS LIST
AddList(house.Access, -1, false, true, from); break; } @@ -478,7 +467,7 @@ namespace Server.Gumps int x = 15 + j % 8 * 50; int y = 130 + j / 8 * 110; - AddButton(x, y, 4005, 4007, GetButtonID(14, index), GumpButtonType.Reply, 0); + AddButton(x, y, 4005, 4007, GetButtonID(14, index)); AddItem(x + 10, y, m_PostNumbers[index++]); } } @@ -492,15 +481,10 @@ namespace Server.Gumps { Mobile m = m_House.Owner; - if (m == null || m.Deleted) + if (m?.Deleted != false) return "(unowned)"; - string name; - - if ((name = m.Name) == null || (name = name.Trim()).Length <= 0) - name = "(no name)"; - - return name; + return String.IsNullOrWhiteSpace(m.Name) ? "(no name)" : m.Name.Trim(); } private string GetDateTime(DateTime val) @@ -512,21 +496,16 @@ namespace Server.Gumps { bool isSelection = m_Page == page; - AddButton(x, y, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0); - AddHtmlLocalized(x + 45, y, 200, 20, number, isSelection ? SelectedColor : LabelColor, false, false); + AddButton(x, y, isSelection ? 4006 : 4005, 4007, buttonID); + AddHtmlLocalized(x + 45, y, 200, 20, number, isSelection ? SelectedColor : LabelColor); } - public void AddButtonLabeled(int x, int y, int buttonID, int number) - { - AddButtonLabeled(x, y, buttonID, number, true); - } - - public void AddButtonLabeled(int x, int y, int buttonID, int number, bool enabled) + public void AddButtonLabeled(int x, int y, int buttonID, int number, bool enabled = true) { if (enabled) - AddButton(x, y, 4005, 4007, buttonID, GumpButtonType.Reply, 0); + AddButton(x, y, 4005, 4007, buttonID); - AddHtmlLocalized(x + 35, y, 240, 20, number, enabled ? LabelColor : DisabledColor, false, false); + AddHtmlLocalized(x + 35, y, 240, 20, number, enabled ? LabelColor : DisabledColor); } public void AddList(List list, int button, bool accountOf, bool leadingStar, Mobile from) @@ -584,7 +563,7 @@ namespace Server.Gumps continue; if (button != -1) - AddButton(10 + xoffset, 150 + yoffset, 4005, 4007, GetButtonID(button, i), GumpButtonType.Reply, 0); + AddButton(10 + xoffset, 150 + yoffset, 4005, 4007, GetButtonID(button, i)); if (accountOf && m.Player && m.Account != null) name = "Account of " + name; @@ -698,7 +677,7 @@ namespace Server.Gumps if (e == null) return; - + int cost = e.Cost - house.Price; if (cost > 0) @@ -1351,7 +1330,7 @@ namespace Server.Gumps { if (isOwner && m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveCoOwner(from, (Mobile)m_List[index]); + m_House.RemoveCoOwner(from, m_List[index]); if (m_House.CoOwners.Count > 0) from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); @@ -1365,7 +1344,7 @@ namespace Server.Gumps { if (isCoOwner && m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveFriend(from, (Mobile)m_List[index]); + m_House.RemoveFriend(from, m_List[index]); if (m_House.Friends.Count > 0) from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); @@ -1379,7 +1358,7 @@ namespace Server.Gumps { if (m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveBan(from, (Mobile)m_List[index]); + m_House.RemoveBan(from, m_List[index]); if (m_House.Bans.Count > 0) from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); @@ -1393,7 +1372,7 @@ namespace Server.Gumps { if (m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveAccess(from, (Mobile)m_List[index]); + m_House.RemoveAccess(from, m_List[index]); if (m_House.Access.Count > 0) from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); @@ -1477,4 +1456,4 @@ namespace Server.Gumps return list; } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/HouseTransferGump.cs b/Scripts/Gumps/HouseTransferGump.cs index 7729d4f68..fc3926804 100644 --- a/Scripts/Gumps/HouseTransferGump.cs +++ b/Scripts/Gumps/HouseTransferGump.cs @@ -23,7 +23,7 @@ namespace Server.Gumps AddImageTiled(10, 10, 400, 20, 2624); AddAlphaRegion(10, 10, 400, 20); - AddHtmlLocalized(10, 10, 400, 20, 1060635, 30720, false, false); //
WARNING
+ AddHtmlLocalized(10, 10, 400, 20, 1060635, 30720); //
WARNING
AddImageTiled(10, 40, 400, 200, 2624); AddAlphaRegion(10, 40, 400, 200); @@ -46,11 +46,11 @@ namespace Server.Gumps AddImageTiled(10, 250, 400, 20, 2624); AddAlphaRegion(10, 250, 400, 20); - AddButton(10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767, false, false); // OKAY + AddButton(10, 250, 4005, 4007, 1); + AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767); // OKAY - AddButton(210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767, false, false); // CANCEL + AddButton(210, 250, 4005, 4007, 0); + AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) @@ -59,4 +59,4 @@ namespace Server.Gumps m_House.EndConfirmTransfer(m_From, m_To); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/NoticeGump.cs b/Scripts/Gumps/NoticeGump.cs index 9214929ea..af0ef55d6 100644 --- a/Scripts/Gumps/NoticeGump.cs +++ b/Scripts/Gumps/NoticeGump.cs @@ -21,7 +21,7 @@ namespace Server.Gumps AddImageTiled(10, 10, width - 20, 20, 2624); AddAlphaRegion(10, 10, width - 20, 20); - AddHtmlLocalized(10, 10, width - 20, 20, header, headerColor, false, false); + AddHtmlLocalized(10, 10, width - 20, 20, header, headerColor); AddImageTiled(10, 40, width - 20, height - 80, 2624); AddAlphaRegion(10, 40, width - 20, height - 80); @@ -34,8 +34,8 @@ namespace Server.Gumps AddImageTiled(10, height - 30, width - 20, 20, 2624); AddAlphaRegion(10, height - 30, width - 20, 20); - AddButton(10, height - 30, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, height - 30, 120, 20, 1011036, 32767, false, false); // OKAY + AddButton(10, height - 30, 4005, 4007, 1); + AddHtmlLocalized(40, height - 30, 120, 20, 1011036, 32767); // OKAY } public override void OnResponse(NetState sender, RelayInfo info) @@ -44,4 +44,4 @@ namespace Server.Gumps m_Callback?.Invoke(); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/PetResurrectGump.cs b/Scripts/Gumps/PetResurrectGump.cs index bee72baf4..4a1bb41ee 100644 --- a/Scripts/Gumps/PetResurrectGump.cs +++ b/Scripts/Gumps/PetResurrectGump.cs @@ -8,12 +8,7 @@ namespace Server.Gumps private double m_HitsScalar; private BaseCreature m_Pet; - public PetResurrectGump(Mobile from, BaseCreature pet) - : this(from, pet, 0.0) - { - } - - public PetResurrectGump(Mobile from, BaseCreature pet, double hitsScalar) : base(50, 50) + public PetResurrectGump(Mobile from, BaseCreature pet, double hitsScalar = 0.0) : base(50, 50) { from.CloseGump(); @@ -31,12 +26,11 @@ namespace Server.Gumps AddItem(195, 90, 0xCAD); AddItem(218, 95, 0xCB0); - AddHtmlLocalized(30, 30, 150, 75, 1049665, false, - false); //
Wilt thou sanctify the resurrection of:
- AddHtml(30, 70, 150, 25, $"
{pet.Name}
", true, false); + AddHtmlLocalized(30, 30, 150, 75, 1049665); //
Wilt thou sanctify the resurrection of:
+ AddHtml(30, 70, 150, 25, $"
{pet.Name}
", true); - AddButton(40, 105, 0x81A, 0x81B, 0x1, GumpButtonType.Reply, 0); // Okay - AddButton(110, 105, 0x819, 0x818, 0x2, GumpButtonType.Reply, 0); // Cancel + AddButton(40, 105, 0x81A, 0x81B, 0x1); // Okay + AddButton(110, 105, 0x819, 0x818, 0x2); // Cancel } public override void OnResponse(NetState state, RelayInfo info) @@ -80,4 +74,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/PlayerVendorGumps.cs b/Scripts/Gumps/PlayerVendorGumps.cs index eecd64f4b..93c2e375b 100644 --- a/Scripts/Gumps/PlayerVendorGumps.cs +++ b/Scripts/Gumps/PlayerVendorGumps.cs @@ -20,21 +20,21 @@ namespace Server.Gumps AddBackground(100, 10, 300, 150, 5054); - AddHtmlLocalized(125, 20, 250, 24, 1019070, false, false); // You have agreed to purchase: + 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, false, false); // an item without a description + AddHtmlLocalized(125, 45, 250, 24, 1019072); // an item without a description - AddHtmlLocalized(125, 70, 250, 24, 1019071, false, false); // for the amount of: + AddHtmlLocalized(125, 70, 250, 24, 1019071); // for the amount of: AddLabel(125, 95, 0, vi.Price.ToString()); - AddButton(250, 130, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(282, 130, 100, 24, 1011012, false, false); // CANCEL + AddButton(250, 130, 4005, 4007, 0); + AddHtmlLocalized(282, 130, 100, 24, 1011012); // CANCEL - AddButton(120, 130, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(152, 130, 100, 24, 1011036, false, false); // OKAY + AddButton(120, 130, 4005, 4007, 1); + AddHtmlLocalized(152, 130, 100, 24, 1011036); // OKAY } public override void OnResponse(NetState state, RelayInfo info) @@ -110,28 +110,28 @@ namespace Server.Gumps AddPage(0); AddBackground(25, 10, 530, 140, 5054); - AddHtmlLocalized(425, 25, 120, 20, 1019068, false, false); // See goods - AddButton(390, 25, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(425, 48, 120, 20, 1019069, false, false); // Customize - AddButton(390, 48, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(425, 72, 120, 20, 1011012, false, false); // CANCEL - AddButton(390, 71, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(425, 25, 120, 20, 1019068); // See goods + AddButton(390, 25, 4005, 4007, 1); + AddHtmlLocalized(425, 48, 120, 20, 1019069); // Customize + AddButton(390, 48, 4005, 4007, 2); + AddHtmlLocalized(425, 72, 120, 20, 1011012); // CANCEL + AddButton(390, 71, 4005, 4007, 0); - AddHtmlLocalized(40, 72, 260, 20, 1038321, false, false); // Gold held for you: + AddHtmlLocalized(40, 72, 260, 20, 1038321); // Gold held for you: AddLabel(300, 72, 0, m_Vendor.HoldGold.ToString()); - AddHtmlLocalized(40, 96, 260, 20, 1038322, false, false); // Gold held in my account: + AddHtmlLocalized(40, 96, 260, 20, 1038322); // Gold held in my account: AddLabel(300, 96, 0, m_Vendor.BankAccount.ToString()); //AddHtmlLocalized( 40, 120, 260, 20, 1038324, false, false ); // My charge per day is: // Localization has changed, we must use a string here - AddHtml(40, 120, 260, 20, "My charge per day is:", false, false); + AddHtml(40, 120, 260, 20, "My charge per day is:"); AddLabel(300, 120, 0, perDay.ToString()); double days = (m_Vendor.HoldGold + m_Vendor.BankAccount) / (double)perDay; - AddHtmlLocalized(40, 25, 260, 20, 1038318, false, false); // Amount of days I can work: + AddHtmlLocalized(40, 25, 260, 20, 1038318); // Amount of days I can work: AddLabel(300, 25, 0, ((int)days).ToString()); - AddHtmlLocalized(40, 48, 260, 20, 1038319, false, false); // Earth days: + AddHtmlLocalized(40, 48, 260, 20, 1038319); // Earth days: AddLabel(300, 48, 0, ((int)(days / 12.0)).ToString()); } @@ -185,24 +185,24 @@ namespace Server.Gumps { int goldNeeded = perRealWorldDay - goldHeld; - AddHtmlLocalized(40, 35, 260, 20, 1038320, 0x7FFF, false, false); // Gold needed for 1 day of vendor salary: + AddHtmlLocalized(40, 35, 260, 20, 1038320, 0x7FFF); // Gold needed for 1 day of vendor salary: AddLabel(300, 35, 0x1F, goldNeeded.ToString()); } else { int days = goldHeld / perRealWorldDay; - AddHtmlLocalized(40, 35, 260, 20, 1038318, 0x7FFF, false, false); // # of days Vendor salary is paid for: + AddHtmlLocalized(40, 35, 260, 20, 1038318, 0x7FFF); // # of days Vendor salary is paid for: AddLabel(300, 35, 0x480, days.ToString()); } - AddHtmlLocalized(40, 58, 260, 20, 1038324, 0x7FFF, false, false); // My charge per real world day is: + AddHtmlLocalized(40, 58, 260, 20, 1038324, 0x7FFF); // My charge per real world day is: AddLabel(300, 58, 0x480, perRealWorldDay.ToString()); - AddHtmlLocalized(40, 82, 260, 20, 1038322, 0x7FFF, false, false); // Gold held in my account: + AddHtmlLocalized(40, 82, 260, 20, 1038322, 0x7FFF); // Gold held in my account: AddLabel(300, 82, 0x480, goldHeld.ToString()); - AddHtmlLocalized(40, 108, 260, 20, 1062509, 0x7FFF, false, false); // Shop Name: + AddHtmlLocalized(40, 108, 260, 20, 1062509, 0x7FFF); // Shop Name: AddLabel(140, 106, 0x66D, vendor.ShopName); if (vendor is RentedVendor rentedVendor) @@ -213,29 +213,29 @@ namespace Server.Gumps $"Location rental will expire in {days} day{(days != 1 ? "s" : "")} and {hours} hour{(hours != 1 ? "s" : "")}."); } - AddButton(390, 24, 0x15E1, 0x15E5, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(408, 21, 120, 20, 1019068, 0x7FFF, false, false); // See goods + AddButton(390, 24, 0x15E1, 0x15E5, 1); + AddHtmlLocalized(408, 21, 120, 20, 1019068, 0x7FFF); // See goods - AddButton(390, 44, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(408, 41, 120, 20, 1019069, 0x7FFF, false, false); // Customize + AddButton(390, 44, 0x15E1, 0x15E5, 2); + AddHtmlLocalized(408, 41, 120, 20, 1019069, 0x7FFF); // Customize - AddButton(390, 64, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(408, 61, 120, 20, 1062434, 0x7FFF, false, false); // Rename Shop + AddButton(390, 64, 0x15E1, 0x15E5, 3); + AddHtmlLocalized(408, 61, 120, 20, 1062434, 0x7FFF); // Rename Shop - AddButton(390, 84, 0x15E1, 0x15E5, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(408, 81, 120, 20, 3006217, 0x7FFF, false, false); // Rename Vendor + AddButton(390, 84, 0x15E1, 0x15E5, 4); + AddHtmlLocalized(408, 81, 120, 20, 3006217, 0x7FFF); // Rename Vendor - AddButton(390, 104, 0x15E1, 0x15E5, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(408, 101, 120, 20, 3006123, 0x7FFF, false, false); // Open Paperdoll + AddButton(390, 104, 0x15E1, 0x15E5, 5); + AddHtmlLocalized(408, 101, 120, 20, 3006123, 0x7FFF); // Open Paperdoll - AddButton(390, 124, 0x15E1, 0x15E5, 6, GumpButtonType.Reply, 0); + AddButton(390, 124, 0x15E1, 0x15E5, 6); AddLabel(408, 121, 0x480, "Collect Gold"); - AddButton(390, 144, 0x15E1, 0x15E5, 7, GumpButtonType.Reply, 0); + AddButton(390, 144, 0x15E1, 0x15E5, 7); AddLabel(408, 141, 0x480, "Dismiss Vendor"); - AddButton(390, 162, 0x15E1, 0x15E5, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(408, 161, 120, 20, 1011012, 0x7FFF, false, false); // CANCEL + AddButton(390, 162, 0x15E1, 0x15E5, 0); + AddHtmlLocalized(408, 161, 120, 20, 1011012, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -431,17 +431,17 @@ namespace Server.Gumps AddPage(0); AddBackground(0, 0, 585, 393, 5054); AddBackground(195, 36, 387, 275, 3000); - AddHtmlLocalized(10, 10, 565, 18, 1011356, false, false); //
VENDOR CUSTOMIZATION MENU
- AddHtmlLocalized(60, 355, 150, 18, 1011036, false, false); // OKAY - AddButton(25, 355, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(320, 355, 150, 18, 1011012, false, false); // CANCEL - AddButton(285, 355, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(10, 10, 565, 18, 1011356); //
VENDOR CUSTOMIZATION MENU
+ AddHtmlLocalized(60, 355, 150, 18, 1011036); // OKAY + AddButton(25, 355, 4005, 4007, 1); + AddHtmlLocalized(320, 355, 150, 18, 1011012); // CANCEL + AddButton(285, 355, 4005, 4007, 0); y = 35; for (int i = 0; i < Categories.Length; i++) { CustomCategory cat = Categories[i]; - AddHtmlLocalized(5, y, 150, 25, cat.LocNumber, true, false); + AddHtmlLocalized(5, y, 150, 25, cat.LocNumber, true); AddButton(155, y, 4005, 4007, 0, GumpButtonType.Page, i + 1); y += 25; } @@ -457,7 +457,7 @@ namespace Server.Gumps x = 198 + c % 3 * 129; y = 38 + c / 3 * 67; - AddHtmlLocalized(x, y, 100, entry.LongText ? 36 : 18, entry.LocNumber, false, false); + AddHtmlLocalized(x, y, 100, entry.LongText ? 36 : 18, entry.LocNumber); if (entry.ArtNumber != 0) AddItem(x + 20, y + 25, entry.ArtNumber); @@ -467,11 +467,11 @@ namespace Server.Gumps if (cat.CanDye) { - AddHtmlLocalized(327, 239, 100, 18, 1011402, false, false); // Color + AddHtmlLocalized(327, 239, 100, 18, 1011402); // Color AddRadio(327, 259, 210, 211, false, 100 + i); } - AddHtmlLocalized(456, 239, 100, 18, 1011403, false, false); // Remove + AddHtmlLocalized(456, 239, 100, 18, 1011403); // Remove AddRadio(456, 259, 210, 211, false, 200 + i); } } @@ -824,57 +824,57 @@ namespace Server.Gumps AddAlphaRegion(10, 10, 350, 350); - AddHtmlLocalized(10, 12, 350, 18, 1011356, 0x7FFF, false, false); //
VENDOR CUSTOMIZATION MENU
+ AddHtmlLocalized(10, 12, 350, 18, 1011356, 0x7FFF); //
VENDOR CUSTOMIZATION MENU
- AddHtmlLocalized(10, 42, 150, 18, 1062459, 0x421F, false, false); //
HAIR
+ AddHtmlLocalized(10, 42, 150, 18, 1062459, 0x421F); //
HAIR
for (int i = 0; i < m_HairStyles.Length; i++) { HairOrBeard hair = m_HairStyles[i]; - AddButton(10, 70 + i * 20, 0xFA5, 0xFA7, 0x100 | i, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 72 + i * 20, 110, 18, hair.Name, 0x7FFF, false, false); + AddButton(10, 70 + i * 20, 0xFA5, 0xFA7, 0x100 | i); + AddHtmlLocalized(45, 72 + i * 20, 110, 18, hair.Name, 0x7FFF); } - AddButton(10, 70 + m_HairStyles.Length * 20, 0xFB1, 0xFB3, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 72 + m_HairStyles.Length * 20, 110, 18, 1011403, 0x7FFF, false, false); // Remove + AddButton(10, 70 + m_HairStyles.Length * 20, 0xFB1, 0xFB3, 2); + AddHtmlLocalized(45, 72 + m_HairStyles.Length * 20, 110, 18, 1011403, 0x7FFF); // Remove - AddButton(10, 70 + (m_HairStyles.Length + 1) * 20, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 72 + (m_HairStyles.Length + 1) * 20, 110, 18, 1011402, 0x7FFF, false, false); // Color + AddButton(10, 70 + (m_HairStyles.Length + 1) * 20, 0xFA5, 0xFA7, 3); + AddHtmlLocalized(45, 72 + (m_HairStyles.Length + 1) * 20, 110, 18, 1011402, 0x7FFF); // Color if (vendor.Female) { - AddButton(160, 290, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 292, 160, 18, 1015327, 0x7FFF, false, false); // Male + AddButton(160, 290, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(195, 292, 160, 18, 1015327, 0x7FFF); // Male - AddHtmlLocalized(195, 312, 160, 18, 1015328, 0x421F, false, false); // Female + AddHtmlLocalized(195, 312, 160, 18, 1015328, 0x421F); // Female } else { - AddHtmlLocalized(160, 42, 210, 18, 1062460, 0x421F, false, false); //
BEARD
+ AddHtmlLocalized(160, 42, 210, 18, 1062460, 0x421F); //
BEARD
for (int i = 0; i < m_BeardStyles.Length; i++) { HairOrBeard beard = m_BeardStyles[i]; - AddButton(160, 70 + i * 20, 0xFA5, 0xFA7, 0x200 | i, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 72 + i * 20, 160, 18, beard.Name, 0x7FFF, false, false); + AddButton(160, 70 + i * 20, 0xFA5, 0xFA7, 0x200 | i); + AddHtmlLocalized(195, 72 + i * 20, 160, 18, beard.Name, 0x7FFF); } - AddButton(160, 70 + m_BeardStyles.Length * 20, 0xFB1, 0xFB3, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 72 + m_BeardStyles.Length * 20, 160, 18, 1011403, 0x7FFF, false, false); // Remove + AddButton(160, 70 + m_BeardStyles.Length * 20, 0xFB1, 0xFB3, 4); + AddHtmlLocalized(195, 72 + m_BeardStyles.Length * 20, 160, 18, 1011403, 0x7FFF); // Remove - AddButton(160, 70 + (m_BeardStyles.Length + 1) * 20, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 72 + (m_BeardStyles.Length + 1) * 20, 160, 18, 1011402, 0x7FFF, false, false); // Color + AddButton(160, 70 + (m_BeardStyles.Length + 1) * 20, 0xFA5, 0xFA7, 5); + AddHtmlLocalized(195, 72 + (m_BeardStyles.Length + 1) * 20, 160, 18, 1011402, 0x7FFF); // Color - AddHtmlLocalized(195, 292, 160, 18, 1015327, 0x421F, false, false); // Male + AddHtmlLocalized(195, 292, 160, 18, 1015327, 0x421F); // Male - AddButton(160, 310, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 312, 160, 18, 1015328, 0x7FFF, false, false); // Female + AddButton(160, 310, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(195, 312, 160, 18, 1015328, 0x7FFF); // Female } - AddButton(10, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 342, 305, 18, 1060675, 0x7FFF, false, false); // CLOSE + AddButton(10, 340, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(45, 342, 305, 18, 1060675, 0x7FFF); // CLOSE } public override void OnResponse(NetState sender, RelayInfo info) @@ -1040,4 +1040,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/PolymorphGump.cs b/Scripts/Gumps/PolymorphGump.cs index 188c8718b..4d6717b53 100644 --- a/Scripts/Gumps/PolymorphGump.cs +++ b/Scripts/Gumps/PolymorphGump.cs @@ -87,17 +87,17 @@ namespace Server.Gumps AddPage(0); AddBackground(0, 0, 585, 393, 5054); AddBackground(195, 36, 387, 275, 3000); - AddHtmlLocalized(0, 0, 510, 18, 1015234, false, false); //
Polymorph Selection Menu
- AddHtmlLocalized(60, 355, 150, 18, 1011036, false, false); // OKAY + AddHtmlLocalized(0, 0, 510, 18, 1015234); //
Polymorph Selection Menu
+ AddHtmlLocalized(60, 355, 150, 18, 1011036); // OKAY AddButton(25, 355, 4005, 4007, 1, GumpButtonType.Reply, 1); - AddHtmlLocalized(320, 355, 150, 18, 1011012, false, false); // CANCEL + AddHtmlLocalized(320, 355, 150, 18, 1011012); // CANCEL AddButton(285, 355, 4005, 4007, 0, GumpButtonType.Reply, 2); y = 35; for (int i = 0; i < Categories.Length; i++) { PolymorphCategory cat = Categories[i]; - AddHtmlLocalized(5, y, 150, 25, cat.LocNumber, true, false); + AddHtmlLocalized(5, y, 150, 25, cat.LocNumber, true); AddButton(155, y, 4005, 4007, 0, GumpButtonType.Page, i + 1); y += 25; } @@ -113,7 +113,7 @@ namespace Server.Gumps x = 198 + c % 3 * 129; y = 38 + c / 3 * 67; - AddHtmlLocalized(x, y, 100, 18, entry.LocNumber, false, false); + AddHtmlLocalized(x, y, 100, 18, entry.LocNumber); AddItem(x + 20, y + 25, entry.ArtID); AddRadio(x, y + 20, 210, 211, false, (c << 8) + i); } @@ -191,10 +191,10 @@ namespace Server.Gumps AddImageTiled(10, 374, 500, 20, 0xA40); AddAlphaRegion(10, 10, 500, 384); - AddHtmlLocalized(14, 12, 500, 20, 1015234, 0x7FFF, false, false); //
Polymorph Selection Menu
+ AddHtmlLocalized(14, 12, 500, 20, 1015234, 0x7FFF); //
Polymorph Selection Menu
- AddButton(10, 374, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 376, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 374, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 376, 450, 20, 1060051, 0x7FFF); // CANCEL for (int i = 0; i < m_Entries.Length; i++) { @@ -208,7 +208,7 @@ namespace Server.Gumps if (page > 1) { AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next } AddPage(page); @@ -216,7 +216,7 @@ namespace Server.Gumps if (page > 1) { AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back } } @@ -224,7 +224,7 @@ namespace Server.Gumps int y = pos / 2 * 64 + 44; AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entry.ArtID, 0x0, entry.X, entry.Y); - AddHtmlLocalized(x + 84, y, 250, 60, entry.LocNumber, 0x7FFF, false, false); + AddHtmlLocalized(x + 84, y, 250, 60, entry.LocNumber, 0x7FFF); } } @@ -239,4 +239,4 @@ namespace Server.Gumps spell.Cast(); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/PropsGump.cs b/Scripts/Gumps/Props/PropsGump.cs index 1d0d3e606..3079792a5 100644 --- a/Scripts/Gumps/Props/PropsGump.cs +++ b/Scripts/Gumps/Props/PropsGump.cs @@ -213,7 +213,7 @@ namespace Server.Gumps if (page > 0) { - AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); if (PrevLabel) AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); @@ -226,7 +226,7 @@ namespace Server.Gumps if (TypeLabel && m_Type != null) AddHtml(x, y, emptyWidth, EntryHeight, - $"
{m_Type.Name}
", false, false); + $"
{m_Type.Name}
"); x += emptyWidth + OffsetSize; @@ -276,8 +276,7 @@ namespace Server.Gumps CPA cpa = GetCPA(prop); if (prop.CanWrite && cpa != null && m_Mobile.AccessLevel >= cpa.WriteLevel && !cpa.ReadOnly) - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, - 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3); } } } @@ -296,10 +295,9 @@ namespace Server.Gumps { case 0: // Closed { - if (m_Stack != null && m_Stack.Count > 0) + if (m_Stack?.Count > 0) { StackEntry entry = m_Stack.Pop(); - from.SendGump(new PropertiesGump(from, entry.m_Object, m_Stack, null)); } @@ -504,7 +502,7 @@ namespace Server.Gumps } if (o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong) - return string.Format("{0} (0x{0:X})", o); + return $"{o} (0x{o:X})"; if (o is Mobile mobile) return $"(M) 0x{mobile.Serial.Value:X} \"{mobile.Name}\""; if (o is Item item) return $"(I) 0x{item.Serial.Value:X}"; if (o is Type type) return type.Name; @@ -572,12 +570,14 @@ namespace Server.Gumps if (baseType == typeofObject || baseType?.GetProperty(prop.Name, prop.PropertyType) == null) break; - + type = baseType; } - + if (type != null && !groups.ContainsKey(type)) groups[type] = new List{ prop }; + else + groups[type].Add(prop); } } } @@ -635,7 +635,7 @@ namespace Server.Gumps } if (o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong) - return string.Format("{0} (0x{0:X})", o); + return $"{o} (0x{o:X})"; if (o is Mobile mobile) return $"(M) 0x{mobile.Serial.Value:X} \"{mobile.Name}\""; if (o is Item item) return $"(I) 0x{item.Serial.Value:X}"; if (o is Type type) return type.Name; @@ -657,13 +657,13 @@ namespace Server.Gumps return 0; if (x == null) return -1; - + return y == null ? 1 : x.Name.CompareTo(x.Name); } } private class GroupComparer : IComparer>> - { + { private Type m_Start; public GroupComparer(Type start) @@ -689,4 +689,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetBodyGump.cs b/Scripts/Gumps/Props/SetBodyGump.cs index a4008a793..e57c1214f 100644 --- a/Scripts/Gumps/Props/SetBodyGump.cs +++ b/Scripts/Gumps/Props/SetBodyGump.cs @@ -76,23 +76,23 @@ namespace Server.Gumps int y = 40 + i / 4 * 93; AddItem(x + (120 - bounds.Width) / 2 - bounds.X, y + (69 - bounds.Height) / 2 - bounds.Y, itemID); - AddButton(x + 6, y + 66, 0x98D, 0x98D, 7 + index, GumpButtonType.Reply, 0); + AddButton(x + 6, y + 66, 0x98D, 0x98D, 7 + index); x += 6; y += 67; - AddHtml(x + 0, y - 1, 108, 21, Center(entry.DisplayName), false, false); - AddHtml(x + 0, y + 1, 108, 21, Center(entry.DisplayName), false, false); - AddHtml(x - 1, y + 0, 108, 21, Center(entry.DisplayName), false, false); - AddHtml(x + 1, y + 0, 108, 21, Center(entry.DisplayName), false, false); - AddHtml(x + 0, y + 0, 108, 21, Color(Center(entry.DisplayName), TextColor32), false, false); + AddHtml(x + 0, y - 1, 108, 21, Center(entry.DisplayName)); + AddHtml(x + 0, y + 1, 108, 21, Center(entry.DisplayName)); + AddHtml(x - 1, y + 0, 108, 21, Center(entry.DisplayName)); + AddHtml(x + 1, y + 0, 108, 21, Center(entry.DisplayName)); + AddHtml(x + 0, y + 0, 108, 21, Color(Center(entry.DisplayName), TextColor32)); } if (ourPage > 0) - AddButton(480, 12, 0x15E3, 0x15E7, 5, GumpButtonType.Reply, 0); + AddButton(480, 12, 0x15E3, 0x15E7, 5); if ((ourPage + 1) * 12 < ourList.Count) - AddButton(497, 12, 0x15E1, 0x15E5, 6, GumpButtonType.Reply, 0); + AddButton(497, 12, 0x15E1, 0x15E5, 6); } } @@ -110,8 +110,8 @@ namespace Server.Gumps { bool isSelection = m_OurType == type; - AddButton(x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0); - AddHtml(x + 35, y, 200, 20, Color(text, isSelection ? SelectedColor32 : LabelColor32), false, false); + AddButton(x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID); + AddHtml(x + 35, y, 200, 20, Color(text, isSelection ? SelectedColor32 : LabelColor32)); } public override void OnResponse(NetState sender, RelayInfo info) @@ -299,4 +299,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetGump.cs b/Scripts/Gumps/Props/SetGump.cs index ad8873f01..8332f257f 100644 --- a/Scripts/Gumps/Props/SetGump.cs +++ b/Scripts/Gumps/Props/SetGump.cs @@ -109,7 +109,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); if (canNull) { @@ -123,7 +123,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); } if (canDye) @@ -138,7 +138,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); } if (isBody) @@ -153,7 +153,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4); } } @@ -280,4 +280,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetListOptionGump.cs b/Scripts/Gumps/Props/SetListOptionGump.cs index 17f66786f..37c274288 100644 --- a/Scripts/Gumps/Props/SetListOptionGump.cs +++ b/Scripts/Gumps/Props/SetListOptionGump.cs @@ -156,7 +156,7 @@ namespace Server.Gumps AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); if (button != 0) - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button); } public override void OnResponse(NetState sender, RelayInfo info) @@ -184,4 +184,4 @@ namespace Server.Gumps m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetObjectGump.cs b/Scripts/Gumps/Props/SetObjectGump.cs index 122b725b9..e69f80c62 100644 --- a/Scripts/Gumps/Props/SetObjectGump.cs +++ b/Scripts/Gumps/Props/SetObjectGump.cs @@ -98,7 +98,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -110,7 +110,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -122,7 +122,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -134,7 +134,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4); } public override void OnResponse(NetState sender, RelayInfo info) @@ -269,4 +269,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetPoint2DGump.cs b/Scripts/Gumps/Props/SetPoint2DGump.cs index c0192c3d1..21f466303 100644 --- a/Scripts/Gumps/Props/SetPoint2DGump.cs +++ b/Scripts/Gumps/Props/SetPoint2DGump.cs @@ -94,7 +94,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -105,7 +105,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -122,7 +122,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); } public override void OnResponse(NetState sender, RelayInfo info) @@ -228,4 +228,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetPoint3DGump.cs b/Scripts/Gumps/Props/SetPoint3DGump.cs index 8539cfbca..1183bf047 100644 --- a/Scripts/Gumps/Props/SetPoint3DGump.cs +++ b/Scripts/Gumps/Props/SetPoint3DGump.cs @@ -94,7 +94,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -105,7 +105,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2); x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; @@ -127,7 +127,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3); } public override void OnResponse(NetState sender, RelayInfo info) @@ -235,4 +235,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/Props/SetTimeSpanGump.cs b/Scripts/Gumps/Props/SetTimeSpanGump.cs index fef434dfd..48e819126 100644 --- a/Scripts/Gumps/Props/SetTimeSpanGump.cs +++ b/Scripts/Gumps/Props/SetTimeSpanGump.cs @@ -100,7 +100,7 @@ namespace Server.Gumps AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); if (button != 0) - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button); } public override void OnResponse(NetState sender, RelayInfo info) @@ -226,4 +226,4 @@ namespace Server.Gumps m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ReclaimVendorGump.cs b/Scripts/Gumps/ReclaimVendorGump.cs index 2651619b3..7f1a0ce6e 100644 --- a/Scripts/Gumps/ReclaimVendorGump.cs +++ b/Scripts/Gumps/ReclaimVendorGump.cs @@ -18,7 +18,7 @@ namespace Server.Gumps AddBackground(0, 0, 170, 50 + m_Vendors.Count * 20, 0x13BE); AddImageTiled(10, 10, 150, 20, 0xA40); - AddHtmlLocalized(10, 10, 150, 20, 1061827, 0x7FFF, false, false); //
Reclaim Vendor
+ AddHtmlLocalized(10, 10, 150, 20, 1061827, 0x7FFF); //
Reclaim Vendor
AddImageTiled(10, 40, 150, m_Vendors.Count * 20, 0xA40); @@ -28,7 +28,7 @@ namespace Server.Gumps int y = 40 + i * 20; - AddButton(10, y, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0); + AddButton(10, y, 0xFA5, 0xFA7, i + 1); AddLabel(45, y, 0x481, m.Name); } } @@ -75,4 +75,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ReportMurderer.cs b/Scripts/Gumps/ReportMurderer.cs index f5436f61f..bab416048 100644 --- a/Scripts/Gumps/ReportMurderer.cs +++ b/Scripts/Gumps/ReportMurderer.cs @@ -90,11 +90,7 @@ namespace Server.Gumps } } - public ReportMurdererGump( Mobile victum, List killers ) : this( victum, killers, 0 ) - { - } - - private ReportMurdererGump( Mobile victum, List killers, int idx ) : base( 0, 0 ) + private ReportMurdererGump(Mobile victum, List killers, int idx = 0) : base( 0, 0 ) { m_Killers = killers; m_Victum = victum; @@ -121,14 +117,14 @@ namespace Server.Gumps AddPage( 1 ); - AddHtml( 260, 234, 300, 140, ((Mobile)m_Killers[m_Idx]).Name, false, false ); // Player's Name - AddHtmlLocalized( 260, 254, 300, 140, 1049066, false, false ); // Would you like to report... + AddHtml( 260, 234, 300, 140, m_Killers[m_Idx].Name ); // Player's Name + AddHtmlLocalized( 260, 254, 300, 140, 1049066 ); // Would you like to report... - AddButton( 260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 300, 300, 300, 50, 1046362, false, false ); // Yes + AddButton( 260, 300, 0xFA5, 0xFA7, 1 ); + AddHtmlLocalized( 300, 300, 300, 50, 1046362 ); // Yes - AddButton( 360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 400, 300, 300, 50, 1046363, false, false ); // No + AddButton( 360, 300, 0xFA5, 0xFA7, 2 ); + AddHtmlLocalized( 400, 300, 300, 50, 1046363 ); // No } public static void ReportedListExpiry_Callback( PlayerMobile from, Mobile killer ) @@ -146,7 +142,7 @@ namespace Server.Gumps case 1: { Mobile killer = m_Killers[m_Idx]; - if ( killer != null && !killer.Deleted ) + if (killer?.Deleted == false) { killer.Kills++; killer.ShortTermMurders++; diff --git a/Scripts/Gumps/ResurrectGump.cs b/Scripts/Gumps/ResurrectGump.cs index 0808100e0..fc8c1e7b8 100644 --- a/Scripts/Gumps/ResurrectGump.cs +++ b/Scripts/Gumps/ResurrectGump.cs @@ -10,7 +10,7 @@ namespace Server.Gumps ChaosShrine = 0, VirtueShrine = 1, Healer = 2, - Generic = 3, + Generic = 3 } public class ResurrectGump : Gump @@ -20,42 +20,22 @@ namespace Server.Gumps private bool m_FromSacrifice; private double m_HitsScalar; - public ResurrectGump( Mobile owner ) - : this( owner, owner, ResurrectMessage.Generic, false ) + public ResurrectGump(Mobile owner, double hitsScalar) + : this(owner, owner, ResurrectMessage.Generic, false, hitsScalar) { } - public ResurrectGump( Mobile owner, double hitsScalar ) - : this( owner, owner, ResurrectMessage.Generic, false, hitsScalar ) + public ResurrectGump(Mobile owner, ResurrectMessage msg) : this(owner, owner, msg) { } - public ResurrectGump( Mobile owner, bool fromSacrifice ) - : this( owner, owner, ResurrectMessage.Generic, fromSacrifice ) + public ResurrectGump(Mobile owner, bool fromSacrifice = false) + : this(owner, owner, ResurrectMessage.Generic, fromSacrifice) { } - public ResurrectGump( Mobile owner, Mobile healer ) - : this( owner, healer, ResurrectMessage.Generic, false ) - { - } - - public ResurrectGump( Mobile owner, ResurrectMessage msg ) - : this( owner, owner, msg, false ) - { - } - - public ResurrectGump( Mobile owner, Mobile healer, ResurrectMessage msg ) - : this( owner, healer, msg, false ) - { - } - - public ResurrectGump( Mobile owner, Mobile healer, ResurrectMessage msg, bool fromSacrifice ) - : this( owner, healer, msg, fromSacrifice, 0.0 ) - { - } - - public ResurrectGump( Mobile owner, Mobile healer, ResurrectMessage msg, bool fromSacrifice, double hitsScalar ) + public ResurrectGump(Mobile owner, Mobile healer, ResurrectMessage msg = ResurrectMessage.Generic, + bool fromSacrifice = false, double hitsScalar = 0.0) : base( 100, 0 ) { m_Healer = healer; @@ -66,18 +46,18 @@ namespace Server.Gumps AddBackground( 0, 0, 400, 350, 2600 ); - AddHtmlLocalized( 0, 20, 400, 35, 1011022, false, false ); //
Resurrection
+ AddHtmlLocalized( 0, 20, 400, 35, 1011022 ); //
Resurrection
AddHtmlLocalized( 50, 55, 300, 140, 1011023 + (int)msg, true, true ); /* It is possible for you to be resurrected here by this healer. Do you wish to try?
* CONTINUE - You chose to try to come back to life now.
* CANCEL - You prefer to remain a ghost for now. */ - AddButton( 200, 227, 4005, 4007, 0, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 235, 230, 110, 35, 1011012, false, false ); // CANCEL + AddButton( 200, 227, 4005, 4007, 0); + AddHtmlLocalized( 235, 230, 110, 35, 1011012 ); // CANCEL - AddButton( 65, 227, 4005, 4007, 1, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 100, 230, 110, 35, 1011011, false, false ); // CONTINUE + AddButton( 65, 227, 4005, 4007, 1); + AddHtmlLocalized( 100, 230, 110, 35, 1011011 ); // CONTINUE } public ResurrectGump( Mobile owner, Mobile healer, int price ) @@ -107,14 +87,14 @@ namespace Server.Gumps AddImageTiled( 15, 15, 365, 190, 2624 ); AddRadio( 30, 140, 9727, 9730, true, 1 ); - AddHtmlLocalized( 65, 145, 300, 25, 1060015, 0x7FFF, false, false ); // Grudgingly pay the money + AddHtmlLocalized( 65, 145, 300, 25, 1060015, 0x7FFF ); // Grudgingly pay the money AddRadio( 30, 175, 9727, 9730, false, 0 ); - AddHtmlLocalized( 65, 178, 300, 25, 1060016, 0x7FFF, false, false ); // I'd rather stay dead, you scoundrel!!! + AddHtmlLocalized( 65, 178, 300, 25, 1060016, 0x7FFF ); // I'd rather stay dead, you scoundrel!!! - AddHtmlLocalized( 30, 20, 360, 35, 1060017, 0x7FFF, false, false ); // Wishing to rejoin the living, are you? I can restore your body... for a price of course... + AddHtmlLocalized( 30, 20, 360, 35, 1060017, 0x7FFF ); // Wishing to rejoin the living, are you? I can restore your body... for a price of course... - AddHtmlLocalized( 30, 105, 345, 40, 1060018, 0x5B2D, false, false ); // Do you accept the fee, which will be withdrawn from your bank? + AddHtmlLocalized( 30, 105, 345, 40, 1060018, 0x5B2D ); // Do you accept the fee, which will be withdrawn from your bank? AddImage( 65, 72, 5605 ); @@ -122,9 +102,9 @@ namespace Server.Gumps AddImageTiled( 95, 92, 200, 1, 9157 ); AddLabel( 90, 70, 1645, price.ToString() ); - AddHtmlLocalized( 140, 70, 100, 25, 1023823, 0x7FFF, false, false ); // gold coins + AddHtmlLocalized( 140, 70, 100, 25, 1023823, 0x7FFF ); // gold coins - AddButton( 290, 175, 247, 248, 2, GumpButtonType.Reply, 0 ); + AddButton( 290, 175, 247, 248, 2 ); AddImageTiled( 15, 14, 365, 1, 9107 ); AddImageTiled( 380, 14, 1, 190, 9105 ); @@ -142,107 +122,107 @@ namespace Server.Gumps from.CloseGump(); - if ( info.ButtonID == 1 || info.ButtonID == 2 ) - { - if ( from.Map == null || !from.Map.CanFit( from.Location, 16, false, false ) ) - { - from.SendLocalizedMessage( 502391 ); // Thou can not be resurrected there! - return; - } + if (info.ButtonID != 1 && info.ButtonID != 2) + return; - if ( m_Price > 0 ) - { - if ( info.IsSwitched( 1 ) ) - { - if ( Banker.Withdraw( from, m_Price ) ) - { - from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - from.SendLocalizedMessage( 1060022, Banker.GetBalance( from ).ToString() ); // You have ~1_AMOUNT~ gold in cash remaining in your bank box. - } - else - { - from.SendLocalizedMessage( 1060020 ); // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing. - return; - } - } - else - { - from.SendLocalizedMessage( 1060019 ); // You decide against paying the healer, and thus remain dead. - return; - } - } + if (from.Map?.CanFit( from.Location, 16, false, false ) != true) + { + from.SendLocalizedMessage( 502391 ); // Thou can not be resurrected there! + return; + } - from.PlaySound( 0x214 ); - from.FixedEffect( 0x376A, 10, 16 ); + if ( m_Price > 0 ) + { + if ( info.IsSwitched( 1 ) ) + { + if ( Banker.Withdraw( from, m_Price ) ) + { + from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + from.SendLocalizedMessage( 1060022, Banker.GetBalance( from ).ToString() ); // You have ~1_AMOUNT~ gold in cash remaining in your bank box. + } + else + { + from.SendLocalizedMessage( 1060020 ); // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing. + return; + } + } + else + { + from.SendLocalizedMessage( 1060019 ); // You decide against paying the healer, and thus remain dead. + return; + } + } - from.Resurrect(); + from.PlaySound( 0x214 ); + from.FixedEffect( 0x376A, 10, 16 ); - if ( m_Healer != null && from != m_Healer ) - { - VirtueLevel level = VirtueHelper.GetLevel( m_Healer, VirtueName.Compassion ); + from.Resurrect(); - switch( level ) - { - case VirtueLevel.Seeker: from.Hits = AOS.Scale( from.HitsMax, 20 ); break; - case VirtueLevel.Follower: from.Hits = AOS.Scale( from.HitsMax, 40 ); break; - case VirtueLevel.Knight: from.Hits = AOS.Scale( from.HitsMax, 80 ); break; - } - } + if ( m_Healer != null && from != m_Healer ) + { + VirtueLevel level = VirtueHelper.GetLevel( m_Healer, VirtueName.Compassion ); - if ( m_FromSacrifice && from is PlayerMobile mobile ) - { - mobile.AvailableResurrects -= 1; + switch( level ) + { + case VirtueLevel.Seeker: from.Hits = AOS.Scale( from.HitsMax, 20 ); break; + case VirtueLevel.Follower: from.Hits = AOS.Scale( from.HitsMax, 40 ); break; + case VirtueLevel.Knight: from.Hits = AOS.Scale( from.HitsMax, 80 ); break; + } + } - Container pack = mobile.Backpack; - Container corpse = mobile.Corpse; + if ( m_FromSacrifice && from is PlayerMobile mobile ) + { + mobile.AvailableResurrects -= 1; - if ( pack != null && corpse != null ) - { - List items = new List( corpse.Items ); + Container pack = mobile.Backpack; + Container corpse = mobile.Corpse; - for( int i = 0; i < items.Count; ++i ) - { - Item item = items[i]; + if ( pack != null && corpse != null ) + { + List items = new List( corpse.Items ); - if ( item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable ) - pack.DropItem( item ); - } - } - } + for( int i = 0; i < items.Count; ++i ) + { + Item item = items[i]; - if ( from.Fame > 0 ) - { - int amount = from.Fame / 10; + if ( item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable ) + pack.DropItem( item ); + } + } + } - Misc.Titles.AwardFame( from, -amount, true ); - } + if ( from.Fame > 0 ) + { + int amount = from.Fame / 10; - if ( !Core.AOS && from.ShortTermMurders >= 5 ) - { - double loss = (100.0 - (4.0 + (from.ShortTermMurders / 5.0))) / 100.0; // 5 to 15% loss + Misc.Titles.AwardFame( from, -amount, true ); + } - if ( loss < 0.85 ) - loss = 0.85; - else if ( loss > 0.95 ) - loss = 0.95; + if ( !Core.AOS && from.ShortTermMurders >= 5 ) + { + double loss = (100.0 - (4.0 + (from.ShortTermMurders / 5.0))) / 100.0; // 5 to 15% loss - if ( from.RawStr * loss > 10 ) - from.RawStr = (int)(from.RawStr * loss); - if ( from.RawInt * loss > 10 ) - from.RawInt = (int)(from.RawInt * loss); - if ( from.RawDex * loss > 10 ) - from.RawDex = (int)(from.RawDex * loss); + if ( loss < 0.85 ) + loss = 0.85; + else if ( loss > 0.95 ) + loss = 0.95; - for( int s = 0; s < from.Skills.Length; s++ ) - { - if ( from.Skills[s].Base * loss > 35 ) - from.Skills[s].Base *= loss; - } - } + if ( from.RawStr * loss > 10 ) + from.RawStr = (int)(from.RawStr * loss); + if ( from.RawInt * loss > 10 ) + from.RawInt = (int)(from.RawInt * loss); + if ( from.RawDex * loss > 10 ) + from.RawDex = (int)(from.RawDex * loss); - if ( from.Alive && m_HitsScalar > 0 ) - from.Hits = (int)(from.HitsMax * m_HitsScalar); - } - } + for( int s = 0; s < from.Skills.Length; s++ ) + { + 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); + } } } diff --git a/Scripts/Gumps/RewardGump.cs b/Scripts/Gumps/RewardGump.cs index 438eae254..233e5567f 100644 --- a/Scripts/Gumps/RewardGump.cs +++ b/Scripts/Gumps/RewardGump.cs @@ -40,14 +40,14 @@ namespace Server.Gumps AddImageTiled(70, 55, 230, 2, 0x23C5); if (Title.String != null) - AddHtml(70, 35, 270, 20, Title.String, false, false); + AddHtml(70, 35, 270, 20, Title.String); else if (Title.Number != 0) - AddHtmlLocalized(70, 35, 270, 20, Title.Number, 1, false, false); + AddHtmlLocalized(70, 35, 270, 20, Title.Number, 1); - AddHtmlLocalized(50, 65, 150, 20, 1072843, 1, false, false); // Your Reward Points: + AddHtmlLocalized(50, 65, 150, 20, 1072843, 1); // Your Reward Points: AddLabel(230, 65, 0x64, Points.ToString()); AddImageTiled(35, 85, 270, 2, 0x23C5); - AddHtmlLocalized(35, 90, 270, 20, 1072844, 1, false, false); // Please Choose a Reward: + AddHtmlLocalized(35, 90, 270, 20, 1072844, 1); // Please Choose a Reward: AddPage(1); @@ -63,13 +63,13 @@ namespace Server.Gumps if (offset + height > 320) { - AddHtmlLocalized(240, 335, 60, 20, 1072854, 1, false, false); //
Next
+ AddHtmlLocalized(240, 335, 60, 20, 1072854, 1); //
Next
AddButton(300, 335, 0x15E1, 0x15E5, 51, GumpButtonType.Page, page + 1); AddPage(++page); AddButton(150, 335, 0x15E3, 0x15E7, 52, GumpButtonType.Page, page - 1); - AddHtmlLocalized(170, 335, 60, 20, 1074880, 1, false, false); // Previous + AddHtmlLocalized(170, 335, 60, 20, 1074880, 1); // Previous offset = 110; } @@ -78,7 +78,7 @@ namespace Server.Gumps int half = offset + height / 2; if (available) - AddButton(35, half - 6, 0x837, 0x838, 100 + i, GumpButtonType.Reply, 0); + AddButton(35, half - 6, 0x837, 0x838, 100 + i); AddItem(83 - bounds.Width / 2 - bounds.X, half - bounds.Height / 2 - bounds.Y, entry.ItemID, available ? entry.Hue : 995); @@ -91,9 +91,9 @@ namespace Server.Gumps if (entry.Description != null) { if (entry.Description.String != null) - AddHtml(190, offset, 114, height, entry.Description.String, false, false); + AddHtml(190, offset, 114, height, entry.Description.String); else if (entry.Description.Number != 0) - AddHtmlLocalized(190, offset, 114, height, entry.Description.Number, 1, false, false); + AddHtmlLocalized(190, offset, 114, height, entry.Description.Number, 1); } offset += height + 10; @@ -166,14 +166,14 @@ namespace Server.Gumps if (entry.Tooltip != 0) AddTooltip(entry.Tooltip); - AddHtmlLocalized(25, 22, 200, 20, 1074974, 0x7D00, false, false); // Confirm Selection + AddHtmlLocalized(25, 22, 200, 20, 1074974, 0x7D00); // Confirm Selection AddImage(25, 40, 0xBBF); - AddHtmlLocalized(25, 55, 300, 120, 1074975, 0xFFFFFF, false, false); // Are you sure you wish to select this? + AddHtmlLocalized(25, 55, 300, 120, 1074975, 0xFFFFFF); // Are you sure you wish to select this? AddRadio(25, 175, 0x25F8, 0x25FB, true, 1); AddRadio(25, 210, 0x25F8, 0x25FB, false, 0); - AddHtmlLocalized(60, 180, 280, 20, 1074976, 0xFFFFFF, false, false); // Yes - AddHtmlLocalized(60, 215, 280, 20, 1074977, 0xFFFFFF, false, false); // No - AddButton(265, 220, 0xF7, 0xF8, 7, GumpButtonType.Reply, 0); + AddHtmlLocalized(60, 180, 280, 20, 1074976, 0xFFFFFF); // Yes + AddHtmlLocalized(60, 215, 280, 20, 1074977, 0xFFFFFF); // No + AddButton(265, 220, 0xF7, 0xF8, 7); } public override void OnResponse(NetState sender, RelayInfo info) @@ -184,4 +184,4 @@ namespace Server.Gumps sender.Mobile.SendGump(new RewardGump(m_Parent.Title, m_Parent.Rewards, m_Parent.Points, m_Parent.OnPicked)); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/RunebookGump.cs b/Scripts/Gumps/RunebookGump.cs index c14411952..dff228d50 100644 --- a/Scripts/Gumps/RunebookGump.cs +++ b/Scripts/Gumps/RunebookGump.cs @@ -88,12 +88,12 @@ namespace Server.Gumps AddButton(xOffset, 187, gumpID, gumpID, 0, GumpButtonType.Page, 6 + i); // Charges - AddHtmlLocalized(140, 40, 80, 18, 1011296, false, false); // Charges: - AddHtml(220, 40, 30, 18, Book.CurCharges.ToString(), false, false); + AddHtmlLocalized(140, 40, 80, 18, 1011296); // Charges: + AddHtml(220, 40, 30, 18, Book.CurCharges.ToString()); // Max charges - AddHtmlLocalized(300, 40, 100, 18, 1011297, false, false); // Max Charges: - AddHtml(400, 40, 30, 18, Book.MaxCharges.ToString(), false, false); + AddHtmlLocalized(300, 40, 100, 18, 1011297); // Max Charges: + AddHtml(400, 40, 30, 18, Book.MaxCharges.ToString()); } private void AddIndex() @@ -102,8 +102,8 @@ namespace Server.Gumps AddPage(1); // Rename button - AddButton(125, 15, 2472, 2473, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(158, 22, 100, 18, 1011299, false, false); // Rename book + AddButton(125, 15, 2472, 2473, 1); + AddHtmlLocalized(158, 22, 100, 18, 1011299); // Rename book // List of entries List entries = Book.Entries; @@ -125,7 +125,7 @@ namespace Server.Gumps } // Use charge button - AddButton(130 + i / 8 * 160, 65 + i % 8 * 15, 2103, 2104, 2 + i * 6 + 0, GumpButtonType.Reply, 0); + AddButton(130 + i / 8 * 160, 65 + i % 8 * 15, 2103, 2104, 2 + i * 6 + 0); // Description label AddLabelCropped(145 + i / 8 * 160, 60 + i % 8 * 15, 115, 17, hue, desc); @@ -138,7 +138,7 @@ namespace Server.Gumps private void AddDetails(int index, int half) { // Use charge button - AddButton(130 + half * 160, 65, 2103, 2104, 2 + index * 6 + 0, GumpButtonType.Reply, 0); + AddButton(130 + half * 160, 65, 2103, 2104, 2 + index * 6 + 0); string desc; int hue; @@ -162,33 +162,33 @@ namespace Server.Gumps } // Drop rune button - AddButton(135 + half * 160, 115, 2437, 2438, 2 + index * 6 + 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(150 + half * 160, 115, 100, 18, 1011298, false, false); // Drop rune + AddButton(135 + half * 160, 115, 2437, 2438, 2 + index * 6 + 1); + AddHtmlLocalized(150 + half * 160, 115, 100, 18, 1011298); // Drop rune // Set as default button int defButtonID = e != Book.Default ? 2361 : 2360; - AddButton(160 + half * 140, 20, defButtonID, defButtonID, 2 + index * 6 + 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(175 + half * 140, 15, 100, 18, 1011300, false, false); // Set default + AddButton(160 + half * 140, 20, defButtonID, defButtonID, 2 + index * 6 + 2); + AddHtmlLocalized(175 + half * 140, 15, 100, 18, 1011300); // Set default if (Core.AOS) { - AddButton(135 + half * 160, 140, 2103, 2104, 2 + index * 6 + 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(150 + half * 160, 136, 110, 20, 1062722, false, false); // Recall + AddButton(135 + half * 160, 140, 2103, 2104, 2 + index * 6 + 3); + AddHtmlLocalized(150 + half * 160, 136, 110, 20, 1062722); // Recall - AddButton(135 + half * 160, 158, 2103, 2104, 2 + index * 6 + 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(150 + half * 160, 154, 110, 20, 1062723, false, false); // Gate Travel + AddButton(135 + half * 160, 158, 2103, 2104, 2 + index * 6 + 4); + AddHtmlLocalized(150 + half * 160, 154, 110, 20, 1062723); // Gate Travel - AddButton(135 + half * 160, 176, 2103, 2104, 2 + index * 6 + 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(150 + half * 160, 172, 110, 20, 1062724, false, false); // Sacred Journey + AddButton(135 + half * 160, 176, 2103, 2104, 2 + index * 6 + 5); + AddHtmlLocalized(150 + half * 160, 172, 110, 20, 1062724); // Sacred Journey } else { // Recall button - AddButton(135 + half * 160, 140, 2271, 2271, 2 + index * 6 + 3, GumpButtonType.Reply, 0); + AddButton(135 + half * 160, 140, 2271, 2271, 2 + index * 6 + 3); // Gate button - AddButton(205 + half * 160, 140, 2291, 2291, 2 + index * 6 + 4, GumpButtonType.Reply, 0); + AddButton(205 + half * 160, 140, 2291, 2291, 2 + index * 6 + 4); } } else @@ -203,9 +203,7 @@ namespace Server.Gumps public static bool HasSpell(Mobile from, int spellID) { - Spellbook book = Spellbook.Find(from, spellID); - - return book != null && book.HasSpell(spellID); + return Spellbook.Find(from, spellID)?.HasSpell(spellID) == true; } public override void OnResponse(NetState state, RelayInfo info) @@ -271,7 +269,7 @@ namespace Server.Gumps } Book.OnTravel(); - new RecallSpell(from, Book, e, Book).Cast(); + new RecallSpell(from, e, Book, Book).Cast(); Book.Openers.Remove(from); } @@ -329,7 +327,7 @@ namespace Server.Gumps } Book.OnTravel(); - new RecallSpell(from, null, e).Cast(); + new RecallSpell(from, e).Cast(); } else { @@ -357,7 +355,7 @@ namespace Server.Gumps } Book.OnTravel(); - new GateTravelSpell(from, null, e).Cast(); + new GateTravelSpell(from, e).Cast(); } else { @@ -387,7 +385,7 @@ namespace Server.Gumps } Book.OnTravel(); - new SacredJourneySpell(from, null, e).Cast(); + new SacredJourneySpell(from, e).Cast(); } else { @@ -451,4 +449,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/SetSecureLevelGump.cs b/Scripts/Gumps/SetSecureLevelGump.cs index a56fce9fb..2d66ba628 100644 --- a/Scripts/Gumps/SetSecureLevelGump.cs +++ b/Scripts/Gumps/SetSecureLevelGump.cs @@ -29,31 +29,31 @@ namespace Server.Gumps AddAlphaRegion(10, 10, 200, 140); - AddHtmlLocalized(10, 10, 200, 20, 1061276, 32767, false, false); //
SET ACCESS
- AddHtmlLocalized(10, 40, 100, 20, 1041474, 32767, false, false); // Owner: + AddHtmlLocalized(10, 10, 200, 20, 1061276, 32767); //
SET ACCESS
+ AddHtmlLocalized(10, 40, 100, 20, 1041474, 32767); // Owner: AddLabel(110, 40, 1152, owner == null ? "" : owner.Name); - AddButton(10, 70, GetFirstID(SecureLevel.Owner), 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 70, 150, 20, 1061277, GetColor(SecureLevel.Owner), false, false); // Owner Only + AddButton(10, 70, GetFirstID(SecureLevel.Owner), 4007, 1); + AddHtmlLocalized(45, 70, 150, 20, 1061277, GetColor(SecureLevel.Owner)); // Owner Only - AddButton(10, 90, GetFirstID(SecureLevel.CoOwners), 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 90, 150, 20, 1061278, GetColor(SecureLevel.CoOwners), false, false); // Co-Owners + AddButton(10, 90, GetFirstID(SecureLevel.CoOwners), 4007, 2); + AddHtmlLocalized(45, 90, 150, 20, 1061278, GetColor(SecureLevel.CoOwners)); // Co-Owners - AddButton(10, 110, GetFirstID(SecureLevel.Friends), 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 110, 150, 20, 1061279, GetColor(SecureLevel.Friends), false, false); // Friends + AddButton(10, 110, GetFirstID(SecureLevel.Friends), 4007, 3); + AddHtmlLocalized(45, 110, 150, 20, 1061279, GetColor(SecureLevel.Friends)); // Friends Mobile houseOwner = house.Owner; if (Guild.NewGuildSystem && houseOwner?.Guild != null && ((Guild)houseOwner.Guild).Leader == houseOwner ) //Only the actual House owner AND guild master can set guild secures { - AddButton(10, 130, GetFirstID(SecureLevel.Guild), 4007, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 130, 150, 20, 1063455, GetColor(SecureLevel.Guild), false, false); // Guild Members + AddButton(10, 130, GetFirstID(SecureLevel.Guild), 4007, 5); + AddHtmlLocalized(45, 130, 150, 20, 1063455, GetColor(SecureLevel.Guild)); // Guild Members } - AddButton(10, 130 + offset, GetFirstID(SecureLevel.Anyone), 4007, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 130 + offset, 150, 20, 1061626, GetColor(SecureLevel.Anyone), false, false); // Anyone + AddButton(10, 130 + offset, GetFirstID(SecureLevel.Anyone), 4007, 4); + AddHtmlLocalized(45, 130 + offset, 150, 20, 1061626, GetColor(SecureLevel.Anyone)); // Anyone } public int GetColor(SecureLevel level) @@ -100,4 +100,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/SkillsGump.cs b/Scripts/Gumps/SkillsGump.cs index 3578bef25..24725e13d 100644 --- a/Scripts/Gumps/SkillsGump.cs +++ b/Scripts/Gumps/SkillsGump.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server.Commands; using Server.Network; @@ -91,7 +91,7 @@ namespace Server.Gumps if (SetGumpID != 0) AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0); + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1); } public override void OnResponse(NetState sender, RelayInfo info) @@ -166,7 +166,7 @@ namespace Server.Gumps private static bool PrevLabel = OldStyle, NextLabel = OldStyle; private static readonly int PrevLabelOffsetX = PrevWidth + 1; - + private static readonly int PrevLabelOffsetY = 0; private static readonly int NextLabelOffsetX = -29; @@ -196,11 +196,7 @@ namespace Server.Gumps private SkillsGumpGroup m_Selected; private Mobile m_Target; - public SkillsGump(Mobile from, Mobile target) : this(from, target, null) - { - } - - public SkillsGump(Mobile from, Mobile target, SkillsGumpGroup selected) : base(GumpOffsetX, GumpOffsetY) + public SkillsGump(Mobile from, Mobile target, SkillsGumpGroup selected = null) : base(GumpOffsetX, GumpOffsetY) { m_From = from; m_Target = target; @@ -252,9 +248,9 @@ namespace Server.Gumps AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); if (group == selected) - AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E2, 0x15E6, GetButtonID(0, i), GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E2, 0x15E6, GetButtonID(0, i)); else - AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(0, i), GumpButtonType.Reply, 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(0, i)); x += PrevWidth + OffsetSize; @@ -286,8 +282,7 @@ namespace Server.Gumps AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); - AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(1, j), GumpButtonType.Reply, - 0); + AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(1, j)); x += PrevWidth + OffsetSize; @@ -331,8 +326,7 @@ namespace Server.Gumps break; } - AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, GetButtonID(2, j), - GumpButtonType.Reply, 0); + AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, GetButtonID(2, j)); y += 1; x -= OffsetSize; @@ -378,7 +372,7 @@ namespace Server.Gumps if (m_Selected != newSelection) m_From.SendGump(new SkillsGump(m_From, m_Target, newSelection)); else - m_From.SendGump(new SkillsGump(m_From, m_Target, null)); + m_From.SendGump(new SkillsGump(m_From, m_Target)); } break; @@ -548,13 +542,10 @@ namespace Server.Gumps }) }; - private class SkillNameComparer : IComparer + private class SkillNameComparer : IComparer { - public int Compare(object x, object y) + public int Compare(SkillName a, SkillName b) { - SkillName a = (SkillName)x; - SkillName b = (SkillName)y; - string aName = SkillInfo.Table[(int)a].Name; string bName = SkillInfo.Table[(int)b].Name; @@ -562,4 +553,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/TithingGump.cs b/Scripts/Gumps/TithingGump.cs index 5ae978886..fef118119 100644 --- a/Scripts/Gumps/TithingGump.cs +++ b/Scripts/Gumps/TithingGump.cs @@ -24,8 +24,7 @@ namespace Server.Gumps AddImage(30, 30, 102); - AddHtmlLocalized(95, 100, 120, 100, 1060198, 0, false, - false); // May your wealth bring blessings to those in need, if tithed upon this most sacred site. + AddHtmlLocalized(95, 100, 120, 100, 1060198, 0); // May your wealth bring blessings to those in need, if tithed upon this most sacred site. AddLabel(57, 274, 0, "Gold:"); AddLabel(87, 274, 53, (totalGold - offer).ToString()); @@ -33,23 +32,23 @@ namespace Server.Gumps AddLabel(137, 274, 0, "Tithe:"); AddLabel(172, 274, 53, offer.ToString()); - AddButton(105, 230, 5220, 5220, 2, GumpButtonType.Reply, 0); - AddButton(113, 230, 5222, 5222, 2, GumpButtonType.Reply, 0); + AddButton(105, 230, 5220, 5220, 2); + AddButton(113, 230, 5222, 5222, 2); AddLabel(108, 228, 0, "<"); AddLabel(112, 228, 0, "<"); - AddButton(127, 230, 5223, 5223, 1, GumpButtonType.Reply, 0); + AddButton(127, 230, 5223, 5223, 1); AddLabel(131, 228, 0, "<"); - AddButton(147, 230, 5224, 5224, 3, GumpButtonType.Reply, 0); + AddButton(147, 230, 5224, 5224, 3); AddLabel(153, 228, 0, ">"); - AddButton(168, 230, 5220, 5220, 4, GumpButtonType.Reply, 0); - AddButton(176, 230, 5222, 5222, 4, GumpButtonType.Reply, 0); + AddButton(168, 230, 5220, 5220, 4); + AddButton(176, 230, 5222, 5222, 4); AddLabel(172, 228, 0, ">"); AddLabel(176, 228, 0, ">"); - AddButton(217, 272, 4023, 4024, 5, GumpButtonType.Reply, 0); + AddButton(217, 272, 4023, 4024, 5); } public override void OnResponse(NetState sender, RelayInfo info) @@ -109,7 +108,7 @@ namespace Server.Gumps Container pack = m_From.Backpack; - if (pack != null && pack.ConsumeTotal(typeof(Gold), m_Offer)) + if (pack?.ConsumeTotal(typeof(Gold), m_Offer) == true) { // You tithe gold to the shrine as a sign of devotion. m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195); @@ -129,4 +128,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/ToTAdminGump.cs b/Scripts/Gumps/ToTAdminGump.cs index 1e8e64410..da81acf3c 100644 --- a/Scripts/Gumps/ToTAdminGump.cs +++ b/Scripts/Gumps/ToTAdminGump.cs @@ -60,7 +60,7 @@ namespace Server.Gumps public void SetupToTEras() { bool isActivated = TreasuresOfTokuno.DropEra != TreasuresOfTokunoEra.None; - AddButton(75, 50, isActivated ? 2361 : 2360, isActivated ? 2361 : 2360, 1, GumpButtonType.Reply, 0); + AddButton(75, 50, isActivated ? 2361 : 2360, isActivated ? 2361 : 2360, 1); AddLabel(90, 45, isActivated ? 167 : 137, isActivated ? "Activated" : "Deactivated"); for (int i = 0; i < m_ToTEras; i++) @@ -73,9 +73,9 @@ namespace Server.Gumps int rewardButtonID = isThisRewardEra ? 2361 : 2360; AddLabel(10, 70 + yoffset, 2100, "ToT " + (i + 1)); - AddButton(75, 75 + yoffset, dropButtonID, dropButtonID, 2 + i * 2, GumpButtonType.Reply, 0); + AddButton(75, 75 + yoffset, dropButtonID, dropButtonID, 2 + i * 2); AddLabel(90, 70 + yoffset, isThisDropEra ? 167 : 137, isThisDropEra ? "Active" : "Inactive"); - AddButton(180, 75 + yoffset, rewardButtonID, rewardButtonID, 2 + i * 2 + 1, GumpButtonType.Reply, 0); + AddButton(180, 75 + yoffset, rewardButtonID, rewardButtonID, 2 + i * 2 + 1); AddLabel(195, 70 + yoffset, isThisRewardEra ? 167 : 137, isThisRewardEra ? "Active" : "Inactive"); AddButton(285, 70 + yoffset, 4005, 4006, i, GumpButtonType.Page, 2 + i); @@ -132,4 +132,4 @@ namespace Server.Gumps e.Mobile.SendGump(tg); } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/VendorInventoryGump.cs b/Scripts/Gumps/VendorInventoryGump.cs index b6f728825..4c5062d05 100644 --- a/Scripts/Gumps/VendorInventoryGump.cs +++ b/Scripts/Gumps/VendorInventoryGump.cs @@ -20,8 +20,8 @@ namespace Server.Gumps AddBackground(0, 0, 420, 50 + 20 * m_Inventories.Count, 0x13BE); AddImageTiled(10, 10, 400, 20, 0xA40); - AddHtmlLocalized(15, 10, 200, 20, 1062435, 0x7FFF, false, false); // Reclaim Vendor Inventory - AddHtmlLocalized(330, 10, 50, 20, 1062465, 0x7FFF, false, false); // Expires + AddHtmlLocalized(15, 10, 200, 20, 1062435, 0x7FFF); // Reclaim Vendor Inventory + AddHtmlLocalized(330, 10, 50, 20, 1062465, 0x7FFF); // Expires AddImageTiled(10, 40, 400, 20 * m_Inventories.Count, 0xA40); @@ -32,7 +32,7 @@ namespace Server.Gumps int y = 40 + 20 * i; if (inventory.Owner == from) - AddButton(10, y, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0); + AddButton(10, y, 0xFA5, 0xFA7, i + 1); AddLabel(45, y, 0x481, $"{inventory.ShopName} ({inventory.VendorName})"); @@ -40,7 +40,7 @@ namespace Server.Gumps int hours = (int)expire.TotalHours; AddLabel(320, y, 0x481, hours.ToString()); - AddHtmlLocalized(350, y, 50, 20, 1062466, 0x7FFF, false, false); // hour(s) + AddHtmlLocalized(350, y, 50, 20, 1062466, 0x7FFF); // hour(s) } } @@ -52,7 +52,7 @@ namespace Server.Gumps Mobile from = sender.Mobile; HouseSign sign = m_House.Sign; - if (m_House.Deleted || sign == null || sign.Deleted || !from.CheckAlive()) + if (m_House.Deleted || sign?.Deleted != false || !from.CheckAlive()) return; if (from.Map != sign.Map || !from.InRange(sign, 5)) @@ -122,4 +122,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/VendorRentalGumps.cs b/Scripts/Gumps/VendorRentalGumps.cs index 2b2772006..77f4ef986 100644 --- a/Scripts/Gumps/VendorRentalGumps.cs +++ b/Scripts/Gumps/VendorRentalGumps.cs @@ -37,7 +37,7 @@ namespace Server.Gumps AddImageTiled( 70, 55, 230, 2, 0x23C5 ); AddImage( 32, 33, 0x2635 ); - AddHtmlLocalized( 70, 35, 270, 20, 1062353, 0x1, false, false ); // Vendor Rental Contract + AddHtmlLocalized( 70, 35, 270, 20, 1062353, 0x1 ); // Vendor Rental Contract AddPage( 1 ); @@ -45,7 +45,7 @@ namespace Server.Gumps if ( type != GumpType.UnlockedContract ) { AddImage( 65, 60, 0x827 ); - AddHtmlLocalized( 79, 58, 270, 20, 1062370, 0x1, false, false ); // Landlord: + AddHtmlLocalized( 79, 58, 270, 20, 1062370, 0x1 ); // Landlord: AddLabel( 150, 58, 0x64, landlord != null ? landlord.Name : "" ); AddImageTiled( 70, 80, 230, 2, 0x23C5 ); @@ -53,48 +53,48 @@ 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, false, false ); // Contract Length - AddHtmlLocalized( 230, 95, 270, 20, duration.Name, 0x1, false, false ); + 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, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 50, 115, 150, 20, 1062356, 0x1, false, false ); // Price Per Rental + 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" ); AddImageTiled( 50, 160, 250, 2, 0x23BF ); if ( type == GumpType.Offer ) { - AddButton( 67, 180, 0x482, 0x483, 2, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 100, 180, 270, 20, 1049011, 0x28, false, false ); // I accept! + AddButton( 67, 180, 0x482, 0x483, 2); + AddHtmlLocalized( 100, 180, 270, 20, 1049011, 0x28 ); // I accept! - AddButton( 67, 210, 0x47F, 0x480, 0, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 100, 210, 270, 20, 1049012, 0x28, false, false ); // No thanks, I decline. + AddButton( 67, 210, 0x47F, 0x480, 0); + AddHtmlLocalized( 100, 210, 270, 20, 1049012, 0x28 ); // No thanks, I decline. } else { AddImage( 49, 170, 0x61 ); - AddHtmlLocalized( 60, 170, 250, 20, 1062355, 0x1, false, false ); // Renew On Expiration? + 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, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 85, 190, 250, 20, 1062359, 0x1, false, false ); // Landlord: - AddHtmlLocalized( 230, 190, 270, 20, landlordRenew ? 1049717 : 1049718, 0x1, false, false ); // YES / NO + 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, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 85, 210, 250, 20, 1062360, 0x1, false, false ); // Renter: - AddHtmlLocalized( 230, 210, 270, 20, renterRenew ? 1049717 : 1049718, 0x1, false, false ); // YES / NO + 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 if ( renew ) { AddImage( 49, 233, 0x939 ); - AddHtmlLocalized( 70, 230, 250, 20, 1062482, 0x1, false, false ); // Contract WILL renew + AddHtmlLocalized( 70, 230, 250, 20, 1062482, 0x1 ); // Contract WILL renew } else { AddImage( 49, 233, 0x938 ); - AddHtmlLocalized( 70, 230, 250, 20, 1062483, 0x1, false, false ); // Contract WILL NOT renew + AddHtmlLocalized( 70, 230, 250, 20, 1062483, 0x1 ); // Contract WILL NOT renew } } @@ -104,17 +104,17 @@ namespace Server.Gumps if ( type == GumpType.LockedContract ) { - AddButton( 67, 295, 0x15E1, 0x15E5, 5, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 85, 294, 270, 20, 1062358, 0x28, false, false ); // Offer Contract To Someone + AddButton( 67, 295, 0x15E1, 0x15E5, 5); + AddHtmlLocalized( 85, 294, 270, 20, 1062358, 0x28 ); // Offer Contract To Someone } else if ( type == GumpType.VendorLandlord || type == GumpType.VendorRenter ) { if ( type == GumpType.VendorLandlord ) - AddButton( 30, 250, 0x15E1, 0x15E1, 6, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 85, 250, 250, 20, 1062499, 0x1, false, false ); // Renewal Price + AddButton( 30, 250, 0x15E1, 0x15E1, 6); + AddHtmlLocalized( 85, 250, 250, 20, 1062499, 0x1 ); // Renewal Price AddLabel( 230, 250, 0x64, renewalPrice.ToString() ); - AddHtmlLocalized( 60, 294, 270, 20, 1062369, 0x1, false, false ); // Renter: + AddHtmlLocalized( 60, 294, 270, 20, 1062369, 0x1 ); // Renter: AddLabel( 120, 293, 0x64, renter != null ? renter.Name : "" ); } @@ -128,7 +128,7 @@ namespace Server.Gumps VendorRentalDuration durationItem = VendorRentalDuration.Instances[i]; AddButton( 30, 76 + i * 20, 0x15E1, 0x15E5, 0x10 | i, GumpButtonType.Reply, 1 ); - AddHtmlLocalized( 50, 75 + i * 20, 150, 20, durationItem.Name, 0x1, false, false ); + AddHtmlLocalized( 50, 75 + i * 20, 150, 20, durationItem.Name, 0x1 ); } } } @@ -280,10 +280,8 @@ namespace Server.Gumps text = text.Trim(); - int price; - - if ( !int.TryParse( text, out price ) ) - price = -1; + if ( !int.TryParse( text, out int price ) ) + price = -1; if ( price < 0 ) { @@ -500,10 +498,8 @@ namespace Server.Gumps text = text.Trim(); - int price; - - if ( !int.TryParse( text, out price ) ) - price = -1; + if ( !int.TryParse( text, out int price ) ) + price = -1; if ( price < 0 ) { @@ -558,20 +554,20 @@ namespace Server.Gumps */ AddHtmlLocalized( 10, 10, 400, 150, 1062501, 0x7FFF, false, true ); - AddHtmlLocalized( 10, 180, 150, 20, 1062508, 0x7FFF, false, false ); // Vendor Name: + AddHtmlLocalized( 10, 180, 150, 20, 1062508, 0x7FFF ); // Vendor Name: AddLabel( 160, 180, 0x480, vendor.Name ); - AddHtmlLocalized( 10, 200, 150, 20, 1062509, 0x7FFF, false, false ); // Shop Name: + AddHtmlLocalized( 10, 200, 150, 20, 1062509, 0x7FFF ); // Shop Name: AddLabel( 160, 200, 0x480, vendor.ShopName ); - AddHtmlLocalized( 10, 220, 150, 20, 1062510, 0x7FFF, false, false ); // Refund Amount: + AddHtmlLocalized( 10, 220, 150, 20, 1062510, 0x7FFF ); // Refund Amount: AddLabel( 160, 220, 0x480, refundAmount.ToString() ); - AddButton( 10, 268, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 45, 268, 350, 20, 1062511, 0x7FFF, false, false ); // Agree, and dismiss vendor + AddButton( 10, 268, 0xFA5, 0xFA7, 1); + AddHtmlLocalized( 45, 268, 350, 20, 1062511, 0x7FFF ); // Agree, and dismiss vendor - AddButton( 10, 288, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 45, 288, 350, 20, 1062512, 0x7FFF, false, false ); // No, I want to keep my vendor + AddButton( 10, 288, 0xFA5, 0xFA7, 0); + AddHtmlLocalized( 45, 288, 350, 20, 1062512, 0x7FFF ); // No, I want to keep my vendor } public override void OnResponse( NetState sender, RelayInfo info ) diff --git a/Scripts/Gumps/ViewHousesGump.cs b/Scripts/Gumps/ViewHousesGump.cs index ccd70cf44..2b4e2845e 100644 --- a/Scripts/Gumps/ViewHousesGump.cs +++ b/Scripts/Gumps/ViewHousesGump.cs @@ -30,14 +30,14 @@ namespace Server.Gumps AddBackground(0, 0, 240, 360, 5054); AddBlackAlpha(10, 10, 220, 340); - if (sel == null || sel.Deleted) + if (sel?.Deleted != false) { m_Selection = null; - AddHtml(35, 15, 120, 20, Color("House Type", White), false, false); + 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), false, false); + AddHtml(35, 40, 160, 40, Color("There were no houses found for that player.", White)); AddImage(190, 17, 0x25EA); AddImage(207, 17, 0x25E6); @@ -59,14 +59,14 @@ namespace Server.Gumps object name = FindHouseName(list[i]); - AddHtml(15, 40 + i % 15 * 20, 20, 20, Color($"{i + 1}.", White), false, false); + AddHtml(15, 40 + i % 15 * 20, 20, 20, Color($"{i + 1}.", White)); if (name is int nameInt) - AddHtmlLocalized(35, 40 + i % 15 * 20, 160, 20, nameInt, White16, false, false); + AddHtmlLocalized(35, 40 + i % 15 * 20, 160, 20, nameInt, White16); else - AddHtml(35, 40 + i % 15 * 20, 160, 20, Color(name.ToString(), White), false, false); + AddHtml(35, 40 + i % 15 * 20, 160, 20, Color(name.ToString(), White)); - AddButton(198, 39 + i % 15 * 20, 4005, 4007, i + 1, GumpButtonType.Reply, 0); + AddButton(198, 39 + i % 15 * 20, 4005, 4007, i + 1); } } else @@ -88,49 +88,49 @@ namespace Server.Gumps else location = "unknown"; - AddHtml(10, 15, 220, 20, Color(Center("House Properties"), White), false, false); + AddHtml(10, 15, 220, 20, Color(Center("House Properties"), White)); - AddHtml(15, 40, 210, 20, Color("Facet:", White), false, false); - AddHtml(15, 40, 210, 20, Color(Right(map == null ? "(null)" : map.Name), White), false, false); + AddHtml(15, 40, 210, 20, Color("Facet:", White)); + AddHtml(15, 40, 210, 20, Color(Right(map == null ? "(null)" : map.Name), White)); - AddHtml(15, 60, 210, 20, Color("Location:", White), false, false); - AddHtml(15, 60, 210, 20, Color(Right(sel.Location.ToString()), White), false, false); + AddHtml(15, 60, 210, 20, Color("Location:", White)); + AddHtml(15, 60, 210, 20, Color(Right(sel.Location.ToString()), White)); - AddHtml(15, 80, 210, 20, Color("Sextant:", White), false, false); - AddHtml(15, 80, 210, 20, Color(Right(location), White), false, false); + AddHtml(15, 80, 210, 20, Color("Sextant:", White)); + AddHtml(15, 80, 210, 20, Color(Right(location), White)); - AddHtml(15, 100, 210, 20, Color("Owner:", White), false, false); - AddHtml(15, 100, 210, 20, Color(Right(owner), White), false, false); + AddHtml(15, 100, 210, 20, Color("Owner:", White)); + AddHtml(15, 100, 210, 20, Color(Right(owner), White)); - AddHtml(15, 120, 210, 20, Color("Name:", White), false, false); - AddHtml(15, 120, 210, 20, Color(Right(houseName), White), false, false); + AddHtml(15, 120, 210, 20, Color("Name:", White)); + AddHtml(15, 120, 210, 20, Color(Right(houseName), White)); - AddHtml(15, 140, 210, 20, Color("Friends:", White), false, false); - AddHtml(15, 140, 210, 20, Color(Right(sel.Friends.Count.ToString()), White), false, false); + AddHtml(15, 140, 210, 20, Color("Friends:", White)); + AddHtml(15, 140, 210, 20, Color(Right(sel.Friends.Count.ToString()), White)); - AddHtml(15, 160, 210, 20, Color("Co-Owners:", White), false, false); - AddHtml(15, 160, 210, 20, Color(Right(sel.CoOwners.Count.ToString()), White), false, false); + AddHtml(15, 160, 210, 20, Color("Co-Owners:", White)); + AddHtml(15, 160, 210, 20, Color(Right(sel.CoOwners.Count.ToString()), White)); - AddHtml(15, 180, 210, 20, Color("Bans:", White), false, false); - AddHtml(15, 180, 210, 20, Color(Right(sel.Bans.Count.ToString()), White), false, false); + AddHtml(15, 180, 210, 20, Color("Bans:", White)); + AddHtml(15, 180, 210, 20, Color(Right(sel.Bans.Count.ToString()), White)); - AddHtml(15, 200, 210, 20, Color("Decays:", White), false, false); - AddHtml(15, 200, 210, 20, Color(Right(sel.CanDecay ? "Yes" : "No"), White), false, false); + AddHtml(15, 200, 210, 20, Color("Decays:", White)); + AddHtml(15, 200, 210, 20, Color(Right(sel.CanDecay ? "Yes" : "No"), White)); - AddHtml(15, 220, 210, 20, Color("Decay Level:", White), false, false); - AddHtml(15, 220, 210, 20, Color(Right(sel.DecayLevel.ToString()), White), false, false); + AddHtml(15, 220, 210, 20, Color("Decay Level:", White)); + AddHtml(15, 220, 210, 20, Color(Right(sel.DecayLevel.ToString()), White)); - AddButton(15, 245, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtml(50, 245, 120, 20, Color("Go to house", White), false, false); + AddButton(15, 245, 4005, 4007, 1); + AddHtml(50, 245, 120, 20, Color("Go to house", White)); - AddButton(15, 265, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtml(50, 265, 120, 20, Color("Open house menu", White), false, false); + AddButton(15, 265, 4005, 4007, 2); + AddHtml(50, 265, 120, 20, Color("Open house menu", White)); - AddButton(15, 285, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtml(50, 285, 120, 20, Color("Demolish house", White), false, false); + AddButton(15, 285, 4005, 4007, 3); + AddHtml(50, 285, 120, 20, Color("Demolish house", White)); - AddButton(15, 305, 4005, 4007, 4, GumpButtonType.Reply, 0); - AddHtml(50, 305, 120, 20, Color("Refresh house", White), false, false); + AddButton(15, 305, 4005, 4007, 4); + AddHtml(50, 305, 120, 20, Color("Refresh house", White)); } } @@ -208,7 +208,7 @@ namespace Server.Gumps HouseSign sign = m_Selection.Sign; - if (sign != null && !sign.Deleted) + if (sign?.Deleted == false) sign.OnDoubleClick(m_From); break; @@ -234,9 +234,7 @@ namespace Server.Gumps public object FindHouseName(BaseHouse house) { int multiID = house.ItemID; - HousePlacementEntry[] entries; - - entries = HousePlacementEntry.ClassicHouses; + HousePlacementEntry[] entries = HousePlacementEntry.ClassicHouses; for (int i = 0; i < entries.Length; ++i) if (entries[i].MultiID == multiID) @@ -288,4 +286,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Gumps/WarningGump.cs b/Scripts/Gumps/WarningGump.cs index 98dfa89ed..568bb945c 100644 --- a/Scripts/Gumps/WarningGump.cs +++ b/Scripts/Gumps/WarningGump.cs @@ -18,7 +18,7 @@ namespace Server.Gumps AddImageTiled( 10, 10, width - 20, 20, 2624 ); AddAlphaRegion( 10, 10, width - 20, 20 ); - AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false ); + AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor ); AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); AddAlphaRegion( 10, 40, width - 20, height - 80 ); @@ -31,13 +31,13 @@ namespace Server.Gumps AddImageTiled( 10, height - 30, width - 20, 20, 2624 ); AddAlphaRegion( 10, height - 30, width - 20, 20 ); - AddButton( 10, height - 30, 4005, 4007, 1, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 40, height - 30, 170, 20, 1011036, 32767, false, false ); // OKAY + AddButton( 10, height - 30, 4005, 4007, 1 ); + AddHtmlLocalized( 40, height - 30, 170, 20, 1011036, 32767 ); // OKAY if ( cancelButton ) { - AddButton( 10 + ((width - 20) / 2), height - 30, 4005, 4007, 0, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 40 + ((width - 20) / 2), height - 30, 170, 20, 1011012, 32767, false, false ); // CANCEL + AddButton( 10 + ((width - 20) / 2), height - 30, 4005, 4007, 0 ); + AddHtmlLocalized( 40 + ((width - 20) / 2), height - 30, 170, 20, 1011012, 32767 ); // CANCEL } } diff --git a/Scripts/Gumps/WhoGump.cs b/Scripts/Gumps/WhoGump.cs index 0f81d166b..b7992794e 100644 --- a/Scripts/Gumps/WhoGump.cs +++ b/Scripts/Gumps/WhoGump.cs @@ -98,11 +98,11 @@ namespace Server.Gumps } } - public WhoGump( Mobile owner, string filter ) : this( owner, BuildList( owner, filter ), 0 ) + public WhoGump(Mobile owner, string filter) : this(owner, BuildList( owner, filter )) { } - public WhoGump( Mobile owner, List list, int page ) : base( GumpOffsetX, GumpOffsetY ) + public WhoGump(Mobile owner, List list, int page = 0) : base(GumpOffsetX, GumpOffsetY) { owner.CloseGump(); @@ -112,12 +112,9 @@ namespace Server.Gumps Initialize( page ); } - public static List BuildList( Mobile owner, string filter ) + public static List BuildList(Mobile owner, string rawFilter) { - if ( filter != null && (filter = filter.Trim()).Length == 0 ) - filter = null; - else - filter = filter.ToLower(); + string filter = String.IsNullOrWhiteSpace(rawFilter) ? null : rawFilter.Trim().ToLower(); List list = new List(); List states = NetState.Instances; @@ -126,9 +123,9 @@ namespace Server.Gumps { Mobile m = states[i].Mobile; - if ( m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel || (m is PlayerMobile mobile && mobile.VisibilityList.Contains( owner ) ) ) ) + if ( m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel || m is PlayerMobile mobile && mobile.VisibilityList.Contains( owner ) ) ) { - if ( filter != null && ( m.Name == null || m.Name.ToLower().IndexOf( filter ) < 0 ) ) + if ( filter != null && !(m.Name?.ToLower().IndexOf(filter) >= 0) ) continue; list.Add( m ); @@ -144,14 +141,14 @@ namespace Server.Gumps { m_Page = page; - int count = m_Mobiles.Count - (page * EntryCount); + int count = m_Mobiles.Count - page * EntryCount; if ( count < 0 ) count = 0; else if ( count > EntryCount ) count = EntryCount; - int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1)); + int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1); AddPage( 0 ); @@ -178,7 +175,7 @@ namespace Server.Gumps if ( page > 0 ) { - AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 ); + AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1 ); if ( PrevLabel ) AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" ); @@ -213,7 +210,7 @@ namespace Server.Gumps AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID ); if ( m.NetState != null && !m.Deleted ) - AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0 ); + AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3 ); } } @@ -227,14 +224,9 @@ namespace Server.Gumps case AccessLevel.Seer: return 0x144; case AccessLevel.GameMaster: return 0x21; case AccessLevel.Counselor: return 0x2; - case AccessLevel.Player: default: + default: { - if ( m.Kills >= 5 ) - return 0x21; - if ( m.Criminal ) - return 0x3B1; - - return 0x58; + return m.Kills >= 5 ? 0x21 : m.Criminal ? 0x3B1 : 0x58; } } } @@ -265,7 +257,7 @@ namespace Server.Gumps } default: { - int index = (m_Page * EntryCount) + (info.ButtonID - 3); + int index = m_Page * EntryCount + (info.ButtonID - 3); if ( index >= 0 && index < m_Mobiles.Count ) { @@ -281,7 +273,7 @@ namespace Server.Gumps from.SendMessage( "That player is no longer online." ); from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) ); } - else if ( m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || (m is PlayerMobile mobile && mobile.VisibilityList.Contains( from ))) + else if ( m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || m is PlayerMobile mobile && mobile.VisibilityList.Contains( from )) { from.SendGump( new ClientGump( from, m.NetState ) ); } diff --git a/Scripts/Gumps/YoungGumps.cs b/Scripts/Gumps/YoungGumps.cs index 11277fc0d..c6e05fc07 100644 --- a/Scripts/Gumps/YoungGumps.cs +++ b/Scripts/Gumps/YoungGumps.cs @@ -11,8 +11,8 @@ namespace Server.Gumps AddHtmlLocalized( 20, 43, 215, 70, 1018030, true, true ); // Warning: monsters may attack you on site down here in the dungeons! - AddButton( 70, 123, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 105, 125, 100, 35, 1011036, false, false ); // OKAY + AddButton( 70, 123, 0xFA5, 0xFA7, 0); + AddHtmlLocalized( 105, 125, 100, 35, 1011036 ); // OKAY } } @@ -27,22 +27,22 @@ namespace Server.Gumps AddImageTiled( 33, 20, 407, 425, 0xA40 ); AddAlphaRegion( 33, 20, 407, 425 ); - AddHtmlLocalized( 190, 24, 120, 20, 1046287, 0x7D00, false, false ); // You have died. + AddHtmlLocalized( 190, 24, 120, 20, 1046287, 0x7D00 ); // You have died. // As a ghost you cannot interact with the world. You cannot touch items nor can you use them. - AddHtmlLocalized( 50, 50, 380, 40, 1046288, 0xFFFFFF, false, false ); + AddHtmlLocalized( 50, 50, 380, 40, 1046288, 0xFFFFFF ); // You can pass through doors as though they do not exist. However, you cannot pass through walls. - AddHtmlLocalized( 50, 100, 380, 45, 1046289, 0xFFFFFF, false, false ); + AddHtmlLocalized( 50, 100, 380, 45, 1046289, 0xFFFFFF ); // Since you are a new player, any items you had on your person at the time of your death will be in your backpack upon resurrection. - AddHtmlLocalized( 50, 140, 380, 60, 1046291, 0xFFFFFF, false, false ); + AddHtmlLocalized( 50, 140, 380, 60, 1046291, 0xFFFFFF ); // To be resurrected you must find a healer in town or wandering in the wilderness. Some powerful players may also be able to resurrect you. - AddHtmlLocalized( 50, 204, 380, 65, 1046292, 0xFFFFFF, false, false ); + AddHtmlLocalized( 50, 204, 380, 65, 1046292, 0xFFFFFF ); // While you are still in young status, you will be transported to the nearest healer (along with your items) at the time of your death. - AddHtmlLocalized( 50, 269, 380, 65, 1046293, 0xFFFFFF, false, false ); + AddHtmlLocalized( 50, 269, 380, 65, 1046293, 0xFFFFFF ); // To rejoin the world of the living simply walk near one of the NPC healers, and they will resurrect you as long as you are not marked as a criminal. - AddHtmlLocalized( 50, 334, 380, 70, 1046294, 0xFFFFFF, false, false ); + AddHtmlLocalized( 50, 334, 380, 70, 1046294, 0xFFFFFF ); - AddButton( 195, 410, 0xF8, 0xF9, 0, GumpButtonType.Reply, 0 ); + AddButton( 195, 410, 0xF8, 0xF9, 0); } } @@ -52,7 +52,7 @@ namespace Server.Gumps { AddBackground( 0, 0, 450, 400, 0xA28 ); - AddHtmlLocalized( 0, 30, 450, 35, 1013004, false, false ); //
Renouncing 'Young Player' Status
+ AddHtmlLocalized( 0, 30, 450, 35, 1013004 ); //
Renouncing 'Young Player' Status
/* As a 'Young' player, you are currently under a system of protection that prevents * you from being attacked by other players and certain monsters.

@@ -66,11 +66,11 @@ namespace Server.Gumps */ AddHtmlLocalized( 30, 70, 390, 210, 1013005, true, true ); - AddButton( 45, 298, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 78, 300, 100, 35, 1011036, false, false ); // OKAY + AddButton( 45, 298, 0xFA5, 0xFA7, 1); + AddHtmlLocalized( 78, 300, 100, 35, 1011036 ); // OKAY - AddButton( 178, 298, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 211, 300, 100, 35, 1011012, false, false ); // CANCEL + AddButton( 178, 298, 0xFA5, 0xFA7, 0); + AddHtmlLocalized( 211, 300, 100, 35, 1011012 ); // CANCEL } public override void OnResponse( NetState sender, RelayInfo info ) diff --git a/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs b/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs index 065b3b9ee..7f6be722c 100644 --- a/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs +++ b/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs @@ -1,3 +1,4 @@ +using System.Linq; using Server.Gumps; using Server.Multis; using Server.Network; @@ -8,13 +9,7 @@ namespace Server.Items public class Fireflies : Item, IAddon { [Constructible] - public Fireflies() - : this(0x1596) - { - } - - [Constructible] - public Fireflies(int itemID) + public Fireflies(int itemID = 0x1596) : base(itemID) { LootType = LootType.Blessed; @@ -65,7 +60,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration? @@ -120,7 +115,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); @@ -175,8 +170,8 @@ namespace Server.Items AddItem(90, 30, 0x2332); AddItem(180, 30, 0x2336); - AddButton(50, 35, 0x868, 0x869, (int)Buttons.East, GumpButtonType.Reply, 0); - AddButton(145, 35, 0x868, 0x869, (int)Buttons.South, GumpButtonType.Reply, 0); + AddButton(50, 35, 0x868, 0x869, (int)Buttons.East); + AddButton(145, 35, 0x868, 0x869, (int)Buttons.South); } public override void OnResponse(NetState sender, RelayInfo info) @@ -219,14 +214,14 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_FirefliesDeed == null || m_FirefliesDeed.Deleted) + if (m_FirefliesDeed?.Deleted != false) return; if (m_FirefliesDeed.IsChildOf(from.Backpack)) { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { IPoint3D p = targeted as IPoint3D; Map map = from.Map; @@ -241,16 +236,12 @@ namespace Server.Items { house = BaseHouse.FindHouseAt(p3d, map, id.Height); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); - bool isclear = true; - - foreach (Item item in Map.Malas.GetItemsInRange(p3d, 0)) - if (item is Fireflies) - isclear = false; + bool isclear = !Map.Malas.GetItemsInRange(p3d, 0).OfType().Any(); if ((m_ItemID == 0x2336 && north || m_ItemID == 0x2332 && west) && isclear) { @@ -290,4 +281,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index 2784cea48..dfe3aa2a3 100644 --- a/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -44,7 +44,8 @@ namespace Server.Engines.Events public static void RemoveHueMod(Mobile target) { - if (target != null && !target.Deleted) target.SolidHueOverride = -1; + if (target?.Deleted == false) + target.SolidHueOverride = -1; } public static void SolidHueMobile(Mobile target) @@ -67,7 +68,7 @@ namespace Server.Engines.Events if (twin.Deleted) return; - + foreach (Item item in m_From.Items) if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank) m_Items.Add(item); @@ -122,78 +123,80 @@ namespace Server.Engines.Events protected override void OnTarget(Mobile from, object targ) { - if (targ != null && CheckMobile(from)) + if (targ == null || !CheckMobile(from)) + return; + + if (!(targ is Mobile)) { - if (!(targ is Mobile)) + from.SendLocalizedMessage(1076781); /* There is little chance of getting candy from that! */ + return; + } + + BaseVendor begged = targ as BaseVendor; + + if (begged?.Deleted != false) + { + from.SendLocalizedMessage(1076765); /* That doesn't look friendly. */ + return; + } + + DateTime now = DateTime.UtcNow; + + + + if (CheckMobile(begged)) + { + if (begged.NextTrickOrTreat > now) { - from.SendLocalizedMessage(1076781); /* There is little chance of getting candy from that! */ + from.SendLocalizedMessage(1076767); /* That doesn't appear to have any more candy. */ return; } - if (!(targ is BaseVendor) || ((BaseVendor)targ).Deleted) - { - from.SendLocalizedMessage(1076765); /* That doesn't look friendly. */ + begged.NextTrickOrTreat = now + TimeSpan.FromMinutes(Utility.RandomMinMax(5, 10)); + + if (from.Backpack?.Deleted != false) return; - } - DateTime now = DateTime.UtcNow; - - BaseVendor m_Begged = targ as BaseVendor; - - if (CheckMobile(m_Begged)) + if (Utility.RandomDouble() > .10) { - if (m_Begged.NextTrickOrTreat > now) + switch (Utility.Random(3)) { - from.SendLocalizedMessage(1076767); /* That doesn't appear to have any more candy. */ - return; + case 0: + begged.Say(1076768); + break; /* Oooooh, aren't you cute! */ + case 1: + begged.Say(1076779); + break; /* All right...This better not spoil your dinner! */ + case 2: + begged.Say(1076778); + break; /* Here you go! Enjoy! */ } - m_Begged.NextTrickOrTreat = now + TimeSpan.FromMinutes(Utility.RandomMinMax(5, 10)); - - if (from.Backpack != null && !from.Backpack.Deleted) + if (Utility.RandomDouble() <= .01 && from.Skills.Begging.Value >= 100) { - if (Utility.RandomDouble() > .10) - { - switch (Utility.Random(3)) - { - case 0: - m_Begged.Say(1076768); - break; /* Oooooh, aren't you cute! */ - case 1: - m_Begged.Say(1076779); - break; /* All right...This better not spoil your dinner! */ - case 2: - m_Begged.Say(1076778); - break; /* Here you go! Enjoy! */ - } + from.AddToBackpack(HolidaySettings.RandomGMBeggerItem); - if (Utility.RandomDouble() <= .01 && from.Skills.Begging.Value >= 100) - { - from.AddToBackpack(HolidaySettings.RandomGMBeggerItem); - - from.SendLocalizedMessage(1076777); /* You receive a special treat! */ - } - else - { - from.AddToBackpack(HolidaySettings.RandomTreat); - - from.SendLocalizedMessage(1076769); /* You receive some candy. */ - } - } - else - { - m_Begged.Say(1076770); /* TRICK! */ - - int action = Utility.Random(4); - - if (action == 0) - Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from); - else if (action == 1) - Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from); - else - Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from); - } + from.SendLocalizedMessage(1076777); /* You receive a special treat! */ } + else + { + from.AddToBackpack(HolidaySettings.RandomTreat); + + from.SendLocalizedMessage(1076769); /* You receive some candy. */ + } + } + else + { + begged.Say(1076770); /* TRICK! */ + + int action = Utility.Random(4); + + if (action == 0) + Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from); + else if (action == 1) + Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from); + else + Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from); } } } @@ -263,7 +266,8 @@ namespace Server.Engines.Events public override void OnThink() { - if (m_From == null || m_From.Deleted) Delete(); + if (m_From?.Deleted != false) + Delete(); } public static Item FindCandyTypes(Mobile target) @@ -287,7 +291,7 @@ namespace Server.Engines.Events target.SendLocalizedMessage(1113967); /* Your naughty twin steals some of your candy. */ - if (item != null && !item.Deleted) + if (item?.Deleted == false) item.Delete(); } else @@ -321,4 +325,4 @@ namespace Server.Engines.Events int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs b/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs index e281b1ecb..f84e9a357 100644 --- a/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs +++ b/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Events.Halloween; using Server.Items; @@ -41,18 +42,10 @@ namespace Server.Engines.Events Rectangle2D rect = m_PumpkinFields[i]; int spawncount = rect.Height * rect.Width / 20; - int pumpkins = 0; - - foreach (Item item in map.GetItemsInBounds(rect)) - if (item is HalloweenPumpkin) - pumpkins++; + int pumpkins = map.GetItemsInBounds(rect).OfType().Count(); if (spawncount > pumpkins) - { - Item item = new HalloweenPumpkin(); - - item.MoveToWorld(RandomPointIn(rect, map), map); - } + new HalloweenPumpkin().MoveToWorld(RandomPointIn(rect, map), map); } } @@ -65,4 +58,4 @@ namespace Server.Engines.Events return new Point3D(x, y, z); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/2009/Foods/CreepyCake.cs b/Scripts/Holiday Stuff/Halloween/2009/Foods/CreepyCake.cs index 3b10ec857..50e6761fd 100644 --- a/Scripts/Holiday Stuff/Halloween/2009/Foods/CreepyCake.cs +++ b/Scripts/Holiday Stuff/Halloween/2009/Foods/CreepyCake.cs @@ -8,8 +8,7 @@ public class CreepyCake : Food { [Constructible] - public CreepyCake() - : base(0x9e9) + public CreepyCake() : base(0x9e9, 1) { Hue = 0x3E4; } @@ -35,4 +34,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/2009/Foods/MrPlainsCookies.cs b/Scripts/Holiday Stuff/Halloween/2009/Foods/MrPlainsCookies.cs index 615ee0f98..7d7a354fc 100644 --- a/Scripts/Holiday Stuff/Halloween/2009/Foods/MrPlainsCookies.cs +++ b/Scripts/Holiday Stuff/Halloween/2009/Foods/MrPlainsCookies.cs @@ -3,8 +3,7 @@ public class MrPlainsCookies : Food { [Constructible] - public MrPlainsCookies() - : base(0x160C) + public MrPlainsCookies() : base(0x160C, 1) { Weight = 1.0; FillFactor = 4; @@ -32,4 +31,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs b/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs index bc0cc2622..7dc4fac64 100644 --- a/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs +++ b/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs @@ -39,9 +39,7 @@ namespace Server.Items.Holiday { get { - if (m_Staffer != null) return $"{MaskName} hand painted by {m_Staffer}"; - - return MaskName; + return m_Staffer != null ? $"{MaskName} hand painted by {m_Staffer}" : MaskName; } } diff --git a/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs b/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs index 2d946172a..f3a2d576b 100644 --- a/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs +++ b/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs @@ -87,10 +87,9 @@ namespace Server.Mobiles public virtual void Lifted_Callback(Mobile from) { - if (from != null && !from.Deleted && from is PlayerMobile) + if (from?.Deleted == false && from is PlayerMobile) { Combatant = from; - Warmode = true; } } @@ -127,4 +126,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs b/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs index a3ab83934..03ba47234 100644 --- a/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs +++ b/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs @@ -37,7 +37,7 @@ namespace Server.Engines.Events new Rectangle2D(4528,1314,28,20), // Moonglow new Rectangle2D(712,1104,22,30), // Yew new Rectangle2D(5824,1464,6,22), // Fire Dungeon - new Rectangle2D(5224,3655,5,14), // T2A + new Rectangle2D(5224,3655,5,14) // T2A }; public static void Initialize() @@ -98,7 +98,7 @@ namespace Server.Engines.Events } } - if ( player != null && !player.Deleted && ReAnimated.Count < m_TotalZombieLimit ) + if (player?.Deleted == false && ReAnimated.Count < m_TotalZombieLimit ) { Map map = Utility.RandomBool() ? Map.Trammel : Map.Felucca; @@ -158,7 +158,7 @@ namespace Server.Engines.Events public override void Serialize( GenericWriter writer ) { base.Serialize( writer ); - writer.Write( ( int )0 ); + writer.Write( 0 ); } public override void Deserialize( GenericReader reader ) @@ -175,17 +175,12 @@ namespace Server.Engines.Events private PlayerMobile m_DeadPlayer; - public ZombieSkeleton() - : this( null ) - { - } - - public ZombieSkeleton( PlayerMobile player ) + public ZombieSkeleton(PlayerMobile player = null) : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 ) { m_DeadPlayer = player; - Name = ( player != null ) ? $"{player.Name}'s {m_Name}" : m_Name; + Name = player != null ? $"{player.Name}'s {m_Name}" : m_Name; Body = 0x93; BaseSoundID = 0x1c3; @@ -228,7 +223,7 @@ namespace Server.Engines.Events case 2: PackItem( new Torso() ); break; case 3: PackItem( new Bone() ); break; case 4: PackItem( new RibCage() ); break; - case 5: if ( m_DeadPlayer != null && !m_DeadPlayer.Deleted ) { PackItem( new PlayerBones( m_DeadPlayer.Name ) ); } break; + case 5: if (m_DeadPlayer?.Deleted == false) { PackItem( new PlayerBones( m_DeadPlayer.Name ) ); } break; default: break; } @@ -248,7 +243,7 @@ namespace Server.Engines.Events { if ( HalloweenHauntings.ReAnimated != null ) { - if ( m_DeadPlayer != null && !m_DeadPlayer.Deleted ) + if (m_DeadPlayer?.Deleted == false) { if ( HalloweenHauntings.ReAnimated.ContainsKey( m_DeadPlayer ) ) HalloweenHauntings.ReAnimated.Remove( m_DeadPlayer ); diff --git a/Scripts/Holiday Stuff/Halloween/Treats/Jellybeans.cs b/Scripts/Holiday Stuff/Halloween/Treats/Jellybeans.cs index b3d01c553..29c41ee19 100644 --- a/Scripts/Holiday Stuff/Halloween/Treats/Jellybeans.cs +++ b/Scripts/Holiday Stuff/Halloween/Treats/Jellybeans.cs @@ -2,13 +2,7 @@ { public class JellyBeans : CandyCane { - [Constructible] - public JellyBeans() - : this(1) - { - } - - public JellyBeans(int amount) + public JellyBeans(int amount = 1) : base(0x468C) { Stackable = true; @@ -35,4 +29,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/Treats/Lollipops.cs b/Scripts/Holiday Stuff/Halloween/Treats/Lollipops.cs index 8691295f2..f4c2e3de4 100644 --- a/Scripts/Holiday Stuff/Halloween/Treats/Lollipops.cs +++ b/Scripts/Holiday Stuff/Halloween/Treats/Lollipops.cs @@ -4,13 +4,7 @@ public class Lollipops : CandyCane { [Constructible] - public Lollipops() - : this(1) - { - } - - [Constructible] - public Lollipops(int amount) + public Lollipops(int amount = 1) : base(0x468D + Utility.Random(3)) { Stackable = true; @@ -35,4 +29,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/Treats/NougatSwirl.cs b/Scripts/Holiday Stuff/Halloween/Treats/NougatSwirl.cs index 3b00afb5a..d4eebd192 100644 --- a/Scripts/Holiday Stuff/Halloween/Treats/NougatSwirl.cs +++ b/Scripts/Holiday Stuff/Halloween/Treats/NougatSwirl.cs @@ -3,12 +3,7 @@ public class NougatSwirl : CandyCane { [Constructible] - public NougatSwirl() : this(1) - { - } - - [Constructible] - public NougatSwirl(int amount) + public NougatSwirl(int amount = 1) : base(0x4690) { Stackable = true; @@ -35,4 +30,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/Treats/Taffy.cs b/Scripts/Holiday Stuff/Halloween/Treats/Taffy.cs index cec62e912..ca74450e6 100644 --- a/Scripts/Holiday Stuff/Halloween/Treats/Taffy.cs +++ b/Scripts/Holiday Stuff/Halloween/Treats/Taffy.cs @@ -2,13 +2,7 @@ { public class Taffy : CandyCane { - [Constructible] - public Taffy() - : this(1) - { - } - - public Taffy(int amount) + public Taffy(int amount = 1) : base(0x469D) { Stackable = true; @@ -35,4 +29,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Halloween/Treats/WrappedCandy.cs b/Scripts/Holiday Stuff/Halloween/Treats/WrappedCandy.cs index 085081968..5bd2e9ab5 100644 --- a/Scripts/Holiday Stuff/Halloween/Treats/WrappedCandy.cs +++ b/Scripts/Holiday Stuff/Halloween/Treats/WrappedCandy.cs @@ -2,13 +2,7 @@ { public class WrappedCandy : CandyCane { - [Constructible] - public WrappedCandy() - : this(1) - { - } - - public WrappedCandy(int amount) + public WrappedCandy(int amount = 1) : base(0x469e) { Stackable = true; @@ -35,4 +29,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs b/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs index 40ebc91f8..f31d2ae7c 100644 --- a/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs +++ b/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs @@ -167,24 +167,23 @@ namespace Server.Items AddPage(0); AddBackground(0, 0, 420, 320, 9300); - AddHtml(10, 10, 400, 21, "
St. Valentine Bear
", false, false); - AddHtmlLocalized(10, 40, 400, 75, 1150293, 0, false, - false); // Enter up to three lines of personalized greeting for your St. Valentine Bear. You many enter up to 25 characters per line. Once you enter text, you will only be able to correct mistakes for 10 minutes. + AddHtml(10, 10, 400, 21, "
St. Valentine Bear
"); + AddHtmlLocalized(10, 40, 400, 75, 1150293, 0); // Enter up to three lines of personalized greeting for your St. Valentine Bear. You many enter up to 25 characters per line. Once you enter text, you will only be able to correct mistakes for 10 minutes. - AddHtmlLocalized(10, 129, 400, 21, 1150296, 0, false, false); // Line 1: + AddHtmlLocalized(10, 129, 400, 21, 1150296, 0); // Line 1: AddBackground(10, 150, 400, 24, 9350); AddTextEntry(15, 152, 390, 20, 0, 0, "", 25); - AddHtmlLocalized(10, 179, 400, 21, 1150297, 0, false, false); // Line 2: + AddHtmlLocalized(10, 179, 400, 21, 1150297, 0); // Line 2: AddBackground(10, 200, 400, 24, 9350); AddTextEntry(15, 202, 390, 20, 0, 1, "", 25); - AddHtmlLocalized(10, 229, 400, 21, 1150298, 0, false, false); // Line 3: + AddHtmlLocalized(10, 229, 400, 21, 1150298, 0); // Line 3: AddBackground(10, 250, 400, 24, 9350); AddTextEntry(15, 252, 390, 20, 0, 2, "", 25); - AddButton(15, 285, 242, 241, 0, GumpButtonType.Reply, 0); - AddButton(335, 285, 247, 248, 1, GumpButtonType.Reply, 0); + AddButton(15, 285, 242, 241, 0); + AddButton(335, 285, 247, 248, 1); } public override void OnResponse(NetState sender, RelayInfo info) @@ -237,13 +236,7 @@ namespace Server.Items public class StValentinesPanda : StValentinesBear { [Constructible] - public StValentinesPanda() - : this(null) - { - } - - [Constructible] - public StValentinesPanda(string name) + public StValentinesPanda(string name = null) : base(0x48E0, name) { } @@ -272,13 +265,7 @@ namespace Server.Items public class StValentinesPolarBear : StValentinesBear { [Constructible] - public StValentinesPolarBear() - : this(null) - { - } - - [Constructible] - public StValentinesPolarBear(string name) + public StValentinesPolarBear(string name = null) : base(0x48E2, name) { } @@ -302,4 +289,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs b/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs index 86a2b5bee..9c34c5824 100644 --- a/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs +++ b/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs @@ -110,7 +110,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int)0 ); + writer.Write( 0 ); writer.Write( m_From ); writer.Write( m_To ); diff --git a/Scripts/Items/Addons/AddonComponent.cs b/Scripts/Items/Addons/AddonComponent.cs index 3d69fc204..a3d5ed2ec 100644 --- a/Scripts/Items/Addons/AddonComponent.cs +++ b/Scripts/Items/Addons/AddonComponent.cs @@ -147,7 +147,7 @@ namespace Server.Items { base.Hue = value; - if (Addon != null && Addon.ShareHue) + if (Addon?.ShareHue == true) Addon.Hue = value; } } @@ -259,4 +259,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/AddonContainerComponent.cs b/Scripts/Items/Addons/AddonContainerComponent.cs index 6ebb94840..08cb07d44 100644 --- a/Scripts/Items/Addons/AddonContainerComponent.cs +++ b/Scripts/Items/Addons/AddonContainerComponent.cs @@ -35,7 +35,7 @@ namespace Server.Items { base.Hue = value; - if (Addon != null && Addon.ShareHue) + if (Addon?.ShareHue == true) Addon.Hue = value; } } @@ -152,4 +152,4 @@ namespace Server.Items m_LabelNumber = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/ArcheryButteAddon.cs b/Scripts/Items/Addons/ArcheryButteAddon.cs index 129f13b8c..aa04779d6 100644 --- a/Scripts/Items/Addons/ArcheryButteAddon.cs +++ b/Scripts/Items/Addons/ArcheryButteAddon.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Network; @@ -20,7 +19,7 @@ namespace Server.Items [CommandProperty( AccessLevel.GameMaster )] public bool FacingEast { - get => ( ItemID == 0x100A ); + get => ItemID == 0x100A; set => ItemID = value ? 0x100A : 0x100B; } @@ -30,12 +29,7 @@ namespace Server.Items [CommandProperty( AccessLevel.GameMaster )] public int Bolts { get; set; } - [Constructible] - public ArcheryButte() : this( 0x100A ) - { - } - - public ArcheryButte( int itemID ) : base( itemID ) + public ArcheryButte(int itemID = 0x100A) : base(itemID) { MinSkill = -25.0; MaxSkill = +25.0; @@ -141,11 +135,11 @@ namespace Server.Items Container pack = from.Backpack; Type ammoType = bow.AmmoType; - bool isArrow = ( ammoType == typeof( Arrow ) ); - bool isBolt = ( ammoType == typeof( Bolt ) ); - bool isKnown = ( isArrow || isBolt ); + bool isArrow = ammoType == typeof( Arrow ); + bool isBolt = ammoType == typeof( Bolt ); + bool isKnown = isArrow || isBolt; - if ( pack == null || !pack.ConsumeTotal( ammoType, 1 ) ) + if (pack?.ConsumeTotal( ammoType ) != true) { if ( isArrow ) from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500594 ); // You do not have any arrows with which to practice. @@ -241,7 +235,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); + writer.Write( 0 ); writer.Write( MinSkill ); writer.Write( MaxSkill ); @@ -283,7 +277,7 @@ namespace Server.Items [Constructible] public ArcheryButteAddon() { - AddComponent( new ArcheryButte( 0x100A ), 0, 0, 0 ); + AddComponent( new ArcheryButte(), 0, 0, 0 ); } public ArcheryButteAddon( Serial serial ) : base( serial ) @@ -294,7 +288,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( 0 ); // version } public override void Deserialize( GenericReader reader ) @@ -323,7 +317,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( 0 ); // version } public override void Deserialize( GenericReader reader ) diff --git a/Scripts/Items/Addons/BallotBox.cs b/Scripts/Items/Addons/BallotBox.cs index bd39cd5cf..e69bebaa4 100644 --- a/Scripts/Items/Addons/BallotBox.cs +++ b/Scripts/Items/Addons/BallotBox.cs @@ -64,7 +64,7 @@ namespace Server.Items return true; BaseHouse house = BaseHouse.FindHouseAt(this); - return house != null && house.IsOwner(from); + return house?.IsOwner(from) == true; } public bool HasVoted(Mobile from) @@ -132,11 +132,11 @@ namespace Server.Items AddBackground(0, 0, 400, 350, 0xA28); if (isOwner) - AddHtmlLocalized(0, 15, 400, 35, 1011000, false, false); //
Ballot Box Owner's Menu
+ AddHtmlLocalized(0, 15, 400, 35, 1011000); //
Ballot Box Owner's Menu
else - AddHtmlLocalized(0, 15, 400, 35, 1011001, false, false); //
Ballot Box -- Vote Here!
+ AddHtmlLocalized(0, 15, 400, 35, 1011001); //
Ballot Box -- Vote Here!
- AddHtmlLocalized(0, 50, 400, 35, 1011002, false, false); //
Topic
+ AddHtmlLocalized(0, 50, 400, 35, 1011002); //
Topic
int lineCount = box.Topic.Length; AddBackground(25, 90, 350, Math.Max(20 * lineCount, 20), 0x1400); @@ -153,16 +153,16 @@ namespace Server.Items int noCount = box.No.Count; int totalVotes = yesCount + noCount; - AddHtmlLocalized(0, 215, 400, 35, 1011003, false, false); //
votes
+ AddHtmlLocalized(0, 215, 400, 35, 1011003); //
votes
if (!isOwner) - AddButton(20, 240, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 242, 25, 35, 1011004, false, false); // aye: + 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, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 277, 25, 35, 1011005, false, false); // nay: + AddButton(20, 275, 0xFA5, 0xFA7, 4); + AddHtmlLocalized(55, 277, 25, 35, 1011005); // nay: AddLabel(78, 277, 0x0, $"[{noCount}]"); if (totalVotes > 0) @@ -171,16 +171,16 @@ namespace Server.Items AddImageTiled(130, 277, noCount * 225 / totalVotes, 10, 0xD6); } - AddButton(45, 305, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 308, 40, 35, 1011008, false, false); // done + AddButton(45, 305, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(80, 308, 40, 35, 1011008); // done if (isOwner) { - AddButton(120, 305, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(155, 308, 100, 35, 1011006, false, false); // change topic + AddButton(120, 305, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(155, 308, 100, 35, 1011006); // change topic - AddButton(240, 305, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(275, 308, 300, 100, 1011007, false, false); // reset votes + AddButton(240, 305, 0xFA5, 0xFA7, 2); + AddHtmlLocalized(275, 308, 300, 100, 1011007); // reset votes } } @@ -375,4 +375,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/BaseAddon.cs b/Scripts/Items/Addons/BaseAddon.cs index 9c0d0558d..3f889fdc2 100644 --- a/Scripts/Items/Addons/BaseAddon.cs +++ b/Scripts/Items/Addons/BaseAddon.cs @@ -72,7 +72,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from) && house.Addons.Contains(this)) + if (house?.IsOwner(from) == true && house.Addons.Contains(this)) { Effects.PlaySound(GetWorldLocation(), Map, 0x3B3); from.SendLocalizedMessage(500461); // You destroy the item. @@ -165,12 +165,7 @@ namespace Server.Items public static bool CheckHouse(Mobile from, Point3D p, Map map, int height, ref BaseHouse house) { - house = BaseHouse.FindHouseAt(p, map, height); - - if (house == null || from != null && !house.IsOwner(from)) - return false; - - return true; + return from == null || BaseHouse.FindHouseAt(p, map, height)?.IsOwner(from) == true; } public static bool IsWall(int x, int y, int z, Map map) @@ -277,4 +272,4 @@ namespace Server.Items #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/BaseAddonContainer.cs b/Scripts/Items/Addons/BaseAddonContainer.cs index 2677e4c06..266565f64 100644 --- a/Scripts/Items/Addons/BaseAddonContainer.cs +++ b/Scripts/Items/Addons/BaseAddonContainer.cs @@ -79,7 +79,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { if (!IsSecure) { @@ -255,16 +255,17 @@ namespace Server.Items { BaseDoor door = doors[i]; - if (door != null && door.Open) + if (door?.Open == true) return AddonFitResult.DoorsNotClosed; Point3D doorLoc = door.GetWorldLocation(); int doorHeight = door.ItemData.CalcHeight; + int addonHeight; foreach (AddonContainerComponent c in Components) { Point3D addonLoc = new Point3D(p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z); - int addonHeight = c.ItemData.CalcHeight; + addonHeight = c.ItemData.CalcHeight; if (Utility.InRange(doorLoc, addonLoc, 1) && (addonLoc.Z == doorLoc.Z || @@ -273,10 +274,10 @@ namespace Server.Items } Point3D addonLo = new Point3D(p.X, p.Y, p.Z); - int addonHeigh = ItemData.CalcHeight; + addonHeight = ItemData.CalcHeight; if (Utility.InRange(doorLoc, addonLo, 1) && - (addonLo.Z == doorLoc.Z || addonLo.Z + addonHeigh > doorLoc.Z && doorLoc.Z + doorHeight > addonLo.Z)) + (addonLo.Z == doorLoc.Z || addonLo.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLo.Z)) return AddonFitResult.DoorTooClose; } } @@ -292,4 +293,4 @@ namespace Server.Items { } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/BaseAddonContainerDeed.cs b/Scripts/Items/Addons/BaseAddonContainerDeed.cs index ab86868c1..2247376b0 100644 --- a/Scripts/Items/Addons/BaseAddonContainerDeed.cs +++ b/Scripts/Items/Addons/BaseAddonContainerDeed.cs @@ -55,7 +55,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; return quality; @@ -164,4 +164,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/DartBoard.cs b/Scripts/Items/Addons/DartBoard.cs index 98b051cf6..fc7dd5435 100644 --- a/Scripts/Items/Addons/DartBoard.cs +++ b/Scripts/Items/Addons/DartBoard.cs @@ -5,12 +5,7 @@ namespace Server.Items public class DartBoard : AddonComponent { [Constructible] - public DartBoard() : this(true) - { - } - - [Constructible] - public DartBoard(bool east) : base(east ? 0x1E2F : 0x1E2E) + public DartBoard(bool east = true) : base(east ? 0x1E2F : 0x1E2E) { } @@ -100,7 +95,7 @@ namespace Server.Items { public DartBoardEastAddon() { - AddComponent(new DartBoard(true), 0, 0, 0); + AddComponent(new DartBoard(), 0, 0, 0); } public DartBoardEastAddon(Serial serial) : base(serial) @@ -211,4 +206,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/FireColumnAddon.cs b/Scripts/Items/Addons/FireColumnAddon.cs index 6ec1ae4cc..11992e3d3 100644 --- a/Scripts/Items/Addons/FireColumnAddon.cs +++ b/Scripts/Items/Addons/FireColumnAddon.cs @@ -3,13 +3,7 @@ namespace Server.Items public class FireColumnAddon : BaseAddon { [Constructible] - public FireColumnAddon() - : this(false) - { - } - - [Constructible] - public FireColumnAddon(bool bloody) + public FireColumnAddon(bool bloody = false) { AddComponent(new AddonComponent(0x3A5), 0, 0, 0); AddComponent(new AddonComponent(0x3A5), 0, 0, 5); @@ -54,4 +48,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/GozaMats.cs b/Scripts/Items/Addons/GozaMats.cs index 53942e991..d24f54a7b 100644 --- a/Scripts/Items/Addons/GozaMats.cs +++ b/Scripts/Items/Addons/GozaMats.cs @@ -3,12 +3,7 @@ namespace Server.Items public class GozaMatEastAddon : BaseAddon { [Constructible] - public GozaMatEastAddon() : this(0) - { - } - - [Constructible] - public GozaMatEastAddon(int hue) + public GozaMatEastAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28a4, 1030688), 1, 0, 0); AddComponent(new LocalizedAddonComponent(0x28a5, 1030688), 0, 0, 0); @@ -70,12 +65,7 @@ namespace Server.Items public class GozaMatSouthAddon : BaseAddon { [Constructible] - public GozaMatSouthAddon() : this(0) - { - } - - [Constructible] - public GozaMatSouthAddon(int hue) + public GozaMatSouthAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28a6, 1030688), 0, 1, 0); AddComponent(new LocalizedAddonComponent(0x28a7, 1030688), 0, 0, 0); @@ -137,12 +127,7 @@ namespace Server.Items public class SquareGozaMatEastAddon : BaseAddon { [Constructible] - public SquareGozaMatEastAddon() : this(0) - { - } - - [Constructible] - public SquareGozaMatEastAddon(int hue) + public SquareGozaMatEastAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28a8, 1030688), 0, 0, 0); Hue = hue; @@ -204,12 +189,7 @@ namespace Server.Items public class SquareGozaMatSouthAddon : BaseAddon { [Constructible] - public SquareGozaMatSouthAddon() : this(0) - { - } - - [Constructible] - public SquareGozaMatSouthAddon(int hue) + public SquareGozaMatSouthAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28a9, 1030688), 0, 0, 0); Hue = hue; @@ -270,12 +250,7 @@ namespace Server.Items public class BrocadeGozaMatEastAddon : BaseAddon { [Constructible] - public BrocadeGozaMatEastAddon() : this(0) - { - } - - [Constructible] - public BrocadeGozaMatEastAddon(int hue) + public BrocadeGozaMatEastAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28AB, 1030688), 0, 0, 0); AddComponent(new LocalizedAddonComponent(0x28AA, 1030688), 1, 0, 0); @@ -337,12 +312,7 @@ namespace Server.Items public class BrocadeGozaMatSouthAddon : BaseAddon { [Constructible] - public BrocadeGozaMatSouthAddon() : this(0) - { - } - - [Constructible] - public BrocadeGozaMatSouthAddon(int hue) + public BrocadeGozaMatSouthAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28AD, 1030688), 0, 0, 0); AddComponent(new LocalizedAddonComponent(0x28AC, 1030688), 0, 1, 0); @@ -404,12 +374,7 @@ namespace Server.Items public class BrocadeSquareGozaMatEastAddon : BaseAddon { [Constructible] - public BrocadeSquareGozaMatEastAddon() : this(0) - { - } - - [Constructible] - public BrocadeSquareGozaMatEastAddon(int hue) + public BrocadeSquareGozaMatEastAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28AE, 1030688), 0, 0, 0); Hue = hue; @@ -470,12 +435,7 @@ namespace Server.Items public class BrocadeSquareGozaMatSouthAddon : BaseAddon { [Constructible] - public BrocadeSquareGozaMatSouthAddon() : this(0) - { - } - - [Constructible] - public BrocadeSquareGozaMatSouthAddon(int hue) + public BrocadeSquareGozaMatSouthAddon(int hue = 0) { AddComponent(new LocalizedAddonComponent(0x28AF, 1030688), 0, 0, 0); Hue = hue; @@ -532,4 +492,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/LargeStoneTableEastAddon.cs b/Scripts/Items/Addons/LargeStoneTableEastAddon.cs index 10585f4aa..1579bd942 100644 --- a/Scripts/Items/Addons/LargeStoneTableEastAddon.cs +++ b/Scripts/Items/Addons/LargeStoneTableEastAddon.cs @@ -3,12 +3,7 @@ namespace Server.Items public class LargeStoneTableEastAddon : BaseAddon { [Constructible] - public LargeStoneTableEastAddon() : this(0) - { - } - - [Constructible] - public LargeStoneTableEastAddon(int hue) + public LargeStoneTableEastAddon(int hue = 0) { AddComponent(new AddonComponent(0x1202), 0, 0, 0); AddComponent(new AddonComponent(0x1203), 0, 1, 0); @@ -67,4 +62,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/LargeStoneTableSouthAddon.cs b/Scripts/Items/Addons/LargeStoneTableSouthAddon.cs index 20b657453..7e12a1c8c 100644 --- a/Scripts/Items/Addons/LargeStoneTableSouthAddon.cs +++ b/Scripts/Items/Addons/LargeStoneTableSouthAddon.cs @@ -3,12 +3,7 @@ namespace Server.Items public class LargeStoneTableSouthAddon : BaseAddon { [Constructible] - public LargeStoneTableSouthAddon() : this(0) - { - } - - [Constructible] - public LargeStoneTableSouthAddon(int hue) + public LargeStoneTableSouthAddon(int hue = 0) { AddComponent(new AddonComponent(0x1205), 0, 0, 0); AddComponent(new AddonComponent(0x1206), 1, 0, 0); @@ -67,4 +62,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/MediumStoneTableEastAddon.cs b/Scripts/Items/Addons/MediumStoneTableEastAddon.cs index 18da0efa7..9e83132df 100644 --- a/Scripts/Items/Addons/MediumStoneTableEastAddon.cs +++ b/Scripts/Items/Addons/MediumStoneTableEastAddon.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MediumStoneTableEastAddon : BaseAddon { [Constructible] - public MediumStoneTableEastAddon() : this(0) - { - } - - [Constructible] - public MediumStoneTableEastAddon(int hue) + public MediumStoneTableEastAddon(int hue = 0) { AddComponent(new AddonComponent(0x1202), 0, 0, 0); AddComponent(new AddonComponent(0x1201), 0, 1, 0); @@ -66,4 +61,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/MediumStoneTableSouthAddon.cs b/Scripts/Items/Addons/MediumStoneTableSouthAddon.cs index 2697185db..674413728 100644 --- a/Scripts/Items/Addons/MediumStoneTableSouthAddon.cs +++ b/Scripts/Items/Addons/MediumStoneTableSouthAddon.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MediumStoneTableSouthAddon : BaseAddon { [Constructible] - public MediumStoneTableSouthAddon() : this(0) - { - } - - [Constructible] - public MediumStoneTableSouthAddon(int hue) + public MediumStoneTableSouthAddon(int hue = 0) { AddComponent(new AddonComponent(0x1205), 0, 0, 0); AddComponent(new AddonComponent(0x1204), 1, 0, 0); @@ -66,4 +61,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/SHTeleporter.cs b/Scripts/Items/Addons/SHTeleporter.cs index f028f2744..a716ddbe4 100644 --- a/Scripts/Items/Addons/SHTeleporter.cs +++ b/Scripts/Items/Addons/SHTeleporter.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Commands; using Server.Mobiles; @@ -10,12 +11,7 @@ namespace Server.Items private SHTeleComponent m_TeleDest; [Constructible] - public SHTeleComponent() : this(0x1775) - { - } - - [Constructible] - public SHTeleComponent(int itemID) : this(itemID, new Point3D(0, 0, 0)) + public SHTeleComponent(int itemID = 0x1775) : this(itemID, new Point3D(0, 0, 0)) { } @@ -73,7 +69,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile m) { - if (!m_Active || m_TeleDest == null || m_TeleDest.Deleted || m_TeleDest.Map == Map.Internal) + if (!m_Active || m_TeleDest?.Deleted != false || m_TeleDest.Map == Map.Internal) return; if (m.InRange(this, 3)) @@ -124,12 +120,7 @@ namespace Server.Items private bool m_Changing; [Constructible] - public SHTeleporter() : this(true) - { - } - - [Constructible] - public SHTeleporter(bool external) + public SHTeleporter(bool external = true) { m_Changing = false; External = external; @@ -318,16 +309,9 @@ namespace Server.Items public static SHTeleporter FindSHTeleporter(Map map, Point3D p) { IPooledEnumerable eable = map.GetItemsInRange(p, 0); - - foreach (SHTeleporter item in eable) - if (item.Z == p.Z) - { - eable.Free(); - return item; - } - + SHTeleporter teleporter = eable.FirstOrDefault(item => item.Z == p.Z); eable.Free(); - return null; + return teleporter; } public SHTeleporter AddSHT(Map map, bool ext, int x, int y, int z) @@ -435,4 +419,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Addons/TrainingDummies.cs b/Scripts/Items/Addons/TrainingDummies.cs index ce7a20690..68c91b4c2 100644 --- a/Scripts/Items/Addons/TrainingDummies.cs +++ b/Scripts/Items/Addons/TrainingDummies.cs @@ -8,12 +8,7 @@ namespace Server.Items private Timer m_Timer; [Constructible] - public TrainingDummy() : this(0x1074) - { - } - - [Constructible] - public TrainingDummy(int itemID) : base(itemID) + public TrainingDummy(int itemID = 0x1074) : base(itemID) { MinSkill = -25.0; MaxSkill = +25.0; @@ -155,7 +150,7 @@ namespace Server.Items [Constructible] public TrainingDummyEastAddon() { - AddComponent(new TrainingDummy(0x1074), 0, 0, 0); + AddComponent(new TrainingDummy(), 0, 0, 0); } public TrainingDummyEastAddon(Serial serial) : base(serial) @@ -265,4 +260,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Aquarium/Aquarium.cs b/Scripts/Items/Aquarium/Aquarium.cs index d5cefdcc0..417a225f3 100644 --- a/Scripts/Items/Aquarium/Aquarium.cs +++ b/Scripts/Items/Aquarium/Aquarium.cs @@ -176,14 +176,10 @@ namespace Server.Items public virtual bool HasAccess(Mobile from) { - if (from == null || from.Deleted) - return false; - if (from.AccessLevel >= AccessLevel.GameMaster) - return true; - - BaseHouse house = BaseHouse.FindHouseAt(this); - - return house != null && house.IsCoOwner(from); + return from?.Deleted == false && ( + from.AccessLevel >= AccessLevel.GameMaster || + BaseHouse.FindHouseAt(this)?.IsCoOwner(from) == true + ); } public override bool OnDragDrop(Mobile from, Item dropped) @@ -1020,7 +1016,7 @@ namespace Server.Items { private Aquarium m_Aquarium; - public GMAddFood(Aquarium aquarium) : base(6231, -1) // GM Add Food + public GMAddFood(Aquarium aquarium) : base(6231) // GM Add Food { m_Aquarium = aquarium; } @@ -1039,7 +1035,7 @@ namespace Server.Items { private Aquarium m_Aquarium; - public GMAddWater(Aquarium aquarium) : base(6232, -1) // GM Add Water + public GMAddWater(Aquarium aquarium) : base(6232) // GM Add Water { m_Aquarium = aquarium; } @@ -1058,7 +1054,7 @@ namespace Server.Items { private Aquarium m_Aquarium; - public GMForceEvaluate(Aquarium aquarium) : base(6233, -1) // GM Force Evaluate + public GMForceEvaluate(Aquarium aquarium) : base(6233) // GM Force Evaluate { m_Aquarium = aquarium; } @@ -1076,7 +1072,7 @@ namespace Server.Items { private Aquarium m_Aquarium; - public GMOpen(Aquarium aquarium) : base(6234, -1) // GM Open Container + public GMOpen(Aquarium aquarium) : base(6234) // GM Open Container { m_Aquarium = aquarium; } @@ -1094,7 +1090,7 @@ namespace Server.Items { private Aquarium m_Aquarium; - public GMFill(Aquarium aquarium) : base(6236, -1) // GM Fill Food and Water + public GMFill(Aquarium aquarium) : base(6236) // GM Fill Food and Water { m_Aquarium = aquarium; } @@ -1170,4 +1166,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Aquarium/AquariumGump.cs b/Scripts/Items/Aquarium/AquariumGump.cs index 3e80470dc..f3071ca2b 100644 --- a/Scripts/Items/Aquarium/AquariumGump.cs +++ b/Scripts/Items/Aquarium/AquariumGump.cs @@ -35,46 +35,46 @@ namespace Server.Items // item name if (item.LabelNumber != 0) - AddHtmlLocalized(20, 217, 250, 20, item.LabelNumber, 0xFFFFFF, false, false); // Name + AddHtmlLocalized(20, 217, 250, 20, item.LabelNumber, 0xFFFFFF); // Name // item details if (item is BaseFish fish) - AddHtmlLocalized(20, 239, 315, 20, fish.GetDescription(), 0xFFFFFF, false, false); + AddHtmlLocalized(20, 239, 315, 20, fish.GetDescription(), 0xFFFFFF); else - AddHtmlLocalized(20, 239, 315, 20, 1073634, 0xFFFFFF, false, false); // An aquarium decoration + AddHtmlLocalized(20, 239, 315, 20, 1073634, 0xFFFFFF); // An aquarium decoration // item image AddItem(150, 80, item.ItemID, item.Hue); // item number / all items - AddHtml(20, 195, 250, 20, $"{page}/{m_Aquarium.Items.Count}", false, false); + AddHtml(20, 195, 250, 20, $"{page}/{m_Aquarium.Items.Count}"); // remove item if (edit) { AddBackground(230, 195, 100, 26, 0x13BE); - AddButton(235, 200, 0x845, 0x846, page, GumpButtonType.Reply, 0); - AddHtmlLocalized(260, 198, 60, 26, 1073838, 0x0, false, false); // Remove + AddButton(235, 200, 0x845, 0x846, page); + AddHtmlLocalized(260, 198, 60, 26, 1073838, 0x0); // Remove } // next page if (page < m_Aquarium.Items.Count) { AddButton(195, 280, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page + 1); - AddHtmlLocalized(230, 283, 100, 18, 1044045, 0xFFFFFF, false, false); // NEXT PAGE + AddHtmlLocalized(230, 283, 100, 18, 1044045, 0xFFFFFF); // NEXT PAGE } // previous page if (page > 1) { AddButton(45, 280, 0xFAE, 0xFAF, 0, GumpButtonType.Page, page - 1); - AddHtmlLocalized(80, 283, 100, 18, 1044044, 0xFFFFFF, false, false); // PREV PAGE + AddHtmlLocalized(80, 283, 100, 18, 1044044, 0xFFFFFF); // PREV PAGE } } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Aquarium == null || m_Aquarium.Deleted) + if (m_Aquarium?.Deleted != false) return; bool edit = m_Aquarium.HasAccess(sender.Mobile); @@ -86,4 +86,4 @@ namespace Server.Items sender.Mobile.SendGump(new AquariumGump(m_Aquarium, edit)); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Aquarium/FishBowl.cs b/Scripts/Items/Aquarium/FishBowl.cs index fe8666470..97477ff16 100644 --- a/Scripts/Items/Aquarium/FishBowl.cs +++ b/Scripts/Items/Aquarium/FishBowl.cs @@ -142,29 +142,29 @@ namespace Server.Items public override void OnClick() { - if (m_Bowl == null || m_Bowl.Deleted || !m_Bowl.IsAccessibleTo(Owner.From)) + if (m_Bowl?.Deleted != false || !m_Bowl.IsAccessibleTo(Owner.From)) return; BaseFish fish = m_Bowl.Fish; - if (fish != null) + if (fish == null) + return; + + if (fish.IsLockedDown) // for legacy fish bowls { - if (fish.IsLockedDown) // for legacy fish bowls - { - Owner.From.SendLocalizedMessage(1010449); // You may not use this object while it is locked down. - } - else if (!Owner.From.PlaceInBackpack(fish)) - { - Owner.From.SendLocalizedMessage(1074496); // There is no room in your pack for the creature. - } - else - { - Owner.From.SendLocalizedMessage(1074495); // The creature has been removed from the fish bowl. - fish.StartTimer(); - m_Bowl.InvalidateProperties(); - } + Owner.From.SendLocalizedMessage(1010449); // You may not use this object while it is locked down. + } + else if (!Owner.From.PlaceInBackpack(fish)) + { + Owner.From.SendLocalizedMessage(1074496); // There is no room in your pack for the creature. + } + else + { + Owner.From.SendLocalizedMessage(1074495); // The creature has been removed from the fish bowl. + fish.StartTimer(); + m_Bowl.InvalidateProperties(); } } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Armor/BaseArmor.cs b/Scripts/Items/Armor/BaseArmor.cs index 2be6dea12..c46c0c399 100644 --- a/Scripts/Items/Armor/BaseArmor.cs +++ b/Scripts/Items/Armor/BaseArmor.cs @@ -499,7 +499,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; if (Quality == ArmorQuality.Exceptional) @@ -563,7 +563,7 @@ namespace Server.Items CraftItem item = system.CraftItems.SearchFor(GetType()); - if (item != null && item.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2) + if (item?.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2) try { Item res = (Item)Activator.CreateInstance(CraftResources.GetInfo(m_Resource).ResourceTypes[0]); @@ -573,6 +573,7 @@ namespace Server.Items } catch { + // ignored } from.SendLocalizedMessage(502440); // Scissors can not be used on that to produce anything. @@ -1461,12 +1462,7 @@ namespace Server.Items private string GetNameString() { - string name = Name; - - if (name == null) - name = $"#{LabelNumber}"; - - return name; + return Name ?? $"#{LabelNumber}"; } public override void AddNameProperty(ObjectPropertyList list) @@ -1793,4 +1789,4 @@ namespace Server.Items #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Items/Body Parts/Head.cs b/Scripts/Items/Body Parts/Head.cs index a72994324..4179a929e 100644 --- a/Scripts/Items/Body Parts/Head.cs +++ b/Scripts/Items/Body Parts/Head.cs @@ -10,19 +10,12 @@ namespace Server.Items public class Head : Item { [Constructible] - public Head() - : this(null) + public Head(string playerName) : this(HeadType.Regular, playerName) { } [Constructible] - public Head(string playerName) - : this(HeadType.Regular, playerName) - { - } - - [Constructible] - public Head(HeadType headType, string playerName) + public Head(HeadType headType = HeadType.Regular, string playerName = null) : base(0x1DA0) { HeadType = headType; @@ -111,4 +104,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Books/BaseBook.cs b/Scripts/Items/Books/BaseBook.cs index 29563da15..906eebe8e 100644 --- a/Scripts/Items/Books/BaseBook.cs +++ b/Scripts/Items/Books/BaseBook.cs @@ -48,24 +48,19 @@ namespace Server.Items private string m_Title; [Constructible] - public BaseBook(int itemID) : this(itemID, 20, true) - { - } - - [Constructible] - public BaseBook(int itemID, int pageCount, bool writable) : this(itemID, null, null, pageCount, writable) + public BaseBook(int itemID, int pageCount = 20, bool writable = true) : this(itemID, null, null, pageCount, writable) { } [Constructible] public BaseBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID) { - m_Title = title; - m_Author = author; - Writable = writable; - BookContent content = DefaultContent; + m_Title = title ?? content?.Title; + m_Author = author ?? content?.Author; + Writable = writable; + if (content == null) { Pages = new BookPageInfo[pageCount]; @@ -80,22 +75,8 @@ namespace Server.Items } // Intended for defined books only - public BaseBook(int itemID, bool writable) : base(itemID) + public BaseBook(int itemID, bool writable) : this(itemID, 0) { - Writable = writable; - - BookContent content = DefaultContent; - - if (content == null) - { - Pages = new BookPageInfo[0]; - } - else - { - m_Title = content.Title; - m_Author = content.Author; - Pages = content.Copy(); - } } public BaseBook(Serial serial) : base(serial) @@ -298,7 +279,7 @@ namespace Server.Items public override void AddNameProperty(ObjectPropertyList list) { - if (m_Title != null && m_Title.Length > 0) + if (!string.IsNullOrEmpty(m_Title)) list.Add(m_Title); else base.AddNameProperty(list); @@ -308,13 +289,13 @@ namespace Server.Items { base.GetProperties( list ); - if ( m_Title != null && m_Title.Length > 0 ) + if ( m_Title?.Length > 0 ) list.Add( 1060658, "Title\t{0}", m_Title ); // ~1_val~: ~2_val~ - if ( m_Author != null && m_Author.Length > 0 ) + if ( m_Author?.Length > 0 ) list.Add( 1060659, "Author\t{0}", m_Author ); // ~1_val~: ~2_val~ - if ( m_Pages != null && m_Pages.Length > 0 ) + if ( m_Pages?.Length > 0 ) list.Add( 1060660, "Pages\t{0}", m_Pages.Length ); // ~1_val~: ~2_val~ }*/ @@ -497,4 +478,4 @@ namespace Server.Items m_Stream.Write((byte)0); // terminate } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Books/BlueBook.cs b/Scripts/Items/Books/BlueBook.cs index 7e464f088..cd9ba8119 100644 --- a/Scripts/Items/Books/BlueBook.cs +++ b/Scripts/Items/Books/BlueBook.cs @@ -3,7 +3,7 @@ namespace Server.Items public class BlueBook : BaseBook { [Constructible] - public BlueBook() : base(0xFF2, 40, true) + public BlueBook() : base(0xFF2, 40) { } diff --git a/Scripts/Items/Clothing/BaseClothing.cs b/Scripts/Items/Clothing/BaseClothing.cs index e0958c126..7c33d025f 100644 --- a/Scripts/Items/Clothing/BaseClothing.cs +++ b/Scripts/Items/Clothing/BaseClothing.cs @@ -31,11 +31,7 @@ namespace Server.Items protected CraftResource m_Resource; private int m_StrReq = -1; - public BaseClothing(int itemID, Layer layer) : this(itemID, layer, 0) - { - } - - public BaseClothing(int itemID, Layer layer, int hue) : base(itemID) + public BaseClothing(int itemID, Layer layer, int hue = 0) : base(itemID) { Layer = layer; Hue = hue; @@ -172,7 +168,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; return quality; @@ -210,18 +206,12 @@ namespace Server.Items CraftItem item = system.CraftItems.SearchFor(GetType()); - if (item != null && item.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2) + if (item?.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2) try { - Type resourceType = null; - CraftResourceInfo info = CraftResources.GetInfo(m_Resource); - if (info != null && info.ResourceTypes.Length > 0) - resourceType = info.ResourceTypes[0]; - - if (resourceType == null) - resourceType = item.Resources.GetAt(0).ItemType; + Type resourceType = info.ResourceTypes?[0] ?? item.Resources.GetAt(0).ItemType; Item res = (Item)Activator.CreateInstance(resourceType); @@ -573,12 +563,7 @@ namespace Server.Items private string GetNameString() { - string name = Name; - - if (name == null) - name = $"#{LabelNumber}"; - - return name; + return Name ?? $"#{LabelNumber}"; } public override void AddNameProperty(ObjectPropertyList list) @@ -1070,4 +1055,4 @@ namespace Server.Items #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/Cloaks.cs b/Scripts/Items/Clothing/Cloaks.cs index 6ad58251a..79d180577 100644 --- a/Scripts/Items/Clothing/Cloaks.cs +++ b/Scripts/Items/Clothing/Cloaks.cs @@ -4,11 +4,7 @@ namespace Server.Items { public abstract class BaseCloak : BaseClothing { - public BaseCloak(int itemID) : this(itemID, 0) - { - } - - public BaseCloak(int itemID, int hue) : base(itemID, Layer.Cloak, hue) + public BaseCloak(int itemID, int hue = 0) : base(itemID, Layer.Cloak, hue) { } @@ -35,12 +31,7 @@ namespace Server.Items public class Cloak : BaseCloak, IArcaneEquip { [Constructible] - public Cloak() : this(0) - { - } - - [Constructible] - public Cloak(int hue) : base(0x1515, hue) + public Cloak(int hue = 0) : base(0x1515, hue) { Weight = 5.0; } @@ -169,17 +160,7 @@ namespace Server.Items private int m_LabelNumber; [Constructible] - public RewardCloak() : this(0) - { - } - - [Constructible] - public RewardCloak(int hue) : this(hue, 0) - { - } - - [Constructible] - public RewardCloak(int hue, int labelNumber) : base(0x1515, hue) + public RewardCloak(int hue = 0, int labelNumber = 0) : base(0x1515, hue) { Weight = 5.0; LootType = LootType.Blessed; @@ -292,12 +273,7 @@ namespace Server.Items public class FurCape : BaseCloak { [Constructible] - public FurCape() : this(0) - { - } - - [Constructible] - public FurCape(int hue) : base(0x230A, hue) + public FurCape(int hue = 0) : base(0x230A, hue) { Weight = 4.0; } @@ -320,4 +296,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/Hats.cs b/Scripts/Items/Clothing/Hats.cs index d24c60a4f..5c837356b 100644 --- a/Scripts/Items/Clothing/Hats.cs +++ b/Scripts/Items/Clothing/Hats.cs @@ -8,11 +8,7 @@ namespace Server.Items { public abstract class BaseHat : BaseClothing, IShipwreckedItem { - public BaseHat(int itemID) : this(itemID, 0) - { - } - - public BaseHat(int itemID, int hue) : base(itemID, Layer.Helm, hue) + public BaseHat(int itemID, int hue = 0) : base(itemID, Layer.Helm, hue) { } @@ -81,12 +77,7 @@ namespace Server.Items public class Kasa : BaseHat { [Constructible] - public Kasa() : this(0) - { - } - - [Constructible] - public Kasa(int hue) : base(0x2798, hue) + public Kasa(int hue = 0) : base(0x2798, hue) { Weight = 3.0; } @@ -123,12 +114,7 @@ namespace Server.Items public class ClothNinjaHood : BaseHat { [Constructible] - public ClothNinjaHood() : this(0) - { - } - - [Constructible] - public ClothNinjaHood(int hue) : base(0x278F, hue) + public ClothNinjaHood(int hue = 0) : base(0x278F, hue) { Weight = 2.0; } @@ -165,12 +151,7 @@ namespace Server.Items public class FlowerGarland : BaseHat { [Constructible] - public FlowerGarland() : this(0) - { - } - - [Constructible] - public FlowerGarland(int hue) : base(0x2306, hue) + public FlowerGarland(int hue = 0) : base(0x2306, hue) { Weight = 1.0; } @@ -206,12 +187,7 @@ namespace Server.Items public class FloppyHat : BaseHat { [Constructible] - public FloppyHat() : this(0) - { - } - - [Constructible] - public FloppyHat(int hue) : base(0x1713, hue) + public FloppyHat(int hue = 0) : base(0x1713, hue) { Weight = 1.0; } @@ -247,12 +223,7 @@ namespace Server.Items public class WideBrimHat : BaseHat { [Constructible] - public WideBrimHat() : this(0) - { - } - - [Constructible] - public WideBrimHat(int hue) : base(0x1714, hue) + public WideBrimHat(int hue = 0) : base(0x1714, hue) { Weight = 1.0; } @@ -288,12 +259,7 @@ namespace Server.Items public class Cap : BaseHat { [Constructible] - public Cap() : this(0) - { - } - - [Constructible] - public Cap(int hue) : base(0x1715, hue) + public Cap(int hue = 0) : base(0x1715, hue) { Weight = 1.0; } @@ -329,12 +295,7 @@ namespace Server.Items public class SkullCap : BaseHat { [Constructible] - public SkullCap() : this(0) - { - } - - [Constructible] - public SkullCap(int hue) : base(0x1544, hue) + public SkullCap(int hue = 0) : base(0x1544, hue) { Weight = 1.0; } @@ -370,12 +331,7 @@ namespace Server.Items public class Bandana : BaseHat { [Constructible] - public Bandana() : this(0) - { - } - - [Constructible] - public Bandana(int hue) : base(0x1540, hue) + public Bandana(int hue = 0) : base(0x1540, hue) { Weight = 1.0; } @@ -411,12 +367,7 @@ namespace Server.Items public class BearMask : BaseHat { [Constructible] - public BearMask() : this(0) - { - } - - [Constructible] - public BearMask(int hue) : base(0x1545, hue) + public BearMask(int hue = 0) : base(0x1545, hue) { Weight = 5.0; } @@ -458,12 +409,7 @@ namespace Server.Items public class DeerMask : BaseHat { [Constructible] - public DeerMask() : this(0) - { - } - - [Constructible] - public DeerMask(int hue) : base(0x1547, hue) + public DeerMask(int hue = 0) : base(0x1547, hue) { Weight = 4.0; } @@ -505,12 +451,7 @@ namespace Server.Items public class HornedTribalMask : BaseHat { [Constructible] - public HornedTribalMask() : this(0) - { - } - - [Constructible] - public HornedTribalMask(int hue) : base(0x1549, hue) + public HornedTribalMask(int hue = 0) : base(0x1549, hue) { Weight = 2.0; } @@ -552,12 +493,7 @@ namespace Server.Items public class TribalMask : BaseHat { [Constructible] - public TribalMask() : this(0) - { - } - - [Constructible] - public TribalMask(int hue) : base(0x154B, hue) + public TribalMask(int hue = 0) : base(0x154B, hue) { Weight = 2.0; } @@ -599,12 +535,7 @@ namespace Server.Items public class TallStrawHat : BaseHat { [Constructible] - public TallStrawHat() : this(0) - { - } - - [Constructible] - public TallStrawHat(int hue) : base(0x1716, hue) + public TallStrawHat(int hue = 0) : base(0x1716, hue) { Weight = 1.0; } @@ -640,12 +571,7 @@ namespace Server.Items public class StrawHat : BaseHat { [Constructible] - public StrawHat() : this(0) - { - } - - [Constructible] - public StrawHat(int hue) : base(0x1717, hue) + public StrawHat(int hue = 0) : base(0x1717, hue) { Weight = 1.0; } @@ -681,12 +607,7 @@ namespace Server.Items public class OrcishKinMask : BaseHat { [Constructible] - public OrcishKinMask() : this(0x8A4) - { - } - - [Constructible] - public OrcishKinMask(int hue) : base(0x141B, hue) + public OrcishKinMask(int hue = 0x8A4) : base(0x141B, hue) { Weight = 2.0; } @@ -755,9 +676,7 @@ namespace Server.Items public class SavageMask : BaseHat { [Constructible] - public SavageMask() : this(GetRandomHue()) - { - } + public SavageMask() : this(GetRandomHue()) {} [Constructible] public SavageMask(int hue) : base(0x154B, hue) @@ -815,12 +734,7 @@ namespace Server.Items public class WizardsHat : BaseHat { [Constructible] - public WizardsHat() : this(0) - { - } - - [Constructible] - public WizardsHat(int hue) : base(0x1718, hue) + public WizardsHat(int hue = 0) : base(0x1718, hue) { Weight = 1.0; } @@ -856,12 +770,7 @@ namespace Server.Items public class MagicWizardsHat : BaseHat { [Constructible] - public MagicWizardsHat() : this(0) - { - } - - [Constructible] - public MagicWizardsHat(int hue) : base(0x1718, hue) + public MagicWizardsHat(int hue = 0) : base(0x1718, hue) { Weight = 1.0; } @@ -903,12 +812,7 @@ namespace Server.Items public class Bonnet : BaseHat { [Constructible] - public Bonnet() : this(0) - { - } - - [Constructible] - public Bonnet(int hue) : base(0x1719, hue) + public Bonnet(int hue = 0) : base(0x1719, hue) { Weight = 1.0; } @@ -944,12 +848,7 @@ namespace Server.Items public class FeatheredHat : BaseHat { [Constructible] - public FeatheredHat() : this(0) - { - } - - [Constructible] - public FeatheredHat(int hue) : base(0x171A, hue) + public FeatheredHat(int hue = 0) : base(0x171A, hue) { Weight = 1.0; } @@ -985,12 +884,7 @@ namespace Server.Items public class TricorneHat : BaseHat { [Constructible] - public TricorneHat() : this(0) - { - } - - [Constructible] - public TricorneHat(int hue) : base(0x171B, hue) + public TricorneHat(int hue = 0) : base(0x171B, hue) { Weight = 1.0; } @@ -1026,12 +920,7 @@ namespace Server.Items public class JesterHat : BaseHat { [Constructible] - public JesterHat() : this(0) - { - } - - [Constructible] - public JesterHat(int hue) : base(0x171C, hue) + public JesterHat(int hue = 0) : base(0x171C, hue) { Weight = 1.0; } @@ -1063,4 +952,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/MiddleTorso.cs b/Scripts/Items/Clothing/MiddleTorso.cs index f1ca6698f..4c6d6f254 100644 --- a/Scripts/Items/Clothing/MiddleTorso.cs +++ b/Scripts/Items/Clothing/MiddleTorso.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BaseMiddleTorso : BaseClothing { - public BaseMiddleTorso(int itemID) : this(itemID, 0) - { - } - - public BaseMiddleTorso(int itemID, int hue) : base(itemID, Layer.MiddleTorso, hue) + public BaseMiddleTorso(int itemID, int hue = 0) : base(itemID, Layer.MiddleTorso, hue) { } @@ -33,12 +29,7 @@ namespace Server.Items public class BodySash : BaseMiddleTorso { [Constructible] - public BodySash() : this(0) - { - } - - [Constructible] - public BodySash(int hue) : base(0x1541, hue) + public BodySash(int hue = 0) : base(0x1541, hue) { Weight = 1.0; } @@ -66,12 +57,7 @@ namespace Server.Items public class FullApron : BaseMiddleTorso { [Constructible] - public FullApron() : this(0) - { - } - - [Constructible] - public FullApron(int hue) : base(0x153d, hue) + public FullApron(int hue = 0) : base(0x153d, hue) { Weight = 4.0; } @@ -99,12 +85,7 @@ namespace Server.Items public class Doublet : BaseMiddleTorso { [Constructible] - public Doublet() : this(0) - { - } - - [Constructible] - public Doublet(int hue) : base(0x1F7B, hue) + public Doublet(int hue = 0) : base(0x1F7B, hue) { Weight = 2.0; } @@ -132,12 +113,7 @@ namespace Server.Items public class Surcoat : BaseMiddleTorso { [Constructible] - public Surcoat() : this(0) - { - } - - [Constructible] - public Surcoat(int hue) : base(0x1FFD, hue) + public Surcoat(int hue = 0) : base(0x1FFD, hue) { Weight = 6.0; } @@ -168,12 +144,7 @@ namespace Server.Items public class Tunic : BaseMiddleTorso { [Constructible] - public Tunic() : this(0) - { - } - - [Constructible] - public Tunic(int hue) : base(0x1FA1, hue) + public Tunic(int hue = 0) : base(0x1FA1, hue) { Weight = 5.0; } @@ -201,12 +172,7 @@ namespace Server.Items public class FormalShirt : BaseMiddleTorso { [Constructible] - public FormalShirt() : this(0) - { - } - - [Constructible] - public FormalShirt(int hue) : base(0x2310, hue) + public FormalShirt(int hue = 0) : base(0x2310, hue) { Weight = 1.0; } @@ -237,12 +203,7 @@ namespace Server.Items public class JesterSuit : BaseMiddleTorso { [Constructible] - public JesterSuit() : this(0) - { - } - - [Constructible] - public JesterSuit(int hue) : base(0x1F9F, hue) + public JesterSuit(int hue = 0) : base(0x1F9F, hue) { Weight = 4.0; } @@ -270,12 +231,7 @@ namespace Server.Items public class JinBaori : BaseMiddleTorso { [Constructible] - public JinBaori() : this(0) - { - } - - [Constructible] - public JinBaori(int hue) : base(0x27A1, hue) + public JinBaori(int hue = 0) : base(0x27A1, hue) { Weight = 3.0; } @@ -298,4 +254,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/OuterLegs.cs b/Scripts/Items/Clothing/OuterLegs.cs index e36437de0..89a9d66ea 100644 --- a/Scripts/Items/Clothing/OuterLegs.cs +++ b/Scripts/Items/Clothing/OuterLegs.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BaseOuterLegs : BaseClothing { - public BaseOuterLegs(int itemID) : this(itemID, 0) - { - } - - public BaseOuterLegs(int itemID, int hue) : base(itemID, Layer.OuterLegs, hue) + public BaseOuterLegs(int itemID, int hue = 0) : base(itemID, Layer.OuterLegs, hue) { } @@ -33,12 +29,7 @@ namespace Server.Items public class FurSarong : BaseOuterLegs { [Constructible] - public FurSarong() : this(0) - { - } - - [Constructible] - public FurSarong(int hue) : base(0x230C, hue) + public FurSarong(int hue = 0) : base(0x230C, hue) { Weight = 3.0; } @@ -69,12 +60,7 @@ namespace Server.Items public class Skirt : BaseOuterLegs { [Constructible] - public Skirt() : this(0) - { - } - - [Constructible] - public Skirt(int hue) : base(0x1516, hue) + public Skirt(int hue = 0) : base(0x1516, hue) { Weight = 4.0; } @@ -102,12 +88,7 @@ namespace Server.Items public class Kilt : BaseOuterLegs { [Constructible] - public Kilt() : this(0) - { - } - - [Constructible] - public Kilt(int hue) : base(0x1537, hue) + public Kilt(int hue = 0) : base(0x1537, hue) { Weight = 2.0; } @@ -135,12 +116,7 @@ namespace Server.Items public class Hakama : BaseOuterLegs { [Constructible] - public Hakama() : this(0) - { - } - - [Constructible] - public Hakama(int hue) : base(0x279A, hue) + public Hakama(int hue = 0) : base(0x279A, hue) { Weight = 2.0; } @@ -163,4 +139,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/OuterTorso.cs b/Scripts/Items/Clothing/OuterTorso.cs index 2db3c5797..d488983a1 100644 --- a/Scripts/Items/Clothing/OuterTorso.cs +++ b/Scripts/Items/Clothing/OuterTorso.cs @@ -5,11 +5,7 @@ namespace Server.Items { public abstract class BaseOuterTorso : BaseClothing { - public BaseOuterTorso(int itemID) : this(itemID, 0) - { - } - - public BaseOuterTorso(int itemID, int hue) : base(itemID, Layer.OuterTorso, hue) + public BaseOuterTorso(int itemID, int hue = 0) : base(itemID, Layer.OuterTorso, hue) { } @@ -36,12 +32,7 @@ namespace Server.Items public class GildedDress : BaseOuterTorso { [Constructible] - public GildedDress() : this(0) - { - } - - [Constructible] - public GildedDress(int hue) : base(0x230E, hue) + public GildedDress(int hue = 0) : base(0x230E, hue) { Weight = 3.0; } @@ -69,12 +60,7 @@ namespace Server.Items public class FancyDress : BaseOuterTorso { [Constructible] - public FancyDress() : this(0) - { - } - - [Constructible] - public FancyDress(int hue) : base(0x1F00, hue) + public FancyDress(int hue = 0) : base(0x1F00, hue) { Weight = 3.0; } @@ -233,17 +219,7 @@ namespace Server.Items private int m_LabelNumber; [Constructible] - public RewardRobe() : this(0) - { - } - - [Constructible] - public RewardRobe(int hue) : this(hue, 0) - { - } - - [Constructible] - public RewardRobe(int hue, int labelNumber) : base(0x1F03, hue) + public RewardRobe(int hue = 0, int labelNumber = 0) : base(0x1F03, hue) { Weight = 3.0; LootType = LootType.Blessed; @@ -358,17 +334,7 @@ namespace Server.Items private int m_LabelNumber; [Constructible] - public RewardDress() : this(0) - { - } - - [Constructible] - public RewardDress(int hue) : this(hue, 0) - { - } - - [Constructible] - public RewardDress(int hue, int labelNumber) : base(0x1F01, hue) + public RewardDress(int hue = 0, int labelNumber = 0) : base(0x1F01, hue) { Weight = 2.0; LootType = LootType.Blessed; @@ -481,12 +447,7 @@ namespace Server.Items public class Robe : BaseOuterTorso, IArcaneEquip { [Constructible] - public Robe() : this(0) - { - } - - [Constructible] - public Robe(int hue) : base(0x1F03, hue) + public Robe(int hue = 0) : base(0x1F03, hue) { Weight = 3.0; } @@ -609,12 +570,7 @@ namespace Server.Items public class MonkRobe : BaseOuterTorso { [Constructible] - public MonkRobe() : this(0x21E) - { - } - - [Constructible] - public MonkRobe(int hue) : base(0x2687, hue) + public MonkRobe(int hue = 0x21E) : base(0x2687, hue) { Weight = 1.0; StrRequirement = 0; @@ -652,12 +608,7 @@ namespace Server.Items public class PlainDress : BaseOuterTorso { [Constructible] - public PlainDress() : this(0) - { - } - - [Constructible] - public PlainDress(int hue) : base(0x1F01, hue) + public PlainDress(int hue = 0) : base(0x1F01, hue) { Weight = 2.0; } @@ -688,12 +639,7 @@ namespace Server.Items public class Kamishimo : BaseOuterTorso { [Constructible] - public Kamishimo() : this(0) - { - } - - [Constructible] - public Kamishimo(int hue) : base(0x2799, hue) + public Kamishimo(int hue = 0) : base(0x2799, hue) { Weight = 3.0; } @@ -721,12 +667,7 @@ namespace Server.Items public class HakamaShita : BaseOuterTorso { [Constructible] - public HakamaShita() : this(0) - { - } - - [Constructible] - public HakamaShita(int hue) : base(0x279C, hue) + public HakamaShita(int hue = 0) : base(0x279C, hue) { Weight = 3.0; } @@ -754,12 +695,7 @@ namespace Server.Items public class MaleKimono : BaseOuterTorso { [Constructible] - public MaleKimono() : this(0) - { - } - - [Constructible] - public MaleKimono(int hue) : base(0x2782, hue) + public MaleKimono(int hue = 0) : base(0x2782, hue) { Weight = 3.0; } @@ -789,12 +725,7 @@ namespace Server.Items public class FemaleKimono : BaseOuterTorso { [Constructible] - public FemaleKimono() : this(0) - { - } - - [Constructible] - public FemaleKimono(int hue) : base(0x2783, hue) + public FemaleKimono(int hue = 0) : base(0x2783, hue) { Weight = 3.0; } @@ -824,12 +755,7 @@ namespace Server.Items public class MaleElvenRobe : BaseOuterTorso { [Constructible] - public MaleElvenRobe() : this(0) - { - } - - [Constructible] - public MaleElvenRobe(int hue) : base(0x2FB9, hue) + public MaleElvenRobe(int hue = 0) : base(0x2FB9, hue) { Weight = 2.0; } @@ -859,12 +785,7 @@ namespace Server.Items public class FemaleElvenRobe : BaseOuterTorso { [Constructible] - public FemaleElvenRobe() : this(0) - { - } - - [Constructible] - public FemaleElvenRobe(int hue) : base(0x2FBA, hue) + public FemaleElvenRobe(int hue = 0) : base(0x2FBA, hue) { Weight = 2.0; } @@ -891,4 +812,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/Pants.cs b/Scripts/Items/Clothing/Pants.cs index 001e0ef46..194f64a86 100644 --- a/Scripts/Items/Clothing/Pants.cs +++ b/Scripts/Items/Clothing/Pants.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BasePants : BaseClothing { - public BasePants(int itemID) : this(itemID, 0) - { - } - - public BasePants(int itemID, int hue) : base(itemID, Layer.Pants, hue) + public BasePants(int itemID, int hue = 0) : base(itemID, Layer.Pants, hue) { } @@ -33,12 +29,7 @@ namespace Server.Items public class ShortPants : BasePants { [Constructible] - public ShortPants() : this(0) - { - } - - [Constructible] - public ShortPants(int hue) : base(0x152E, hue) + public ShortPants(int hue = 0) : base(0x152E, hue) { Weight = 2.0; } @@ -66,12 +57,7 @@ namespace Server.Items public class LongPants : BasePants { [Constructible] - public LongPants() : this(0) - { - } - - [Constructible] - public LongPants(int hue) : base(0x1539, hue) + public LongPants(int hue = 0) : base(0x1539, hue) { Weight = 2.0; } @@ -99,12 +85,7 @@ namespace Server.Items public class TattsukeHakama : BasePants { [Constructible] - public TattsukeHakama() : this(0) - { - } - - [Constructible] - public TattsukeHakama(int hue) : base(0x279B, hue) + public TattsukeHakama(int hue = 0) : base(0x279B, hue) { Weight = 2.0; } @@ -132,12 +113,7 @@ namespace Server.Items public class ElvenPants : BasePants { [Constructible] - public ElvenPants() : this(0) - { - } - - [Constructible] - public ElvenPants(int hue) : base(0x2FC3, hue) + public ElvenPants(int hue = 0) : base(0x2FC3, hue) { Weight = 2.0; } @@ -162,4 +138,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/Shirts.cs b/Scripts/Items/Clothing/Shirts.cs index 5e85cf4d5..7fecc9b4a 100644 --- a/Scripts/Items/Clothing/Shirts.cs +++ b/Scripts/Items/Clothing/Shirts.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BaseShirt : BaseClothing { - public BaseShirt(int itemID) : this(itemID, 0) - { - } - - public BaseShirt(int itemID, int hue) : base(itemID, Layer.Shirt, hue) + public BaseShirt(int itemID, int hue = 0) : base(itemID, Layer.Shirt, hue) { } @@ -33,12 +29,7 @@ namespace Server.Items public class FancyShirt : BaseShirt { [Constructible] - public FancyShirt() : this(0) - { - } - - [Constructible] - public FancyShirt(int hue) : base(0x1EFD, hue) + public FancyShirt(int hue = 0) : base(0x1EFD, hue) { Weight = 2.0; } @@ -66,12 +57,7 @@ namespace Server.Items public class Shirt : BaseShirt { [Constructible] - public Shirt() : this(0) - { - } - - [Constructible] - public Shirt(int hue) : base(0x1517, hue) + public Shirt(int hue = 0) : base(0x1517, hue) { Weight = 1.0; } @@ -102,12 +88,7 @@ namespace Server.Items public class ClothNinjaJacket : BaseShirt { [Constructible] - public ClothNinjaJacket() : this(0) - { - } - - [Constructible] - public ClothNinjaJacket(int hue) : base(0x2794, hue) + public ClothNinjaJacket(int hue = 0) : base(0x2794, hue) { Weight = 5.0; Layer = Layer.InnerTorso; @@ -135,12 +116,7 @@ namespace Server.Items public class ElvenShirt : BaseShirt { [Constructible] - public ElvenShirt() : this(0) - { - } - - [Constructible] - public ElvenShirt(int hue) : base(0x3175, hue) + public ElvenShirt(int hue = 0) : base(0x3175, hue) { Weight = 2.0; } @@ -170,12 +146,7 @@ namespace Server.Items public class ElvenDarkShirt : BaseShirt { [Constructible] - public ElvenDarkShirt() : this(0) - { - } - - [Constructible] - public ElvenDarkShirt(int hue) : base(0x3176, hue) + public ElvenDarkShirt(int hue = 0) : base(0x3176, hue) { Weight = 2.0; } @@ -200,4 +171,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/Shoes.cs b/Scripts/Items/Clothing/Shoes.cs index 9f0fa954e..ffdc83f57 100644 --- a/Scripts/Items/Clothing/Shoes.cs +++ b/Scripts/Items/Clothing/Shoes.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BaseShoes : BaseClothing { - public BaseShoes(int itemID) : this(itemID, 0) - { - } - - public BaseShoes(int itemID, int hue) : base(itemID, Layer.Shoes, hue) + public BaseShoes(int itemID, int hue = 0) : base(itemID, Layer.Shoes, hue) { } @@ -57,12 +53,7 @@ namespace Server.Items public class FurBoots : BaseShoes { [Constructible] - public FurBoots() : this(0) - { - } - - [Constructible] - public FurBoots(int hue) : base(0x2307, hue) + public FurBoots(int hue = 0) : base(0x2307, hue) { Weight = 3.0; } @@ -90,12 +81,7 @@ namespace Server.Items public class Boots : BaseShoes { [Constructible] - public Boots() : this(0) - { - } - - [Constructible] - public Boots(int hue) : base(0x170B, hue) + public Boots(int hue = 0) : base(0x170B, hue) { Weight = 3.0; } @@ -125,12 +111,7 @@ namespace Server.Items public class ThighBoots : BaseShoes, IArcaneEquip { [Constructible] - public ThighBoots() : this(0) - { - } - - [Constructible] - public ThighBoots(int hue) : base(0x1711, hue) + public ThighBoots(int hue = 0) : base(0x1711, hue) { Weight = 4.0; } @@ -256,12 +237,7 @@ namespace Server.Items public class Shoes : BaseShoes { [Constructible] - public Shoes() : this(0) - { - } - - [Constructible] - public Shoes(int hue) : base(0x170F, hue) + public Shoes(int hue = 0) : base(0x170F, hue) { Weight = 2.0; } @@ -291,12 +267,7 @@ namespace Server.Items public class Sandals : BaseShoes { [Constructible] - public Sandals() : this(0) - { - } - - [Constructible] - public Sandals(int hue) : base(0x170D, hue) + public Sandals(int hue = 0) : base(0x170D, hue) { Weight = 1.0; } @@ -331,12 +302,7 @@ namespace Server.Items public class NinjaTabi : BaseShoes { [Constructible] - public NinjaTabi() : this(0) - { - } - - [Constructible] - public NinjaTabi(int hue) : base(0x2797, hue) + public NinjaTabi(int hue = 0) : base(0x2797, hue) { Weight = 2.0; } @@ -364,12 +330,7 @@ namespace Server.Items public class SamuraiTabi : BaseShoes { [Constructible] - public SamuraiTabi() : this(0) - { - } - - [Constructible] - public SamuraiTabi(int hue) : base(0x2796, hue) + public SamuraiTabi(int hue = 0) : base(0x2796, hue) { Weight = 2.0; } @@ -397,12 +358,7 @@ namespace Server.Items public class Waraji : BaseShoes { [Constructible] - public Waraji() : this(0) - { - } - - [Constructible] - public Waraji(int hue) : base(0x2796, hue) + public Waraji(int hue = 0) : base(0x2796, hue) { Weight = 2.0; } @@ -430,12 +386,7 @@ namespace Server.Items public class ElvenBoots : BaseShoes { [Constructible] - public ElvenBoots() : this(0) - { - } - - [Constructible] - public ElvenBoots(int hue) : base(0x2FC4, hue) + public ElvenBoots(int hue = 0) : base(0x2FC4, hue) { Weight = 2.0; } @@ -467,4 +418,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Clothing/Waist.cs b/Scripts/Items/Clothing/Waist.cs index d611bfc5a..5c6f62b9e 100644 --- a/Scripts/Items/Clothing/Waist.cs +++ b/Scripts/Items/Clothing/Waist.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BaseWaist : BaseClothing { - public BaseWaist(int itemID) : this(itemID, 0) - { - } - - public BaseWaist(int itemID, int hue) : base(itemID, Layer.Waist, hue) + public BaseWaist(int itemID, int hue = 0) : base(itemID, Layer.Waist, hue) { } @@ -33,12 +29,7 @@ namespace Server.Items public class HalfApron : BaseWaist { [Constructible] - public HalfApron() : this(0) - { - } - - [Constructible] - public HalfApron(int hue) : base(0x153b, hue) + public HalfApron(int hue = 0) : base(0x153b, hue) { Weight = 2.0; } @@ -66,12 +57,7 @@ namespace Server.Items public class Obi : BaseWaist { [Constructible] - public Obi() : this(0) - { - } - - [Constructible] - public Obi(int hue) : base(0x27A0, hue) + public Obi(int hue = 0) : base(0x27A0, hue) { Weight = 1.0; } @@ -99,12 +85,7 @@ namespace Server.Items public class WoodlandBelt : BaseWaist { [Constructible] - public WoodlandBelt() : this(0) - { - } - - [Constructible] - public WoodlandBelt(int hue) : base(0x2B68, hue) + public WoodlandBelt(int hue = 0) : base(0x2B68, hue) { Weight = 4.0; } @@ -141,4 +122,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Construction/Ankhs.cs b/Scripts/Items/Construction/Ankhs.cs index a5d0d1df2..16dd12f07 100644 --- a/Scripts/Items/Construction/Ankhs.cs +++ b/Scripts/Items/Construction/Ankhs.cs @@ -106,12 +106,7 @@ namespace Server.Items private InternalItem m_Item; [Constructible] - public AnkhWest() : this(false) - { - } - - [Constructible] - public AnkhWest(bool bloodied) : base(bloodied ? 0x1D98 : 0x3) + public AnkhWest(bool bloodied = false) : base(bloodied ? 0x1D98 : 0x3) { Movable = false; @@ -281,12 +276,7 @@ namespace Server.Items private InternalItem m_Item; [Constructible] - public AnkhNorth() : this(false) - { - } - - [Constructible] - public AnkhNorth(bool bloodied) : base(bloodied ? 0x1E5D : 0x4) + public AnkhNorth(bool bloodied = false) : base(bloodied ? 0x1E5D : 0x4) { Movable = false; @@ -452,4 +442,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Construction/Doors/BaseDoor.cs b/Scripts/Items/Construction/Doors/BaseDoor.cs index b86749317..03e43fc4d 100644 --- a/Scripts/Items/Construction/Doors/BaseDoor.cs +++ b/Scripts/Items/Construction/Doors/BaseDoor.cs @@ -94,7 +94,7 @@ namespace Server.Items { get { - if (m_Link != null && m_Link.Deleted) + if (m_Link?.Deleted == true) m_Link = null; return m_Link; @@ -435,7 +435,7 @@ namespace Server.Items BaseDoor link = Link; - if (m_Open && link != null && !link.Open) + if (m_Open && link?.Open == false) link.Open = true; } } @@ -521,4 +521,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Construction/Doors/HouseDoors.cs b/Scripts/Items/Construction/Doors/HouseDoors.cs index 694804130..f872c42b9 100644 --- a/Scripts/Items/Construction/Doors/HouseDoors.cs +++ b/Scripts/Items/Construction/Doors/HouseDoors.cs @@ -63,13 +63,7 @@ namespace Server.Items public class GenericHouseDoor : BaseHouseDoor { [Constructible] - public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound) : this(facing, - baseItemID, openedSound, closedSound, true) - { - } - - [Constructible] - public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound, bool autoAdjust) + public GenericHouseDoor(DoorFacing facing, int baseItemID, int openedSound, int closedSound, bool autoAdjust = true) : base(facing, baseItemID + (autoAdjust ? 2 * (int)facing : 0), baseItemID + 1 + (autoAdjust ? 2 * (int)facing : 0), openedSound, closedSound, GetOffset(facing)) { @@ -151,18 +145,16 @@ namespace Server.Items { BaseHouse house = FindHouse(); - if (house != null && house.IsFriend(from) && from.AccessLevel == AccessLevel.Player && house.RefreshDecay()) + if (house?.IsFriend(from) == true && from.AccessLevel == AccessLevel.Player && house.RefreshDecay()) from.SendLocalizedMessage(1043293); // Your house's age and contents have been refreshed. - if (house != null && house.Public && !house.IsFriend(from)) + if (house?.Public == true && !house.IsFriend(from)) house.Visits++; } public override bool UseLocks() { - BaseHouse house = FindHouse(); - - return house == null || !house.IsAosRules; + return FindHouse()?.IsAosRules != true; } public override void Use(Mobile from) @@ -250,7 +242,7 @@ namespace Server.Items h = bs; break; - //No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until furthur information gained + //No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until further information gained default: return false; } @@ -262,4 +254,4 @@ namespace Server.Items return rx >= x && rx < x + w && ry >= y && ry < y + h && az <= 4; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Containers/BaseTreasureChest.cs b/Scripts/Items/Containers/BaseTreasureChest.cs index 7c68fbb69..d907bf111 100644 --- a/Scripts/Items/Containers/BaseTreasureChest.cs +++ b/Scripts/Items/Containers/BaseTreasureChest.cs @@ -16,11 +16,8 @@ namespace Server.Items private TreasureResetTimer m_ResetTimer; - public BaseTreasureChest(int itemID) : this(itemID, TreasureLevel.Level2) - { - } - - public BaseTreasureChest(int itemID, TreasureLevel level) : base(itemID) + public BaseTreasureChest(int itemID, TreasureLevel level = TreasureLevel.Level2) + : base(itemID) { Level = level; Locked = true; @@ -212,4 +209,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Containers/FillableContainers.cs b/Scripts/Items/Containers/FillableContainers.cs index cbf604d32..735a701b9 100644 --- a/Scripts/Items/Containers/FillableContainers.cs +++ b/Scripts/Items/Containers/FillableContainers.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Mobiles; diff --git a/Scripts/Items/Containers/MarkContainer.cs b/Scripts/Items/Containers/MarkContainer.cs index ee4fd7614..2f6185e85 100644 --- a/Scripts/Items/Containers/MarkContainer.cs +++ b/Scripts/Items/Containers/MarkContainer.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Commands; namespace Server.Items @@ -9,17 +10,7 @@ namespace Server.Items private InternalTimer m_RelockTimer; [Constructible] - public MarkContainer() : this(false) - { - } - - [Constructible] - public MarkContainer(bool bone) : this(bone, false) - { - } - - [Constructible] - public MarkContainer(bool bone, bool locked) : base(bone ? 0xECA : 0xE79) + public MarkContainer(bool bone = false, bool locked = false) : base(bone ? 0xECA : 0xE79) { Movable = false; @@ -117,30 +108,26 @@ namespace Server.Items private static bool FindMarkContainer(Point3D p, Map map) { IPooledEnumerable eable = map.GetItemsInRange(p, 0); - - foreach (Item item in eable) - if (item.Z == p.Z) - { - eable.Free(); - return true; - } - + bool found = eable.Any(item => item.Z == p.Z); eable.Free(); - return false; + + return found; } private static void CreateMalasPassage(int x, int y, int z, int xTarget, int yTarget, int zTarget, bool bone, - bool locked) +bool locked) { Point3D location = new Point3D(x, y, z); if (FindMarkContainer(location, Map.Malas)) return; - MarkContainer cont = new MarkContainer(bone, locked); - cont.TargetMap = Map.Malas; - cont.Target = new Point3D(xTarget, yTarget, zTarget); - cont.Description = "strange location"; + MarkContainer cont = new MarkContainer(bone, locked) + { + TargetMap = Map.Malas, + Target = new Point3D(xTarget, yTarget, zTarget), + Description = "strange location" + }; cont.MoveToWorld(location, Map.Malas); } @@ -148,7 +135,6 @@ namespace Server.Items public void StopTimer() { m_RelockTimer?.Stop(); - m_RelockTimer = null; } @@ -243,4 +229,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Containers/Strongbox.cs b/Scripts/Items/Containers/Strongbox.cs index 8c3aada18..6149db6ed 100644 --- a/Scripts/Items/Containers/Strongbox.cs +++ b/Scripts/Items/Containers/Strongbox.cs @@ -38,29 +38,14 @@ namespace Server.Items public override int DefaultMaxWeight => 0; - public override bool Decays - { - get - { - if (m_House != null && m_Owner != null && !m_Owner.Deleted) - return !m_House.IsCoOwner(m_Owner); - return true; - } - } + public override bool Decays => m_House == null || m_Owner?.Deleted != false || !m_House.IsCoOwner(m_Owner); public override TimeSpan DecayTime => TimeSpan.FromMinutes(30.0); public void OnChop(Mobile from) { - if (m_House != null && !m_House.Deleted && m_Owner != null && !m_Owner.Deleted) - { - if (from == m_Owner || m_House.IsOwner(from)) - Chop(from); - } - else - { + if (m_House?.Deleted != false || m_Owner?.Deleted != false || from == m_Owner || m_House.IsOwner(from)) Chop(from); - } } public override void Serialize(GenericWriter writer) @@ -95,7 +80,7 @@ namespace Server.Items private void Validate() { - if (m_Owner != null && m_House != null && !m_House.IsCoOwner(m_Owner)) + if (m_Owner != null && m_House?.IsCoOwner(m_Owner) == false) { Console.WriteLine("Warning: Destroying strongbox of {0}", m_Owner.Name); Destroy(); @@ -127,11 +112,9 @@ namespace Server.Items public override bool IsAccessibleTo(Mobile m) { - if (m_Owner == null || m_Owner.Deleted || m_House == null || m_House.Deleted || - m.AccessLevel >= AccessLevel.GameMaster) - return true; - - return m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m); + return m_Owner?.Deleted != false || m_House?.Deleted != false || + m.AccessLevel >= AccessLevel.GameMaster || + m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m); } private void Chop(Mobile from) @@ -153,4 +136,4 @@ namespace Server.Items return metalBox; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Containers/TreasureMapChest.cs b/Scripts/Items/Containers/TreasureMapChest.cs index 33d26b29a..7c3291520 100644 --- a/Scripts/Items/Containers/TreasureMapChest.cs +++ b/Scripts/Items/Containers/TreasureMapChest.cs @@ -14,11 +14,11 @@ namespace Server.Items private Timer m_Timer; [Constructible] - public TreasureMapChest(int level) : this(null, level, false) + public TreasureMapChest(int level) : this(null, level) { } - public TreasureMapChest(Mobile owner, int level, bool temporary) : base(0xE40) + public TreasureMapChest(Mobile owner, int level, bool temporary = false) : base(0xE40) { Owner = owner; Level = level; @@ -346,14 +346,12 @@ namespace Server.Items if (m.AccessLevel >= AccessLevel.GameMaster || Owner == null || m == Owner) return true; - Party p = Party.Get(Owner); - - if (p != null && p.Contains(m)) + if (Party.Get(Owner)?.Contains(m) == true) return true; Map map = Map; - if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0) + if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) { if (criminalAction) m.CriminalAction(true); @@ -518,16 +516,14 @@ namespace Server.Items AddBackground(30, 0, 240, 240, 2620); - AddHtmlLocalized(45, 15, 200, 80, 1048125, 0xFFFFFF, false, - false); // When this treasure chest is removed, any items still inside of it will be lost. - AddHtmlLocalized(45, 95, 200, 60, 1048126, 0xFFFFFF, false, - false); // Are you certain you're ready to remove this chest? + AddHtmlLocalized(45, 15, 200, 80, 1048125, 0xFFFFFF); // When this treasure chest is removed, any items still inside of it will be lost. + AddHtmlLocalized(45, 95, 200, 60, 1048126, 0xFFFFFF); // Are you certain you're ready to remove this chest? - AddButton(40, 153, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(75, 155, 180, 40, 1048127, 0xFFFFFF, false, false); // Remove the Treasure Chest + AddButton(40, 153, 4005, 4007, 1); + AddHtmlLocalized(75, 155, 180, 40, 1048127, 0xFFFFFF); // Remove the Treasure Chest - AddButton(40, 195, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(75, 197, 180, 35, 1006045, 0xFFFFFF, false, false); // Cancel + AddButton(40, 195, 4005, 4007, 2); + AddHtmlLocalized(75, 197, 180, 35, 1006045, 0xFFFFFF); // Cancel } public override void OnResponse(NetState sender, RelayInfo info) @@ -575,4 +571,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs b/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs index 334fa6e4b..5a1b4cea4 100644 --- a/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs +++ b/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Commands; @@ -200,7 +199,7 @@ namespace Server.Items public static bool Create() { - if (Instance != null && !Instance.Deleted) + if (Instance?.Deleted == false) return false; Instance = new StealableArtifactsSpawner(); @@ -243,7 +242,8 @@ namespace Server.Items public void CheckRespawn() { - foreach (StealableInstance si in m_Artifacts) si.CheckRespawn(); + foreach (StealableInstance si in m_Artifacts) + si.CheckRespawn(); } public override void Serialize(GenericWriter writer) @@ -381,7 +381,8 @@ namespace Server.Items if (Item != null && (Item.Deleted || Item.Movable || Item.Parent != null)) Item = null; - if (Item == null && DateTime.UtcNow >= NextRespawn) Item = Entry.CreateInstance(); + if (Item == null && DateTime.UtcNow >= NextRespawn) + Item = Entry.CreateInstance(); } } } diff --git a/Scripts/Items/Deeds/CommodityDeed.cs b/Scripts/Items/Deeds/CommodityDeed.cs index a06e6c580..4393f8d22 100644 --- a/Scripts/Items/Deeds/CommodityDeed.cs +++ b/Scripts/Items/Deeds/CommodityDeed.cs @@ -10,7 +10,7 @@ namespace Server.Items public class CommodityDeed : Item { - public CommodityDeed(Item commodity) : base(0x14F0) + public CommodityDeed(Item commodity = null) : base(0x14F0) { Weight = 1.0; Hue = 0x47; @@ -20,11 +20,6 @@ namespace Server.Items LootType = LootType.Blessed; } - [Constructible] - public CommodityDeed() : this(null) - { - } - public CommodityDeed(Serial serial) : base(serial) { } @@ -167,7 +162,7 @@ namespace Server.Items number = 1047024; // To claim the resources .... } } - else if (cox != null && !cox.IsSecure) + else if (cox?.IsSecure == false) { number = 1080525; // The commodity deed box must be secured before you can use it. } @@ -215,7 +210,7 @@ namespace Server.Items // Veteran Rewards mods if (box != null && m_Deed.IsChildOf(box) && item.IsChildOf(box) || - cox != null && cox.IsSecure && item.IsChildOf(cox)) + cox?.IsSecure != true && item.IsChildOf(cox)) { if (m_Deed.SetCommodity(item)) { @@ -245,4 +240,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Deeds/DragonBardingDeed.cs b/Scripts/Items/Deeds/DragonBardingDeed.cs index 27b8ece1d..7ea718212 100644 --- a/Scripts/Items/Deeds/DragonBardingDeed.cs +++ b/Scripts/Items/Deeds/DragonBardingDeed.cs @@ -76,7 +76,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; return quality; @@ -172,4 +172,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Deeds/HairRestylingDeed.cs b/Scripts/Items/Deeds/HairRestylingDeed.cs index 8bddc8238..19eecb70c 100644 --- a/Scripts/Items/Deeds/HairRestylingDeed.cs +++ b/Scripts/Items/Deeds/HairRestylingDeed.cs @@ -104,30 +104,30 @@ namespace Server.Items AddBackground(100, 10, 400, 385, 0xA28); - AddHtmlLocalized(100, 25, 400, 35, 1013008, false, false); - AddButton(175, 340, 0xFA5, 0xFA7, 0x0, GumpButtonType.Reply, 0); // CANCEL + AddHtmlLocalized(100, 25, 400, 35, 1013008); + AddButton(175, 340, 0xFA5, 0xFA7, 0x0); // CANCEL - AddHtmlLocalized(210, 342, 90, 35, 1011012, false, false); //
HAIRSTYLE SELECTION MENU
+ AddHtmlLocalized(210, 342, 90, 35, 1011012); //
HAIRSTYLE SELECTION MENU
int[][] RacialData = from.Race == Race.Human ? HumanArray : ElvenArray; for (int i = 1; i < RacialData.Length; i++) { AddHtmlLocalized(LayoutArray[i][2], LayoutArray[i][3], i == 1 ? 125 : 80, i == 1 ? 70 : 35, - m_From.Female ? RacialData[i][0] : RacialData[i][1], false, false); + m_From.Female ? RacialData[i][0] : RacialData[i][1]); if (LayoutArray[i][4] != 0) { AddBackground(LayoutArray[i][0], LayoutArray[i][1], 50, 50, 0xA3C); AddImage(LayoutArray[i][4], LayoutArray[i][5], m_From.Female ? RacialData[i][4] : RacialData[i][5]); } - AddButton(LayoutArray[i][6], LayoutArray[i][7], 0xFA5, 0xFA7, i, GumpButtonType.Reply, 0); + AddButton(LayoutArray[i][6], LayoutArray[i][7], 0xFA5, 0xFA7, i); } } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_From == null || !m_From.Alive) + if (m_From?.Alive != true) return; if (m_Deed.Deleted) @@ -147,4 +147,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Deeds/HolidayTreeDeed.cs b/Scripts/Items/Deeds/HolidayTreeDeed.cs index efe1970ab..2444dd3b4 100644 --- a/Scripts/Items/Deeds/HolidayTreeDeed.cs +++ b/Scripts/Items/Deeds/HolidayTreeDeed.cs @@ -130,11 +130,11 @@ namespace Server.Items AddBackground(0, 0, 220, 120, 5054); AddBackground(10, 10, 200, 100, 3000); - AddButton(20, 35, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 35, 145, 25, 1018322, false, false); // Classic + AddButton(20, 35, 4005, 4007, 1); + AddHtmlLocalized(55, 35, 145, 25, 1018322); // Classic - AddButton(20, 65, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 65, 145, 25, 1018321, false, false); // Modern + AddButton(20, 65, 4005, 4007, 2); + AddHtmlLocalized(55, 65, 145, 25, 1018321); // Modern } public override void OnResponse(NetState sender, RelayInfo info) @@ -157,4 +157,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Deeds/NameChangeDeed.cs b/Scripts/Items/Deeds/NameChangeDeed.cs index b37842fa9..b50914696 100644 --- a/Scripts/Items/Deeds/NameChangeDeed.cs +++ b/Scripts/Items/Deeds/NameChangeDeed.cs @@ -61,7 +61,7 @@ namespace Server.Items AddPage(0); AddBlackAlpha(10, 120, 250, 85); - AddHtml(10, 125, 250, 20, Color(Center("Name Change Deed"), 0xFFFFFF), false, false); + AddHtml(10, 125, 250, 20, Color(Center("Name Change Deed"), 0xFFFFFF)); AddLabel(73, 15, 1152, ""); AddLabel(20, 150, 0x480, "New Name:"); @@ -94,13 +94,13 @@ namespace Server.Items public void AddButtonLabeled(int x, int y, int buttonID, string text) { - AddButton(x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0); - AddHtml(x + 35, y, 240, 20, Color(text, 0xFFFFFF), false, false); + AddButton(x, y - 1, 4005, 4007, buttonID); + AddHtml(x + 35, y, 240, 20, Color(text, 0xFFFFFF)); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Sender == null || m_Sender.Deleted || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile) + if (m_Sender?.Deleted != false || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile) return; Mobile m = sender.Mobile; @@ -121,4 +121,4 @@ namespace Server.Items m_Sender.Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Deeds/NewPlayerTicket.cs b/Scripts/Items/Deeds/NewPlayerTicket.cs index 8b6e10f26..e4b02d07e 100644 --- a/Scripts/Items/Deeds/NewPlayerTicket.cs +++ b/Scripts/Items/Deeds/NewPlayerTicket.cs @@ -95,7 +95,7 @@ namespace Server.Items { Mobile them = theirTicket.Owner; - if (them == null || them.Deleted) + if (them?.Deleted != false) { from.SendLocalizedMessage(501930); // That is not a valid ticket. } @@ -131,26 +131,26 @@ namespace Server.Items AddHtmlLocalized(30, 45, 340, 70, 1013011, true, true); // Choose the gift you prefer. WARNING: if you cancel, and your partner does not, you will need to find another matching ticket! - AddButton(46, 128, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 130, 320, 35, 1013012, false, false); // A sextant + AddButton(46, 128, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(80, 130, 320, 35, 1013012); // A sextant - AddButton(46, 163, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 165, 320, 35, 1013013, false, false); // A coupon for a single hair restyling + AddButton(46, 163, 0xFA5, 0xFA7, 2); + AddHtmlLocalized(80, 165, 320, 35, 1013013); // A coupon for a single hair restyling - AddButton(46, 198, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 200, 320, 35, 1013014, false, false); // A spellbook with all 1st - 4th spells. + AddButton(46, 198, 0xFA5, 0xFA7, 3); + AddHtmlLocalized(80, 200, 320, 35, 1013014); // A spellbook with all 1st - 4th spells. - AddButton(46, 233, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 235, 320, 35, 1013015, false, false); // A wand of fireworks + AddButton(46, 233, 0xFA5, 0xFA7, 4); + AddHtmlLocalized(80, 235, 320, 35, 1013015); // A wand of fireworks - AddButton(46, 268, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 270, 320, 35, 1013016, false, false); // A spyglass + AddButton(46, 268, 0xFA5, 0xFA7, 5); + AddHtmlLocalized(80, 270, 320, 35, 1013016); // A spyglass - AddButton(46, 303, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 305, 320, 35, 1013017, false, false); // Dyes and a dye tub + AddButton(46, 303, 0xFA5, 0xFA7, 6); + AddHtmlLocalized(80, 305, 320, 35, 1013017); // Dyes and a dye tub - AddButton(120, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(154, 342, 100, 35, 1011012, false, false); // CANCEL + AddButton(120, 340, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(154, 342, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -205,4 +205,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Asian.cs b/Scripts/Items/Food/Asian.cs index 63704e726..edf6ce827 100644 --- a/Scripts/Items/Food/Asian.cs +++ b/Scripts/Items/Food/Asian.cs @@ -30,7 +30,7 @@ namespace Server.Items public class WasabiClumps : Food { [Constructible] - public WasabiClumps() : base(0x24EB) + public WasabiClumps() : base(0x24EB, 1) { Stackable = false; Weight = 1.0; @@ -86,7 +86,7 @@ namespace Server.Items public class BentoBox : Food { [Constructible] - public BentoBox() : base(0x2836) + public BentoBox() : base(0x2836, 1) { Stackable = false; Weight = 5.0; @@ -124,7 +124,7 @@ namespace Server.Items public class SushiRolls : Food { [Constructible] - public SushiRolls() : base(0x283E) + public SushiRolls() : base(0x283E, 1) { Stackable = false; Weight = 3.0; @@ -153,7 +153,7 @@ namespace Server.Items public class SushiPlatter : Food { [Constructible] - public SushiPlatter() : base(0x2840) + public SushiPlatter() : base(0x2840, 1) { Stackable = Core.ML; Weight = 3.0; @@ -209,7 +209,7 @@ namespace Server.Items public class GreenTea : Food { [Constructible] - public GreenTea() : base(0x284C) + public GreenTea() : base(0x284C, 1) { Stackable = false; Weight = 4.0; @@ -238,7 +238,7 @@ namespace Server.Items public class MisoSoup : Food { [Constructible] - public MisoSoup() : base(0x284D) + public MisoSoup() : base(0x284D, 1) { Stackable = false; Weight = 4.0; @@ -267,7 +267,7 @@ namespace Server.Items public class WhiteMisoSoup : Food { [Constructible] - public WhiteMisoSoup() : base(0x284E) + public WhiteMisoSoup() : base(0x284E, 1) { Stackable = false; Weight = 4.0; @@ -296,7 +296,7 @@ namespace Server.Items public class RedMisoSoup : Food { [Constructible] - public RedMisoSoup() : base(0x284F) + public RedMisoSoup() : base(0x284F, 1) { Stackable = false; Weight = 4.0; @@ -325,7 +325,7 @@ namespace Server.Items public class AwaseMisoSoup : Food { [Constructible] - public AwaseMisoSoup() : base(0x2850) + public AwaseMisoSoup() : base(0x2850, 1) { Stackable = false; Weight = 4.0; @@ -350,4 +350,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Beverage.cs b/Scripts/Items/Food/Beverage.cs index 2c54548a4..451663c65 100644 --- a/Scripts/Items/Food/Beverage.cs +++ b/Scripts/Items/Food/Beverage.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Engines.Quests; diff --git a/Scripts/Items/Food/Bowls.cs b/Scripts/Items/Food/Bowls.cs index c47d0c5c9..164d4b1da 100644 --- a/Scripts/Items/Food/Bowls.cs +++ b/Scripts/Items/Food/Bowls.cs @@ -57,7 +57,7 @@ namespace Server.Items public class WoodenBowlOfCarrots : Food { [Constructible] - public WoodenBowlOfCarrots() : base(0x15F9) + public WoodenBowlOfCarrots() : base(0x15F9, 1) { Stackable = false; Weight = 1.0; @@ -95,7 +95,7 @@ namespace Server.Items public class WoodenBowlOfCorn : Food { [Constructible] - public WoodenBowlOfCorn() : base(0x15FA) + public WoodenBowlOfCorn() : base(0x15FA, 1) { Stackable = false; Weight = 1.0; @@ -133,7 +133,7 @@ namespace Server.Items public class WoodenBowlOfLettuce : Food { [Constructible] - public WoodenBowlOfLettuce() : base(0x15FB) + public WoodenBowlOfLettuce() : base(0x15FB, 1) { Stackable = false; Weight = 1.0; @@ -171,7 +171,7 @@ namespace Server.Items public class WoodenBowlOfPeas : Food { [Constructible] - public WoodenBowlOfPeas() : base(0x15FC) + public WoodenBowlOfPeas() : base(0x15FC, 1) { Stackable = false; Weight = 1.0; @@ -209,7 +209,7 @@ namespace Server.Items public class PewterBowlOfCarrots : Food { [Constructible] - public PewterBowlOfCarrots() : base(0x15FE) + public PewterBowlOfCarrots() : base(0x15FE, 1) { Stackable = false; Weight = 1.0; @@ -247,7 +247,7 @@ namespace Server.Items public class PewterBowlOfCorn : Food { [Constructible] - public PewterBowlOfCorn() : base(0x15FF) + public PewterBowlOfCorn() : base(0x15FF, 1) { Stackable = false; Weight = 1.0; @@ -285,7 +285,7 @@ namespace Server.Items public class PewterBowlOfLettuce : Food { [Constructible] - public PewterBowlOfLettuce() : base(0x1600) + public PewterBowlOfLettuce() : base(0x1600, 1) { Stackable = false; Weight = 1.0; @@ -323,7 +323,7 @@ namespace Server.Items public class PewterBowlOfPeas : Food { [Constructible] - public PewterBowlOfPeas() : base(0x1601) + public PewterBowlOfPeas() : base(0x1601, 1) { Stackable = false; Weight = 1.0; @@ -361,7 +361,7 @@ namespace Server.Items public class PewterBowlOfPotatos : Food { [Constructible] - public PewterBowlOfPotatos() : base(0x1602) + public PewterBowlOfPotatos() : base(0x1602, 1) { Stackable = false; Weight = 1.0; @@ -455,7 +455,7 @@ namespace Server.Items public class WoodenBowlOfStew : Food { [Constructible] - public WoodenBowlOfStew() : base(0x1604) + public WoodenBowlOfStew() : base(0x1604, 1) { Stackable = false; Weight = 2.0; @@ -493,7 +493,7 @@ namespace Server.Items public class WoodenBowlOfTomatoSoup : Food { [Constructible] - public WoodenBowlOfTomatoSoup() : base(0x1606) + public WoodenBowlOfTomatoSoup() : base(0x1606, 1) { Stackable = false; Weight = 2.0; @@ -527,4 +527,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Chocolatiering.cs b/Scripts/Items/Food/Chocolatiering.cs index 5558bc13d..e536d4a7f 100644 --- a/Scripts/Items/Food/Chocolatiering.cs +++ b/Scripts/Items/Food/Chocolatiering.cs @@ -35,13 +35,7 @@ namespace Server.Items public class SackOfSugar : Item { [Constructible] - public SackOfSugar() - : this(1) - { - } - - [Constructible] - public SackOfSugar(int amount) + public SackOfSugar(int amount = 1) : base(0x1039) { Hue = 0x461; @@ -107,13 +101,7 @@ namespace Server.Items public class Vanilla : Item { [Constructible] - public Vanilla() - : this(1) - { - } - - [Constructible] - public Vanilla(int amount) + public Vanilla(int amount = 1) : base(0xE2A) { Hue = 0x462; @@ -147,13 +135,7 @@ namespace Server.Items public class CocoaPulp : Item { [Constructible] - public CocoaPulp() - : this(1) - { - } - - [Constructible] - public CocoaPulp(int amount) + public CocoaPulp(int amount = 1) : base(0xF7C) { Hue = 0x219; @@ -282,4 +264,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/CookableFood.cs b/Scripts/Items/Food/CookableFood.cs index 8594d683e..0854404e5 100644 --- a/Scripts/Items/Food/CookableFood.cs +++ b/Scripts/Items/Food/CookableFood.cs @@ -161,12 +161,7 @@ namespace Server.Items public class RawRibs : CookableFood { [Constructible] - public RawRibs() : this(1) - { - } - - [Constructible] - public RawRibs(int amount) : base(0x9F1, 10) + public RawRibs(int amount = 1) : base(0x9F1, 10) { Weight = 1.0; Stackable = true; @@ -202,12 +197,7 @@ namespace Server.Items public class RawLambLeg : CookableFood { [Constructible] - public RawLambLeg() : this(1) - { - } - - [Constructible] - public RawLambLeg(int amount) : base(0x1609, 10) + public RawLambLeg(int amount = 1) : base(0x1609, 10) { Stackable = true; Amount = amount; @@ -279,12 +269,7 @@ namespace Server.Items public class RawBird : CookableFood { [Constructible] - public RawBird() : this(1) - { - } - - [Constructible] - public RawBird(int amount) : base(0x9B9, 10) + public RawBird(int amount = 1) : base(0x9B9, 10) { Weight = 1.0; Stackable = true; @@ -648,12 +633,7 @@ namespace Server.Items public class Eggs : CookableFood { [Constructible] - public Eggs() : this(1) - { - } - - [Constructible] - public Eggs(int amount) : base(0x9B5, 15) + public Eggs(int amount = 1) : base(0x9B5, 15) { Weight = 1.0; Stackable = true; @@ -835,12 +815,7 @@ namespace Server.Items public class RawFishSteak : CookableFood { [Constructible] - public RawFishSteak() : this(1) - { - } - - [Constructible] - public RawFishSteak(int amount) : base(0x097A, 10) + public RawFishSteak(int amount = 1) : base(0x097A, 10) { Stackable = true; Amount = amount; @@ -871,4 +846,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Cooking.cs b/Scripts/Items/Food/Cooking.cs index cad1684b3..5bf3cc134 100644 --- a/Scripts/Items/Food/Cooking.cs +++ b/Scripts/Items/Food/Cooking.cs @@ -81,36 +81,29 @@ namespace Server.Items if (targeted is Eggs) { - targetItem.Consume(); - from.AddToBackpack(new UnbakedQuiche()); from.AddToBackpack(new Eggshells()); } else if (targeted is CheeseWheel) { - targetItem.Consume(); - from.AddToBackpack(new CheesePizza()); } else if (targeted is Sausage) { - targetItem.Consume(); - from.AddToBackpack(new SausagePizza()); } else if (targeted is Apple) { - targetItem.Consume(); - from.AddToBackpack(new UnbakedApplePie()); } - else if (targeted is Peach) { - targetItem.Consume(); - from.AddToBackpack(new UnbakedPeachCobbler()); } + else + return; + + targetItem.Consume(); } } } @@ -598,12 +591,7 @@ namespace Server.Items public class WheatSheaf : Item { [Constructible] - public WheatSheaf() : this(1) - { - } - - [Constructible] - public WheatSheaf(int amount) : base(7869) + public WheatSheaf(int amount = 1) : base(7869) { Weight = 1.0; Stackable = true; @@ -653,4 +641,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Food.cs b/Scripts/Items/Food/Food.cs index 7b797cb28..119cf2b98 100644 --- a/Scripts/Items/Food/Food.cs +++ b/Scripts/Items/Food/Food.cs @@ -5,11 +5,7 @@ namespace Server.Items { public abstract class Food : Item { - public Food(int itemID) : this(1, itemID) - { - } - - public Food(int amount, int itemID) : base(itemID) + public Food(int itemID, int amount) : base(itemID) { Stackable = true; Amount = amount; @@ -173,12 +169,7 @@ namespace Server.Items public class BreadLoaf : Food { [Constructible] - public BreadLoaf() : this(1) - { - } - - [Constructible] - public BreadLoaf(int amount) : base(amount, 0x103B) + public BreadLoaf(int amount = 1) : base(0x103B, amount) { Weight = 1.0; FillFactor = 3; @@ -206,12 +197,7 @@ namespace Server.Items public class Bacon : Food { [Constructible] - public Bacon() : this(1) - { - } - - [Constructible] - public Bacon(int amount) : base(amount, 0x979) + public Bacon(int amount = 1) : base(0x979, amount) { Weight = 1.0; FillFactor = 1; @@ -239,12 +225,7 @@ namespace Server.Items public class SlabOfBacon : Food { [Constructible] - public SlabOfBacon() : this(1) - { - } - - [Constructible] - public SlabOfBacon(int amount) : base(amount, 0x976) + public SlabOfBacon(int amount = 1) : base(0x976, amount) { Weight = 1.0; FillFactor = 3; @@ -272,12 +253,7 @@ namespace Server.Items public class FishSteak : Food { [Constructible] - public FishSteak() : this(1) - { - } - - [Constructible] - public FishSteak(int amount) : base(amount, 0x97B) + public FishSteak(int amount = 1) : base(0x97B, amount) { FillFactor = 3; } @@ -306,12 +282,7 @@ namespace Server.Items public class CheeseWheel : Food { [Constructible] - public CheeseWheel() : this(1) - { - } - - [Constructible] - public CheeseWheel(int amount) : base(amount, 0x97E) + public CheeseWheel(int amount = 1) : base(0x97E, amount) { FillFactor = 3; } @@ -340,12 +311,7 @@ namespace Server.Items public class CheeseWedge : Food { [Constructible] - public CheeseWedge() : this(1) - { - } - - [Constructible] - public CheeseWedge(int amount) : base(amount, 0x97D) + public CheeseWedge(int amount = 1) : base(0x97D, amount) { FillFactor = 3; } @@ -374,12 +340,7 @@ namespace Server.Items public class CheeseSlice : Food { [Constructible] - public CheeseSlice() : this(1) - { - } - - [Constructible] - public CheeseSlice(int amount) : base(amount, 0x97C) + public CheeseSlice(int amount = 1) : base(0x97C, amount) { FillFactor = 1; } @@ -408,12 +369,7 @@ namespace Server.Items public class FrenchBread : Food { [Constructible] - public FrenchBread() : this(1) - { - } - - [Constructible] - public FrenchBread(int amount) : base(amount, 0x98C) + public FrenchBread(int amount = 1) : base(0x98C, amount) { Weight = 2.0; FillFactor = 3; @@ -442,12 +398,7 @@ namespace Server.Items public class FriedEggs : Food { [Constructible] - public FriedEggs() : this(1) - { - } - - [Constructible] - public FriedEggs(int amount) : base(amount, 0x9B6) + public FriedEggs(int amount = 1) : base(0x9B6, amount) { Weight = 1.0; FillFactor = 4; @@ -475,12 +426,7 @@ namespace Server.Items public class CookedBird : Food { [Constructible] - public CookedBird() : this(1) - { - } - - [Constructible] - public CookedBird(int amount) : base(amount, 0x9B7) + public CookedBird(int amount = 1) : base(0x9B7, amount) { Weight = 1.0; FillFactor = 5; @@ -508,12 +454,7 @@ namespace Server.Items public class RoastPig : Food { [Constructible] - public RoastPig() : this(1) - { - } - - [Constructible] - public RoastPig(int amount) : base(amount, 0x9BB) + public RoastPig(int amount = 1) : base(0x9BB, amount) { Weight = 45.0; FillFactor = 20; @@ -541,12 +482,7 @@ namespace Server.Items public class Sausage : Food { [Constructible] - public Sausage() : this(1) - { - } - - [Constructible] - public Sausage(int amount) : base(amount, 0x9C0) + public Sausage(int amount = 1) : base(0x9C0, amount) { Weight = 1.0; FillFactor = 4; @@ -574,12 +510,7 @@ namespace Server.Items public class Ham : Food { [Constructible] - public Ham() : this(1) - { - } - - [Constructible] - public Ham(int amount) : base(amount, 0x9C9) + public Ham(int amount = 1) : base(0x9C9, amount) { Weight = 1.0; FillFactor = 5; @@ -607,7 +538,7 @@ namespace Server.Items public class Cake : Food { [Constructible] - public Cake() : base(0x9E9) + public Cake() : base(0x9E9, 1) { Stackable = false; Weight = 1.0; @@ -636,12 +567,7 @@ namespace Server.Items public class Ribs : Food { [Constructible] - public Ribs() : this(1) - { - } - - [Constructible] - public Ribs(int amount) : base(amount, 0x9F2) + public Ribs(int amount = 1) : base(0x9F2, amount) { Weight = 1.0; FillFactor = 5; @@ -669,7 +595,7 @@ namespace Server.Items public class Cookies : Food { [Constructible] - public Cookies() : base(0x160b) + public Cookies() : base(0x160b, 1) { Stackable = Core.ML; Weight = 1.0; @@ -698,7 +624,7 @@ namespace Server.Items public class Muffins : Food { [Constructible] - public Muffins() : base(0x9eb) + public Muffins() : base(0x9eb, 1) { Stackable = false; Weight = 1.0; @@ -728,7 +654,7 @@ namespace Server.Items public class CheesePizza : Food { [Constructible] - public CheesePizza() : base(0x1040) + public CheesePizza() : base(0x1040, 1) { Stackable = false; Weight = 1.0; @@ -759,7 +685,7 @@ namespace Server.Items public class SausagePizza : Food { [Constructible] - public SausagePizza() : base(0x1040) + public SausagePizza() : base(0x1040, 1) { Stackable = false; Weight = 1.0; @@ -821,7 +747,7 @@ namespace Server.Items public class FruitPie : Food { [Constructible] - public FruitPie() : base(0x1041) + public FruitPie() : base(0x1041, 1) { Stackable = false; Weight = 1.0; @@ -852,7 +778,7 @@ namespace Server.Items public class MeatPie : Food { [Constructible] - public MeatPie() : base(0x1041) + public MeatPie() : base(0x1041, 1) { Stackable = false; Weight = 1.0; @@ -883,7 +809,7 @@ namespace Server.Items public class PumpkinPie : Food { [Constructible] - public PumpkinPie() : base(0x1041) + public PumpkinPie() : base(0x1041, 1) { Stackable = false; Weight = 1.0; @@ -914,7 +840,7 @@ namespace Server.Items public class ApplePie : Food { [Constructible] - public ApplePie() : base(0x1041) + public ApplePie() : base(0x1041, 1) { Stackable = false; Weight = 1.0; @@ -945,7 +871,7 @@ namespace Server.Items public class PeachCobbler : Food { [Constructible] - public PeachCobbler() : base(0x1041) + public PeachCobbler() : base(0x1041, 1) { Stackable = false; Weight = 1.0; @@ -976,7 +902,7 @@ namespace Server.Items public class Quiche : Food { [Constructible] - public Quiche() : base(0x1041) + public Quiche() : base(0x1041, 1) { Stackable = Core.ML; Weight = 1.0; @@ -1007,12 +933,7 @@ namespace Server.Items public class LambLeg : Food { [Constructible] - public LambLeg() : this(1) - { - } - - [Constructible] - public LambLeg(int amount) : base(amount, 0x160a) + public LambLeg(int amount = 1) : base(0x160a, amount) { Weight = 2.0; FillFactor = 5; @@ -1040,12 +961,7 @@ namespace Server.Items public class ChickenLeg : Food { [Constructible] - public ChickenLeg() : this(1) - { - } - - [Constructible] - public ChickenLeg(int amount) : base(amount, 0x1608) + public ChickenLeg(int amount = 1) : base(0x1608, amount) { Weight = 1.0; FillFactor = 4; @@ -1074,12 +990,7 @@ namespace Server.Items public class HoneydewMelon : Food { [Constructible] - public HoneydewMelon() : this(1) - { - } - - [Constructible] - public HoneydewMelon(int amount) : base(amount, 0xC74) + public HoneydewMelon(int amount = 1) : base(0xC74, amount) { Weight = 1.0; FillFactor = 1; @@ -1108,12 +1019,7 @@ namespace Server.Items public class YellowGourd : Food { [Constructible] - public YellowGourd() : this(1) - { - } - - [Constructible] - public YellowGourd(int amount) : base(amount, 0xC64) + public YellowGourd(int amount = 1) : base(0xC64, amount) { Weight = 1.0; FillFactor = 1; @@ -1142,12 +1048,7 @@ namespace Server.Items public class GreenGourd : Food { [Constructible] - public GreenGourd() : this(1) - { - } - - [Constructible] - public GreenGourd(int amount) : base(amount, 0xC66) + public GreenGourd(int amount = 1) : base(0xC66, amount) { Weight = 1.0; FillFactor = 1; @@ -1176,12 +1077,7 @@ namespace Server.Items public class EarOfCorn : Food { [Constructible] - public EarOfCorn() : this(1) - { - } - - [Constructible] - public EarOfCorn(int amount) : base(amount, 0xC81) + public EarOfCorn(int amount = 1) : base(0xC81, amount) { Weight = 1.0; FillFactor = 1; @@ -1209,12 +1105,7 @@ namespace Server.Items public class Turnip : Food { [Constructible] - public Turnip() : this(1) - { - } - - [Constructible] - public Turnip(int amount) : base(amount, 0xD3A) + public Turnip(int amount = 1) : base(0xD3A, amount) { Weight = 1.0; FillFactor = 1; @@ -1265,4 +1156,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Fruits.cs b/Scripts/Items/Food/Fruits.cs index 591d4e7af..ecce95f87 100644 --- a/Scripts/Items/Food/Fruits.cs +++ b/Scripts/Items/Food/Fruits.cs @@ -3,7 +3,7 @@ namespace Server.Items public class FruitBasket : Food { [Constructible] - public FruitBasket() : base(1, 0x993) + public FruitBasket() : base(0x993, 1) { Weight = 2.0; FillFactor = 5; @@ -42,12 +42,7 @@ namespace Server.Items public class Banana : Food { [Constructible] - public Banana() : this(1) - { - } - - [Constructible] - public Banana(int amount) : base(amount, 0x171f) + public Banana(int amount = 1) : base(0x171f, amount) { Weight = 1.0; FillFactor = 1; @@ -76,12 +71,7 @@ namespace Server.Items public class Bananas : Food { [Constructible] - public Bananas() : this(1) - { - } - - [Constructible] - public Bananas(int amount) : base(amount, 0x1721) + public Bananas(int amount = 1) : base(0x1721, amount) { Weight = 1.0; FillFactor = 1; @@ -109,12 +99,7 @@ namespace Server.Items public class SplitCoconut : Food { [Constructible] - public SplitCoconut() : this(1) - { - } - - [Constructible] - public SplitCoconut(int amount) : base(amount, 0x1725) + public SplitCoconut(int amount = 1) : base(0x1725, amount) { Weight = 1.0; FillFactor = 1; @@ -142,12 +127,7 @@ namespace Server.Items public class Lemon : Food { [Constructible] - public Lemon() : this(1) - { - } - - [Constructible] - public Lemon(int amount) : base(amount, 0x1728) + public Lemon(int amount = 1) : base(0x1728, amount) { Weight = 1.0; FillFactor = 1; @@ -175,12 +155,7 @@ namespace Server.Items public class Lemons : Food { [Constructible] - public Lemons() : this(1) - { - } - - [Constructible] - public Lemons(int amount) : base(amount, 0x1729) + public Lemons(int amount = 1) : base(0x1729, amount) { Weight = 1.0; FillFactor = 1; @@ -208,12 +183,7 @@ namespace Server.Items public class Lime : Food { [Constructible] - public Lime() : this(1) - { - } - - [Constructible] - public Lime(int amount) : base(amount, 0x172a) + public Lime(int amount = 1) : base(0x172a, amount) { Weight = 1.0; FillFactor = 1; @@ -241,12 +211,7 @@ namespace Server.Items public class Limes : Food { [Constructible] - public Limes() : this(1) - { - } - - [Constructible] - public Limes(int amount) : base(amount, 0x172B) + public Limes(int amount = 1) : base(0x172B, amount) { Weight = 1.0; FillFactor = 1; @@ -274,12 +239,7 @@ namespace Server.Items public class Coconut : Food { [Constructible] - public Coconut() : this(1) - { - } - - [Constructible] - public Coconut(int amount) : base(amount, 0x1726) + public Coconut(int amount = 1) : base(0x1726, amount) { Weight = 1.0; FillFactor = 1; @@ -307,12 +267,7 @@ namespace Server.Items public class OpenCoconut : Food { [Constructible] - public OpenCoconut() : this(1) - { - } - - [Constructible] - public OpenCoconut(int amount) : base(amount, 0x1723) + public OpenCoconut(int amount = 1) : base(0x1723, amount) { Weight = 1.0; FillFactor = 1; @@ -340,12 +295,7 @@ namespace Server.Items public class Dates : Food { [Constructible] - public Dates() : this(1) - { - } - - [Constructible] - public Dates(int amount) : base(amount, 0x1727) + public Dates(int amount = 1) : base(0x1727, amount) { Weight = 1.0; FillFactor = 1; @@ -373,12 +323,7 @@ namespace Server.Items public class Grapes : Food { [Constructible] - public Grapes() : this(1) - { - } - - [Constructible] - public Grapes(int amount) : base(amount, 0x9D1) + public Grapes(int amount = 1) : base(0x9D1, amount) { Weight = 1.0; FillFactor = 1; @@ -406,12 +351,7 @@ namespace Server.Items public class Peach : Food { [Constructible] - public Peach() : this(1) - { - } - - [Constructible] - public Peach(int amount) : base(amount, 0x9D2) + public Peach(int amount = 1) : base(0x9D2, amount) { Weight = 1.0; FillFactor = 1; @@ -439,12 +379,7 @@ namespace Server.Items public class Pear : Food { [Constructible] - public Pear() : this(1) - { - } - - [Constructible] - public Pear(int amount) : base(amount, 0x994) + public Pear(int amount = 1) : base(0x994, amount) { Weight = 1.0; FillFactor = 1; @@ -472,12 +407,7 @@ namespace Server.Items public class Apple : Food { [Constructible] - public Apple() : this(1) - { - } - - [Constructible] - public Apple(int amount) : base(amount, 0x9D0) + public Apple(int amount = 1) : base(0x9D0, amount) { Weight = 1.0; FillFactor = 1; @@ -505,12 +435,7 @@ namespace Server.Items public class Watermelon : Food { [Constructible] - public Watermelon() : this(1) - { - } - - [Constructible] - public Watermelon(int amount) : base(amount, 0xC5C) + public Watermelon(int amount = 1) : base(0xC5C, amount) { Weight = 5.0; FillFactor = 5; @@ -547,12 +472,7 @@ namespace Server.Items public class SmallWatermelon : Food { [Constructible] - public SmallWatermelon() : this(1) - { - } - - [Constructible] - public SmallWatermelon(int amount) : base(amount, 0xC5D) + public SmallWatermelon(int amount = 1) : base(0xC5D, amount) { Weight = 5.0; FillFactor = 5; @@ -581,12 +501,7 @@ namespace Server.Items public class Squash : Food { [Constructible] - public Squash() : this(1) - { - } - - [Constructible] - public Squash(int amount) : base(amount, 0xc72) + public Squash(int amount = 1) : base(0xc72, amount) { Weight = 1.0; FillFactor = 1; @@ -615,12 +530,7 @@ namespace Server.Items public class Cantaloupe : Food { [Constructible] - public Cantaloupe() : this(1) - { - } - - [Constructible] - public Cantaloupe(int amount) : base(amount, 0xc79) + public Cantaloupe(int amount = 1) : base(0xc79, amount) { Weight = 1.0; FillFactor = 1; @@ -644,4 +554,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Food/Vegetables.cs b/Scripts/Items/Food/Vegetables.cs index c951d2d0a..5a94f8e5f 100644 --- a/Scripts/Items/Food/Vegetables.cs +++ b/Scripts/Items/Food/Vegetables.cs @@ -4,12 +4,7 @@ namespace Server.Items public class Carrot : Food { [Constructible] - public Carrot() : this(1) - { - } - - [Constructible] - public Carrot(int amount) : base(amount, 0xc78) + public Carrot(int amount = 1) : base(0xc78, amount) { Weight = 1.0; FillFactor = 1; @@ -38,12 +33,7 @@ namespace Server.Items public class Cabbage : Food { [Constructible] - public Cabbage() : this(1) - { - } - - [Constructible] - public Cabbage(int amount) : base(amount, 0xc7b) + public Cabbage(int amount = 1) : base(0xc7b, amount) { Weight = 1.0; FillFactor = 1; @@ -72,12 +62,7 @@ namespace Server.Items public class Onion : Food { [Constructible] - public Onion() : this(1) - { - } - - [Constructible] - public Onion(int amount) : base(amount, 0xc6d) + public Onion(int amount = 1) : base(0xc6d, amount) { Weight = 1.0; FillFactor = 1; @@ -106,12 +91,7 @@ namespace Server.Items public class Lettuce : Food { [Constructible] - public Lettuce() : this(1) - { - } - - [Constructible] - public Lettuce(int amount) : base(amount, 0xc70) + public Lettuce(int amount = 1) : base(0xc70, amount) { Weight = 1.0; FillFactor = 1; @@ -140,12 +120,7 @@ namespace Server.Items public class Pumpkin : Food { [Constructible] - public Pumpkin() : this(1) - { - } - - [Constructible] - public Pumpkin(int amount) : base(amount, 0xC6A) + public Pumpkin(int amount = 1) : base(0xC6A, amount) { Weight = 1.0; FillFactor = 8; @@ -182,12 +157,7 @@ namespace Server.Items public class SmallPumpkin : Food { [Constructible] - public SmallPumpkin() : this(1) - { - } - - [Constructible] - public SmallPumpkin(int amount) : base(amount, 0xC6C) + public SmallPumpkin(int amount = 1) : base(0xC6C, amount) { Weight = 1.0; FillFactor = 8; @@ -211,4 +181,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Games/BaseBoard.cs b/Scripts/Items/Games/BaseBoard.cs index 32a8dc5fe..d5b8767fa 100644 --- a/Scripts/Items/Games/BaseBoard.cs +++ b/Scripts/Items/Games/BaseBoard.cs @@ -105,26 +105,12 @@ namespace Server.Items public static bool ValidateDefault(Mobile from, BaseBoard board) { - if (from.AccessLevel >= AccessLevel.GameMaster) - return true; - - if (!from.Alive) - return false; - - if (board.IsChildOf(from.Backpack)) - return true; - - object root = board.RootParent; - - if (root is Mobile && root != from) - return false; - - if (board.Deleted || board.Map != from.Map || !from.InRange(board.GetWorldLocation(), 1)) - return false; - - BaseHouse house = BaseHouse.FindHouseAt(board); - - return house != null && house.IsOwner(from); + // Fixed this because it implies you can use it from your bank, if you can access your bank + // while in your house. (!(board.RootParent is Mobile) || board.RootParent == from) + return !board.Deleted && (from.AccessLevel >= AccessLevel.GameMaster || from.Alive && + (board.IsChildOf(from.Backpack) || !(board.RootParent is Mobile) && + board.Map == from.Map && from.InRange(board.GetWorldLocation(), 1) && + BaseHouse.FindHouseAt(board)?.IsOwner(from) == true)); } public class DefaultEntry : ContextMenuEntry @@ -146,4 +132,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Games/BasePiece.cs b/Scripts/Items/Games/BasePiece.cs index be88dbe7e..bd0cb36f8 100644 --- a/Scripts/Items/Games/BasePiece.cs +++ b/Scripts/Items/Games/BasePiece.cs @@ -47,7 +47,7 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { - if (Board == null || Board.Deleted) + if (Board?.Deleted != false) Delete(); else if (!IsChildOf(Board)) Board.DropItem(this); @@ -57,7 +57,7 @@ namespace Server.Items public override bool OnDragLift(Mobile from) { - if (Board == null || Board.Deleted) + if (Board?.Deleted != false) { Delete(); return false; @@ -92,4 +92,4 @@ namespace Server.Items return -1; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Games/Mahjong/MahjongPlayers.cs b/Scripts/Items/Games/Mahjong/MahjongPlayers.cs index c3899aef8..22c810a28 100644 --- a/Scripts/Items/Games/Mahjong/MahjongPlayers.cs +++ b/Scripts/Items/Games/Mahjong/MahjongPlayers.cs @@ -144,47 +144,47 @@ namespace Server.Engines.Mahjong { Mobile player = m_Players[i]; - if (player != null) + if (player == null) + continue; + + if (player.Deleted) { - if (player.Deleted) + m_Players[i] = null; + + SendPlayerExitMessage(player); + UpdateDealer(true); + + removed = true; + } + else if (m_InGame[i]) + { + if (player.NetState == null) { - m_Players[i] = null; + m_InGame[i] = false; SendPlayerExitMessage(player); UpdateDealer(true); removed = true; } - else if (m_InGame[i]) + else if (!Game.IsAccessibleTo(player) || player.Map != Game.Map || + !player.InRange(Game.GetWorldLocation(), 5)) { - if (player.NetState == null) - { - m_InGame[i] = false; + m_InGame[i] = false; - SendPlayerExitMessage(player); - UpdateDealer(true); + player.Send(new MahjongRelieve(Game)); - removed = true; - } - else if (!Game.IsAccessibleTo(player) || player.Map != Game.Map || - !player.InRange(Game.GetWorldLocation(), 5)) - { - m_InGame[i] = false; + SendPlayerExitMessage(player); + UpdateDealer(true); - player.Send(new MahjongRelieve(Game)); - - SendPlayerExitMessage(player); - UpdateDealer(true); - - removed = true; - } + removed = true; } } } for (int i = 0; i < m_Spectators.Count;) { - Mobile mobile = (Mobile)m_Spectators[i]; + Mobile mobile = m_Spectators[i]; if (mobile.NetState == null || mobile.Deleted) { @@ -257,7 +257,7 @@ namespace Server.Engines.Mahjong if (nextSeat >= 0) { - Mobile newPlayer = (Mobile)m_Spectators[0]; + Mobile newPlayer = m_Spectators[0]; m_Spectators.RemoveAt(0); @@ -502,4 +502,4 @@ namespace Server.Engines.Mahjong writer.Write(DealerPosition); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Amber.cs b/Scripts/Items/Gems/Amber.cs index 53410017a..2d2babbb4 100644 --- a/Scripts/Items/Gems/Amber.cs +++ b/Scripts/Items/Gems/Amber.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Amber : Item { [Constructible] - public Amber() : this(1) - { - } - - [Constructible] - public Amber(int amount) : base(0xF25) + public Amber(int amount = 1) : base(0xF25) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Amethyst.cs b/Scripts/Items/Gems/Amethyst.cs index ee40435b6..289ce4cf9 100644 --- a/Scripts/Items/Gems/Amethyst.cs +++ b/Scripts/Items/Gems/Amethyst.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Amethyst : Item { [Constructible] - public Amethyst() : this(1) - { - } - - [Constructible] - public Amethyst(int amount) : base(0xF16) + public Amethyst(int amount = 1) : base(0xF16) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Citrine.cs b/Scripts/Items/Gems/Citrine.cs index d71f748d7..7401146d8 100644 --- a/Scripts/Items/Gems/Citrine.cs +++ b/Scripts/Items/Gems/Citrine.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Citrine : Item { [Constructible] - public Citrine() : this(1) - { - } - - [Constructible] - public Citrine(int amount) : base(0xF15) + public Citrine(int amount = 1) : base(0xF15) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Diamond.cs b/Scripts/Items/Gems/Diamond.cs index 316f1cfad..57e6c0233 100644 --- a/Scripts/Items/Gems/Diamond.cs +++ b/Scripts/Items/Gems/Diamond.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Diamond : Item { [Constructible] - public Diamond() : this(1) - { - } - - [Constructible] - public Diamond(int amount) : base(0xF26) + public Diamond(int amount = 1) : base(0xF26) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Emerald.cs b/Scripts/Items/Gems/Emerald.cs index 0605bc44c..41c0866e4 100644 --- a/Scripts/Items/Gems/Emerald.cs +++ b/Scripts/Items/Gems/Emerald.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Emerald : Item { [Constructible] - public Emerald() : this(1) - { - } - - [Constructible] - public Emerald(int amount) : base(0xF10) + public Emerald(int amount = 1) : base(0xF10) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Ruby.cs b/Scripts/Items/Gems/Ruby.cs index 74d6f5598..29c576cc9 100644 --- a/Scripts/Items/Gems/Ruby.cs +++ b/Scripts/Items/Gems/Ruby.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Ruby : Item { [Constructible] - public Ruby() : this(1) - { - } - - [Constructible] - public Ruby(int amount) : base(0xF13) + public Ruby(int amount = 1) : base(0xF13) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Sapphire.cs b/Scripts/Items/Gems/Sapphire.cs index 5f776c0b5..332fda2a5 100644 --- a/Scripts/Items/Gems/Sapphire.cs +++ b/Scripts/Items/Gems/Sapphire.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Sapphire : Item { [Constructible] - public Sapphire() : this(1) - { - } - - [Constructible] - public Sapphire(int amount) : base(0xF19) + public Sapphire(int amount = 1) : base(0xF19) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/StarSapphire.cs b/Scripts/Items/Gems/StarSapphire.cs index 1a89ce1d3..5e39a884c 100644 --- a/Scripts/Items/Gems/StarSapphire.cs +++ b/Scripts/Items/Gems/StarSapphire.cs @@ -3,12 +3,7 @@ namespace Server.Items public class StarSapphire : Item { [Constructible] - public StarSapphire() : this(1) - { - } - - [Constructible] - public StarSapphire(int amount) : base(0xF21) + public StarSapphire(int amount = 1) : base(0xF21) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Gems/Tourmaline.cs b/Scripts/Items/Gems/Tourmaline.cs index 6f81db0c0..5da101bb2 100644 --- a/Scripts/Items/Gems/Tourmaline.cs +++ b/Scripts/Items/Gems/Tourmaline.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Tourmaline : Item { [Constructible] - public Tourmaline() : this(1) - { - } - - [Constructible] - public Tourmaline(int amount) : base(0xF2D) + public Tourmaline(int amount = 1) : base(0xF2D) { Stackable = true; Amount = amount; @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Guilds/GuildTeleporter.cs b/Scripts/Items/Guilds/GuildTeleporter.cs index a7de75a93..4835a6b26 100644 --- a/Scripts/Items/Guilds/GuildTeleporter.cs +++ b/Scripts/Items/Guilds/GuildTeleporter.cs @@ -7,12 +7,7 @@ namespace Server.Items { private Item m_Stone; - [Constructible] - public GuildTeleporter() : this(null) - { - } - - public GuildTeleporter(Item stone) : base(0x1869) + public GuildTeleporter(Item stone = null) : base(0x1869) { Weight = 1.0; LootType = LootType.Blessed; @@ -69,7 +64,7 @@ namespace Server.Items { from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. } - else if (stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this) + else if (stone?.Deleted != false || stone.Guild?.Teleporter != this) { from.SendLocalizedMessage(501197); // This teleporting object can not determine what guildstone to teleport } @@ -98,4 +93,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Guilds/Guildstone.cs b/Scripts/Items/Guilds/Guildstone.cs index dd30f47f9..776687b53 100644 --- a/Scripts/Items/Guilds/Guildstone.cs +++ b/Scripts/Items/Guilds/Guildstone.cs @@ -67,19 +67,22 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(this); - if (house == null && m_BeforeChangeover || house != null && house.IsOwner(from) && house.Addons.Contains(this)) + bool contains = false; + + if (house == null && m_BeforeChangeover || house?.IsOwner(from) == true && (contains = house.Addons.Contains(this))) { Effects.PlaySound(GetWorldLocation(), Map, 0x3B3); from.SendLocalizedMessage(500461); // You destroy the item. Delete(); - if (house != null && house.Addons.Contains(this)) + if (contains) house.Addons.Remove(this); Item deed = Deed; - if (deed != null) from.AddToBackpack(deed); + if (deed != null) + from.AddToBackpack(deed); } } @@ -89,7 +92,7 @@ namespace Server.Items { base.Serialize(writer); - if (Guild != null && !Guild.Disbanded) + if (Guild?.Disbanded == false) { m_GuildName = Guild.Name; m_GuildAbbrev = Guild.Abbreviation; @@ -154,7 +157,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (Guild.NewGuildSystem && m_BeforeChangeover && house != null && !house.Addons.Contains(this)) + if (Guild.NewGuildSystem && m_BeforeChangeover && house?.Addons.Contains(this) == false) { house.Addons.Add(this); m_BeforeChangeover = false; @@ -165,7 +168,7 @@ namespace Server.Items { base.GetProperties(list); - if (Guild != null && !Guild.Disbanded) + if (Guild?.Disbanded == false) { string name; string abbr; @@ -189,7 +192,7 @@ namespace Server.Items { base.OnSingleClick(from); - if (Guild != null && !Guild.Disbanded) + if (Guild?.Disbanded == false) { string name; @@ -206,7 +209,7 @@ namespace Server.Items public override void OnAfterDelete() { - if (!Guild.NewGuildSystem && Guild != null && !Guild.Disbanded) + if (!Guild.NewGuildSystem && Guild?.Disbanded == false) Guild.Disband(); } @@ -215,7 +218,7 @@ namespace Server.Items if (Guild.NewGuildSystem) return; - if (Guild == null || Guild.Disbanded) + if (Guild?.Disbanded != false) { Delete(); } @@ -233,7 +236,7 @@ namespace Server.Items Faction guildFaction = guildState?.Faction; Faction targetFaction = targetState?.Faction; - if (guildFaction != targetFaction || targetState != null && targetState.IsLeaving) + if (guildFaction != targetFaction || targetState?.IsLeaving == true) return; if (guildState != null && targetState != null) @@ -278,17 +281,8 @@ namespace Server.Items private string m_GuildName; - [Constructible] - public GuildstoneDeed() : this(null, null) - { - } - - [Constructible] - public GuildstoneDeed(string guildName, string abbrev) : this(null, guildName, abbrev) - { - } - - public GuildstoneDeed(Guild g, string guildName, string abbrev) : base(0x14F0) + public GuildstoneDeed(Guild g = null, string guildName = null, string abbrev = null) : + base(0x14F0) { Guild = g; m_GuildName = guildName; @@ -332,7 +326,7 @@ namespace Server.Items { base.Serialize(writer); - if (Guild != null && !Guild.Disbanded) + if (Guild?.Disbanded == false) { m_GuildName = Guild.Name; m_GuildAbbrev = Guild.Abbreviation; @@ -370,7 +364,7 @@ namespace Server.Items { base.GetProperties(list); - if (Guild != null && !Guild.Disbanded) + if (Guild?.Disbanded == false) { string name; string abbr; @@ -396,7 +390,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.SendLocalizedMessage(1062838); // Where would you like to place this decoration? from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget); @@ -423,7 +417,7 @@ namespace Server.Items if (IsChildOf(from.Backpack)) { - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { Item addon = new Guildstone(Guild, m_GuildName, m_GuildAbbrev); @@ -443,4 +437,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Jewels/BaseJewel.cs b/Scripts/Items/Jewels/BaseJewel.cs index aadf71d57..944144bb9 100644 --- a/Scripts/Items/Jewels/BaseJewel.cs +++ b/Scripts/Items/Jewels/BaseJewel.cs @@ -140,7 +140,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; if (1 < craftItem.Resources.Count) @@ -404,4 +404,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Lights/BaseLight.cs b/Scripts/Items/Lights/BaseLight.cs index 70c23fe06..c1881fc35 100644 --- a/Scripts/Items/Lights/BaseLight.cs +++ b/Scripts/Items/Lights/BaseLight.cs @@ -208,9 +208,9 @@ namespace Server.Items protected override void OnTick() { - if (m_Light != null && !m_Light.Deleted) + if (m_Light?.Deleted == false) m_Light.Burn(); } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Maps/MapItem.cs b/Scripts/Items/Maps/MapItem.cs index 2930e9533..651b37ec3 100644 --- a/Scripts/Items/Maps/MapItem.cs +++ b/Scripts/Items/Maps/MapItem.cs @@ -174,12 +174,7 @@ namespace Server.Items if (!Movable || Protected || !from.InRange(GetWorldLocation(), 2)) return false; - object root = RootParent; - - if (root is Mobile && root != from) - return false; - - return true; + return !(RootParent is Mobile && RootParent != from); } public void ConvertToWorld(int x, int y, out int worldX, out int worldY) @@ -381,4 +376,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Maps/TreasureMap.cs b/Scripts/Items/Maps/TreasureMap.cs index 41824e61d..900af3744 100644 --- a/Scripts/Items/Maps/TreasureMap.cs +++ b/Scripts/Items/Maps/TreasureMap.cs @@ -206,6 +206,7 @@ namespace Server.Items } catch { + // ignored } } @@ -299,10 +300,7 @@ namespace Server.Items public static bool HasDiggingTool(Mobile m) { - if (m.Backpack == null) - return false; - - return m.Backpack.FindItemsByType().Any(tool => tool.HarvestSystem == Mining.System); + return m.Backpack?.FindItemsByType().Any(tool => tool.HarvestSystem == Mining.System) == true; } public void OnBeginDig(Mobile from) @@ -820,7 +818,7 @@ namespace Server.Items Effects.PlaySound(m_Chest, m_Map, 0x33B); } - if (m_Chest != null && m_Chest.Location.Z >= m_Location.Z) + if (m_Chest?.Location.Z >= m_Location.Z) { Stop(); m_From.EndAction(); @@ -978,4 +976,4 @@ namespace Server.Items Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/BankCheck.cs b/Scripts/Items/Misc/BankCheck.cs index cd713bc83..140a57247 100644 --- a/Scripts/Items/Misc/BankCheck.cs +++ b/Scripts/Items/Misc/BankCheck.cs @@ -83,11 +83,7 @@ namespace Server.Items list.Add(1060738, worth); // value: ~1_val~ } -#if NEWPARENT public override void OnAdded(IEntity parent) -#else - public override void OnAdded(object parent) -#endif { base.OnAdded(parent); @@ -98,7 +94,8 @@ namespace Server.Items Container root = parent as Container; - while (root?.Parent is Container) root = (Container)root.Parent; + while (root?.Parent is Container container) + root = container; parent = root ?? parent; @@ -124,7 +121,7 @@ namespace Server.Items if (tradeInfo != null) { - if (owner.NetState != null && !owner.NetState.NewSecureTrading) + if (owner.NetState?.NewSecureTrading == false) { int plat = Math.DivRem(Worth, AccountGold.CurrencyThreshold, out int gold); @@ -247,4 +244,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Beeswax.cs b/Scripts/Items/Misc/Beeswax.cs index 0a0510209..cd284dade 100644 --- a/Scripts/Items/Misc/Beeswax.cs +++ b/Scripts/Items/Misc/Beeswax.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Beeswax : Item { [Constructible] - public Beeswax() : this(1) - { - } - - [Constructible] - public Beeswax(int amount) : base(0x1422) + public Beeswax(int amount = 1) : base(0x1422) { Weight = 1.0; Stackable = true; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs b/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs index a654d9f59..2c02c7bdf 100644 --- a/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs +++ b/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs @@ -66,7 +66,7 @@ namespace Server.Items public override void Confirm(Mobile from) { - if (m_Item != null && !m_Item.Deleted && m_Item.IsChildOf(from.Backpack)) + if (m_Item?.Deleted == false && m_Item.IsChildOf(from.Backpack)) { if (from.HairItemID != 0) { @@ -92,4 +92,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Blocker.cs b/Scripts/Items/Misc/Blocker.cs index f0099f728..ef07f1532 100644 --- a/Scripts/Items/Misc/Blocker.cs +++ b/Scripts/Items/Misc/Blocker.cs @@ -20,7 +20,7 @@ namespace Server.Items { Mobile mob = state.Mobile; - if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster) + if (mob?.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this); return base.GetWorldPacketFor(state); @@ -51,7 +51,7 @@ namespace Server.Items // +2 - Hue // +1 - Flags - uint serial = (uint)item.Serial.Value; + uint serial = item.Serial.Value; int itemID = 0x1183; int amount = item.Amount; Point3D loc = item.Location; @@ -102,4 +102,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Bola.cs b/Scripts/Items/Misc/Bola.cs index b3c2464ec..ced67e757 100644 --- a/Scripts/Items/Misc/Bola.cs +++ b/Scripts/Items/Misc/Bola.cs @@ -9,12 +9,7 @@ namespace Server.Items public class Bola : Item { [Constructible] - public Bola() : this(1) - { - } - - [Constructible] - public Bola(int amount) : base(0x26AC) + public Bola(int amount = 1) : base(0x26AC) { Weight = 4.0; Stackable = true; @@ -103,13 +98,13 @@ namespace Server.Items if (pack != null) { - if (one != null && one.Movable) + if (one?.Movable == true) { pack.DropItem(one); one = null; } - if (two != null && two.Movable) + if (two?.Movable == true) { pack.DropItem(two); two = null; @@ -118,13 +113,13 @@ namespace Server.Items } else if (Core.AOS) { - if (one != null && one.Movable) + if (one?.Movable == true) { from.AddToBackpack(one); one = null; } - if (two != null && two.Movable) + if (two?.Movable == true) { from.AddToBackpack(two); two = null; @@ -214,4 +209,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/BolaBall.cs b/Scripts/Items/Misc/BolaBall.cs index 260287fc5..61eda9af1 100644 --- a/Scripts/Items/Misc/BolaBall.cs +++ b/Scripts/Items/Misc/BolaBall.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BolaBall : Item { [Constructible] - public BolaBall() : this(1) - { - } - - [Constructible] - public BolaBall(int amount) : base(0xE73) + public BolaBall(int amount = 1) : base(0xE73) { Weight = 4.0; Stackable = true; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/BulletinBoards.cs b/Scripts/Items/Misc/BulletinBoards.cs index eb1b421e3..5199469ec 100644 --- a/Scripts/Items/Misc/BulletinBoards.cs +++ b/Scripts/Items/Misc/BulletinBoards.cs @@ -468,14 +468,9 @@ namespace Server.Items { public BBDisplayBoard(BaseBulletinBoard board) : base(0x71) { - string name = board.BoardName; - - if (name == null) - name = ""; - EnsureCapacity(38); - byte[] buffer = Utility.UTF8.GetBytes(name); + byte[] buffer = Utility.UTF8.GetBytes(board.BoardName ?? ""); m_Stream.Write((byte)0x00); // PacketID m_Stream.Write(board.Serial); // Bulletin board serial @@ -535,10 +530,7 @@ namespace Server.Items public string SafeString(string v) { - if (v == null) - return string.Empty; - - return v; + return v ?? string.Empty; } } @@ -620,4 +612,4 @@ namespace Server.Items return v; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/CommunicationCrystals.cs b/Scripts/Items/Misc/CommunicationCrystals.cs index aa9b7873f..6d532e7bf 100644 --- a/Scripts/Items/Misc/CommunicationCrystals.cs +++ b/Scripts/Items/Misc/CommunicationCrystals.cs @@ -46,12 +46,7 @@ namespace Server.Items private int m_Charges; [Constructible] - public BroadcastCrystal() : this(2000) - { - } - - [Constructible] - public BroadcastCrystal(int charges) : base(0x1ED0) + public BroadcastCrystal(int charges = 2000) : base(0x1ED0) { Light = LightType.Circle150; @@ -452,4 +447,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Corpses/Corpse.cs b/Scripts/Items/Misc/Corpses/Corpse.cs index 9adfc9fe3..df1cba941 100644 --- a/Scripts/Items/Misc/Corpses/Corpse.cs +++ b/Scripts/Items/Misc/Corpses/Corpse.cs @@ -289,9 +289,9 @@ namespace Server.Items public void Carve(Mobile from, Item item) { - if (IsCriminalAction(from) && Map != null && (Map.Rules & MapRules.HarmfulRestrictions) != 0) + if (IsCriminalAction(from) && (Map?.Rules & MapRules.HarmfulRestrictions) != 0) { - if (Owner == null || !Owner.Player) + if (Owner?.Player != true) from.SendLocalizedMessage(1005035); // You did not earn the right to loot this creature! else from.SendLocalizedMessage(1010049); // You may not loot this corpse. @@ -339,14 +339,9 @@ namespace Server.Items public override bool IsChildVisibleTo(Mobile m, Item child) { - if (!m.Player || m.AccessLevel > AccessLevel.Player) //Staff and creatures not subject to instancing. - return true; - - if (m_InstancedItems != null && m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) - && (InstancedCorpse || info.Perpetual)) - return info.IsOwner(m); //IsOwner checks Party stuff. - - return true; + return !m.Player || m.AccessLevel > AccessLevel.Player || m_InstancedItems == null || + !m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) || !InstancedCorpse && !info.Perpetual + || info.IsOwner(m); } private void AssignInstancedLoot() @@ -364,7 +359,7 @@ namespace Server.Items { Item item = Items[i]; - if (item.LootType != LootType.Cursed) //Don't have curesd items take up someone's item spot.. (?) + if (item.LootType != LootType.Cursed) //Don't have cursed items take up someone's item spot.. (?) { if (item.Stackable) m_Stackables.Add(item); @@ -384,7 +379,7 @@ namespace Server.Items attackers[i] = temp; } - //stackables first, for the remaining stackables, have those be randomly added after + // stackables first, for the remaining stackables, have those be randomly added after for (int i = 0; i < m_Stackables.Count; i++) { @@ -488,11 +483,9 @@ namespace Server.Items public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List initialContent, List equipItems) { - Corpse c; - if (owner is MilitiaFighter) - c = new MilitiaFighterCorpse(owner, hair, facialhair, equipItems); - else - c = new Corpse(owner, hair, facialhair, equipItems); + Corpse c = owner is MilitiaFighter ? + new MilitiaFighterCorpse(owner, hair, facialhair, equipItems) : + new Corpse(owner, hair, facialhair, equipItems); owner.Corpse = c; @@ -757,8 +750,8 @@ namespace Server.Items public bool DevourCorpse() { - if (Devoured || Deleted || Killer == null || Killer.Deleted || !Killer.Alive || !(Killer is IDevourer devourer) || - Owner == null || Owner.Deleted) + if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || !(Killer is IDevourer devourer) || + Owner?.Deleted != false) return false; m_Devourer = devourer; // Set the devourer the killer @@ -769,15 +762,15 @@ namespace Server.Items { base.SendInfoTo(state, sendOplPacket); - if (((Body)Amount).IsHuman && ItemID == 0x2006) - { - if (state.ContainerGridLines) - state.Send(new CorpseContent6017(state.Mobile, this)); - else - state.Send(new CorpseContent(state.Mobile, this)); + if (!(((Body)Amount).IsHuman && ItemID == 0x2006)) + return; - state.Send(new CorpseEquip(state.Mobile, this)); - } + if (state.ContainerGridLines) + state.Send(new CorpseContent6017(state.Mobile, this)); + else + state.Send(new CorpseContent(state.Mobile, this)); + + state.Send(new CorpseEquip(state.Mobile, this)); } public bool IsCriminalAction(Mobile from) @@ -787,7 +780,7 @@ namespace Server.Items Party p = Party.Get(Owner); - if (p != null && p.Contains(from)) + if (p?.Contains(from) == true) { PartyMemberInfo pmi = p[Owner]; @@ -800,21 +793,12 @@ namespace Server.Items public override bool CheckItemUse(Mobile from, Item item) { - if (!base.CheckItemUse(from, item)) - return false; - - if (item != this) - return CanLoot(from, item); - - return true; + return base.CheckItemUse(from, item) && (item == this || CanLoot(from, item)); } public override bool CheckLift(Mobile from, Item item, ref LRReason reject) { - if (!base.CheckLift(from, item, ref reject)) - return false; - - return CanLoot(from, item); + return base.CheckLift(from, item, ref reject) && CanLoot(from, item); } public override void OnItemUsed(Mobile from, Item item) @@ -888,17 +872,14 @@ namespace Server.Items public bool CanLoot(Mobile from, Item item) { - if (!IsCriminalAction(from)) - return true; - - return Map != null && (Map.Rules & MapRules.HarmfulRestrictions) == 0; + return !IsCriminalAction(from) || (Map.Rules & MapRules.HarmfulRestrictions) == 0; } public bool CheckLoot(Mobile from, Item item) { if (!CanLoot(from, item)) { - if (Owner == null || !Owner.Player) + if (Owner?.Player != true) from.SendLocalizedMessage(1005035); // You did not earn the right to loot this creature! else from.SendLocalizedMessage(1010049); // You may not loot this corpse. @@ -908,7 +889,7 @@ namespace Server.Items if (IsCriminalAction(from)) { - if (Owner == null || !Owner.Player) + if (Owner?.Player != true) from.SendLocalizedMessage(1005036); // Looting this monster corpse will be a criminal act! else from.SendLocalizedMessage(1005038); // Looting this corpse will be a criminal act! @@ -965,12 +946,12 @@ namespace Server.Items !GetRestoreInfo(item, ref loc)) continue; - if (pack != null && pack.CheckHold(from, item, false, true)) + if (pack?.CheckHold(from, item, false, true) == true) { item.Location = loc; pack.AddItem(item); - if (RestoreEquip != null && RestoreEquip.Contains(item)) + if (RestoreEquip?.Contains(item) == true) from.EquipItem(item); } else diff --git a/Scripts/Items/Misc/Firebomb.cs b/Scripts/Items/Misc/Firebomb.cs index a148214c0..e3dde80f3 100644 --- a/Scripts/Items/Misc/Firebomb.cs +++ b/Scripts/Items/Misc/Firebomb.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Network; using Server.Spells; using Server.Targeting; @@ -14,12 +15,7 @@ namespace Server.Items private List m_Users; [Constructible] - public Firebomb() : this(0x99B) - { - } - - [Constructible] - public Firebomb(int itemID) : base(itemID) + public Firebomb(int itemID = 0x99B) : base(itemID) { //Name = "a firebomb"; Weight = 2.0; @@ -128,11 +124,8 @@ namespace Server.Items } else if (RootParent == null) { - List toDamage = new List(); IPooledEnumerable eable = Map.GetMobilesInRange(Location, 1); - - foreach (Mobile m in eable) - toDamage.Add(m); + List toDamage = eable.ToList(); eable.Free(); @@ -290,4 +283,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/FlippableAddonAttribute.cs b/Scripts/Items/Misc/FlippableAddonAttribute.cs index 4e6cfb4aa..3ac04de4b 100644 --- a/Scripts/Items/Misc/FlippableAddonAttribute.cs +++ b/Scripts/Items/Misc/FlippableAddonAttribute.cs @@ -23,7 +23,7 @@ namespace Server.Items public virtual void Flip(Mobile from, Item addon) { - if (Directions != null && Directions.Length > 1) + if (Directions?.Length > 1) try { MethodInfo flipMethod = addon.GetType().GetMethod(m_MethodName, m_Params); @@ -44,7 +44,7 @@ namespace Server.Items ClearComponents(addon); - flipMethod.Invoke(addon, new object[2] { from, Directions[index] }); + flipMethod.Invoke(addon, new object[] { from, Directions[index] }); BaseHouse house = null; AddonFitResult result = AddonFitResult.Valid; @@ -86,6 +86,7 @@ namespace Server.Items } catch { + // ignored } } @@ -113,4 +114,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/FlippableAttribute.cs b/Scripts/Items/Misc/FlippableAttribute.cs index e55a23786..12ceeacd8 100644 --- a/Scripts/Items/Misc/FlippableAttribute.cs +++ b/Scripts/Items/Misc/FlippableAttribute.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using Server.Commands; using Server.Targeting; @@ -56,11 +55,6 @@ namespace Server.Items [AttributeUsage(AttributeTargets.Class)] public class FlippableAttribute : Attribute { - public FlippableAttribute() - : this(null) - { - } - public FlippableAttribute(params int[] itemIDs) { ItemIDs = itemIDs; @@ -74,12 +68,11 @@ namespace Server.Items { try { - MethodInfo flipMethod = item.GetType().GetMethod("Flip", Type.EmptyTypes); - if (flipMethod != null) - flipMethod.Invoke(item, new object[0]); + item.GetType().GetMethod("Flip", Type.EmptyTypes)?.Invoke(item, new object[0]); } catch { + // ignored } } else @@ -99,4 +92,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Gold.cs b/Scripts/Items/Misc/Gold.cs index 649088263..59497e15e 100644 --- a/Scripts/Items/Misc/Gold.cs +++ b/Scripts/Items/Misc/Gold.cs @@ -5,18 +5,13 @@ namespace Server.Items { public class Gold : Item { - [Constructible] - public Gold() : this(1) - { - } - [Constructible] public Gold(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) { } [Constructible] - public Gold(int amount) : base(0xEED) + public Gold(int amount = 1) : base(0xEED) { Stackable = true; Amount = amount; @@ -44,11 +39,7 @@ namespace Server.Items UpdateTotal(this, TotalType.Gold, newValue - oldValue); } -#if NEWPARENT public override void OnAdded(IEntity parent) -#else - public override void OnAdded(object parent) -#endif { base.OnAdded(parent); @@ -59,7 +50,8 @@ namespace Server.Items Container root = parent as Container; - while (root?.Parent is Container) root = (Container)root.Parent; + while (root?.Parent is Container container) + root = container; parent = root ?? parent; @@ -85,7 +77,7 @@ namespace Server.Items if (tradeInfo != null) { - if (owner.NetState != null && !owner.NetState.NewSecureTrading) + if (owner.NetState?.NewSecureTrading == false) { int plat = Math.DivRem(Amount, AccountGold.CurrencyThreshold, out int gold); @@ -127,4 +119,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/HairDye.cs b/Scripts/Items/Misc/HairDye.cs index 238afe195..323f13b54 100644 --- a/Scripts/Items/Misc/HairDye.cs +++ b/Scripts/Items/Misc/HairDye.cs @@ -74,10 +74,10 @@ namespace Server.Items AddBackground(100, 10, 350, 355, 2600); AddBackground(120, 54, 110, 270, 5100); - AddHtmlLocalized(70, 25, 400, 35, 1011013, false, false); //
Hair Color Selection Menu
+ AddHtmlLocalized(70, 25, 400, 35, 1011013); //
Hair Color Selection Menu
- AddButton(149, 328, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(185, 329, 250, 35, 1011014, false, false); // Dye my hair this color! + AddButton(149, 328, 4005, 4007, 1); + AddHtmlLocalized(185, 329, 250, 35, 1011014); // Dye my hair this color! for (int i = 0; i < m_Entries.Length; ++i) { @@ -166,4 +166,4 @@ namespace Server.Items public int HueCount{ get; } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/InteriorDecorator.cs b/Scripts/Items/Misc/InteriorDecorator.cs index d6b543d33..f3506643c 100644 --- a/Scripts/Items/Misc/InteriorDecorator.cs +++ b/Scripts/Items/Misc/InteriorDecorator.cs @@ -79,7 +79,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - return house != null && house.IsCoOwner(from); + return house?.IsCoOwner(from) == true; } public static bool CheckUse(InteriorDecorator tool, Mobile from) @@ -105,15 +105,14 @@ namespace Server.Items AddBackground(0, 0, 200, 200, 2600); - AddButton(50, 45, decorator.Command == DecorateCommand.Turn ? 2154 : 2152, 2154, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(90, 50, 70, 40, 1018323, false, false); // Turn + AddButton(50, 45, decorator.Command == DecorateCommand.Turn ? 2154 : 2152, 2154, 1); + AddHtmlLocalized(90, 50, 70, 40, 1018323); // Turn - AddButton(50, 95, decorator.Command == DecorateCommand.Up ? 2154 : 2152, 2154, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(90, 100, 70, 40, 1018324, false, false); // Up + AddButton(50, 95, decorator.Command == DecorateCommand.Up ? 2154 : 2152, 2154, 2); + AddHtmlLocalized(90, 100, 70, 40, 1018324); // Up - AddButton(50, 145, decorator.Command == DecorateCommand.Down ? 2154 : 2152, 2154, 3, GumpButtonType.Reply, - 0); - AddHtmlLocalized(90, 150, 70, 40, 1018325, false, false); // Down + AddButton(50, 145, decorator.Command == DecorateCommand.Down ? 2154 : 2152, 2154, 3); + AddHtmlLocalized(90, 150, 70, 40, 1018325); // Down } public override void OnResponse(NetState sender, RelayInfo info) @@ -334,4 +333,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Key.cs b/Scripts/Items/Misc/Key.cs index e35f9c7c6..715e1f349 100644 --- a/Scripts/Items/Misc/Key.cs +++ b/Scripts/Items/Misc/Key.cs @@ -24,32 +24,16 @@ namespace Server.Items private uint m_KeyVal; [Constructible] - public Key() : this(KeyType.Iron, 0) + public Key(uint val = 0) : this(KeyType.Iron, val) { } - [Constructible] - public Key(KeyType type) : this(type, 0) - { - } - - [Constructible] - public Key(uint val) : this(KeyType.Iron, val) - { - } - - [Constructible] - public Key(KeyType type, uint LockVal) : this(type, LockVal, null) - { - m_KeyVal = LockVal; - } - - public Key(KeyType type, uint LockVal, Item link) : base((int)type) + public Key(KeyType type, uint val = 0, Item link = null) : base((int)type) { Weight = 1.0; MaxRange = 3; - m_KeyVal = LockVal; + m_KeyVal = val; Link = link; } @@ -404,4 +388,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/LOSBlocker.cs b/Scripts/Items/Misc/LOSBlocker.cs index 4d8d8f570..ba4dad9ac 100644 --- a/Scripts/Items/Misc/LOSBlocker.cs +++ b/Scripts/Items/Misc/LOSBlocker.cs @@ -26,7 +26,7 @@ namespace Server.Items { Mobile mob = state.Mobile; - if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this); + if (mob?.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this); return base.GetWorldPacketFor(state); } @@ -59,7 +59,7 @@ namespace Server.Items // +2 - Hue // +1 - Flags - uint serial = (uint)item.Serial.Value; + uint serial = item.Serial.Value; int itemID = 0x36FF; int amount = item.Amount; Point3D loc = item.Location; @@ -110,4 +110,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/MorphItem.cs b/Scripts/Items/Misc/MorphItem.cs index 62a342f02..f5693d0de 100644 --- a/Scripts/Items/Misc/MorphItem.cs +++ b/Scripts/Items/Misc/MorphItem.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace Server.Items { @@ -80,21 +81,8 @@ namespace Server.Items public void Refresh() { - bool found = false; - - foreach (Mobile mob in GetMobilesInRange(CurrentRange)) - { - if (mob.Hidden && mob.AccessLevel > AccessLevel.Player) - continue; - - found = true; - break; - } - - if (found) - ItemID = ActiveItemID; - else - ItemID = InactiveItemID; + bool found = GetMobilesInRange(CurrentRange).Any(mob => !mob.Hidden || mob.AccessLevel <= AccessLevel.Player); + ItemID = found ? ActiveItemID : InactiveItemID; Visible = ItemID != 0x1; } @@ -141,4 +129,4 @@ namespace Server.Items Timer.DelayCall(TimeSpan.Zero, Refresh); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/PlayerBulletinBoards.cs b/Scripts/Items/Misc/PlayerBulletinBoards.cs index c78840c83..06354eb33 100644 --- a/Scripts/Items/Misc/PlayerBulletinBoards.cs +++ b/Scripts/Items/Misc/PlayerBulletinBoards.cs @@ -27,7 +27,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( 0 ); // version } public override void Deserialize( GenericReader reader ) @@ -56,7 +56,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 0 ); // version + writer.Write( 0 ); // version } public override void Deserialize( GenericReader reader ) @@ -99,7 +99,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int) 1 ); + writer.Write( 1 ); writer.Write( (int) Level ); @@ -441,7 +441,7 @@ namespace Server.Items { if ( page >= 1 && page <= board.Messages.Count ) { - PlayerBBMessage message = (PlayerBBMessage)board.Messages[page - 1]; + PlayerBBMessage message = board.Messages[page - 1]; Mobile poster = message.Poster; if ( poster == null ) @@ -510,7 +510,7 @@ namespace Server.Items PlayerBBMessage message = board.Greeting; if ( page >= 1 && page <= board.Messages.Count ) - message = (PlayerBBMessage)board.Messages[page - 1]; + message = board.Messages[page - 1]; from.SendGump( new PlayerBBGump( from, house, board, page ) ); from.SendGump( new PropertiesGump( from, message ) ); @@ -534,26 +534,26 @@ namespace Server.Items AddImage( 30, 30, 5400 ); - AddButton( 393, 145, 2084, 2084, 4, GumpButtonType.Reply, 0 ); // Scroll up - AddButton( 390, 371, 2085, 2085, 5, GumpButtonType.Reply, 0 ); // Scroll down + AddButton( 393, 145, 2084, 2084, 4); // Scroll up + AddButton( 390, 371, 2085, 2085, 5); // Scroll down - AddButton( 32, 183, 5412, 5413, 1, GumpButtonType.Reply, 0 ); // Post message + AddButton( 32, 183, 5412, 5413, 1); // Post message if ( house.IsOwner( from ) ) { - AddButton( 63, 90, 5601, 5605, 2, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 81, 89, 230, 20, 1062400, LabelColor, false, false ); // Set title + AddButton( 63, 90, 5601, 5605, 2); + AddHtmlLocalized( 81, 89, 230, 20, 1062400, LabelColor ); // Set title - AddButton( 63, 109, 5601, 5605, 3, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 81, 108, 230, 20, 1062401, LabelColor, false, false ); // Post greeting + AddButton( 63, 109, 5601, 5605, 3); + AddHtmlLocalized( 81, 108, 230, 20, 1062401, LabelColor ); // Post greeting } string title = board.Title; if ( title != null ) - AddHtml( 183, 68, 180, 23, title, false, false ); + AddHtml( 183, 68, 180, 23, title ); - AddHtmlLocalized( 385, 89, 60, 20, 1062409, LabelColor, false, false ); // Post + AddHtmlLocalized( 385, 89, 60, 20, 1062409, LabelColor ); // Post AddLabel( 440, 89, LabelHue, page.ToString() ); AddLabel( 455, 89, LabelHue, "/" ); @@ -562,16 +562,16 @@ namespace Server.Items PlayerBBMessage message = board.Greeting; if ( page >= 1 && page <= board.Messages.Count ) - message = (PlayerBBMessage)board.Messages[page - 1]; + message = board.Messages[page - 1]; AddImageTiled( 150, 220, 240, 1, 2700 ); // Separator - AddHtmlLocalized( 150, 180, 100, 20, 1062405, 16715, false, false ); // Posted On: - AddHtmlLocalized( 150, 200, 100, 20, 1062406, 16715, false, false ); // Posted By: + AddHtmlLocalized( 150, 180, 100, 20, 1062405, 16715 ); // Posted On: + AddHtmlLocalized( 150, 200, 100, 20, 1062406, 16715 ); // Posted By: if ( message != null ) { - AddHtml( 255, 180, 150, 20, message.Time.ToString( "yyyy-MM-dd HH:mm:ss" ), false, false ); + AddHtml( 255, 180, 150, 20, message.Time.ToString( "yyyy-MM-dd HH:mm:ss" ) ); Mobile poster = message.Poster; string name = poster?.Name; @@ -579,26 +579,21 @@ namespace Server.Items if ( name == null || (name = name.Trim()).Length == 0 ) name = "Someone"; - AddHtml( 255, 200, 150, 20, name, false, false ); + AddHtml( 255, 200, 150, 20, name ); - string body = message.Message; - - if ( body == null ) - body = ""; - - AddHtml( 150, 240, 250, 100, body, false, false ); + AddHtml( 150, 240, 250, 100, message.Message ?? "" ); if ( message != board.Greeting && house.IsOwner( from ) ) { - AddButton( 130, 395, 1209, 1210, 6, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 150, 393, 150, 20, 1062410, LabelColor, false, false ); // Banish Poster + AddButton( 130, 395, 1209, 1210, 6); + AddHtmlLocalized( 150, 393, 150, 20, 1062410, LabelColor ); // Banish Poster - AddButton( 310, 395, 1209, 1210, 7, GumpButtonType.Reply, 0 ); - AddHtmlLocalized( 330, 393, 150, 20, 1062411, LabelColor, false, false ); // Delete Message + AddButton( 310, 395, 1209, 1210, 7); + AddHtmlLocalized( 330, 393, 150, 20, 1062411, LabelColor ); // Delete Message } if ( from.AccessLevel >= AccessLevel.GameMaster ) - AddButton( 135, 242, 1209, 1210, 8, GumpButtonType.Reply, 0 ); // Post props + AddButton( 135, 242, 1209, 1210, 8); // Post props } } } diff --git a/Scripts/Items/Misc/PowerGenerator.cs b/Scripts/Items/Misc/PowerGenerator.cs index 254044364..d0d0006d9 100644 --- a/Scripts/Items/Misc/PowerGenerator.cs +++ b/Scripts/Items/Misc/PowerGenerator.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Gumps; using Server.Network; @@ -325,10 +324,10 @@ namespace Server.Items AddBackground(95, 20, 442, 90, 0xA28); - AddHtml(229, 35, 300, 45, "GENERATOR CONTROL PANEL", false, false); + AddHtml(229, 35, 300, 45, "GENERATOR CONTROL PANEL"); - AddHtml(223, 60, 300, 70, "Use the Directional Controls to", false, false); - AddHtml(253, 75, 300, 85, "Close the Grid Circuit", false, false); + AddHtml(223, 60, 300, 70, "Use the Directional Controls to"); + AddHtml(253, 75, 300, 85, "Close the Grid Circuit"); AddImage(140, 40, 0x28D3); AddImage(420, 40, 0x28D3); @@ -341,10 +340,10 @@ namespace Server.Items AddImage(414, 189, 0x589); AddImage(435, 210, 0xA52); - AddButton(408, 222, 0x29EA, 0x29EC, 1, GumpButtonType.Reply, 0); // Left - AddButton(448, 185, 0x29CC, 0x29CE, 2, GumpButtonType.Reply, 0); // Up - AddButton(473, 222, 0x29D6, 0x29D8, 3, GumpButtonType.Reply, 0); // Right - AddButton(448, 243, 0x29E0, 0x29E2, 4, GumpButtonType.Reply, 0); // Down + AddButton(408, 222, 0x29EA, 0x29EC, 1); // Left + AddButton(448, 185, 0x29CC, 0x29CE, 2); // Up + AddButton(473, 222, 0x29D6, 0x29D8, 3); // Right + AddButton(448, 243, 0x29E0, 0x29E2, 4); // Down AddBackground(90, 115, 30 + 40 * sideLength, 30 + 40 * sideLength, 0xA28); AddBackground(100, 125, 10 + 40 * sideLength, 10 + 40 * sideLength, 0x1400); @@ -385,8 +384,8 @@ namespace Server.Items if (from.Skills.Lockpicking.Value >= 65.0) { - AddButton(365, 350, 0xFA6, 0xFA7, 5, GumpButtonType.Reply, 0); - AddHtml(405, 345, 140, 40, "Attempt to Decipher the Circuit Path", false, false); + AddButton(365, 350, 0xFA6, 0xFA7, 5); + AddHtml(405, 345, 140, 40, "Attempt to Decipher the Circuit Path"); } } diff --git a/Scripts/Items/Misc/PromotionalToken.cs b/Scripts/Items/Misc/PromotionalToken.cs index 924fe2d48..4746e18ce 100644 --- a/Scripts/Items/Misc/PromotionalToken.cs +++ b/Scripts/Items/Misc/PromotionalToken.cs @@ -58,7 +58,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int)0 ); + writer.Write( 0 ); } public override void Deserialize( GenericReader reader ) @@ -82,11 +82,11 @@ namespace Server.Items AddPage( 0 ); AddBackground( 0, 0, 240, 135, 0x2422 ); - AddHtmlLocalized( 15, 15, 210, 75, 1070972, 0x0, true, false ); // Click "OKAY" to redeem the following promotional item: + AddHtmlLocalized( 15, 15, 210, 75, 1070972, 0x0, true ); // Click "OKAY" to redeem the following promotional item: TextDefinition.AddHtmlText( this, 15, 60, 210, 75, m_Token.ItemGumpName, false, false ); - AddButton( 160, 95, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 ); //Okay - AddButton( 90, 95, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0 ); //Cancel + AddButton( 160, 95, 0xF7, 0xF8, 1); //Okay + AddButton( 90, 95, 0xF2, 0xF1, 0); //Cancel } public override void OnResponse( NetState sender, RelayInfo info ) @@ -143,7 +143,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int)0 ); + writer.Write( 0 ); } public override void Deserialize( GenericReader reader ) diff --git a/Scripts/Items/Misc/PublicMoongate.cs b/Scripts/Items/Misc/PublicMoongate.cs index 8fe043e74..4ba1a79a1 100644 --- a/Scripts/Items/Misc/PublicMoongate.cs +++ b/Scripts/Items/Misc/PublicMoongate.cs @@ -314,18 +314,18 @@ namespace Server.Items AddBackground(0, 0, 380, 280, 5054); - AddButton(10, 210, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 210, 140, 25, 1011036, false, false); // OKAY + AddButton(10, 210, 4005, 4007, 1); + AddHtmlLocalized(45, 210, 140, 25, 1011036); // OKAY - AddButton(10, 235, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 235, 140, 25, 1011012, false, false); // CANCEL + AddButton(10, 235, 4005, 4007, 0); + AddHtmlLocalized(45, 235, 140, 25, 1011012); // CANCEL - AddHtmlLocalized(5, 5, 200, 20, 1012011, false, false); // Pick your destination: + AddHtmlLocalized(5, 5, 200, 20, 1012011); // Pick your destination: for (int i = 0; i < checkLists.Length; ++i) { AddButton(10, 35 + i * 25, 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(m_Lists, checkLists[i]) + 1); - AddHtmlLocalized(30, 35 + i * 25, 150, 20, checkLists[i].Number, false, false); + AddHtmlLocalized(30, 35 + i * 25, 150, 20, checkLists[i].Number); } for (int i = 0; i < m_Lists.Length; ++i) @@ -339,14 +339,14 @@ namespace Server.Items AddPage(index + 1); AddButton(10, 35 + offset * 25, 2117, 2118, 0, GumpButtonType.Page, index + 1); - AddHtmlLocalized(30, 35 + offset * 25, 150, 20, list.SelNumber, false, false); + AddHtmlLocalized(30, 35 + offset * 25, 150, 20, list.SelNumber); PMEntry[] entries = list.Entries; for (int i = 0; i < entries.Length; ++i) { AddRadio(200, 35 + i * 25, 210, 211, false, index * 100 + i); - AddHtmlLocalized(225, 35 + i * 25, 150, 20, entries[i].Number, false, false); + AddHtmlLocalized(225, 35 + i * 25, 150, 20, entries[i].Number); } } @@ -418,4 +418,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Rares.cs b/Scripts/Items/Misc/Rares.cs index b83ab784b..ecf56c624 100644 --- a/Scripts/Items/Misc/Rares.cs +++ b/Scripts/Items/Misc/Rares.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Rope : Item { [Constructible] - public Rope() : this(1) - { - } - - [Constructible] - public Rope(int amount) : base(0x14F8) + public Rope(int amount = 1) : base(0x14F8) { Stackable = true; Weight = 1.0; @@ -38,12 +33,7 @@ namespace Server.Items public class IronWire : Item { [Constructible] - public IronWire() : this(1) - { - } - - [Constructible] - public IronWire(int amount) : base(0x1876) + public IronWire(int amount = 1) : base(0x1876) { Stackable = true; Weight = 5.0; @@ -76,12 +66,7 @@ namespace Server.Items public class SilverWire : Item { [Constructible] - public SilverWire() : this(1) - { - } - - [Constructible] - public SilverWire(int amount) : base(0x1877) + public SilverWire(int amount = 1) : base(0x1877) { Stackable = true; Weight = 5.0; @@ -114,12 +99,7 @@ namespace Server.Items public class GoldWire : Item { [Constructible] - public GoldWire() : this(1) - { - } - - [Constructible] - public GoldWire(int amount) : base(0x1878) + public GoldWire(int amount = 1) : base(0x1878) { Stackable = true; Weight = 5.0; @@ -152,12 +132,7 @@ namespace Server.Items public class CopperWire : Item { [Constructible] - public CopperWire() : this(1) - { - } - - [Constructible] - public CopperWire(int amount) : base(0x1879) + public CopperWire(int amount = 1) : base(0x1879) { Stackable = true; Weight = 5.0; @@ -190,12 +165,7 @@ namespace Server.Items public class WhiteDriedFlowers : Item { [Constructible] - public WhiteDriedFlowers() : this(1) - { - } - - [Constructible] - public WhiteDriedFlowers(int amount) : base(0xC3C) + public WhiteDriedFlowers(int amount = 1) : base(0xC3C) { Stackable = true; Weight = 1.0; @@ -225,12 +195,7 @@ namespace Server.Items public class GreenDriedFlowers : Item { [Constructible] - public GreenDriedFlowers() : this(1) - { - } - - [Constructible] - public GreenDriedFlowers(int amount) : base(0xC3E) + public GreenDriedFlowers(int amount = 1) : base(0xC3E) { Stackable = true; Weight = 1.0; @@ -260,12 +225,7 @@ namespace Server.Items public class DriedOnions : Item { [Constructible] - public DriedOnions() : this(1) - { - } - - [Constructible] - public DriedOnions(int amount) : base(0xC40) + public DriedOnions(int amount = 1) : base(0xC40) { Stackable = true; Weight = 1.0; @@ -295,12 +255,7 @@ namespace Server.Items public class DriedHerbs : Item { [Constructible] - public DriedHerbs() : this(1) - { - } - - [Constructible] - public DriedHerbs(int amount) : base(0xC42) + public DriedHerbs(int amount = 1) : base(0xC42) { Stackable = true; Weight = 1.0; @@ -704,4 +659,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Scales.cs b/Scripts/Items/Misc/Scales.cs index f10c8cfef..9c33239e4 100644 --- a/Scripts/Items/Misc/Scales.cs +++ b/Scripts/Items/Misc/Scales.cs @@ -53,7 +53,7 @@ namespace Server.Items } else if (targeted is Item item) { - object root = item.RootParent; + IEntity root = item.RootParent; if (root != null && root != from || item.Parent == from) { @@ -61,10 +61,7 @@ namespace Server.Items } else if (item.Movable) { - if (item.Amount > 1) - message = "You place one item on the scale. "; - else - message = "You place that item on the scale. "; + message = item.Amount > 1 ? "You place one item on the scale. " : "You place that item on the scale. "; double weight = item.Weight; diff --git a/Scripts/Items/Misc/SerpentPillar.cs b/Scripts/Items/Misc/SerpentPillar.cs index 800715669..fd7d1f9fc 100644 --- a/Scripts/Items/Misc/SerpentPillar.cs +++ b/Scripts/Items/Misc/SerpentPillar.cs @@ -9,11 +9,7 @@ namespace Server.Items { } - public SerpentPillar(string word, Rectangle2D destination) : this(word, destination, true) - { - } - - public SerpentPillar(string word, Rectangle2D destination, bool active) : base(0x233F) + public SerpentPillar(string word, Rectangle2D destination, bool active = true) : base(0x233F) { Movable = false; diff --git a/Scripts/Items/Misc/SpecialBeardDye.cs b/Scripts/Items/Misc/SpecialBeardDye.cs index b50f9324a..0efa223a1 100644 --- a/Scripts/Items/Misc/SpecialBeardDye.cs +++ b/Scripts/Items/Misc/SpecialBeardDye.cs @@ -69,9 +69,9 @@ namespace Server.Items AddPage(0); AddBackground(150, 60, 350, 358, 2600); AddBackground(170, 104, 110, 270, 5100); - AddHtmlLocalized(230, 75, 200, 20, 1011013, false, false); // Hair Color Selection Menu - AddHtmlLocalized(235, 380, 300, 20, 1013007, false, false); // Dye my beard this color! - AddButton(200, 380, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); // DYE HAIR + AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu + AddHtmlLocalized(235, 380, 300, 20, 1013007); // Dye my beard this color! + AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR for (int i = 0; i < m_Entries.Length; ++i) { @@ -159,4 +159,4 @@ namespace Server.Items public int HueCount{ get; } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/SpecialHairDye.cs b/Scripts/Items/Misc/SpecialHairDye.cs index 9fa12c19f..5c474ecb7 100644 --- a/Scripts/Items/Misc/SpecialHairDye.cs +++ b/Scripts/Items/Misc/SpecialHairDye.cs @@ -69,9 +69,9 @@ namespace Server.Items AddPage(0); AddBackground(150, 60, 350, 358, 2600); AddBackground(170, 104, 110, 270, 5100); - AddHtmlLocalized(230, 75, 200, 20, 1011013, false, false); // Hair Color Selection Menu - AddHtmlLocalized(235, 380, 300, 20, 1011014, false, false); // Dye my hair this color! - AddButton(200, 380, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); // DYE HAIR + AddHtmlLocalized(230, 75, 200, 20, 1011013); // Hair Color Selection Menu + AddHtmlLocalized(235, 380, 300, 20, 1011014); // Dye my hair this color! + AddButton(200, 380, 0xFA5, 0xFA7, 1); // DYE HAIR for (int i = 0; i < m_Entries.Length; ++i) { @@ -160,4 +160,4 @@ namespace Server.Items public int HueCount{ get; } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Teleporter.cs b/Scripts/Items/Misc/Teleporter.cs index 561f62108..bffd28486 100644 --- a/Scripts/Items/Misc/Teleporter.cs +++ b/Scripts/Items/Misc/Teleporter.cs @@ -18,20 +18,12 @@ namespace Server.Items private bool m_SourceEffect; [Constructible] - public Teleporter() - : this(new Point3D(0, 0, 0), null, false) + public Teleporter() : this(new Point3D(0, 0, 0)) { } [Constructible] - public Teleporter(Point3D pointDest, Map mapDest) - : this(pointDest, mapDest, false) - { - } - - [Constructible] - public Teleporter(Point3D pointDest, Map mapDest, bool creatures) - : base(0x1BC3) + public Teleporter(Point3D pointDest, Map mapDest = null, bool creatures = false) : base(0x1BC3) { Movable = false; Visible = false; @@ -45,8 +37,7 @@ namespace Server.Items m_CriminalCheck = false; } - public Teleporter(Serial serial) - : base(serial) + public Teleporter(Serial serial) : base(serial) { } diff --git a/Scripts/Items/Misc/TrashBarrel.cs b/Scripts/Items/Misc/TrashBarrel.cs index 7913851ff..da67c25df 100644 --- a/Scripts/Items/Misc/TrashBarrel.cs +++ b/Scripts/Items/Misc/TrashBarrel.cs @@ -30,7 +30,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { Effects.PlaySound(Location, Map, 0x3B3); from.SendLocalizedMessage(500461); // You destroy the item. @@ -144,4 +144,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/TribalBerry.cs b/Scripts/Items/Misc/TribalBerry.cs index 1c17fd2ed..b7c46fc3b 100644 --- a/Scripts/Items/Misc/TribalBerry.cs +++ b/Scripts/Items/Misc/TribalBerry.cs @@ -3,12 +3,7 @@ namespace Server.Items public class TribalBerry : Item { [Constructible] - public TribalBerry() : this(1) - { - } - - [Constructible] - public TribalBerry(int amount) : base(0x9D0) + public TribalBerry(int amount = 1) : base(0x9D0) { Weight = 1.0; Stackable = true; @@ -40,4 +35,4 @@ namespace Server.Items Hue = 6; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/Waypoint.cs b/Scripts/Items/Misc/Waypoint.cs index 7383e9a53..8046e6242 100644 --- a/Scripts/Items/Misc/Waypoint.cs +++ b/Scripts/Items/Misc/Waypoint.cs @@ -9,15 +9,11 @@ namespace Server.Items private WayPoint m_Next; [Constructible] - public WayPoint() : base(0x1f14) + public WayPoint(WayPoint prev = null) : base(0x1f14) { Hue = 0x498; Visible = false; //this.Movable = false; - } - - public WayPoint(WayPoint prev) : this() - { if (prev != null) prev.NextPoint = this; } @@ -147,4 +143,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Misc/WindChimes.cs b/Scripts/Items/Misc/WindChimes.cs index 8ac33639d..30a70a429 100644 --- a/Scripts/Items/Misc/WindChimes.cs +++ b/Scripts/Items/Misc/WindChimes.cs @@ -52,17 +52,14 @@ namespace Server.Items public bool IsOwner(Mobile mob) { - BaseHouse house = BaseHouse.FindHouseAt(this); - - return house != null && house.IsOwner(mob); + return BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true; } public override void OnDoubleClick(Mobile from) { if (IsOwner(from)) { - OnOffGump onOffGump = new OnOffGump(this); - from.SendGump(onOffGump); + from.SendGump(new OnOffGump(this)); } else { @@ -104,12 +101,11 @@ namespace Server.Items m_Chimes = chimes; AddBackground(0, 0, 300, 150, 0xA28); - AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034, false, - false); // [De]Activate this item - AddButton(40, 53, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 55, 65, 35, 1011036, false, false); // OKAY - AddButton(150, 53, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(190, 55, 100, 35, 1011012, false, false); // CANCEL + AddHtmlLocalized(45, 20, 300, 35, chimes.TurnedOn ? 1011035 : 1011034); // [De]Activate this item + AddButton(40, 53, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY + AddButton(150, 53, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -184,4 +180,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/New Haven Quest Rewards/BagOfNecromancerReagents.cs b/Scripts/Items/New Haven Quest Rewards/BagOfNecromancerReagents.cs index 5f7e12ee4..35083a8b7 100644 --- a/Scripts/Items/New Haven Quest Rewards/BagOfNecromancerReagents.cs +++ b/Scripts/Items/New Haven Quest Rewards/BagOfNecromancerReagents.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BagOfNecromancerReagents : Bag { [Constructible] - public BagOfNecromancerReagents() : this(50) - { - } - - [Constructible] - public BagOfNecromancerReagents(int amount) + public BagOfNecromancerReagents(int amount = 50) { DropItem(new BatWing(amount)); DropItem(new GraveDust(amount)); @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs b/Scripts/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs index 16d2e2373..38559f253 100644 --- a/Scripts/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs +++ b/Scripts/Items/New Haven Quest Rewards/BagOfSmokeBombs.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BagOfSmokeBombs : Bag { [Constructible] - public BagOfSmokeBombs() : this(20) - { - } - - [Constructible] - public BagOfSmokeBombs(int amount) + public BagOfSmokeBombs(int amount = 20) { for (int i = 0; i < amount; ++i) DropItem(new SmokeBomb()); @@ -32,4 +27,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Quivers/BaseQuiver.cs b/Scripts/Items/Quivers/BaseQuiver.cs index f339b2ea1..cded38db7 100644 --- a/Scripts/Items/Quivers/BaseQuiver.cs +++ b/Scripts/Items/Quivers/BaseQuiver.cs @@ -18,11 +18,7 @@ namespace Server.Items private ClothingQuality m_Quality; private int m_WeightReduction; - public BaseQuiver() : this(0x2FB7) - { - } - - public BaseQuiver(int itemID) : base(itemID) + public BaseQuiver(int itemID = 0x2FB7) : base(itemID) { Weight = 2.0; Capacity = 500; @@ -175,32 +171,15 @@ namespace Server.Items public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { - if (!CheckType(item)) + if (CheckType(item)) { - if (message) - m.SendLocalizedMessage(1074836); // The container can not hold that type of object. - - return false; + 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 (Items.Count < DefaultMaxItems) - { - if (item.Amount <= m_Capacity) - return base.CheckHold(m, item, message, checkItems, plusItems, plusWeight); - - return false; - } - - if (checkItems) - return false; - - Item ammo = Ammo; - - if (ammo == null || ammo.Deleted) - return false; - - if (ammo.Amount + item.Amount <= m_Capacity) - return true; + if (message) + m.SendLocalizedMessage(1074836); // The container can not hold that type of object. return false; } @@ -352,10 +331,7 @@ namespace Server.Items if ((prop = m_LowerAmmoCost) > 0) list.Add(1075208, prop.ToString()); // Lower Ammo Cost ~1_Percentage~% - double weight = 0; - - if (ammo != null) - weight = ammo.Weight * ammo.Amount; + double weight = ammo != null ? ammo.Weight + ammo.Amount : 0; list.Add(1072241, "{0}\t{1}\t{2}\t{3}", Items.Count, DefaultMaxItems, (int)weight, DefaultMaxWeight); // Contents: ~1_COUNT~/~2_MAXCOUNT items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones @@ -471,4 +447,4 @@ namespace Server.Items DamageIncrease = 0x00000080 } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Arrows/Arrow.cs b/Scripts/Items/Resources/Arrows/Arrow.cs index fba85c744..29855011d 100644 --- a/Scripts/Items/Resources/Arrows/Arrow.cs +++ b/Scripts/Items/Resources/Arrows/Arrow.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Arrow : Item, ICommodity { [Constructible] - public Arrow() : this(1) - { - } - - [Constructible] - public Arrow(int amount) : base(0xF3F) + public Arrow(int amount = 1) : base(0xF3F) { Stackable = true; Amount = amount; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Arrows/Bolt.cs b/Scripts/Items/Resources/Arrows/Bolt.cs index 67aa02d56..484ba74d9 100644 --- a/Scripts/Items/Resources/Arrows/Bolt.cs +++ b/Scripts/Items/Resources/Arrows/Bolt.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Bolt : Item, ICommodity { [Constructible] - public Bolt() : this(1) - { - } - - [Constructible] - public Bolt(int amount) : base(0x1BFB) + public Bolt(int amount = 1) : base(0x1BFB) { Stackable = true; Amount = amount; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Arrows/Feather.cs b/Scripts/Items/Resources/Arrows/Feather.cs index 3af198b1e..801898a4e 100644 --- a/Scripts/Items/Resources/Arrows/Feather.cs +++ b/Scripts/Items/Resources/Arrows/Feather.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Feather : Item, ICommodity { [Constructible] - public Feather() : this(1) - { - } - - [Constructible] - public Feather(int amount) : base(0x1BD1) + public Feather(int amount = 1) : base(0x1BD1) { Stackable = true; Amount = amount; @@ -36,4 +31,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Arrows/Shaft.cs b/Scripts/Items/Resources/Arrows/Shaft.cs index 90a285426..4a047283c 100644 --- a/Scripts/Items/Resources/Arrows/Shaft.cs +++ b/Scripts/Items/Resources/Arrows/Shaft.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Shaft : Item, ICommodity { [Constructible] - public Shaft() : this(1) - { - } - - [Constructible] - public Shaft(int amount) : base(0x1BD4) + public Shaft(int amount = 1) : base(0x1BD4) { Stackable = true; Amount = amount; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Blacksmithing/Ingots.cs b/Scripts/Items/Resources/Blacksmithing/Ingots.cs index 85cd94b17..7418eaf2b 100644 --- a/Scripts/Items/Resources/Blacksmithing/Ingots.cs +++ b/Scripts/Items/Resources/Blacksmithing/Ingots.cs @@ -4,11 +4,7 @@ namespace Server.Items { private CraftResource m_Resource; - public BaseIngot(CraftResource resource) : this(resource, 1) - { - } - - public BaseIngot(CraftResource resource, int amount) : base(0x1BF2) + public BaseIngot(CraftResource resource, int amount = 1) : base(0x1BF2) { Stackable = true; Amount = amount; @@ -142,12 +138,7 @@ namespace Server.Items public class IronIngot : BaseIngot { [Constructible] - public IronIngot() : this(1) - { - } - - [Constructible] - public IronIngot(int amount) : base(CraftResource.Iron, amount) + public IronIngot(int amount = 1) : base(CraftResource.Iron, amount) { } @@ -174,12 +165,7 @@ namespace Server.Items public class DullCopperIngot : BaseIngot { [Constructible] - public DullCopperIngot() : this(1) - { - } - - [Constructible] - public DullCopperIngot(int amount) : base(CraftResource.DullCopper, amount) + public DullCopperIngot(int amount = 1) : base(CraftResource.DullCopper, amount) { } @@ -206,12 +192,7 @@ namespace Server.Items public class ShadowIronIngot : BaseIngot { [Constructible] - public ShadowIronIngot() : this(1) - { - } - - [Constructible] - public ShadowIronIngot(int amount) : base(CraftResource.ShadowIron, amount) + public ShadowIronIngot(int amount = 1) : base(CraftResource.ShadowIron, amount) { } @@ -238,12 +219,7 @@ namespace Server.Items public class CopperIngot : BaseIngot { [Constructible] - public CopperIngot() : this(1) - { - } - - [Constructible] - public CopperIngot(int amount) : base(CraftResource.Copper, amount) + public CopperIngot(int amount = 1) : base(CraftResource.Copper, amount) { } @@ -270,12 +246,7 @@ namespace Server.Items public class BronzeIngot : BaseIngot { [Constructible] - public BronzeIngot() : this(1) - { - } - - [Constructible] - public BronzeIngot(int amount) : base(CraftResource.Bronze, amount) + public BronzeIngot(int amount = 1) : base(CraftResource.Bronze, amount) { } @@ -302,12 +273,7 @@ namespace Server.Items public class GoldIngot : BaseIngot { [Constructible] - public GoldIngot() : this(1) - { - } - - [Constructible] - public GoldIngot(int amount) : base(CraftResource.Gold, amount) + public GoldIngot(int amount = 1) : base(CraftResource.Gold, amount) { } @@ -334,12 +300,7 @@ namespace Server.Items public class AgapiteIngot : BaseIngot { [Constructible] - public AgapiteIngot() : this(1) - { - } - - [Constructible] - public AgapiteIngot(int amount) : base(CraftResource.Agapite, amount) + public AgapiteIngot(int amount = 1) : base(CraftResource.Agapite, amount) { } @@ -366,12 +327,7 @@ namespace Server.Items public class VeriteIngot : BaseIngot { [Constructible] - public VeriteIngot() : this(1) - { - } - - [Constructible] - public VeriteIngot(int amount) : base(CraftResource.Verite, amount) + public VeriteIngot(int amount = 1) : base(CraftResource.Verite, amount) { } @@ -398,12 +354,7 @@ namespace Server.Items public class ValoriteIngot : BaseIngot { [Constructible] - public ValoriteIngot() : this(1) - { - } - - [Constructible] - public ValoriteIngot(int amount) : base(CraftResource.Valorite, amount) + public ValoriteIngot(int amount = 1) : base(CraftResource.Valorite, amount) { } @@ -425,4 +376,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Blacksmithing/Ore.cs b/Scripts/Items/Resources/Blacksmithing/Ore.cs index 5228ade52..b97d59d31 100644 --- a/Scripts/Items/Resources/Blacksmithing/Ore.cs +++ b/Scripts/Items/Resources/Blacksmithing/Ore.cs @@ -8,11 +8,7 @@ namespace Server.Items { private CraftResource m_Resource; - public BaseOre(CraftResource resource) : this(resource, 1) - { - } - - public BaseOre(CraftResource resource, int amount) : base(RandomSize()) + public BaseOre(CraftResource resource, int amount = 1) : base(RandomSize()) { Stackable = true; Amount = amount; @@ -423,16 +419,11 @@ namespace Server.Items public class IronOre : BaseOre { [Constructible] - public IronOre() : this(1) + public IronOre(int amount = 1) : base(CraftResource.Iron, amount) { } - [Constructible] - public IronOre(int amount) : base(CraftResource.Iron, amount) - { - } - - public IronOre(bool fixedSize) : this(1) + public IronOre(bool fixedSize) : this() { if (fixedSize) ItemID = 0x19B8; @@ -465,12 +456,7 @@ namespace Server.Items public class DullCopperOre : BaseOre { [Constructible] - public DullCopperOre() : this(1) - { - } - - [Constructible] - public DullCopperOre(int amount) : base(CraftResource.DullCopper, amount) + public DullCopperOre(int amount = 1) : base(CraftResource.DullCopper, amount) { } @@ -501,12 +487,7 @@ namespace Server.Items public class ShadowIronOre : BaseOre { [Constructible] - public ShadowIronOre() : this(1) - { - } - - [Constructible] - public ShadowIronOre(int amount) : base(CraftResource.ShadowIron, amount) + public ShadowIronOre(int amount = 1) : base(CraftResource.ShadowIron, amount) { } @@ -537,12 +518,7 @@ namespace Server.Items public class CopperOre : BaseOre { [Constructible] - public CopperOre() : this(1) - { - } - - [Constructible] - public CopperOre(int amount) : base(CraftResource.Copper, amount) + public CopperOre(int amount = 1) : base(CraftResource.Copper, amount) { } @@ -573,12 +549,7 @@ namespace Server.Items public class BronzeOre : BaseOre { [Constructible] - public BronzeOre() : this(1) - { - } - - [Constructible] - public BronzeOre(int amount) : base(CraftResource.Bronze, amount) + public BronzeOre(int amount = 1) : base(CraftResource.Bronze, amount) { } @@ -609,12 +580,7 @@ namespace Server.Items public class GoldOre : BaseOre { [Constructible] - public GoldOre() : this(1) - { - } - - [Constructible] - public GoldOre(int amount) : base(CraftResource.Gold, amount) + public GoldOre(int amount = 1) : base(CraftResource.Gold, amount) { } @@ -645,12 +611,7 @@ namespace Server.Items public class AgapiteOre : BaseOre { [Constructible] - public AgapiteOre() : this(1) - { - } - - [Constructible] - public AgapiteOre(int amount) : base(CraftResource.Agapite, amount) + public AgapiteOre(int amount = 1) : base(CraftResource.Agapite, amount) { } @@ -681,12 +642,7 @@ namespace Server.Items public class VeriteOre : BaseOre { [Constructible] - public VeriteOre() : this(1) - { - } - - [Constructible] - public VeriteOre(int amount) : base(CraftResource.Verite, amount) + public VeriteOre(int amount = 1) : base(CraftResource.Verite, amount) { } @@ -717,12 +673,7 @@ namespace Server.Items public class ValoriteOre : BaseOre { [Constructible] - public ValoriteOre() : this(1) - { - } - - [Constructible] - public ValoriteOre(int amount) : base(CraftResource.Valorite, amount) + public ValoriteOre(int amount = 1) : base(CraftResource.Valorite, amount) { } @@ -749,4 +700,4 @@ namespace Server.Items return new ValoriteIngot(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Blacksmithing/Scales.cs b/Scripts/Items/Resources/Blacksmithing/Scales.cs index 24f5f397c..0823d697f 100644 --- a/Scripts/Items/Resources/Blacksmithing/Scales.cs +++ b/Scripts/Items/Resources/Blacksmithing/Scales.cs @@ -4,11 +4,7 @@ namespace Server.Items { private CraftResource m_Resource; - public BaseScales(CraftResource resource) : this(resource, 1) - { - } - - public BaseScales(CraftResource resource, int amount) : base(0x26B4) + public BaseScales(CraftResource resource, int amount = 1) : base(0x26B4) { Stackable = true; Amount = amount; @@ -68,12 +64,7 @@ namespace Server.Items public class RedScales : BaseScales { [Constructible] - public RedScales() : this(1) - { - } - - [Constructible] - public RedScales(int amount) : base(CraftResource.RedScales, amount) + public RedScales(int amount = 1) : base(CraftResource.RedScales, amount) { } @@ -99,12 +90,7 @@ namespace Server.Items public class YellowScales : BaseScales { [Constructible] - public YellowScales() : this(1) - { - } - - [Constructible] - public YellowScales(int amount) : base(CraftResource.YellowScales, amount) + public YellowScales(int amount = 1) : base(CraftResource.YellowScales, amount) { } @@ -130,12 +116,7 @@ namespace Server.Items public class BlackScales : BaseScales { [Constructible] - public BlackScales() : this(1) - { - } - - [Constructible] - public BlackScales(int amount) : base(CraftResource.BlackScales, amount) + public BlackScales(int amount = 1) : base(CraftResource.BlackScales, amount) { } @@ -161,12 +142,7 @@ namespace Server.Items public class GreenScales : BaseScales { [Constructible] - public GreenScales() : this(1) - { - } - - [Constructible] - public GreenScales(int amount) : base(CraftResource.GreenScales, amount) + public GreenScales(int amount = 1) : base(CraftResource.GreenScales, amount) { } @@ -192,12 +168,7 @@ namespace Server.Items public class WhiteScales : BaseScales { [Constructible] - public WhiteScales() : this(1) - { - } - - [Constructible] - public WhiteScales(int amount) : base(CraftResource.WhiteScales, amount) + public WhiteScales(int amount = 1) : base(CraftResource.WhiteScales, amount) { } @@ -223,12 +194,7 @@ namespace Server.Items public class BlueScales : BaseScales { [Constructible] - public BlueScales() : this(1) - { - } - - [Constructible] - public BlueScales(int amount) : base(CraftResource.BlueScales, amount) + public BlueScales(int amount = 1) : base(CraftResource.BlueScales, amount) { } @@ -252,4 +218,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Fishing/Fish.cs b/Scripts/Items/Resources/Fishing/Fish.cs index d90f45020..0fb9d367d 100644 --- a/Scripts/Items/Resources/Fishing/Fish.cs +++ b/Scripts/Items/Resources/Fishing/Fish.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Fish : Item, ICarvable { [Constructible] - public Fish() : this(1) - { - } - - [Constructible] - public Fish(int amount) : base(Utility.Random(0x09CC, 4)) + public Fish(int amount = 1) : base(Utility.Random(0x09CC, 4)) { Stackable = true; Weight = 1.0; @@ -39,4 +34,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/MiscMLResources.cs b/Scripts/Items/Resources/MiscMLResources.cs index f726dee1e..65ab6e9b5 100644 --- a/Scripts/Items/Resources/MiscMLResources.cs +++ b/Scripts/Items/Resources/MiscMLResources.cs @@ -3,13 +3,7 @@ namespace Server.Items public class Blight : Item { [Constructible] - public Blight() - : this(1) - { - } - - [Constructible] - public Blight(int amount) + public Blight(int amount = 1) : base(0x3183) { Stackable = true; @@ -39,13 +33,7 @@ namespace Server.Items public class LuminescentFungi : Item { [Constructible] - public LuminescentFungi() - : this(1) - { - } - - [Constructible] - public LuminescentFungi(int amount) + public LuminescentFungi(int amount = 1) : base(0x3191) { Stackable = true; @@ -76,13 +64,7 @@ namespace Server.Items public class CapturedEssence : Item { [Constructible] - public CapturedEssence() - : this(1) - { - } - - [Constructible] - public CapturedEssence(int amount) + public CapturedEssence(int amount = 1) : base(0x318E) { Stackable = true; @@ -112,12 +94,6 @@ namespace Server.Items public class EyeOfTheTravesty : Item { - [Constructible] - public EyeOfTheTravesty() - : this(1) - { - } - [Constructible] public EyeOfTheTravesty(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -125,7 +101,7 @@ namespace Server.Items } [Constructible] - public EyeOfTheTravesty(int amount) + public EyeOfTheTravesty(int amount = 1) : base(0x318D) { Stackable = true; @@ -155,12 +131,6 @@ namespace Server.Items public class Corruption : Item { - [Constructible] - public Corruption() - : this(1) - { - } - [Constructible] public Corruption(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -168,7 +138,7 @@ namespace Server.Items } [Constructible] - public Corruption(int amount) + public Corruption(int amount = 1) : base(0x3184) { Stackable = true; @@ -198,12 +168,6 @@ namespace Server.Items public class DreadHornMane : Item { - [Constructible] - public DreadHornMane() - : this(1) - { - } - [Constructible] public DreadHornMane(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -211,7 +175,7 @@ namespace Server.Items } [Constructible] - public DreadHornMane(int amount) + public DreadHornMane(int amount = 1) : base(0x318A) { Stackable = true; @@ -241,12 +205,6 @@ namespace Server.Items public class ParasiticPlant : Item { - [Constructible] - public ParasiticPlant() - : this(1) - { - } - [Constructible] public ParasiticPlant(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -254,7 +212,7 @@ namespace Server.Items } [Constructible] - public ParasiticPlant(int amount) + public ParasiticPlant(int amount = 1) : base(0x3190) { Stackable = true; @@ -284,12 +242,6 @@ namespace Server.Items public class Muculent : Item { - [Constructible] - public Muculent() - : this(1) - { - } - [Constructible] public Muculent(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -297,7 +249,7 @@ namespace Server.Items } [Constructible] - public Muculent(int amount) + public Muculent(int amount = 1) : base(0x3188) { Stackable = true; @@ -327,12 +279,6 @@ namespace Server.Items public class DiseasedBark : Item { - [Constructible] - public DiseasedBark() - : this(1) - { - } - [Constructible] public DiseasedBark(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -340,7 +286,7 @@ namespace Server.Items } [Constructible] - public DiseasedBark(int amount) + public DiseasedBark(int amount = 1) : base(0x318B) { Stackable = true; @@ -370,12 +316,6 @@ namespace Server.Items public class BarkFragment : Item { - [Constructible] - public BarkFragment() - : this(1) - { - } - [Constructible] public BarkFragment(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -383,7 +323,7 @@ namespace Server.Items } [Constructible] - public BarkFragment(int amount) + public BarkFragment(int amount = 1) : base(0x318F) { Stackable = true; @@ -413,12 +353,6 @@ namespace Server.Items public class GrizzledBones : Item { - [Constructible] - public GrizzledBones() - : this(1) - { - } - [Constructible] public GrizzledBones(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -426,7 +360,7 @@ namespace Server.Items } [Constructible] - public GrizzledBones(int amount) + public GrizzledBones(int amount = 1) : base(0x318C) { Stackable = true; @@ -459,12 +393,6 @@ namespace Server.Items public class LardOfParoxysmus : Item { - [Constructible] - public LardOfParoxysmus() - : this(1) - { - } - [Constructible] public LardOfParoxysmus(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -472,7 +400,7 @@ namespace Server.Items } [Constructible] - public LardOfParoxysmus(int amount) + public LardOfParoxysmus(int amount = 1) : base(0x3189) { Stackable = true; @@ -501,12 +429,6 @@ namespace Server.Items public class PerfectEmerald : Item { - [Constructible] - public PerfectEmerald() - : this(1) - { - } - [Constructible] public PerfectEmerald(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -514,7 +436,7 @@ namespace Server.Items } [Constructible] - public PerfectEmerald(int amount) + public PerfectEmerald(int amount = 1) : base(0x3194) { Stackable = true; @@ -543,12 +465,6 @@ namespace Server.Items public class DarkSapphire : Item { - [Constructible] - public DarkSapphire() - : this(1) - { - } - [Constructible] public DarkSapphire(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -556,7 +472,7 @@ namespace Server.Items } [Constructible] - public DarkSapphire(int amount) + public DarkSapphire(int amount = 1) : base(0x3192) { Stackable = true; @@ -586,12 +502,6 @@ namespace Server.Items public class Turquoise : Item { - [Constructible] - public Turquoise() - : this(1) - { - } - [Constructible] public Turquoise(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -599,7 +509,7 @@ namespace Server.Items } [Constructible] - public Turquoise(int amount) + public Turquoise(int amount = 1) : base(0x3193) { Stackable = true; @@ -629,12 +539,6 @@ namespace Server.Items public class EcruCitrine : Item { - [Constructible] - public EcruCitrine() - : this(1) - { - } - [Constructible] public EcruCitrine(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -642,7 +546,7 @@ namespace Server.Items } [Constructible] - public EcruCitrine(int amount) + public EcruCitrine(int amount = 1) : base(0x3195) { Stackable = true; @@ -672,12 +576,6 @@ namespace Server.Items public class WhitePearl : Item { - [Constructible] - public WhitePearl() - : this(1) - { - } - [Constructible] public WhitePearl(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -685,7 +583,7 @@ namespace Server.Items } [Constructible] - public WhitePearl(int amount) + public WhitePearl(int amount = 1) : base(0x3196) { Stackable = true; @@ -715,12 +613,6 @@ namespace Server.Items public class FireRuby : Item { - [Constructible] - public FireRuby() - : this(1) - { - } - [Constructible] public FireRuby(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -728,7 +620,7 @@ namespace Server.Items } [Constructible] - public FireRuby(int amount) + public FireRuby(int amount = 1) : base(0x3197) { Stackable = true; @@ -758,12 +650,6 @@ namespace Server.Items public class BlueDiamond : Item { - [Constructible] - public BlueDiamond() - : this(1) - { - } - [Constructible] public BlueDiamond(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -771,7 +657,7 @@ namespace Server.Items } [Constructible] - public BlueDiamond(int amount) + public BlueDiamond(int amount = 1) : base(0x3198) { Stackable = true; @@ -801,12 +687,6 @@ namespace Server.Items public class BrilliantAmber : Item { - [Constructible] - public BrilliantAmber() - : this(1) - { - } - [Constructible] public BrilliantAmber(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -814,7 +694,7 @@ namespace Server.Items } [Constructible] - public BrilliantAmber(int amount) + public BrilliantAmber(int amount = 1) : base(0x3199) { Stackable = true; @@ -843,12 +723,6 @@ namespace Server.Items public class Scourge : Item { - [Constructible] - public Scourge() - : this(1) - { - } - [Constructible] public Scourge(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -856,7 +730,7 @@ namespace Server.Items } [Constructible] - public Scourge(int amount) + public Scourge(int amount = 1) : base(0x3185) { Stackable = true; @@ -887,12 +761,6 @@ namespace Server.Items public class Putrefication : Item { - [Constructible] - public Putrefication() - : this(1) - { - } - [Constructible] public Putrefication(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -900,7 +768,7 @@ namespace Server.Items } [Constructible] - public Putrefication(int amount) + public Putrefication(int amount = 1) : base(0x3186) { Stackable = true; @@ -931,12 +799,6 @@ namespace Server.Items public class Taint : Item { - [Constructible] - public Taint() - : this(1) - { - } - [Constructible] public Taint(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -944,7 +806,7 @@ namespace Server.Items } [Constructible] - public Taint(int amount) + public Taint(int amount = 1) : base(0x3187) { Stackable = true; @@ -1003,12 +865,6 @@ namespace Server.Items public class SwitchItem : Item { - [Constructible] - public SwitchItem() - : this(1) - { - } - [Constructible] public SwitchItem(int amountFrom, int amountTo) : this(Utility.RandomMinMax(amountFrom, amountTo)) @@ -1016,7 +872,7 @@ namespace Server.Items } [Constructible] - public SwitchItem(int amount) + public SwitchItem(int amount = 1) : base(0x2F5F) { Stackable = true; @@ -1042,4 +898,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/BagOfAllReagents.cs b/Scripts/Items/Resources/Reagents/BagOfAllReagents.cs index f95bcbd20..9776abe4f 100644 --- a/Scripts/Items/Resources/Reagents/BagOfAllReagents.cs +++ b/Scripts/Items/Resources/Reagents/BagOfAllReagents.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BagOfAllReagents : Bag { [Constructible] - public BagOfAllReagents() : this(50) - { - } - - [Constructible] - public BagOfAllReagents(int amount) + public BagOfAllReagents(int amount = 50) { DropItem(new BlackPearl(amount)); DropItem(new Bloodmoss(amount)); @@ -43,4 +38,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/BagOfNecroReagents.cs b/Scripts/Items/Resources/Reagents/BagOfNecroReagents.cs index 2c5c03da5..d25ca877b 100644 --- a/Scripts/Items/Resources/Reagents/BagOfNecroReagents.cs +++ b/Scripts/Items/Resources/Reagents/BagOfNecroReagents.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BagOfNecroReagents : Bag { [Constructible] - public BagOfNecroReagents() : this(50) - { - } - - [Constructible] - public BagOfNecroReagents(int amount) + public BagOfNecroReagents(int amount = 50) { DropItem(new BatWing(amount)); DropItem(new GraveDust(amount)); @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/BagOfReagents.cs b/Scripts/Items/Resources/Reagents/BagOfReagents.cs index 6896b8603..35e4c59c6 100644 --- a/Scripts/Items/Resources/Reagents/BagOfReagents.cs +++ b/Scripts/Items/Resources/Reagents/BagOfReagents.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BagOfReagents : Bag { [Constructible] - public BagOfReagents() : this(50) - { - } - - [Constructible] - public BagOfReagents(int amount) + public BagOfReagents(int amount = 50) { DropItem(new BlackPearl(amount)); DropItem(new Bloodmoss(amount)); @@ -38,4 +33,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/BaseReagent.cs b/Scripts/Items/Resources/Reagents/BaseReagent.cs index 1dd6d7b59..482689618 100644 --- a/Scripts/Items/Resources/Reagents/BaseReagent.cs +++ b/Scripts/Items/Resources/Reagents/BaseReagent.cs @@ -2,11 +2,7 @@ namespace Server.Items { public abstract class BaseReagent : Item { - public BaseReagent(int itemID) : this(itemID, 1) - { - } - - public BaseReagent(int itemID, int amount) : base(itemID) + public BaseReagent(int itemID, int amount = 1) : base(itemID) { Stackable = true; Amount = amount; diff --git a/Scripts/Items/Resources/Reagents/BatWing.cs b/Scripts/Items/Resources/Reagents/BatWing.cs index 46247b7f0..f01cb742a 100644 --- a/Scripts/Items/Resources/Reagents/BatWing.cs +++ b/Scripts/Items/Resources/Reagents/BatWing.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BatWing : BaseReagent, ICommodity { [Constructible] - public BatWing() : this(1) - { - } - - [Constructible] - public BatWing(int amount) : base(0xF78, amount) + public BatWing(int amount = 1) : base(0xF78, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/BlackPearl.cs b/Scripts/Items/Resources/Reagents/BlackPearl.cs index 0cc6dffd1..a2b9c9f64 100644 --- a/Scripts/Items/Resources/Reagents/BlackPearl.cs +++ b/Scripts/Items/Resources/Reagents/BlackPearl.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BlackPearl : BaseReagent, ICommodity { [Constructible] - public BlackPearl() : this(1) - { - } - - [Constructible] - public BlackPearl(int amount) : base(0xF7A, amount) + public BlackPearl(int amount = 1) : base(0xF7A, amount) { } @@ -33,4 +28,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/Bloodmoss.cs b/Scripts/Items/Resources/Reagents/Bloodmoss.cs index c50261e2a..19ea4f571 100644 --- a/Scripts/Items/Resources/Reagents/Bloodmoss.cs +++ b/Scripts/Items/Resources/Reagents/Bloodmoss.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Bloodmoss : BaseReagent, ICommodity { [Constructible] - public Bloodmoss() : this(1) - { - } - - [Constructible] - public Bloodmoss(int amount) : base(0xF7B, amount) + public Bloodmoss(int amount = 1) : base(0xF7B, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/DaemonBlood.cs b/Scripts/Items/Resources/Reagents/DaemonBlood.cs index c23e96895..8eded5c6e 100644 --- a/Scripts/Items/Resources/Reagents/DaemonBlood.cs +++ b/Scripts/Items/Resources/Reagents/DaemonBlood.cs @@ -3,12 +3,7 @@ namespace Server.Items public class DaemonBlood : BaseReagent, ICommodity { [Constructible] - public DaemonBlood() : this(1) - { - } - - [Constructible] - public DaemonBlood(int amount) : base(0xF7D, amount) + public DaemonBlood(int amount = 1) : base(0xF7D, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/DaemonBone.cs b/Scripts/Items/Resources/Reagents/DaemonBone.cs index 9142c0a2a..aa6727c3f 100644 --- a/Scripts/Items/Resources/Reagents/DaemonBone.cs +++ b/Scripts/Items/Resources/Reagents/DaemonBone.cs @@ -4,12 +4,7 @@ namespace Server.Items public class DaemonBone : BaseReagent { [Constructible] - public DaemonBone() : this(1) - { - } - - [Constructible] - public DaemonBone(int amount) : base(0xF80, amount) + public DaemonBone(int amount = 1) : base(0xF80, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/DeadWood.cs b/Scripts/Items/Resources/Reagents/DeadWood.cs index 5e00a06cf..341f44807 100644 --- a/Scripts/Items/Resources/Reagents/DeadWood.cs +++ b/Scripts/Items/Resources/Reagents/DeadWood.cs @@ -3,12 +3,7 @@ namespace Server.Items public class DeadWood : BaseReagent, ICommodity { [Constructible] - public DeadWood() : this(1) - { - } - - [Constructible] - public DeadWood(int amount) : base(0xF90, amount) + public DeadWood(int amount = 1) : base(0xF90, amount) { } @@ -33,4 +28,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/DragonsBlood.cs b/Scripts/Items/Resources/Reagents/DragonsBlood.cs index 9154b5c04..93d658fbe 100644 --- a/Scripts/Items/Resources/Reagents/DragonsBlood.cs +++ b/Scripts/Items/Resources/Reagents/DragonsBlood.cs @@ -3,13 +3,7 @@ public class DragonsBlood : BaseReagent, ICommodity { [Constructible] - public DragonsBlood() - : this(1) - { - } - - [Constructible] - public DragonsBlood(int amount) + public DragonsBlood(int amount = 1) : base(0x4077, amount) { } @@ -36,4 +30,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/Garlic.cs b/Scripts/Items/Resources/Reagents/Garlic.cs index 0d1608a6f..518ffb11a 100644 --- a/Scripts/Items/Resources/Reagents/Garlic.cs +++ b/Scripts/Items/Resources/Reagents/Garlic.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Garlic : BaseReagent, ICommodity { [Constructible] - public Garlic() : this(1) - { - } - - [Constructible] - public Garlic(int amount) : base(0xF84, amount) + public Garlic(int amount = 1) : base(0xF84, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/Ginseng.cs b/Scripts/Items/Resources/Reagents/Ginseng.cs index cafd6d79a..64f3015e8 100644 --- a/Scripts/Items/Resources/Reagents/Ginseng.cs +++ b/Scripts/Items/Resources/Reagents/Ginseng.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Ginseng : BaseReagent, ICommodity { [Constructible] - public Ginseng() : this(1) - { - } - - [Constructible] - public Ginseng(int amount) : base(0xF85, amount) + public Ginseng(int amount = 1) : base(0xF85, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/GraveDust.cs b/Scripts/Items/Resources/Reagents/GraveDust.cs index cd2e9c804..acbf5202b 100644 --- a/Scripts/Items/Resources/Reagents/GraveDust.cs +++ b/Scripts/Items/Resources/Reagents/GraveDust.cs @@ -3,12 +3,7 @@ namespace Server.Items public class GraveDust : BaseReagent, ICommodity { [Constructible] - public GraveDust() : this(1) - { - } - - [Constructible] - public GraveDust(int amount) : base(0xF8F, amount) + public GraveDust(int amount = 1) : base(0xF8F, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/MandrakeRoot.cs b/Scripts/Items/Resources/Reagents/MandrakeRoot.cs index 65a3928a1..43f85d4a9 100644 --- a/Scripts/Items/Resources/Reagents/MandrakeRoot.cs +++ b/Scripts/Items/Resources/Reagents/MandrakeRoot.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MandrakeRoot : BaseReagent, ICommodity { [Constructible] - public MandrakeRoot() : this(1) - { - } - - [Constructible] - public MandrakeRoot(int amount) : base(0xF86, amount) + public MandrakeRoot(int amount = 1) : base(0xF86, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/Nightshade.cs b/Scripts/Items/Resources/Reagents/Nightshade.cs index 163b6f909..fbe3b78a8 100644 --- a/Scripts/Items/Resources/Reagents/Nightshade.cs +++ b/Scripts/Items/Resources/Reagents/Nightshade.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Nightshade : BaseReagent, ICommodity { [Constructible] - public Nightshade() : this(1) - { - } - - [Constructible] - public Nightshade(int amount) : base(0xF88, amount) + public Nightshade(int amount = 1) : base(0xF88, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/NoxCrystal.cs b/Scripts/Items/Resources/Reagents/NoxCrystal.cs index 0e5aec390..a56c422da 100644 --- a/Scripts/Items/Resources/Reagents/NoxCrystal.cs +++ b/Scripts/Items/Resources/Reagents/NoxCrystal.cs @@ -3,12 +3,7 @@ namespace Server.Items public class NoxCrystal : BaseReagent, ICommodity { [Constructible] - public NoxCrystal() : this(1) - { - } - - [Constructible] - public NoxCrystal(int amount) : base(0xF8E, amount) + public NoxCrystal(int amount = 1) : base(0xF8E, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/PigIron.cs b/Scripts/Items/Resources/Reagents/PigIron.cs index 2fe6ed4a0..402c96e88 100644 --- a/Scripts/Items/Resources/Reagents/PigIron.cs +++ b/Scripts/Items/Resources/Reagents/PigIron.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PigIron : BaseReagent, ICommodity { [Constructible] - public PigIron() : this(1) - { - } - - [Constructible] - public PigIron(int amount) : base(0xF8A, amount) + public PigIron(int amount = 1) : base(0xF8A, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/SpidersSilk.cs b/Scripts/Items/Resources/Reagents/SpidersSilk.cs index 07dc98dab..678fe0975 100644 --- a/Scripts/Items/Resources/Reagents/SpidersSilk.cs +++ b/Scripts/Items/Resources/Reagents/SpidersSilk.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SpidersSilk : BaseReagent, ICommodity { [Constructible] - public SpidersSilk() : this(1) - { - } - - [Constructible] - public SpidersSilk(int amount) : base(0xF8D, amount) + public SpidersSilk(int amount = 1) : base(0xF8D, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Reagents/SulfurousAsh.cs b/Scripts/Items/Resources/Reagents/SulfurousAsh.cs index e4bf1bd87..756cc228a 100644 --- a/Scripts/Items/Resources/Reagents/SulfurousAsh.cs +++ b/Scripts/Items/Resources/Reagents/SulfurousAsh.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SulfurousAsh : BaseReagent, ICommodity { [Constructible] - public SulfurousAsh() : this(1) - { - } - - [Constructible] - public SulfurousAsh(int amount) : base(0xF8C, amount) + public SulfurousAsh(int amount = 1) : base(0xF8C, amount) { } @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/BoltOfCloth.cs b/Scripts/Items/Resources/Tailor/BoltOfCloth.cs index 6179c06d6..d57728a15 100644 --- a/Scripts/Items/Resources/Tailor/BoltOfCloth.cs +++ b/Scripts/Items/Resources/Tailor/BoltOfCloth.cs @@ -6,12 +6,7 @@ namespace Server.Items public class BoltOfCloth : Item, IScissorable, IDyable, ICommodity { [Constructible] - public BoltOfCloth() : this(1) - { - } - - [Constructible] - public BoltOfCloth(int amount) : base(0xF95) + public BoltOfCloth(int amount = 1) : base(0xF95) { Stackable = true; Weight = 5.0; @@ -65,4 +60,4 @@ namespace Server.Items new MessageLocalized(Serial, ItemID, MessageType.Label, 0x3B2, 3, number, "", (Amount * 50).ToString())); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Bone.cs b/Scripts/Items/Resources/Tailor/Bone.cs index d777c6f42..0ef7d7c19 100644 --- a/Scripts/Items/Resources/Tailor/Bone.cs +++ b/Scripts/Items/Resources/Tailor/Bone.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Bone : Item, ICommodity { [Constructible] - public Bone() : this(1) - { - } - - [Constructible] - public Bone(int amount) : base(0xf7e) + public Bone(int amount = 1) : base(0xf7e) { Stackable = true; Amount = amount; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Cloth.cs b/Scripts/Items/Resources/Tailor/Cloth.cs index a6a05bad4..9c98be700 100644 --- a/Scripts/Items/Resources/Tailor/Cloth.cs +++ b/Scripts/Items/Resources/Tailor/Cloth.cs @@ -6,12 +6,7 @@ namespace Server.Items public class Cloth : Item, IScissorable, IDyable, ICommodity { [Constructible] - public Cloth() : this(1) - { - } - - [Constructible] - public Cloth(int amount) : base(0x1766) + public Cloth(int amount = 1) : base(0x1766) { Stackable = true; Amount = amount; @@ -65,4 +60,4 @@ namespace Server.Items from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", Amount.ToString())); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Cotton.cs b/Scripts/Items/Resources/Tailor/Cotton.cs index 4e00b6199..8809a69b5 100644 --- a/Scripts/Items/Resources/Tailor/Cotton.cs +++ b/Scripts/Items/Resources/Tailor/Cotton.cs @@ -5,12 +5,7 @@ namespace Server.Items public class Cotton : Item, IDyable { [Constructible] - public Cotton() : this(1) - { - } - - [Constructible] - public Cotton(int amount) : base(0xDF9) + public Cotton(int amount = 1) : base(0xDF9) { Stackable = true; Weight = 4.0; @@ -109,4 +104,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Flax.cs b/Scripts/Items/Resources/Tailor/Flax.cs index 58141263a..db5685f9e 100644 --- a/Scripts/Items/Resources/Tailor/Flax.cs +++ b/Scripts/Items/Resources/Tailor/Flax.cs @@ -5,12 +5,7 @@ namespace Server.Items public class Flax : Item { [Constructible] - public Flax() : this(1) - { - } - - [Constructible] - public Flax(int amount) : base(0x1A9C) + public Flax(int amount = 1) : base(0x1A9C) { Stackable = true; Weight = 1.0; @@ -99,4 +94,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Hides.cs b/Scripts/Items/Resources/Tailor/Hides.cs index ce122e574..c04f83968 100644 --- a/Scripts/Items/Resources/Tailor/Hides.cs +++ b/Scripts/Items/Resources/Tailor/Hides.cs @@ -4,11 +4,7 @@ namespace Server.Items { private CraftResource m_Resource; - public BaseHides(CraftResource resource) : this(resource, 1) - { - } - - public BaseHides(CraftResource resource, int amount) : base(0x1079) + public BaseHides(CraftResource resource, int amount = 1) : base(0x1079) { Stackable = true; Weight = 5.0; @@ -107,12 +103,7 @@ namespace Server.Items public class Hides : BaseHides, IScissorable { [Constructible] - public Hides() : this(1) - { - } - - [Constructible] - public Hides(int amount) : base(CraftResource.RegularLeather, amount) + public Hides(int amount = 1) : base(CraftResource.RegularLeather, amount) { } @@ -154,12 +145,7 @@ namespace Server.Items public class SpinedHides : BaseHides, IScissorable { [Constructible] - public SpinedHides() : this(1) - { - } - - [Constructible] - public SpinedHides(int amount) : base(CraftResource.SpinedLeather, amount) + public SpinedHides(int amount = 1) : base(CraftResource.SpinedLeather, amount) { } @@ -201,12 +187,7 @@ namespace Server.Items public class HornedHides : BaseHides, IScissorable { [Constructible] - public HornedHides() : this(1) - { - } - - [Constructible] - public HornedHides(int amount) : base(CraftResource.HornedLeather, amount) + public HornedHides(int amount = 1) : base(CraftResource.HornedLeather, amount) { } @@ -248,12 +229,7 @@ namespace Server.Items public class BarbedHides : BaseHides, IScissorable { [Constructible] - public BarbedHides() : this(1) - { - } - - [Constructible] - public BarbedHides(int amount) : base(CraftResource.BarbedLeather, amount) + public BarbedHides(int amount = 1) : base(CraftResource.BarbedLeather, amount) { } @@ -290,4 +266,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Leathers.cs b/Scripts/Items/Resources/Tailor/Leathers.cs index 89f791728..a8568f553 100644 --- a/Scripts/Items/Resources/Tailor/Leathers.cs +++ b/Scripts/Items/Resources/Tailor/Leathers.cs @@ -4,11 +4,7 @@ namespace Server.Items { private CraftResource m_Resource; - public BaseLeather(CraftResource resource) : this(resource, 1) - { - } - - public BaseLeather(CraftResource resource, int amount) : base(0x1081) + public BaseLeather(CraftResource resource, int amount = 1) : base(0x1081) { Stackable = true; Weight = 1.0; @@ -107,12 +103,7 @@ namespace Server.Items public class Leather : BaseLeather { [Constructible] - public Leather() : this(1) - { - } - - [Constructible] - public Leather(int amount) : base(CraftResource.RegularLeather, amount) + public Leather(int amount = 1) : base(CraftResource.RegularLeather, amount) { } @@ -139,12 +130,7 @@ namespace Server.Items public class SpinedLeather : BaseLeather { [Constructible] - public SpinedLeather() : this(1) - { - } - - [Constructible] - public SpinedLeather(int amount) : base(CraftResource.SpinedLeather, amount) + public SpinedLeather(int amount = 1) : base(CraftResource.SpinedLeather, amount) { } @@ -171,12 +157,7 @@ namespace Server.Items public class HornedLeather : BaseLeather { [Constructible] - public HornedLeather() : this(1) - { - } - - [Constructible] - public HornedLeather(int amount) : base(CraftResource.HornedLeather, amount) + public HornedLeather(int amount = 1) : base(CraftResource.HornedLeather, amount) { } @@ -203,12 +184,7 @@ namespace Server.Items public class BarbedLeather : BaseLeather { [Constructible] - public BarbedLeather() : this(1) - { - } - - [Constructible] - public BarbedLeather(int amount) : base(CraftResource.BarbedLeather, amount) + public BarbedLeather(int amount = 1) : base(CraftResource.BarbedLeather, amount) { } @@ -230,4 +206,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/UncutCloth.cs b/Scripts/Items/Resources/Tailor/UncutCloth.cs index db5fe8c62..676283400 100644 --- a/Scripts/Items/Resources/Tailor/UncutCloth.cs +++ b/Scripts/Items/Resources/Tailor/UncutCloth.cs @@ -6,12 +6,7 @@ namespace Server.Items public class UncutCloth : Item, IScissorable, IDyable, ICommodity { [Constructible] - public UncutCloth() : this(1) - { - } - - [Constructible] - public UncutCloth(int amount) : base(0x1767) + public UncutCloth(int amount = 1) : base(0x1767) { Stackable = true; Amount = amount; @@ -65,4 +60,4 @@ namespace Server.Items from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", Amount.ToString())); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/Wool.cs b/Scripts/Items/Resources/Tailor/Wool.cs index 787827d24..fa701e07e 100644 --- a/Scripts/Items/Resources/Tailor/Wool.cs +++ b/Scripts/Items/Resources/Tailor/Wool.cs @@ -5,12 +5,7 @@ namespace Server.Items public class Wool : Item, IDyable { [Constructible] - public Wool() : this(1) - { - } - - [Constructible] - public Wool(int amount) : base(0xDF8) + public Wool(int amount = 1) : base(0xDF8) { Stackable = true; Weight = 4.0; @@ -113,12 +108,7 @@ namespace Server.Items public class TaintedWool : Wool { [Constructible] - public TaintedWool() : this(1) - { - } - - [Constructible] - public TaintedWool(int amount) : base(0x101F) + public TaintedWool(int amount = 1) : base(0x101F) { Stackable = true; Weight = 4.0; @@ -145,11 +135,11 @@ namespace Server.Items public override void OnSpun(ISpinningWheel wheel, Mobile from, int hue) { - Item item = new DarkYarn(1); + Item item = new DarkYarn(); item.Hue = hue; from.AddToBackpack(item); from.SendLocalizedMessage(1010574); // You put a ball of yarn in your backpack. } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs b/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs index 26b072330..0d2ab0268 100644 --- a/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs +++ b/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs @@ -4,11 +4,7 @@ namespace Server.Items { public abstract class BaseClothMaterial : Item, IDyable { - public BaseClothMaterial(int itemID) : this(itemID, 1) - { - } - - public BaseClothMaterial(int itemID, int amount) : base(itemID) + public BaseClothMaterial(int itemID, int amount = 1) : base(itemID) { Stackable = true; Weight = 1.0; @@ -110,12 +106,7 @@ namespace Server.Items public class DarkYarn : BaseClothMaterial { [Constructible] - public DarkYarn() : this(1) - { - } - - [Constructible] - public DarkYarn(int amount) : base(0xE1D, amount) + public DarkYarn(int amount = 1) : base(0xE1D, amount) { } @@ -141,12 +132,7 @@ namespace Server.Items public class LightYarn : BaseClothMaterial { [Constructible] - public LightYarn() : this(1) - { - } - - [Constructible] - public LightYarn(int amount) : base(0xE1E, amount) + public LightYarn(int amount = 1) : base(0xE1E, amount) { } @@ -172,12 +158,7 @@ namespace Server.Items public class LightYarnUnraveled : BaseClothMaterial { [Constructible] - public LightYarnUnraveled() : this(1) - { - } - - [Constructible] - public LightYarnUnraveled(int amount) : base(0xE1F, amount) + public LightYarnUnraveled(int amount = 1) : base(0xE1F, amount) { } @@ -203,12 +184,7 @@ namespace Server.Items public class SpoolOfThread : BaseClothMaterial { [Constructible] - public SpoolOfThread() : this(1) - { - } - - [Constructible] - public SpoolOfThread(int amount) : base(0xFA0, amount) + public SpoolOfThread(int amount = 1) : base(0xFA0, amount) { } @@ -230,4 +206,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Camping/Bedroll.cs b/Scripts/Items/Skill Items/Camping/Bedroll.cs index 7cc4f33e7..d19183d1e 100644 --- a/Scripts/Items/Skill Items/Camping/Bedroll.cs +++ b/Scripts/Items/Skill Items/Camping/Bedroll.cs @@ -82,7 +82,7 @@ namespace Server.Items AddBackground(0, 0, 400, 350, 0xA28); - AddHtmlLocalized(100, 20, 200, 35, 1011015, false, false); //
Logging out via camping
+ AddHtmlLocalized(100, 20, 200, 35, 1011015); //
Logging out via camping
/* Using a bedroll in the safety of a camp will log you out of the game safely. * If this is what you wish to do choose CONTINUE and you will be logged out. @@ -92,11 +92,11 @@ namespace Server.Items */ AddHtmlLocalized(50, 55, 300, 140, 1011016, true, true); - AddButton(45, 298, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 300, 110, 35, 1011011, false, false); // CONTINUE + AddButton(45, 298, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(80, 300, 110, 35, 1011011); // CONTINUE - AddButton(200, 298, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(235, 300, 110, 35, 1011012, false, false); // CANCEL + AddButton(200, 298, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(235, 300, 110, 35, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) diff --git a/Scripts/Items/Skill Items/Camping/Kindling.cs b/Scripts/Items/Skill Items/Camping/Kindling.cs index c4cb3075d..36188647b 100644 --- a/Scripts/Items/Skill Items/Camping/Kindling.cs +++ b/Scripts/Items/Skill Items/Camping/Kindling.cs @@ -7,12 +7,7 @@ namespace Server.Items public class Kindling : Item { [Constructible] - public Kindling() : this(1) - { - } - - [Constructible] - public Kindling(int amount) : base(0xDE1) + public Kindling(int amount = 1) : base(0xDE1) { Stackable = true; Weight = 5.0; @@ -114,4 +109,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Carpenter Items/Board.cs b/Scripts/Items/Skill Items/Carpenter Items/Board.cs index 392b9f89b..ad877ea4b 100644 --- a/Scripts/Items/Skill Items/Carpenter Items/Board.cs +++ b/Scripts/Items/Skill Items/Carpenter Items/Board.cs @@ -6,13 +6,7 @@ namespace Server.Items private CraftResource m_Resource; [Constructible] - public Board() - : this(1) - { - } - - [Constructible] - public Board(int amount) + public Board(int amount = 1) : this(CraftResource.RegularWood, amount) { } @@ -23,12 +17,7 @@ namespace Server.Items } [Constructible] - public Board(CraftResource resource) : this(resource, 1) - { - } - - [Constructible] - public Board(CraftResource resource, int amount) + public Board(CraftResource resource, int amount = 1) : base(0x1BD7) { Stackable = true; @@ -122,13 +111,7 @@ namespace Server.Items public class HeartwoodBoard : Board { [Constructible] - public HeartwoodBoard() - : this(1) - { - } - - [Constructible] - public HeartwoodBoard(int amount) + public HeartwoodBoard(int amount = 1) : base(CraftResource.Heartwood, amount) { } @@ -156,13 +139,7 @@ namespace Server.Items public class BloodwoodBoard : Board { [Constructible] - public BloodwoodBoard() - : this(1) - { - } - - [Constructible] - public BloodwoodBoard(int amount) + public BloodwoodBoard(int amount = 1) : base(CraftResource.Bloodwood, amount) { } @@ -190,13 +167,7 @@ namespace Server.Items public class FrostwoodBoard : Board { [Constructible] - public FrostwoodBoard() - : this(1) - { - } - - [Constructible] - public FrostwoodBoard(int amount) + public FrostwoodBoard(int amount = 1) : base(CraftResource.Frostwood, amount) { } @@ -224,13 +195,7 @@ namespace Server.Items public class OakBoard : Board { [Constructible] - public OakBoard() - : this(1) - { - } - - [Constructible] - public OakBoard(int amount) + public OakBoard(int amount = 1) : base(CraftResource.OakWood, amount) { } @@ -258,13 +223,7 @@ namespace Server.Items public class AshBoard : Board { [Constructible] - public AshBoard() - : this(1) - { - } - - [Constructible] - public AshBoard(int amount) + public AshBoard(int amount = 1) : base(CraftResource.AshWood, amount) { } @@ -292,13 +251,7 @@ namespace Server.Items public class YewBoard : Board { [Constructible] - public YewBoard() - : this(1) - { - } - - [Constructible] - public YewBoard(int amount) + public YewBoard(int amount = 1) : base(CraftResource.YewWood, amount) { } @@ -322,4 +275,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs b/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs index b04a39072..d92e40725 100644 --- a/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs +++ b/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs @@ -96,11 +96,13 @@ namespace Server.Items if (m_Kit.Deleted) return; - if (!(targeted is Corpse) && !(targeted is BigFish)) + Corpse corpse = targeted as Corpse; + + if (!(corpse != null || targeted is BigFish)) { from.SendLocalizedMessage(1042600); // That is not a corpse! } - else if (targeted is Corpse corpse && corpse.VisitedByTaxidermist) + else if (corpse?.VisitedByTaxidermist == true) { from.SendLocalizedMessage(1042596); // That corpse seems to have been visited by a taxidermist already. } @@ -114,48 +116,46 @@ namespace Server.Items } else { - object obj = targeted; + object obj = corpse?.Owner ?? targeted; - if (obj is Corpse) - obj = ((Corpse)obj).Owner; + foreach (TrophyInfo t in m_Table) + { + if (t.CreatureType != obj.GetType()) + continue; - if (obj != null) - for (int i = 0; i < m_Table.Length; i++) - if (m_Table[i].CreatureType == obj.GetType()) + Container pack = from.Backpack; + + if (pack?.ConsumeTotal(typeof(Board), 10) == true) + { + from.SendLocalizedMessage( + 1042278); // You review the corpse and find it worthy of a trophy. + from.SendLocalizedMessage(1042602); // You use your kit up making the trophy. + + Mobile hunter = null; + int weight = 0; + + if (targeted is BigFish fish) { - Container pack = from.Backpack; + hunter = fish.Fisher; + weight = (int)fish.Weight; - if (pack != null && pack.ConsumeTotal(typeof(Board), 10)) - { - from.SendLocalizedMessage( - 1042278); // You review the corpse and find it worthy of a trophy. - from.SendLocalizedMessage(1042602); // You use your kit up making the trophy. - - Mobile hunter = null; - int weight = 0; - - if (targeted is BigFish fish) - { - hunter = fish.Fisher; - weight = (int)fish.Weight; - - fish.Consume(); - } - - - from.AddToBackpack(new TrophyDeed(m_Table[i], hunter, weight)); - - if (targeted is Corpse corpse1) - corpse1.VisitedByTaxidermist = true; - - m_Kit.Delete(); - return; - } - - from.SendLocalizedMessage(1042598); // You do not have enough boards. - return; + fish.Consume(); } + + from.AddToBackpack(new TrophyDeed(t, hunter, weight)); + + if (corpse != null) + corpse.VisitedByTaxidermist = true; + + m_Kit.Delete(); + return; + } + + from.SendLocalizedMessage(1042598); // You do not have enough boards. + return; + } + from.SendLocalizedMessage(1042599); // That does not look like something you want hanging on a wall. } } @@ -169,14 +169,8 @@ namespace Server.Items private Mobile m_Hunter; - [Constructible] - public TrophyAddon(Mobile from, int itemID, int westID, int northID, int deedNumber, int addonNumber) : this(from, - itemID, westID, northID, deedNumber, addonNumber, null, 0) - { - } - - public TrophyAddon(Mobile from, int itemID, int westID, int northID, int deedNumber, int addonNumber, Mobile hunter, - int animalWeight) : base(itemID) + public TrophyAddon(Mobile from, int itemID, int westID, int northID, int deedNumber, + int addonNumber, Mobile hunter = null, int animalWeight = 0) : base(itemID) { WestID = westID; NorthID = northID; @@ -335,7 +329,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { if (from.InRange(GetWorldLocation(), 1)) { @@ -358,14 +352,8 @@ namespace Server.Items private Mobile m_Hunter; - [Constructible] - public TrophyDeed(int westID, int northID, int deedNumber, int addonNumber) : this(westID, northID, deedNumber, - addonNumber, null, 0) - { - } - - public TrophyDeed(int westID, int northID, int deedNumber, int addonNumber, Mobile hunter, int animalWeight) : - base(0x14F0) + public TrophyDeed(int westID, int northID, int deedNumber, int addonNumber, + Mobile hunter = null, int animalWeight = 0) : base(0x14F0) { WestID = westID; NorthID = northID; @@ -487,7 +475,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { bool northWall = BaseAddon.IsWall(from.X, from.Y - 1, from.Z, from.Map); bool westWall = BaseAddon.IsWall(from.X - 1, from.Y, from.Z, from.Map); @@ -497,14 +485,12 @@ namespace Server.Items { case Direction.North: case Direction.South: - northWall = true; westWall = false; break; case Direction.East: case Direction.West: northWall = false; - westWall = true; break; default: @@ -539,4 +525,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs b/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs index ab16decf2..b7c931006 100644 --- a/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs +++ b/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs @@ -7,12 +7,7 @@ namespace Server.Items { private int m_Level; - [Constructible] - public MessageInABottle() : this(Map.Trammel) - { - } - - public MessageInABottle(Map map) : this(map, GetRandomLevel()) + public MessageInABottle(Map map = null) : this(map, GetRandomLevel()) { } @@ -20,7 +15,7 @@ namespace Server.Items public MessageInABottle(Map map, int level) : base(0x099F) { Weight = 1.0; - TargetMap = map; + TargetMap = map ?? Map.Trammel; m_Level = level; } @@ -105,4 +100,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs b/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs index 8db8f5ec7..50c127f7f 100644 --- a/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs +++ b/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs @@ -52,12 +52,7 @@ namespace Server.Items } [Constructible] - public SOS() : this(Map.Trammel) - { - } - - [Constructible] - public SOS(Map map) : this(map, MessageInABottle.GetRandomLevel()) + public SOS(Map map = null) : this(map, MessageInABottle.GetRandomLevel()) { } @@ -68,7 +63,7 @@ namespace Server.Items m_Level = level; MessageIndex = Utility.Random(MessageEntry.Entries.Length); - TargetMap = map; + TargetMap = map ?? Map.Trammel; TargetLocation = FindLocation(TargetMap); UpdateHue(); @@ -276,10 +271,10 @@ namespace Server.Items * The message gives the ship's last known sextant co-ordinates. */ - AddHtml(35, 240, 230, 20, fmt, false, false); + AddHtml(35, 240, 230, 20, fmt); - AddButton(35, 265, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(70, 265, 100, 20, 1011036, false, false); // OKAY + AddButton(35, 265, 4005, 4007, 0); + AddHtmlLocalized(70, 265, 100, 20, 1011036); // OKAY } } #endif @@ -328,4 +323,4 @@ namespace Server.Items }; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs index d35f7aa06..908c8207e 100644 --- a/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs +++ b/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs @@ -20,11 +20,7 @@ namespace Server.Items private ToolQuality m_Quality; private int m_UsesRemaining; - public BaseHarvestTool(int itemID) : this(50, itemID) - { - } - - public BaseHarvestTool(int usesRemaining, int itemID) : base(itemID) + public BaseHarvestTool(int itemID, int usesRemaining = 50) : base(itemID) { m_UsesRemaining = usesRemaining; m_Quality = ToolQuality.Regular; @@ -257,4 +253,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Harvest Tools/Shovel.cs b/Scripts/Items/Skill Items/Harvest Tools/Shovel.cs index 6578d8ab2..7417a8973 100644 --- a/Scripts/Items/Skill Items/Harvest Tools/Shovel.cs +++ b/Scripts/Items/Skill Items/Harvest Tools/Shovel.cs @@ -5,12 +5,7 @@ namespace Server.Items public class Shovel : BaseHarvestTool { [Constructible] - public Shovel() : this(50) - { - } - - [Constructible] - public Shovel(int uses) : base(uses, 0xF39) + public Shovel(int uses = 50) : base(0xF39, uses) { Weight = 5.0; } @@ -35,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs b/Scripts/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs index c332af5bd..ba236a6bb 100644 --- a/Scripts/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs +++ b/Scripts/Items/Skill Items/Harvest Tools/SturdyPickaxe.cs @@ -5,12 +5,7 @@ namespace Server.Items public class SturdyPickaxe : BaseAxe, IUsesRemaining { [Constructible] - public SturdyPickaxe() : this(180) - { - } - - [Constructible] - public SturdyPickaxe(int uses) : base(0xE86) + public SturdyPickaxe(int uses = 180) : base(0xE86) { Weight = 11.0; Hue = 0x973; @@ -55,4 +50,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Harvest Tools/SturdyShovel.cs b/Scripts/Items/Skill Items/Harvest Tools/SturdyShovel.cs index 4e632d01f..366d987ab 100644 --- a/Scripts/Items/Skill Items/Harvest Tools/SturdyShovel.cs +++ b/Scripts/Items/Skill Items/Harvest Tools/SturdyShovel.cs @@ -5,12 +5,7 @@ namespace Server.Items public class SturdyShovel : BaseHarvestTool { [Constructible] - public SturdyShovel() : this(180) - { - } - - [Constructible] - public SturdyShovel(int uses) : base(uses, 0xF39) + public SturdyShovel(int uses = 180) : base(0xF39, uses) { Weight = 5.0; Hue = 0x973; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Lumberjack/Log.cs b/Scripts/Items/Skill Items/Lumberjack/Log.cs index 1bdb326a2..921fb0752 100644 --- a/Scripts/Items/Skill Items/Lumberjack/Log.cs +++ b/Scripts/Items/Skill Items/Lumberjack/Log.cs @@ -6,12 +6,7 @@ namespace Server.Items private CraftResource m_Resource; [Constructible] - public Log() : this(1) - { - } - - [Constructible] - public Log(int amount) : this(CraftResource.RegularWood, amount) + public Log(int amount = 1) : this(CraftResource.RegularWood, amount) { } @@ -125,12 +120,7 @@ namespace Server.Items public class HeartwoodLog : Log { [Constructible] - public HeartwoodLog() : this(1) - { - } - - [Constructible] - public HeartwoodLog(int amount) + public HeartwoodLog(int amount = 1) : base(CraftResource.Heartwood, amount) { } @@ -165,13 +155,7 @@ namespace Server.Items public class BloodwoodLog : Log { [Constructible] - public BloodwoodLog() - : this(1) - { - } - - [Constructible] - public BloodwoodLog(int amount) + public BloodwoodLog(int amount = 1) : base(CraftResource.Bloodwood, amount) { } @@ -207,13 +191,7 @@ namespace Server.Items public class FrostwoodLog : Log { [Constructible] - public FrostwoodLog() - : this(1) - { - } - - [Constructible] - public FrostwoodLog(int amount) + public FrostwoodLog(int amount = 1) : base(CraftResource.Frostwood, amount) { } @@ -249,13 +227,7 @@ namespace Server.Items public class OakLog : Log { [Constructible] - public OakLog() - : this(1) - { - } - - [Constructible] - public OakLog(int amount) + public OakLog(int amount = 1) : base(CraftResource.OakWood, amount) { } @@ -291,13 +263,7 @@ namespace Server.Items public class AshLog : Log { [Constructible] - public AshLog() - : this(1) - { - } - - [Constructible] - public AshLog(int amount) + public AshLog(int amount = 1) : base(CraftResource.AshWood, amount) { } @@ -333,13 +299,7 @@ namespace Server.Items public class YewLog : Log { [Constructible] - public YewLog() - : this(1) - { - } - - [Constructible] - public YewLog(int amount) + public YewLog(int amount = 1) : base(CraftResource.YewWood, amount) { } @@ -371,4 +331,4 @@ namespace Server.Items return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/BookOfBushido.cs b/Scripts/Items/Skill Items/Magical/BookOfBushido.cs index 5eafe24e3..d41ac5435 100644 --- a/Scripts/Items/Skill Items/Magical/BookOfBushido.cs +++ b/Scripts/Items/Skill Items/Magical/BookOfBushido.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BookOfBushido : Spellbook { [Constructible] - public BookOfBushido() : this((ulong)0x3F) - { - } - - [Constructible] - public BookOfBushido(ulong content) : base(content, 0x238C) + public BookOfBushido(ulong content = 0x3F) : base(content, 0x238C) { Layer = Core.ML ? Layer.OneHanded : Layer.Invalid; } @@ -38,4 +33,4 @@ namespace Server.Items Layer = Layer.OneHanded; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/BookOfChivalry.cs b/Scripts/Items/Skill Items/Magical/BookOfChivalry.cs index 13f75bb69..de54ef4aa 100644 --- a/Scripts/Items/Skill Items/Magical/BookOfChivalry.cs +++ b/Scripts/Items/Skill Items/Magical/BookOfChivalry.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BookOfChivalry : Spellbook { [Constructible] - public BookOfChivalry() : this((ulong)0x3FF) - { - } - - [Constructible] - public BookOfChivalry(ulong content) : base(content, 0x2252) + public BookOfChivalry(ulong content = 0x3FF) : base(content, 0x2252) { Layer = Core.ML ? Layer.OneHanded : Layer.Invalid; } @@ -38,4 +33,4 @@ namespace Server.Items Layer = Layer.OneHanded; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/BookOfNinjitsu.cs b/Scripts/Items/Skill Items/Magical/BookOfNinjitsu.cs index 33a500345..370813216 100644 --- a/Scripts/Items/Skill Items/Magical/BookOfNinjitsu.cs +++ b/Scripts/Items/Skill Items/Magical/BookOfNinjitsu.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BookOfNinjitsu : Spellbook { [Constructible] - public BookOfNinjitsu() : this((ulong)0xFF) - { - } - - [Constructible] - public BookOfNinjitsu(ulong content) : base(content, 0x23A0) + public BookOfNinjitsu(ulong content = 0xFF) : base(content, 0x23A0) { Layer = Core.ML ? Layer.OneHanded : Layer.Invalid; } @@ -38,4 +33,4 @@ namespace Server.Items Layer = Layer.OneHanded; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Misc/BlankScroll.cs b/Scripts/Items/Skill Items/Magical/Misc/BlankScroll.cs index 4a783a956..b5ba14142 100644 --- a/Scripts/Items/Skill Items/Magical/Misc/BlankScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Misc/BlankScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BlankScroll : Item, ICommodity { [Constructible] - public BlankScroll() : this(1) - { - } - - [Constructible] - public BlankScroll(int amount) : base(0xEF3) + public BlankScroll(int amount = 1) : base(0xEF3) { Stackable = true; Weight = 1.0; @@ -36,4 +31,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs b/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs index 64caf2f86..5396a1cbe 100644 --- a/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs +++ b/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs @@ -3,12 +3,7 @@ namespace Server.Items public class Bottle : Item, ICommodity { [Constructible] - public Bottle() : this(1) - { - } - - [Constructible] - public Bottle(int amount) : base(0xF0E) + public Bottle(int amount = 1) : base(0xF0E) { Stackable = true; Weight = 1.0; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs b/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs index c31bb4189..8cbb850c1 100644 --- a/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs +++ b/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs @@ -11,26 +11,22 @@ namespace Server.Items [DispellableField] public class Moongate : Item { + [Constructible] - public Moongate() : this(Point3D.Zero, null) + public Moongate(bool dispellable = true) : + this(Point3D.Zero, null, dispellable) { - Dispellable = true; } [Constructible] - public Moongate(bool bDispellable) : this(Point3D.Zero, null) - { - Dispellable = bDispellable; - } - - [Constructible] - public Moongate(Point3D target, Map targetMap) : base(0xF6C) + public Moongate(Point3D target, Map targetMap = null, bool dispellable = true) : base(0xF6C) { Movable = false; Light = LightType.Circle300; Target = target; TargetMap = targetMap; + Dispellable = dispellable; } public Moongate(Serial serial) : base(serial) @@ -202,12 +198,7 @@ namespace Server.Items public static bool IsInTown(Point3D p, Map map) { - if (map == null) - return false; - - GuardedRegion reg = Region.Find(p, map).GetRegion(); - - return reg != null && !reg.IsDisabled(); + return map != null && Region.Find(p, map).GetRegion()?.IsDisabled() == false; } private class DelayTimer : Timer @@ -233,12 +224,12 @@ namespace Server.Items public class ConfirmationMoongate : Moongate { [Constructible] - public ConfirmationMoongate() : this(Point3D.Zero, null) + public ConfirmationMoongate() : this(Point3D.Zero) { } [Constructible] - public ConfirmationMoongate(Point3D target, Map targetMap) : base(target, targetMap) + public ConfirmationMoongate(Point3D target, Map targetMap = null) : base(target, targetMap) { } @@ -354,7 +345,7 @@ namespace Server.Items AddImageTiled(10, 10, 400, 20, 2624); AddAlphaRegion(10, 10, 400, 20); - AddHtmlLocalized(10, 10, 400, 20, 1062051, 30720, false, false); // Gate Warning + AddHtmlLocalized(10, 10, 400, 20, 1062051, 30720); // Gate Warning AddImageTiled(10, 40, 400, 200, 2624); AddAlphaRegion(10, 40, 400, 200); @@ -369,11 +360,11 @@ namespace Server.Items AddImageTiled(10, 250, 400, 20, 2624); AddAlphaRegion(10, 250, 400, 20); - AddButton(10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767, false, false); // OKAY + AddButton(10, 250, 4005, 4007, 1); + AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767); // OKAY - AddButton(210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767, false, false); // CANCEL + AddButton(210, 250, 4005, 4007, 0); + AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL } else { @@ -383,14 +374,13 @@ namespace Server.Items AddBackground(10, 10, 400, 380, 3000); AddHtml(20, 40, 380, 60, - @"Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here", false, - false); + @"Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here"); - AddHtmlLocalized(55, 110, 290, 20, 1011012, false, false); // CANCEL - AddButton(20, 110, 4005, 4007, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 110, 290, 20, 1011012); // CANCEL + AddButton(20, 110, 4005, 4007, 0); - AddHtmlLocalized(55, 140, 290, 40, 1011011, false, false); // CONTINUE - AddButton(20, 140, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 140, 290, 40, 1011011); // CONTINUE + AddButton(20, 140, 4005, 4007, 1); } } @@ -400,4 +390,4 @@ namespace Server.Items m_Gate.EndConfirmation(m_From); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs b/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs index 9e76afd72..9bef5d574 100644 --- a/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs +++ b/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs @@ -170,7 +170,7 @@ namespace Server.Items { Container pack = from.Backpack; - if (pack != null && pack.ConsumeTotal(typeof(Bottle), 1)) + if (pack?.ConsumeTotal(typeof(Bottle)) == true) { from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle... @@ -284,7 +284,7 @@ namespace Server.Items Bottle bottle = new Bottle(amount); - if (pack == null || !pack.TryDropItem(m, bottle, false)) + if (pack?.TryDropItem(m, bottle, false) != true) { bottle.Delete(); return false; @@ -339,4 +339,4 @@ namespace Server.Items TileData.ItemTable[0x1940].Height = 4; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs b/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs index 844c3c2d3..07f49d96a 100644 --- a/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs +++ b/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs @@ -29,7 +29,7 @@ namespace Server.Items { get { - if (m_House != null && m_House.Deleted) + if (m_House?.Deleted == true) House = null; return m_House; @@ -90,7 +90,7 @@ namespace Server.Items { base.Serialize(writer); - if (m_House != null && !m_House.Deleted) + if (m_House?.Deleted == false) { writer.Write(1); // version @@ -184,7 +184,7 @@ namespace Server.Items Map map = m_House.Map; - if (map != null && !map.CanFit(x, y, z, 16, false, false)) + if (map?.CanFit(x, y, z, 16, false, false) == false) z = map.GetAverageZ(x, y); Target = new Point3D(x, y, z); @@ -305,4 +305,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/MysticSpellbook.cs b/Scripts/Items/Skill Items/Magical/MysticSpellbook.cs index 636028726..9b68fca9f 100644 --- a/Scripts/Items/Skill Items/Magical/MysticSpellbook.cs +++ b/Scripts/Items/Skill Items/Magical/MysticSpellbook.cs @@ -3,13 +3,7 @@ public class MysticSpellbook : Spellbook { [Constructible] - public MysticSpellbook() - : this((ulong)0) - { - } - - [Constructible] - public MysticSpellbook(ulong content) + public MysticSpellbook(ulong content = 0) : base(content, 0x2D9D) { Layer = Layer.OneHanded; @@ -40,4 +34,4 @@ reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/NecromancerSpellbook.cs b/Scripts/Items/Skill Items/Magical/NecromancerSpellbook.cs index 6f8569a2d..af6fa7818 100644 --- a/Scripts/Items/Skill Items/Magical/NecromancerSpellbook.cs +++ b/Scripts/Items/Skill Items/Magical/NecromancerSpellbook.cs @@ -3,12 +3,7 @@ namespace Server.Items public class NecromancerSpellbook : Spellbook { [Constructible] - public NecromancerSpellbook() : this((ulong)0) - { - } - - [Constructible] - public NecromancerSpellbook(ulong content) : base(content, 0x2253) + public NecromancerSpellbook(ulong content = 0) : base(content, 0x2253) { Layer = Core.ML ? Layer.OneHanded : Layer.Invalid; } @@ -38,4 +33,4 @@ namespace Server.Items Layer = Layer.OneHanded; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs b/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs index 571818323..bcc478807 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs @@ -145,7 +145,7 @@ namespace Server.Items Amount--; - if (from.Backpack != null && !from.Backpack.Deleted) + if (from.Backpack?.Deleted != false) from.Backpack.DropItem(pot); else pot.MoveToWorld(from.Location, from.Map); @@ -260,4 +260,4 @@ namespace Server.Items base.StackWith(from, potion, playSound); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs b/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs index b4b1cb2ff..caf6de7ca 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Spells; using Server.Targeting; @@ -260,19 +259,12 @@ namespace Server.Items if (m_Item.Map == null || from == null) return; - List mobiles = new List(); - - foreach (Mobile mobile in m_Item.GetMobilesInRange(0)) - mobiles.Add(mobile); - - for (int i = 0; i < mobiles.Count; i++) + foreach (Mobile m in m_Item.GetMobilesInRange(0)) { - Mobile m = mobiles[i]; - 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); m.PlaySound(0x208); diff --git a/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs index 6d151acff..1722c96d0 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Misc; using Server.Mobiles; diff --git a/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs index 11331c9ef..a0a7f3027 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Network; using Server.Spells; using Server.Targeting; @@ -45,17 +46,13 @@ namespace Server.Items int version = reader.ReadInt(); } - public virtual object FindParent(Mobile from) + public virtual IEntity FindParent(Mobile from) { - Mobile m = HeldBy; + if (HeldBy?.Holding == this) + return HeldBy; - if (m != null && m.Holding == this) - return m; - - object obj = RootParent; - - if (obj != null) - return obj; + if (RootParent != null) + return RootParent; if (Map == Map.Internal) return from; @@ -74,7 +71,7 @@ namespace Server.Items ThrowTarget targ = from.Target as ThrowTarget; Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode. - if (targ != null && targ.Potion == this) + if (targ?.Potion == this) return; from.RevealingAction(); @@ -107,7 +104,7 @@ namespace Server.Items if (Deleted) return; - object parent = FindParent(from); + IEntity parent = FindParent(from); if (timer == 0) { @@ -179,22 +176,17 @@ namespace Server.Items alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); IPooledEnumerable eable = map.GetObjectsInRange(loc, ExplosionRange, LeveledExplosion); - List toExplode = new List(); - int toDamage = 0; - foreach (IEntity o in eable) - if (o is Mobile mobile && (from == null || - SpellHelper.ValidIndirectTarget(from, mobile) && - from.CanBeHarmful(mobile, false))) - { - toExplode.Add(mobile); - ++toDamage; - } - else if (o is BaseExplosionPotion && o != this) - { - toExplode.Add(o); - } + List toExplode = eable.Where(o => + { + if (!(o is Mobile mobile) || from != null && + (!SpellHelper.ValidIndirectTarget(from, mobile) || !from.CanBeHarmful(mobile, false))) + return o is BaseExplosionPotion && o != this; + + ++toDamage; + return true; + }).ToList(); eable.Free(); @@ -203,7 +195,7 @@ namespace Server.Items for (int i = 0; i < toExplode.Count; ++i) { - object o = toExplode[i]; + IEntity o = toExplode[i]; if (o is Mobile m) { @@ -272,4 +264,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs b/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs index 673ab77bf..e83f79a6f 100644 --- a/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs +++ b/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Items diff --git a/Scripts/Items/Skill Items/Magical/Runebook.cs b/Scripts/Items/Skill Items/Magical/Runebook.cs index a5252a05d..b2cfad96a 100644 --- a/Scripts/Items/Skill Items/Magical/Runebook.cs +++ b/Scripts/Items/Skill Items/Magical/Runebook.cs @@ -19,6 +19,11 @@ namespace Server.Items private BookQuality m_Quality; + [Constructible] + public Runebook() : this(Core.SE ? 12 : 6) + { + } + [Constructible] public Runebook(int maxCharges) : base(Core.AOS ? 0x22C5 : 0xEFA) { @@ -37,11 +42,6 @@ namespace Server.Items Level = SecureLevel.CoOwners; } - [Constructible] - public Runebook() : this(Core.SE ? 12 : 6) - { - } - public Runebook(Serial serial) : base(serial) { } @@ -289,7 +289,7 @@ namespace Server.Items public override void OnSingleClick(Mobile from) { - if (m_Description != null && m_Description.Length > 0) + if (m_Description?.Length > 0) LabelTo(from, m_Description); base.OnSingleClick(from); @@ -349,10 +349,8 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsAosRules && (house.Public ? house.IsBanned(m) : !house.HasAccess(m))) - return false; - - return house != null && house.HasSecureAccess(m, Level); + return (house?.IsAosRules != true || house.Public && !house.IsBanned(m) || house.HasAccess(m)) && + house?.HasSecureAccess(m, Level) == true; } public override bool OnDragDrop(Mobile from, Item dropped) @@ -427,7 +425,7 @@ namespace Server.Items public class RunebookEntry { - public RunebookEntry(Point3D loc, Map map, string desc, BaseHouse house) + public RunebookEntry(Point3D loc, Map map, string desc, BaseHouse house = null) { Location = loc; Map = map; @@ -467,7 +465,7 @@ namespace Server.Items public void Serialize(GenericWriter writer) { - if (House != null && !House.Deleted) + if (House?.Deleted == false) { writer.Write((byte)1); // version @@ -483,4 +481,4 @@ namespace Server.Items writer.Write(Description); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EarthquakeScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EarthquakeScroll.cs index 3ab21547b..b48d0b6fd 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EarthquakeScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EarthquakeScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class EarthquakeScroll : SpellScroll { [Constructible] - public EarthquakeScroll() : this(1) - { - } - - [Constructible] - public EarthquakeScroll(int amount) : base(56, 0x1F65, amount) + public EarthquakeScroll(int amount = 1) : base(56, 0x1F65, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EnergyVortexScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EnergyVortexScroll.cs index da96ce56a..3711a4b86 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EnergyVortexScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/EnergyVortexScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class EnergyVortexScroll : SpellScroll { [Constructible] - public EnergyVortexScroll() : this(1) - { - } - - [Constructible] - public EnergyVortexScroll(int amount) : base(57, 0x1F66, amount) + public EnergyVortexScroll(int amount = 1) : base(57, 0x1F66, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/ResurrectionScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/ResurrectionScroll.cs index 2e1567889..8d76153a1 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/ResurrectionScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/ResurrectionScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ResurrectionScroll : SpellScroll { [Constructible] - public ResurrectionScroll() : this(1) - { - } - - [Constructible] - public ResurrectionScroll(int amount) : base(58, 0x1F67, amount) + public ResurrectionScroll(int amount = 1) : base(58, 0x1F67, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonAirElementalScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonAirElementalScroll.cs index c339a17c1..90c52429f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonAirElementalScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonAirElementalScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonAirElementalScroll : SpellScroll { [Constructible] - public SummonAirElementalScroll() : this(1) - { - } - - [Constructible] - public SummonAirElementalScroll(int amount) : base(59, 0x1F68, amount) + public SummonAirElementalScroll(int amount = 1) : base(59, 0x1F68, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonDaemonScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonDaemonScroll.cs index c916db1e6..d021e235a 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonDaemonScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonDaemonScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonDaemonScroll : SpellScroll { [Constructible] - public SummonDaemonScroll() : this(1) - { - } - - [Constructible] - public SummonDaemonScroll(int amount) : base(60, 0x1F69, amount) + public SummonDaemonScroll(int amount = 1) : base(60, 0x1F69, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonEarthElementalScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonEarthElementalScroll.cs index 316a067e0..c665f6ab1 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonEarthElementalScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonEarthElementalScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonEarthElementalScroll : SpellScroll { [Constructible] - public SummonEarthElementalScroll() : this(1) - { - } - - [Constructible] - public SummonEarthElementalScroll(int amount) : base(61, 0x1F6A, amount) + public SummonEarthElementalScroll(int amount = 1) : base(61, 0x1F6A, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonFireElementalScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonFireElementalScroll.cs index a2e01d6b7..85fba807f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonFireElementalScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonFireElementalScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonFireElementalScroll : SpellScroll { [Constructible] - public SummonFireElementalScroll() : this(1) - { - } - - [Constructible] - public SummonFireElementalScroll(int amount) : base(62, 0x1F6B, amount) + public SummonFireElementalScroll(int amount = 1) : base(62, 0x1F6B, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonWaterElementalScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonWaterElementalScroll.cs index 25ca9d75b..e335f18ee 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonWaterElementalScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Eighth Circle/SummonWaterElementalScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonWaterElementalScroll : SpellScroll { [Constructible] - public SummonWaterElementalScroll() : this(1) - { - } - - [Constructible] - public SummonWaterElementalScroll(int amount) : base(63, 0x1F6C, amount) + public SummonWaterElementalScroll(int amount = 1) : base(63, 0x1F6C, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/BladeSpiritsScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/BladeSpiritsScroll.cs index cf94e46b0..0462f2f0f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/BladeSpiritsScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/BladeSpiritsScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BladeSpiritsScroll : SpellScroll { [Constructible] - public BladeSpiritsScroll() : this(1) - { - } - - [Constructible] - public BladeSpiritsScroll(int amount) : base(32, 0x1F4D, amount) + public BladeSpiritsScroll(int amount = 1) : base(32, 0x1F4D, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/DispelFieldScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/DispelFieldScroll.cs index 5cd507af9..4eb83ffba 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/DispelFieldScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/DispelFieldScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class DispelFieldScroll : SpellScroll { [Constructible] - public DispelFieldScroll() : this(1) - { - } - - [Constructible] - public DispelFieldScroll(int amount) : base(33, 0x1F4E, amount) + public DispelFieldScroll(int amount = 1) : base(33, 0x1F4E, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/IncognitoScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/IncognitoScroll.cs index 26cf51c68..8dd0bfb79 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/IncognitoScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/IncognitoScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class IncognitoScroll : SpellScroll { [Constructible] - public IncognitoScroll() : this(1) - { - } - - [Constructible] - public IncognitoScroll(int amount) : base(34, 0x1F4F, amount) + public IncognitoScroll(int amount = 1) : base(34, 0x1F4F, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MagicReflectScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MagicReflectScroll.cs index 8f363e550..34efe80b2 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MagicReflectScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MagicReflectScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MagicReflectScroll : SpellScroll { [Constructible] - public MagicReflectScroll() : this(1) - { - } - - [Constructible] - public MagicReflectScroll(int amount) : base(35, 0x1F50, amount) + public MagicReflectScroll(int amount = 1) : base(35, 0x1F50, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MindBlastScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MindBlastScroll.cs index 0eb741ba5..f2847537e 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MindBlastScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/MindBlastScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MindBlastScroll : SpellScroll { [Constructible] - public MindBlastScroll() : this(1) - { - } - - [Constructible] - public MindBlastScroll(int amount) : base(36, 0x1F51, amount) + public MindBlastScroll(int amount = 1) : base(36, 0x1F51, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/ParalyzeScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/ParalyzeScroll.cs index 98ae2513b..feebcb1aa 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/ParalyzeScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/ParalyzeScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ParalyzeScroll : SpellScroll { [Constructible] - public ParalyzeScroll() : this(1) - { - } - - [Constructible] - public ParalyzeScroll(int amount) : base(37, 0x1F52, amount) + public ParalyzeScroll(int amount = 1) : base(37, 0x1F52, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/PoisonFieldScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/PoisonFieldScroll.cs index 3a802c176..69bbada43 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/PoisonFieldScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/PoisonFieldScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PoisonFieldScroll : SpellScroll { [Constructible] - public PoisonFieldScroll() : this(1) - { - } - - [Constructible] - public PoisonFieldScroll(int amount) : base(38, 0x1F53, amount) + public PoisonFieldScroll(int amount = 1) : base(38, 0x1F53, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/SummonCreatureScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/SummonCreatureScroll.cs index 2144a41aa..5854ad74a 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/SummonCreatureScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fifth Circle/SummonCreatureScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonCreatureScroll : SpellScroll { [Constructible] - public SummonCreatureScroll() : this(1) - { - } - - [Constructible] - public SummonCreatureScroll(int amount) : base(39, 0x1F54, amount) + public SummonCreatureScroll(int amount = 1) : base(39, 0x1F54, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ClumsyScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ClumsyScroll.cs index 17889990f..ac2ddcbab 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ClumsyScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ClumsyScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ClumsyScroll : SpellScroll { [Constructible] - public ClumsyScroll() : this(1) - { - } - - [Constructible] - public ClumsyScroll(int amount) : base(0, 0x1F2E, amount) + public ClumsyScroll(int amount = 1) : base(0, 0x1F2E, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/CreateFoodScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/CreateFoodScroll.cs index 169d8bbbf..fcfad1d45 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/CreateFoodScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/CreateFoodScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class CreateFoodScroll : SpellScroll { [Constructible] - public CreateFoodScroll() : this(1) - { - } - - [Constructible] - public CreateFoodScroll(int amount) : base(1, 0x1F2F, amount) + public CreateFoodScroll(int amount = 1) : base(1, 0x1F2F, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/FeeblemindScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/FeeblemindScroll.cs index 7c401fa69..133af37d1 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/FeeblemindScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/FeeblemindScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class FeeblemindScroll : SpellScroll { [Constructible] - public FeeblemindScroll() : this(1) - { - } - - [Constructible] - public FeeblemindScroll(int amount) : base(2, 0x1F30, amount) + public FeeblemindScroll(int amount = 1) : base(2, 0x1F30, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/HealScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/HealScroll.cs index 5e0162ee3..c5957f643 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/HealScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/HealScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class HealScroll : SpellScroll { [Constructible] - public HealScroll() : this(1) - { - } - - [Constructible] - public HealScroll(int amount) : base(3, 0x1F31, amount) + public HealScroll(int amount = 1) : base(3, 0x1F31, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/MagicArrowScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/MagicArrowScroll.cs index ca01564cf..2c3617fe7 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/MagicArrowScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/MagicArrowScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MagicArrowScroll : SpellScroll { [Constructible] - public MagicArrowScroll() : this(1) - { - } - - [Constructible] - public MagicArrowScroll(int amount) : base(4, 0x1F32, amount) + public MagicArrowScroll(int amount = 1) : base(4, 0x1F32, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/NightSightScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/NightSightScroll.cs index 803b3ec97..c632bc0bf 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/NightSightScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/NightSightScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class NightSightScroll : SpellScroll { [Constructible] - public NightSightScroll() : this(1) - { - } - - [Constructible] - public NightSightScroll(int amount) : base(5, 0x1F33, amount) + public NightSightScroll(int amount = 1) : base(5, 0x1F33, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ReactiveArmorScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ReactiveArmorScroll.cs index 7c94295db..b09a21d62 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ReactiveArmorScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/ReactiveArmorScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ReactiveArmorScroll : SpellScroll { [Constructible] - public ReactiveArmorScroll() : this(1) - { - } - - [Constructible] - public ReactiveArmorScroll(int amount) : base(6, 0x1F2D, amount) + public ReactiveArmorScroll(int amount = 1) : base(6, 0x1F2D, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/WeakenScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/WeakenScroll.cs index c61a744b0..79c52bf38 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/WeakenScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/First Circle/WeakenScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class WeakenScroll : SpellScroll { [Constructible] - public WeakenScroll() : this(1) - { - } - - [Constructible] - public WeakenScroll(int amount) : base(7, 0x1F34, amount) + public WeakenScroll(int amount = 1) : base(7, 0x1F34, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchProtectionScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchProtectionScroll.cs index dfbb655ab..0d3b44582 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchProtectionScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchProtectionScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ArchProtectionScroll : SpellScroll { [Constructible] - public ArchProtectionScroll() : this(1) - { - } - - [Constructible] - public ArchProtectionScroll(int amount) : base(25, 0x1F46, amount) + public ArchProtectionScroll(int amount = 1) : base(25, 0x1F46, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchcureScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchcureScroll.cs index a3620c902..94280516c 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchcureScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ArchcureScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ArchCureScroll : SpellScroll { [Constructible] - public ArchCureScroll() : this(1) - { - } - - [Constructible] - public ArchCureScroll(int amount) : base(24, 0x1F45, amount) + public ArchCureScroll(int amount = 1) : base(24, 0x1F45, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/CurseScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/CurseScroll.cs index 8f1e95059..e60543237 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/CurseScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/CurseScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class CurseScroll : SpellScroll { [Constructible] - public CurseScroll() : this(1) - { - } - - [Constructible] - public CurseScroll(int amount) : base(26, 0x1F47, amount) + public CurseScroll(int amount = 1) : base(26, 0x1F47, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/FireFieldScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/FireFieldScroll.cs index 9bc93b857..1bd38889f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/FireFieldScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/FireFieldScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class FireFieldScroll : SpellScroll { [Constructible] - public FireFieldScroll() : this(1) - { - } - - [Constructible] - public FireFieldScroll(int amount) : base(27, 0x1F48, amount) + public FireFieldScroll(int amount = 1) : base(27, 0x1F48, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/GreaterHealScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/GreaterHealScroll.cs index 4776f90a0..0b278f314 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/GreaterHealScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/GreaterHealScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class GreaterHealScroll : SpellScroll { [Constructible] - public GreaterHealScroll() : this(1) - { - } - - [Constructible] - public GreaterHealScroll(int amount) : base(28, 0x1F49, amount) + public GreaterHealScroll(int amount = 1) : base(28, 0x1F49, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/LightningScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/LightningScroll.cs index e6ea3ae4b..812e3409d 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/LightningScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/LightningScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class LightningScroll : SpellScroll { [Constructible] - public LightningScroll() : this(1) - { - } - - [Constructible] - public LightningScroll(int amount) : base(29, 0x1F4A, amount) + public LightningScroll(int amount = 1) : base(29, 0x1F4A, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ManaDrainScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ManaDrainScroll.cs index 02592afc3..c77f537e4 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ManaDrainScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/ManaDrainScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ManaDrainScroll : SpellScroll { [Constructible] - public ManaDrainScroll() : this(1) - { - } - - [Constructible] - public ManaDrainScroll(int amount) : base(30, 0x1F4B, amount) + public ManaDrainScroll(int amount = 1) : base(30, 0x1F4B, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/RecallScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/RecallScroll.cs index ae7ca9542..ec02766ff 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/RecallScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Fourth Circle/RecallScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class RecallScroll : SpellScroll { [Constructible] - public RecallScroll() : this(1) - { - } - - [Constructible] - public RecallScroll(int amount) : base(31, 0x1F4C, amount) + public RecallScroll(int amount = 1) : base(31, 0x1F4C, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/AnimatedWeaponScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/AnimatedWeaponScroll.cs index a91cf2c35..15d0bfc45 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/AnimatedWeaponScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/AnimatedWeaponScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class AnimatedWeaponScroll : SpellScroll { [Constructible] - public AnimatedWeaponScroll() - : this(1) - { - } - - [Constructible] - public AnimatedWeaponScroll(int amount) + public AnimatedWeaponScroll(int amount = 1) : base(683, 0x2DA4, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/BombardScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/BombardScroll.cs index c2915c518..767e8c7ee 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/BombardScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/BombardScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class BombardScroll : SpellScroll { [Constructible] - public BombardScroll() - : this(1) - { - } - - [Constructible] - public BombardScroll(int amount) + public BombardScroll(int amount = 1) : base(688, 0x2DA9, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/CleansingWindsScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/CleansingWindsScroll.cs index 799c0eeb2..7683236c5 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/CleansingWindsScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/CleansingWindsScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class CleansingWindsScroll : SpellScroll { [Constructible] - public CleansingWindsScroll() - : this(1) - { - } - - [Constructible] - public CleansingWindsScroll(int amount) + public CleansingWindsScroll(int amount = 1) : base(687, 0x2DA8, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EagleStrikeScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EagleStrikeScroll.cs index ca925c2c9..0535d523b 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EagleStrikeScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EagleStrikeScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class EagleStrikeScroll : SpellScroll { [Constructible] - public EagleStrikeScroll() - : this(1) - { - } - - [Constructible] - public EagleStrikeScroll(int amount) + public EagleStrikeScroll(int amount = 1) : base(682, 0x2DA3, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EnchantScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EnchantScroll.cs index 30ade7cad..aff13416a 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EnchantScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/EnchantScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class EnchantScroll : SpellScroll { [Constructible] - public EnchantScroll() - : this(1) - { - } - - [Constructible] - public EnchantScroll(int amount) + public EnchantScroll(int amount = 1) : base(680, 0x2DA1, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HailStormScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HailStormScroll.cs index 18b87ba69..b6d382385 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HailStormScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HailStormScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class HailStormScroll : SpellScroll { [Constructible] - public HailStormScroll() - : this(1) - { - } - - [Constructible] - public HailStormScroll(int amount) + public HailStormScroll(int amount = 1) : base(690, 0x2DAB, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HealingStoneScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HealingStoneScroll.cs index 8dd510fa7..3b7bb0e4e 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HealingStoneScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/HealingStoneScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class HealingStoneScroll : SpellScroll { [Constructible] - public HealingStoneScroll() - : this(1) - { - } - - [Constructible] - public HealingStoneScroll(int amount) + public HealingStoneScroll(int amount = 1) : base(678, 0x2D9F, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/MassSleepScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/MassSleepScroll.cs index c849cb1ee..3212ecdcd 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/MassSleepScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/MassSleepScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class MassSleepScroll : SpellScroll { [Constructible] - public MassSleepScroll() - : this(1) - { - } - - [Constructible] - public MassSleepScroll(int amount) + public MassSleepScroll(int amount = 1) : base(686, 0x2DA7, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherBoltScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherBoltScroll.cs index 0cca48558..f9c8d38e5 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherBoltScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherBoltScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class NetherBoltScroll : SpellScroll { [Constructible] - public NetherBoltScroll() - : this(1) - { - } - - [Constructible] - public NetherBoltScroll(int amount) + public NetherBoltScroll(int amount = 1) : base(677, 0x2D9E, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherCycloneScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherCycloneScroll.cs index 320aae763..14ff2eb51 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherCycloneScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/NetherCycloneScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class NetherCycloneScroll : SpellScroll { [Constructible] - public NetherCycloneScroll() - : this(1) - { - } - - [Constructible] - public NetherCycloneScroll(int amount) + public NetherCycloneScroll(int amount = 1) : base(691, 0x2DAC, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/PurgeMagicScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/PurgeMagicScroll.cs index 7a313035d..2f495c281 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/PurgeMagicScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/PurgeMagicScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class PurgeMagicScroll : SpellScroll { [Constructible] - public PurgeMagicScroll() - : this(1) - { - } - - [Constructible] - public PurgeMagicScroll(int amount) + public PurgeMagicScroll(int amount = 1) : base(679, 0x2DA0, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/RisingColossusScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/RisingColossusScroll.cs index 1a364fdfc..cc7a2c92e 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/RisingColossusScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/RisingColossusScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class RisingColossusScroll : SpellScroll { [Constructible] - public RisingColossusScroll() - : this(1) - { - } - - [Constructible] - public RisingColossusScroll(int amount) + public RisingColossusScroll(int amount = 1) : base(692, 0x2DAD, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SleepScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SleepScroll.cs index 1e102867e..edcc2bcd5 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SleepScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SleepScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class SleepScroll : SpellScroll { [Constructible] - public SleepScroll() - : this(1) - { - } - - [Constructible] - public SleepScroll(int amount) + public SleepScroll(int amount = 1) : base(681, 0x2DA2, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellPlagueScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellPlagueScroll.cs index 4cc306f8a..45389f32c 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellPlagueScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellPlagueScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class SpellPlagueScroll : SpellScroll { [Constructible] - public SpellPlagueScroll() - : this(1) - { - } - - [Constructible] - public SpellPlagueScroll(int amount) + public SpellPlagueScroll(int amount = 1) : base(689, 0x2DAA, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellTriggerScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellTriggerScroll.cs index facc8063c..e8c9dbd1d 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellTriggerScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/SpellTriggerScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class SpellTriggerScroll : SpellScroll { [Constructible] - public SpellTriggerScroll() - : this(1) - { - } - - [Constructible] - public SpellTriggerScroll(int amount) + public SpellTriggerScroll(int amount = 1) : base(685, 0x2DA6, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/StoneFormScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/StoneFormScroll.cs index 7baf86c43..9b5cdacf4 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/StoneFormScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Mysticism/StoneFormScroll.cs @@ -3,13 +3,7 @@ namespace Server.Items public class StoneFormScroll : SpellScroll { [Constructible] - public StoneFormScroll() - : this(1) - { - } - - [Constructible] - public StoneFormScroll(int amount) + public StoneFormScroll(int amount = 1) : base(684, 0x2DA5, amount) { } @@ -34,4 +28,4 @@ namespace Server.Items reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/AnimateDeadScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/AnimateDeadScroll.cs index c1667d406..2984607e9 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/AnimateDeadScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/AnimateDeadScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class AnimateDeadScroll : SpellScroll { [Constructible] - public AnimateDeadScroll() : this(1) - { - } - - [Constructible] - public AnimateDeadScroll(int amount) : base(100, 0x2260, amount) + public AnimateDeadScroll(int amount = 1) : base(100, 0x2260, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/BloodOathScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/BloodOathScroll.cs index 28a45013d..217808048 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/BloodOathScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/BloodOathScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BloodOathScroll : SpellScroll { [Constructible] - public BloodOathScroll() : this(1) - { - } - - [Constructible] - public BloodOathScroll(int amount) : base(101, 0x2261, amount) + public BloodOathScroll(int amount = 1) : base(101, 0x2261, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CorpseSkinScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CorpseSkinScroll.cs index 3560736e1..2ce5ca3d3 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CorpseSkinScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CorpseSkinScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class CorpseSkinScroll : SpellScroll { [Constructible] - public CorpseSkinScroll() : this(1) - { - } - - [Constructible] - public CorpseSkinScroll(int amount) : base(102, 0x2262, amount) + public CorpseSkinScroll(int amount = 1) : base(102, 0x2262, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CurseWeaponScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CurseWeaponScroll.cs index cabcf4666..9f23df475 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CurseWeaponScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/CurseWeaponScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class CurseWeaponScroll : SpellScroll { [Constructible] - public CurseWeaponScroll() : this(1) - { - } - - [Constructible] - public CurseWeaponScroll(int amount) : base(103, 0x2263, amount) + public CurseWeaponScroll(int amount = 1) : base(103, 0x2263, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/EvilOmenScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/EvilOmenScroll.cs index a90ddb7ca..e1954d24d 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/EvilOmenScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/EvilOmenScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class EvilOmenScroll : SpellScroll { [Constructible] - public EvilOmenScroll() : this(1) - { - } - - [Constructible] - public EvilOmenScroll(int amount) : base(104, 0x2264, amount) + public EvilOmenScroll(int amount = 1) : base(104, 0x2264, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/ExorcismScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/ExorcismScroll.cs index 0a439d3eb..a7110ff46 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/ExorcismScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/ExorcismScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ExorcismScroll : SpellScroll { [Constructible] - public ExorcismScroll() : this(1) - { - } - - [Constructible] - public ExorcismScroll(int amount) : base(116, 0x2270, amount) + public ExorcismScroll(int amount = 1) : base(116, 0x2270, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/HorrificBeastScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/HorrificBeastScroll.cs index 6f4193133..c21e4e427 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/HorrificBeastScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/HorrificBeastScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class HorrificBeastScroll : SpellScroll { [Constructible] - public HorrificBeastScroll() : this(1) - { - } - - [Constructible] - public HorrificBeastScroll(int amount) : base(105, 0x2265, amount) + public HorrificBeastScroll(int amount = 1) : base(105, 0x2265, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/LichFormScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/LichFormScroll.cs index 18bc20215..4b6f4afae 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/LichFormScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/LichFormScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class LichFormScroll : SpellScroll { [Constructible] - public LichFormScroll() : this(1) - { - } - - [Constructible] - public LichFormScroll(int amount) : base(106, 0x2266, amount) + public LichFormScroll(int amount = 1) : base(106, 0x2266, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/MindRotScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/MindRotScroll.cs index ecc6a6770..3c958700f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/MindRotScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/MindRotScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MindRotScroll : SpellScroll { [Constructible] - public MindRotScroll() : this(1) - { - } - - [Constructible] - public MindRotScroll(int amount) : base(107, 0x2267, amount) + public MindRotScroll(int amount = 1) : base(107, 0x2267, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PainSpikeScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PainSpikeScroll.cs index c763d542d..48496cbb9 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PainSpikeScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PainSpikeScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PainSpikeScroll : SpellScroll { [Constructible] - public PainSpikeScroll() : this(1) - { - } - - [Constructible] - public PainSpikeScroll(int amount) : base(108, 0x2268, amount) + public PainSpikeScroll(int amount = 1) : base(108, 0x2268, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PoisonStrikeScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PoisonStrikeScroll.cs index c07da0cf3..598718fb3 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PoisonStrikeScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/PoisonStrikeScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PoisonStrikeScroll : SpellScroll { [Constructible] - public PoisonStrikeScroll() : this(1) - { - } - - [Constructible] - public PoisonStrikeScroll(int amount) : base(109, 0x2269, amount) + public PoisonStrikeScroll(int amount = 1) : base(109, 0x2269, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/StrangleScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/StrangleScroll.cs index 1ba75a170..d67debda0 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/StrangleScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/StrangleScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class StrangleScroll : SpellScroll { [Constructible] - public StrangleScroll() : this(1) - { - } - - [Constructible] - public StrangleScroll(int amount) : base(110, 0x226A, amount) + public StrangleScroll(int amount = 1) : base(110, 0x226A, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/SummonFamiliarScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/SummonFamiliarScroll.cs index 8ffda47b2..bea45ef17 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/SummonFamiliarScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/SummonFamiliarScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SummonFamiliarScroll : SpellScroll { [Constructible] - public SummonFamiliarScroll() : this(1) - { - } - - [Constructible] - public SummonFamiliarScroll(int amount) : base(111, 0x226B, amount) + public SummonFamiliarScroll(int amount = 1) : base(111, 0x226B, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VampiricEmbraceScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VampiricEmbraceScroll.cs index f5e0cf657..fc0715132 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VampiricEmbraceScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VampiricEmbraceScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class VampiricEmbraceScroll : SpellScroll { [Constructible] - public VampiricEmbraceScroll() : this(1) - { - } - - [Constructible] - public VampiricEmbraceScroll(int amount) : base(112, 0x226C, amount) + public VampiricEmbraceScroll(int amount = 1) : base(112, 0x226C, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VengefulSpiritScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VengefulSpiritScroll.cs index c3c85c504..dad2901f1 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VengefulSpiritScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/VengefulSpiritScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class VengefulSpiritScroll : SpellScroll { [Constructible] - public VengefulSpiritScroll() : this(1) - { - } - - [Constructible] - public VengefulSpiritScroll(int amount) : base(113, 0x226D, amount) + public VengefulSpiritScroll(int amount = 1) : base(113, 0x226D, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WitherScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WitherScroll.cs index 22f44258f..cfdbea58d 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WitherScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WitherScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class WitherScroll : SpellScroll { [Constructible] - public WitherScroll() : this(1) - { - } - - [Constructible] - public WitherScroll(int amount) : base(114, 0x226E, amount) + public WitherScroll(int amount = 1) : base(114, 0x226E, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WraithFormScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WraithFormScroll.cs index bac25f917..4f8e18668 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WraithFormScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Necromancy/WraithFormScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class WraithFormScroll : SpellScroll { [Constructible] - public WraithFormScroll() : this(1) - { - } - - [Constructible] - public WraithFormScroll(int amount) : base(115, 0x226F, amount) + public WraithFormScroll(int amount = 1) : base(115, 0x226F, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/AgilityScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/AgilityScroll.cs index b0c0a6f58..7125477bd 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/AgilityScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/AgilityScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class AgilityScroll : SpellScroll { [Constructible] - public AgilityScroll() : this(1) - { - } - - [Constructible] - public AgilityScroll(int amount) : base(8, 0x1F35, amount) + public AgilityScroll(int amount = 1) : base(8, 0x1F35, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CunningScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CunningScroll.cs index 6ccda1a8d..8d62f6c01 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CunningScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CunningScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class CunningScroll : SpellScroll { [Constructible] - public CunningScroll() : this(1) - { - } - - [Constructible] - public CunningScroll(int amount) : base(9, 0x1F36, amount) + public CunningScroll(int amount = 1) : base(9, 0x1F36, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CureScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CureScroll.cs index 956344220..55e495b5f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CureScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/CureScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class CureScroll : SpellScroll { [Constructible] - public CureScroll() : this(1) - { - } - - [Constructible] - public CureScroll(int amount) : base(10, 0x1F37, amount) + public CureScroll(int amount = 1) : base(10, 0x1F37, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/HarmScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/HarmScroll.cs index 4d295fb72..a09fecd81 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/HarmScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/HarmScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class HarmScroll : SpellScroll { [Constructible] - public HarmScroll() : this(1) - { - } - - [Constructible] - public HarmScroll(int amount) : base(11, 0x1F38, amount) + public HarmScroll(int amount = 1) : base(11, 0x1F38, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicTrapScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicTrapScroll.cs index 3ab44a402..c955b0edb 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicTrapScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicTrapScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MagicTrapScroll : SpellScroll { [Constructible] - public MagicTrapScroll() : this(1) - { - } - - [Constructible] - public MagicTrapScroll(int amount) : base(12, 0x1F39, amount) + public MagicTrapScroll(int amount = 1) : base(12, 0x1F39, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicUnTrapScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicUnTrapScroll.cs index 165fd199f..1fa5ba663 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicUnTrapScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/MagicUnTrapScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MagicUnTrapScroll : SpellScroll { [Constructible] - public MagicUnTrapScroll() : this(1) - { - } - - [Constructible] - public MagicUnTrapScroll(int amount) : base(13, 0x1F3A, amount) + public MagicUnTrapScroll(int amount = 1) : base(13, 0x1F3A, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/ProtectionScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/ProtectionScroll.cs index 423909ad4..477c44d45 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/ProtectionScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/ProtectionScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ProtectionScroll : SpellScroll { [Constructible] - public ProtectionScroll() : this(1) - { - } - - [Constructible] - public ProtectionScroll(int amount) : base(14, 0x1F3B, amount) + public ProtectionScroll(int amount = 1) : base(14, 0x1F3B, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/StrengthScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/StrengthScroll.cs index 001a1576c..1327eebbc 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/StrengthScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Second Circle/StrengthScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class StrengthScroll : SpellScroll { [Constructible] - public StrengthScroll() : this(1) - { - } - - [Constructible] - public StrengthScroll(int amount) : base(15, 0x1F3C, amount) + public StrengthScroll(int amount = 1) : base(15, 0x1F3C, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ChainLightningScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ChainLightningScroll.cs index e7fb19a33..f2e6febdb 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ChainLightningScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ChainLightningScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ChainLightningScroll : SpellScroll { [Constructible] - public ChainLightningScroll() : this(1) - { - } - - [Constructible] - public ChainLightningScroll(int amount) : base(48, 0x1F5D, amount) + public ChainLightningScroll(int amount = 1) : base(48, 0x1F5D, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/EnergyFieldScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/EnergyFieldScroll.cs index 3a8d5f8b0..d9f20e01f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/EnergyFieldScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/EnergyFieldScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class EnergyFieldScroll : SpellScroll { [Constructible] - public EnergyFieldScroll() : this(1) - { - } - - [Constructible] - public EnergyFieldScroll(int amount) : base(49, 0x1F5E, amount) + public EnergyFieldScroll(int amount = 1) : base(49, 0x1F5E, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/FlamestrikeScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/FlamestrikeScroll.cs index 96b6c1fe7..b0724ca2a 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/FlamestrikeScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/FlamestrikeScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class FlamestrikeScroll : SpellScroll { [Constructible] - public FlamestrikeScroll() : this(1) - { - } - - [Constructible] - public FlamestrikeScroll(int amount) : base(50, 0x1F5F, amount) + public FlamestrikeScroll(int amount = 1) : base(50, 0x1F5F, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/GateTravelScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/GateTravelScroll.cs index 39ee11534..4767fb015 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/GateTravelScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/GateTravelScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class GateTravelScroll : SpellScroll { [Constructible] - public GateTravelScroll() : this(1) - { - } - - [Constructible] - public GateTravelScroll(int amount) : base(51, 0x1F60, amount) + public GateTravelScroll(int amount = 1) : base(51, 0x1F60, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ManaVampireScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ManaVampireScroll.cs index 6fb6838ef..3cd04ef52 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ManaVampireScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/ManaVampireScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ManaVampireScroll : SpellScroll { [Constructible] - public ManaVampireScroll() : this(1) - { - } - - [Constructible] - public ManaVampireScroll(int amount) : base(52, 0x1F61, amount) + public ManaVampireScroll(int amount = 1) : base(52, 0x1F61, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MassDispelScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MassDispelScroll.cs index 57c492764..33e734591 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MassDispelScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MassDispelScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MassDispelScroll : SpellScroll { [Constructible] - public MassDispelScroll() : this(1) - { - } - - [Constructible] - public MassDispelScroll(int amount) : base(53, 0x1F62, amount) + public MassDispelScroll(int amount = 1) : base(53, 0x1F62, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MeteorStormScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MeteorStormScroll.cs index f4318728d..194f642f2 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MeteorStormScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/MeteorStormScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MeteorSwarmScroll : SpellScroll { [Constructible] - public MeteorSwarmScroll() : this(1) - { - } - - [Constructible] - public MeteorSwarmScroll(int amount) : base(54, 0x1F63, amount) + public MeteorSwarmScroll(int amount = 1) : base(54, 0x1F63, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/PolymorphScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/PolymorphScroll.cs index 9c268a57f..81865bc94 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/PolymorphScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Seventh Circle/PolymorphScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PolymorphScroll : SpellScroll { [Constructible] - public PolymorphScroll() : this(1) - { - } - - [Constructible] - public PolymorphScroll(int amount) : base(55, 0x1F64, amount) + public PolymorphScroll(int amount = 1) : base(55, 0x1F64, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/DispelScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/DispelScroll.cs index 78d98f302..10d490ac0 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/DispelScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/DispelScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class DispelScroll : SpellScroll { [Constructible] - public DispelScroll() : this(1) - { - } - - [Constructible] - public DispelScroll(int amount) : base(40, 0x1F55, amount) + public DispelScroll(int amount = 1) : base(40, 0x1F55, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/EnergyBoltScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/EnergyBoltScroll.cs index f3296f073..4a18f7edb 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/EnergyBoltScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/EnergyBoltScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class EnergyBoltScroll : SpellScroll { [Constructible] - public EnergyBoltScroll() : this(1) - { - } - - [Constructible] - public EnergyBoltScroll(int amount) : base(41, 0x1F56, amount) + public EnergyBoltScroll(int amount = 1) : base(41, 0x1F56, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ExplosionScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ExplosionScroll.cs index cf380e190..9445a79c9 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ExplosionScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ExplosionScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ExplosionScroll : SpellScroll { [Constructible] - public ExplosionScroll() : this(1) - { - } - - [Constructible] - public ExplosionScroll(int amount) : base(42, 0x1F57, amount) + public ExplosionScroll(int amount = 1) : base(42, 0x1F57, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/InvisibilityScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/InvisibilityScroll.cs index 5edf03b1c..0e55bd8e5 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/InvisibilityScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/InvisibilityScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class InvisibilityScroll : SpellScroll { [Constructible] - public InvisibilityScroll() : this(1) - { - } - - [Constructible] - public InvisibilityScroll(int amount) : base(43, 0x1F58, amount) + public InvisibilityScroll(int amount = 1) : base(43, 0x1F58, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MarkScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MarkScroll.cs index 38e97dbae..b14df6f7b 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MarkScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MarkScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MarkScroll : SpellScroll { [Constructible] - public MarkScroll() : this(1) - { - } - - [Constructible] - public MarkScroll(int amount) : base(44, 0x1F59, amount) + public MarkScroll(int amount = 1) : base(44, 0x1F59, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MassCurseScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MassCurseScroll.cs index 46a3a7d47..5ae537d51 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MassCurseScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/MassCurseScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MassCurseScroll : SpellScroll { [Constructible] - public MassCurseScroll() : this(1) - { - } - - [Constructible] - public MassCurseScroll(int amount) : base(45, 0x1F5A, amount) + public MassCurseScroll(int amount = 1) : base(45, 0x1F5A, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ParalyzeFieldSpell.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ParalyzeFieldSpell.cs index 009af8e9b..4d9eafea5 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ParalyzeFieldSpell.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/ParalyzeFieldSpell.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ParalyzeFieldScroll : SpellScroll { [Constructible] - public ParalyzeFieldScroll() : this(1) - { - } - - [Constructible] - public ParalyzeFieldScroll(int amount) : base(46, 0x1F5B, amount) + public ParalyzeFieldScroll(int amount = 1) : base(46, 0x1F5B, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/RevealScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/RevealScroll.cs index 9b65b0a1c..945d0cc3b 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/RevealScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Sixth Circle/RevealScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class RevealScroll : SpellScroll { [Constructible] - public RevealScroll() : this(1) - { - } - - [Constructible] - public RevealScroll(int amount) : base(47, 0x1F5C, amount) + public RevealScroll(int amount = 1) : base(47, 0x1F5C, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs index 8ffb6c2b6..dbb420038 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs @@ -7,17 +7,8 @@ namespace Server.Items { public class SpellScroll : Item, ICommodity { - public SpellScroll(Serial serial) : base(serial) - { - } - [Constructible] - public SpellScroll(int spellID, int itemID) : this(spellID, itemID, 1) - { - } - - [Constructible] - public SpellScroll(int spellID, int itemID, int amount) : base(itemID) + public SpellScroll(int spellID, int itemID, int amount = 1) : base(itemID) { Stackable = true; Weight = 1.0; @@ -26,6 +17,10 @@ namespace Server.Items SpellID = spellID; } + public SpellScroll(Serial serial) : base(serial) + { + } + public int SpellID{ get; private set; } int ICommodity.DescriptionNumber => LabelNumber; @@ -84,4 +79,4 @@ namespace Server.Items from.SendLocalizedMessage(502345); // This spell has been temporarily disabled. } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/SpellweavingScrolls.cs b/Scripts/Items/Skill Items/Magical/Scrolls/SpellweavingScrolls.cs index 921180059..6e48cba52 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/SpellweavingScrolls.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/SpellweavingScrolls.cs @@ -3,13 +3,7 @@ namespace Server.Items public class ArcaneCircleScroll : SpellScroll { [Constructible] - public ArcaneCircleScroll() - : this(1) - { - } - - [Constructible] - public ArcaneCircleScroll(int amount) + public ArcaneCircleScroll(int amount = 1) : base(600, 0x2D51, amount) { Hue = 0x8FD; @@ -38,13 +32,7 @@ namespace Server.Items public class GiftOfRenewalScroll : SpellScroll { [Constructible] - public GiftOfRenewalScroll() - : this(1) - { - } - - [Constructible] - public GiftOfRenewalScroll(int amount) + public GiftOfRenewalScroll(int amount = 1) : base(601, 0x2D52, amount) { Hue = 0x8FD; @@ -73,13 +61,7 @@ namespace Server.Items public class ImmolatingWeaponScroll : SpellScroll { [Constructible] - public ImmolatingWeaponScroll() - : this(1) - { - } - - [Constructible] - public ImmolatingWeaponScroll(int amount) + public ImmolatingWeaponScroll(int amount = 1) : base(602, 0x2D53, amount) { Hue = 0x8FD; @@ -108,13 +90,7 @@ namespace Server.Items public class AttuneWeaponScroll : SpellScroll { [Constructible] - public AttuneWeaponScroll() - : this(1) - { - } - - [Constructible] - public AttuneWeaponScroll(int amount) + public AttuneWeaponScroll(int amount = 1) : base(603, 0x2D54, amount) { Hue = 0x8FD; @@ -143,13 +119,7 @@ namespace Server.Items public class ThunderstormScroll : SpellScroll { [Constructible] - public ThunderstormScroll() - : this(1) - { - } - - [Constructible] - public ThunderstormScroll(int amount) + public ThunderstormScroll(int amount = 1) : base(604, 0x2D55, amount) { Hue = 0x8FD; @@ -178,13 +148,7 @@ namespace Server.Items public class NatureFuryScroll : SpellScroll { [Constructible] - public NatureFuryScroll() - : this(1) - { - } - - [Constructible] - public NatureFuryScroll(int amount) + public NatureFuryScroll(int amount = 1) : base(605, 0x2D56, amount) { Hue = 0x8FD; @@ -213,13 +177,7 @@ namespace Server.Items public class SummonFeyScroll : SpellScroll { [Constructible] - public SummonFeyScroll() - : this(1) - { - } - - [Constructible] - public SummonFeyScroll(int amount) + public SummonFeyScroll(int amount = 1) : base(606, 0x2D57, amount) { Hue = 0x8FD; @@ -248,13 +206,7 @@ namespace Server.Items public class SummonFiendScroll : SpellScroll { [Constructible] - public SummonFiendScroll() - : this(1) - { - } - - [Constructible] - public SummonFiendScroll(int amount) + public SummonFiendScroll(int amount = 1) : base(607, 0x2D58, amount) { Hue = 0x8FD; @@ -283,13 +235,7 @@ namespace Server.Items public class ReaperFormScroll : SpellScroll { [Constructible] - public ReaperFormScroll() - : this(1) - { - } - - [Constructible] - public ReaperFormScroll(int amount) + public ReaperFormScroll(int amount = 1) : base(608, 0x2D59, amount) { Hue = 0x8FD; @@ -318,13 +264,7 @@ namespace Server.Items public class WildfireScroll : SpellScroll { [Constructible] - public WildfireScroll() - : this(1) - { - } - - [Constructible] - public WildfireScroll(int amount) + public WildfireScroll(int amount = 1) : base(609, 0x2D5A, amount) { Hue = 0x8FD; @@ -353,13 +293,7 @@ namespace Server.Items public class EssenceOfWindScroll : SpellScroll { [Constructible] - public EssenceOfWindScroll() - : this(1) - { - } - - [Constructible] - public EssenceOfWindScroll(int amount) + public EssenceOfWindScroll(int amount = 1) : base(610, 0x2D5B, amount) { Hue = 0x8FD; @@ -388,13 +322,7 @@ namespace Server.Items public class DryadAllureScroll : SpellScroll { [Constructible] - public DryadAllureScroll() - : this(1) - { - } - - [Constructible] - public DryadAllureScroll(int amount) + public DryadAllureScroll(int amount = 1) : base(611, 0x2D5C, amount) { Hue = 0x8FD; @@ -423,13 +351,7 @@ namespace Server.Items public class EtherealVoyageScroll : SpellScroll { [Constructible] - public EtherealVoyageScroll() - : this(1) - { - } - - [Constructible] - public EtherealVoyageScroll(int amount) + public EtherealVoyageScroll(int amount = 1) : base(612, 0x2D5D, amount) { Hue = 0x8FD; @@ -458,13 +380,7 @@ namespace Server.Items public class WordOfDeathScroll : SpellScroll { [Constructible] - public WordOfDeathScroll() - : this(1) - { - } - - [Constructible] - public WordOfDeathScroll(int amount) + public WordOfDeathScroll(int amount = 1) : base(613, 0x2D5E, amount) { Hue = 0x8FD; @@ -493,13 +409,7 @@ namespace Server.Items public class GiftOfLifeScroll : SpellScroll { [Constructible] - public GiftOfLifeScroll() - : this(1) - { - } - - [Constructible] - public GiftOfLifeScroll(int amount) + public GiftOfLifeScroll(int amount = 1) : base(614, 0x2D5F, amount) { Hue = 0x8FD; @@ -528,13 +438,7 @@ namespace Server.Items public class ArcaneEmpowermentScroll : SpellScroll { [Constructible] - public ArcaneEmpowermentScroll() - : this(1) - { - } - - [Constructible] - public ArcaneEmpowermentScroll(int amount) + public ArcaneEmpowermentScroll(int amount = 1) : base(615, 0x2D60, amount) { Hue = 0x8FD; @@ -559,4 +463,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/BlessScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/BlessScroll.cs index d465bb2d1..95475578d 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/BlessScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/BlessScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BlessScroll : SpellScroll { [Constructible] - public BlessScroll() : this(1) - { - } - - [Constructible] - public BlessScroll(int amount) : base(16, 0x1F3D, amount) + public BlessScroll(int amount = 1) : base(16, 0x1F3D, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/FireballScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/FireballScroll.cs index cc405f4e7..1d9b3e256 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/FireballScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/FireballScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class FireballScroll : SpellScroll { [Constructible] - public FireballScroll() : this(1) - { - } - - [Constructible] - public FireballScroll(int amount) : base(17, 0x1F3E, amount) + public FireballScroll(int amount = 1) : base(17, 0x1F3E, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/MagicLockScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/MagicLockScroll.cs index eba14df08..d9e991d91 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/MagicLockScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/MagicLockScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class MagicLockScroll : SpellScroll { [Constructible] - public MagicLockScroll() : this(1) - { - } - - [Constructible] - public MagicLockScroll(int amount) : base(18, 0x1F3F, amount) + public MagicLockScroll(int amount = 1) : base(18, 0x1F3F, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/PoisonScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/PoisonScroll.cs index 9c57aeb6d..72157ff8f 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/PoisonScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/PoisonScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class PoisonScroll : SpellScroll { [Constructible] - public PoisonScroll() : this(1) - { - } - - [Constructible] - public PoisonScroll(int amount) : base(19, 0x1F40, amount) + public PoisonScroll(int amount = 1) : base(19, 0x1F40, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TelekinisisScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TelekinisisScroll.cs index 9a872fa1f..ed89017e3 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TelekinisisScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TelekinisisScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class TelekinisisScroll : SpellScroll { [Constructible] - public TelekinisisScroll() : this(1) - { - } - - [Constructible] - public TelekinisisScroll(int amount) : base(20, 0x1F41, amount) + public TelekinisisScroll(int amount = 1) : base(20, 0x1F41, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TeleportScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TeleportScroll.cs index e99460c98..44b2d1d43 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TeleportScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/TeleportScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class TeleportScroll : SpellScroll { [Constructible] - public TeleportScroll() : this(1) - { - } - - [Constructible] - public TeleportScroll(int amount) : base(21, 0x1F42, amount) + public TeleportScroll(int amount = 1) : base(21, 0x1F42, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/UnlockScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/UnlockScroll.cs index 0e7de86b0..8c36b8277 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/UnlockScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/UnlockScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class UnlockScroll : SpellScroll { [Constructible] - public UnlockScroll() : this(1) - { - } - - [Constructible] - public UnlockScroll(int amount) : base(22, 0x1F43, amount) + public UnlockScroll(int amount = 1) : base(22, 0x1F43, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/WallOfStoneScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/WallOfStoneScroll.cs index d2ae27fd4..ea5596fd6 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/WallOfStoneScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/Third Circle/WallOfStoneScroll.cs @@ -3,12 +3,7 @@ namespace Server.Items public class WallOfStoneScroll : SpellScroll { [Constructible] - public WallOfStoneScroll() : this(1) - { - } - - [Constructible] - public WallOfStoneScroll(int amount) : base(23, 0x1F44, amount) + public WallOfStoneScroll(int amount = 1) : base(23, 0x1F44, amount) { } @@ -30,4 +25,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Scripts/Items/Skill Items/Magical/Spellbook.cs index f4416b20c..ca2e19308 100644 --- a/Scripts/Items/Skill Items/Magical/Spellbook.cs +++ b/Scripts/Items/Skill Items/Magical/Spellbook.cs @@ -79,17 +79,7 @@ namespace Server.Items private SlayerName m_Slayer; private SlayerName m_Slayer2; - [Constructible] - public Spellbook() : this((ulong)0) - { - } - - [Constructible] - public Spellbook(ulong content) : this(content, 0xEFA) - { - } - - public Spellbook(ulong content, int itemID) : base(itemID) + public Spellbook(ulong content = 0, int itemID = 0xEFA) : base(itemID) { Attributes = new AosAttributes(this); SkillBonuses = new AosSkillBonuses(this); @@ -337,10 +327,10 @@ namespace Server.Items Spellbook book = e.Spellbook as Spellbook; int spellID = e.SpellID; - if (book == null || !book.HasSpell(spellID)) + if (book?.HasSpell(spellID) != true) book = Find(from, spellID); - if (book != null && book.HasSpell(spellID)) + if (book?.HasSpell(spellID) == true) { SpecialMove move = SpellRegistry.GetSpecialMove(spellID); @@ -479,22 +469,17 @@ namespace Server.Items { List list = new List(); - Item item = from.FindItemOnLayer(Layer.OneHanded); + Spellbook spellbook = FindEquippedSpellbook(from); - if (item is Spellbook spellbook) + if (spellbook != null) list.Add(spellbook); Container pack = from.Backpack; - if (pack == null) - return list; - - for (int i = 0; i < pack.Items.Count; ++i) + for (int i = 0; i < pack?.Items.Count; ++i) { - item = pack.Items[i]; - - if (item is Spellbook spellbook1) - list.Add(spellbook1); + if (pack.Items[i] is Spellbook sp) + list.Add(sp); } return list; diff --git a/Scripts/Items/Skill Items/Magical/SpellweavingBook.cs b/Scripts/Items/Skill Items/Magical/SpellweavingBook.cs index 92887eb0c..956bb9704 100644 --- a/Scripts/Items/Skill Items/Magical/SpellweavingBook.cs +++ b/Scripts/Items/Skill Items/Magical/SpellweavingBook.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SpellweavingBook : Spellbook { [Constructible] - public SpellweavingBook() : this((ulong)0) - { - } - - [Constructible] - public SpellweavingBook(ulong content) : base(content, 0x2D50) + public SpellweavingBook(ulong content = 0) : base(content, 0x2D50) { Hue = 0x8A2; @@ -37,4 +32,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Misc/Bandage.cs b/Scripts/Items/Skill Items/Misc/Bandage.cs index 534f5e7dd..7d93906f6 100644 --- a/Scripts/Items/Skill Items/Misc/Bandage.cs +++ b/Scripts/Items/Skill Items/Misc/Bandage.cs @@ -13,12 +13,7 @@ namespace Server.Items public static int Range = Core.AOS ? 2 : 1; [Constructible] - public Bandage() : this(1) - { - } - - [Constructible] - public Bandage(int amount) : base(0xE21) + public Bandage(int amount = 1) : base(0xE21) { Stackable = true; Amount = amount; @@ -84,16 +79,13 @@ namespace Server.Items if (from.InRange(b.GetWorldLocation(), Range)) { - Target t = from.Target; - - if (t != null) + if (from.Target != null) { Target.Cancel(from); from.Target = null; } from.RevealingAction(); - from.SendLocalizedMessage(500948); // Who will you use the bandages on? new InternalTarget(b).Invoke(from, e.Target); @@ -122,9 +114,8 @@ namespace Server.Items { if (from.InRange(m_Bandage.GetWorldLocation(), Bandage.Range)) { - if (BandageContext.BeginHeal(from, mobile) != null) - if (!DuelContext.IsFreeConsume(from)) - m_Bandage.Consume(); + if (!(BandageContext.BeginHeal(from, mobile) == null || DuelContext.IsFreeConsume(from))) + m_Bandage.Consume(); } else { @@ -187,9 +178,7 @@ namespace Server.Items public void StopHeal() { m_Table.Remove(Healer); - Timer?.Stop(); - Timer = null; } @@ -238,7 +227,7 @@ namespace Server.Items patientNumber = -1; playSound = false; } - else if (!Patient.Alive || petPatient != null && petPatient.IsDeadPet) + else if (!Patient.Alive || petPatient?.IsDeadPet == true) { double healing = Healer.Skills[primarySkill].Value; double anatomy = Healer.Skills[secondarySkill].Value; @@ -267,7 +256,7 @@ namespace Server.Items Patient.PlaySound(0x214); Patient.FixedEffect(0x376A, 10, 16); - if (petPatient != null && petPatient.IsDeadPet) + if (petPatient?.IsDeadPet == true) { Mobile master = petPatient.ControlMaster; @@ -277,7 +266,7 @@ namespace Server.Items for (int i = 0; i < petPatient.Skills.Length; ++i) petPatient.Skills[i].Base -= 0.1; } - else if (master != null && master.InRange(petPatient, 3)) + else if (master?.InRange(petPatient, 3) == true) { healerNumber = 503255; // You are able to resurrect the creature. @@ -319,7 +308,7 @@ namespace Server.Items } else { - if (petPatient != null && petPatient.IsDeadPet) + if (petPatient?.IsDeadPet == true) healerNumber = 503256; // You fail to resurrect the creature. else healerNumber = 500966; // You are unable to resurrect your patient. @@ -536,4 +525,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Misc/FireHorn.cs b/Scripts/Items/Skill Items/Misc/FireHorn.cs index 5bc95ba17..beb1b5975 100644 --- a/Scripts/Items/Skill Items/Misc/FireHorn.cs +++ b/Scripts/Items/Skill Items/Misc/FireHorn.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Network; using Server.Spells; using Server.Targeting; @@ -38,14 +39,11 @@ namespace Server.Items return false; } - int sulfAsh = Core.AOS ? 4 : 15; - if (from.Backpack == null || from.Backpack.GetAmount(typeof(SulfurousAsh)) < sulfAsh) - { - from.SendLocalizedMessage(1049617); // You do not have enough sulfurous ash. - return false; - } + if (from.Backpack?.GetAmount(typeof(SulfurousAsh)) >= (Core.AOS ? 4 : 15)) + return true; - return true; + from.SendLocalizedMessage(1049617); // You do not have enough sulfurous ash. + return false; } public override void OnDoubleClick(Mobile from) @@ -85,22 +83,21 @@ namespace Server.Items new HuedEffect(EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0, 0)); - List targets = new List(); - bool playerVsPlayer = false; - IPooledEnumerable eable = from.Map.GetMobilesInRange(new Point3D(loc), 2); - foreach (Mobile m in eable) - if (from != m && SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false)) - { - if (Core.AOS && !from.InLOS(m)) - continue; + bool playerVsPlayer = false; + List targets = eable.Where(m => + { + if (from == m || !SpellHelper.ValidIndirectTarget(from, m) || !from.CanBeHarmful(m, false) + || Core.AOS && !from.InLOS(m)) + return false; - targets.Add(m); + if (m.Player) + playerVsPlayer = true; - if (m.Player) - playerVsPlayer = true; - } + return true; + + }).ToList(); eable.Free(); @@ -219,4 +216,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Misc/RecipeScroll.cs b/Scripts/Items/Skill Items/Misc/RecipeScroll.cs index d811eaa90..65e13ecb8 100644 --- a/Scripts/Items/Skill Items/Misc/RecipeScroll.cs +++ b/Scripts/Items/Skill Items/Misc/RecipeScroll.cs @@ -8,14 +8,12 @@ namespace Server.Items { private int m_RecipeID; - public RecipeScroll(Recipe r) - : this(r.ID) + public RecipeScroll(Recipe r) : this(r.ID) { } [Constructible] - public RecipeScroll(int recipeID) - : base(0x2831) + public RecipeScroll(int recipeID) : base(0x2831) { m_RecipeID = recipeID; } diff --git a/Scripts/Items/Skill Items/Misc/RepairDeed.cs b/Scripts/Items/Skill Items/Misc/RepairDeed.cs index a9ee0fd13..89f0c4139 100644 --- a/Scripts/Items/Skill Items/Misc/RepairDeed.cs +++ b/Scripts/Items/Skill Items/Misc/RepairDeed.cs @@ -23,26 +23,13 @@ namespace Server.Items private double m_SkillLevel; [Constructible] - public RepairDeed() : this(RepairSkillType.Smithing, 100.0, null, true) + public RepairDeed(RepairSkillType skill, double level, bool normalizeLevel) : + this(skill, level, null, normalizeLevel) { } - [Constructible] - public RepairDeed(RepairSkillType skill, double level) : this(skill, level, null, true) - { - } - - [Constructible] - public RepairDeed(RepairSkillType skill, double level, bool normalizeLevel) : this(skill, level, null, - normalizeLevel) - { - } - - public RepairDeed(RepairSkillType skill, double level, Mobile crafter) : this(skill, level, crafter, true) - { - } - - public RepairDeed(RepairSkillType skill, double level, Mobile crafter, bool normalizeLevel) : base(0x14F0) + public RepairDeed(RepairSkillType skill = RepairSkillType.Smithing, double level = 100.0, + Mobile crafter = null, bool normalizeLevel = true) : base(0x14F0) { if (normalizeLevel) SkillLevel = (int)(level / 10) * 10; @@ -250,4 +237,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs index 93dd08df2..a8a76404a 100644 --- a/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Craft; using Server.Mobiles; @@ -294,7 +293,7 @@ namespace Server.Items val /= 10; - if (bc != null && bc.IsParagon) + if (bc?.IsParagon == true) val += 40.0; if (Core.SE && val > 160.0) diff --git a/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs b/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs index 3a0ffd626..71f994a81 100644 --- a/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs +++ b/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs @@ -10,12 +10,7 @@ namespace Server.Items private int m_UsesRemaining; [Constructible] - public FukiyaDarts() : this(1) - { - } - - [Constructible] - public FukiyaDarts(int amount) : base(0x2806) + public FukiyaDarts(int amount = 1) : base(0x2806) { Weight = 1.0; @@ -116,4 +111,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs b/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs index 8a759a0b9..d93982b05 100644 --- a/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs +++ b/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs @@ -270,8 +270,7 @@ namespace Server.Items { Item item = weapon as Item; - if (!item.Deleted && item.RootParent == from) return true; - return false; + return !item.Deleted && item.RootParent == from; } public class LoadEntry : ContextMenuEntry diff --git a/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs b/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs index 1e522ab6f..3fe31a6ab 100644 --- a/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs +++ b/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs @@ -11,12 +11,7 @@ namespace Server.Items private int m_UsesRemaining; [Constructible] - public Shuriken() : this(1) - { - } - - [Constructible] - public Shuriken(int amount) : base(0x27AC) + public Shuriken(int amount = 1) : base(0x27AC) { Weight = 1.0; @@ -117,4 +112,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Specialized/Sand.cs b/Scripts/Items/Skill Items/Specialized/Sand.cs index d2d4dfbcc..d0f99c51c 100644 --- a/Scripts/Items/Skill Items/Specialized/Sand.cs +++ b/Scripts/Items/Skill Items/Specialized/Sand.cs @@ -4,12 +4,7 @@ namespace Server.Items public class Sand : Item, ICommodity { [Constructible] - public Sand() : this(1) - { - } - - [Constructible] - public Sand(int amount) : base(0x11EA) + public Sand(int amount = 1) : base(0x11EA) { Stackable = Core.ML; Weight = 1.0; @@ -40,4 +35,4 @@ namespace Server.Items Name = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs index 2d03683c0..55d936f8c 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs @@ -137,16 +137,16 @@ namespace Server.Items AddBackground(10, 10, 430, 430, 3000); if (m_Definition.TitleString != null) - AddHtml(20, 30, 400, 25, m_Definition.TitleString, false, false); + AddHtml(20, 30, 400, 25, m_Definition.TitleString); else if (m_Definition.Title > 0) - AddHtmlLocalized(20, 30, 400, 25, m_Definition.Title, false, false); + AddHtmlLocalized(20, 30, 400, 25, m_Definition.Title); - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 400, 200, 25, 1011036, false, false); // OKAY + AddButton(20, 400, 4005, 4007, 1); + AddHtmlLocalized(55, 400, 200, 25, 1011036); // OKAY if (m_Definition.DefaultSupported) { - AddButton(200, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddButton(200, 400, 4005, 4007, 2); AddLabel(235, 400, 0, "DEFAULT"); } } @@ -160,9 +160,9 @@ 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, false, false); + AddHtml(55, 85 + i * 25, 200, 25, groups[i].NameString); else - AddHtmlLocalized(55, 85 + i * 25, 200, 25, groups[i].Name, false, false); + AddHtmlLocalized(55, 85 + i * 25, 200, 25, groups[i].Name); } for (int i = 0; i < groups.Length; ++i) @@ -215,4 +215,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs index 4a28a7d32..1dd3920f4 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs @@ -25,7 +25,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -67,4 +67,4 @@ namespace Server.Items LootType = LootType.Blessed; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs index 018708c5f..1540a7c08 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs @@ -26,7 +26,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -65,4 +65,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs index 16ef79bca..4a2f9a02b 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs @@ -2,7 +2,7 @@ using Server.Gumps; using Server.Network; namespace Server.Items -{ +{ public class MetallicHuePicker : Gump { private CustomHuePickerCallback m_Callback; @@ -27,14 +27,14 @@ namespace Server.Items AddBackground(0, 0, 450, 450, 0x13BE); AddBackground(10, 10, 430, 430, 0xBB8); - AddHtmlLocalized(55, 400, 200, 25, 1011036, false, false); // OKAY + AddHtmlLocalized(55, 400, 200, 25, 1011036); // OKAY - AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddButton(200, 400, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddButton(20, 400, 4005, 4007, 1); + AddButton(200, 400, 4005, 4007, 2); AddLabel(235, 400, 0, "DEFAULT"); - AddHtmlLocalized(55, 25, 200, 25, 1150063, false, false); // Base/Shadow Color - AddHtmlLocalized(260, 25, 200, 25, 1150064, false, false); // Highlight Color + AddHtmlLocalized(55, 25, 200, 25, 1150063); // Base/Shadow Color + AddHtmlLocalized(260, 25, 200, 25, 1150064); // Highlight Color for (int row = 0; row < 13; row++) { @@ -74,4 +74,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs index 9f24a0101..76725a562 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs @@ -23,7 +23,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -62,4 +62,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs index 155bbf662..2dbf03023 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs @@ -26,7 +26,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -65,4 +65,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs index 4fc696206..22521aa78 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs @@ -22,7 +22,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -61,4 +61,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs index fdc58f0af..cf14e926b 100644 --- a/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs +++ b/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs @@ -26,7 +26,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -65,4 +65,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Thief/DisguiseKit.cs b/Scripts/Items/Skill Items/Thief/DisguiseKit.cs index 7b34f086b..5ce7d8084 100644 --- a/Scripts/Items/Skill Items/Thief/DisguiseKit.cs +++ b/Scripts/Items/Skill Items/Thief/DisguiseKit.cs @@ -117,13 +117,13 @@ namespace Server.Items AddBackground(100, 10, 400, 385, 2600); //
THIEF DISGUISE KIT
- AddHtmlLocalized(100, 25, 400, 35, 1011045, false, false); + AddHtmlLocalized(100, 25, 400, 35, 1011045); - AddButton(140, 353, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(172, 355, 90, 35, 1011036, false, false); // OKAY + AddButton(140, 353, 4005, 4007, 0); + AddHtmlLocalized(172, 355, 90, 35, 1011036); // OKAY - AddButton(257, 353, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(289, 355, 90, 35, 1011046, false, false); // APPLY + AddButton(257, 353, 4005, 4007, 1); + AddHtmlLocalized(289, 355, 90, 35, 1011046); // APPLY if (from.Female || from.Body.IsFemale) { @@ -148,7 +148,7 @@ namespace Server.Items if (nextPage != -1) { AddButton(155, 320, 250 + index * 2, 251 + index * 2, 0, GumpButtonType.Page, nextPage); - AddHtmlLocalized(180, 320, 150, 35, nextNumber, false, false); + AddHtmlLocalized(180, 320, 150, 35, nextNumber); } for (int i = 0; i < entries.Length; ++i) @@ -167,7 +167,7 @@ namespace Server.Items AddImage(153 + x + entry.m_OffsetX, 15 + y + entry.m_OffsetY, entry.m_GumpID); } - AddHtmlLocalized(140 + x, 72 + y, 80, 35, entry.m_Number, false, false); + AddHtmlLocalized(140 + x, 72 + y, 80, 35, entry.m_Number); AddRadio(118 + x, 73 + y, 208, 209, false, i * 2 + index); } } diff --git a/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs b/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs index daa1cd284..5220a033f 100644 --- a/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs +++ b/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs @@ -9,7 +9,7 @@ namespace Server.Items { Movable = false; - if (Instance == null || Instance.Deleted) + if (Instance?.Deleted != false) Instance = this; else base.Delete(); @@ -72,4 +72,4 @@ namespace Server.Items { } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Thief/LockPick.cs b/Scripts/Items/Skill Items/Thief/LockPick.cs index 989a624de..1221a4eb5 100644 --- a/Scripts/Items/Skill Items/Thief/LockPick.cs +++ b/Scripts/Items/Skill Items/Thief/LockPick.cs @@ -19,12 +19,7 @@ namespace Server.Items public class Lockpick : Item { [Constructible] - public Lockpick() : this(1) - { - } - - [Constructible] - public Lockpick(int amount) : base(0x14FC) + public Lockpick(int amount = 1) : base(0x14FC) { Stackable = true; Amount = amount; @@ -166,4 +161,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/Axle.cs b/Scripts/Items/Skill Items/Tinkering/Axle.cs index 3d8c98da3..364937f01 100644 --- a/Scripts/Items/Skill Items/Tinkering/Axle.cs +++ b/Scripts/Items/Skill Items/Tinkering/Axle.cs @@ -4,12 +4,7 @@ namespace Server.Items public class Axle : Item { [Constructible] - public Axle() : this(1) - { - } - - [Constructible] - public Axle(int amount) : base(0x105B) + public Axle(int amount = 1) : base(0x105B) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/AxleGears.cs b/Scripts/Items/Skill Items/Tinkering/AxleGears.cs index fdab2f161..b474810f0 100644 --- a/Scripts/Items/Skill Items/Tinkering/AxleGears.cs +++ b/Scripts/Items/Skill Items/Tinkering/AxleGears.cs @@ -4,12 +4,7 @@ namespace Server.Items public class AxleGears : Item { [Constructible] - public AxleGears() : this(1) - { - } - - [Constructible] - public AxleGears(int amount) : base(0x1051) + public AxleGears(int amount = 1) : base(0x1051) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/ClockFrame.cs b/Scripts/Items/Skill Items/Tinkering/ClockFrame.cs index 8658cbae6..8557975d9 100644 --- a/Scripts/Items/Skill Items/Tinkering/ClockFrame.cs +++ b/Scripts/Items/Skill Items/Tinkering/ClockFrame.cs @@ -4,12 +4,7 @@ namespace Server.Items public class ClockFrame : Item { [Constructible] - public ClockFrame() : this(1) - { - } - - [Constructible] - public ClockFrame(int amount) : base(0x104D) + public ClockFrame(int amount = 1) : base(0x104D) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/ClockParts.cs b/Scripts/Items/Skill Items/Tinkering/ClockParts.cs index dcb4b6318..ae59b252f 100644 --- a/Scripts/Items/Skill Items/Tinkering/ClockParts.cs +++ b/Scripts/Items/Skill Items/Tinkering/ClockParts.cs @@ -4,12 +4,7 @@ namespace Server.Items public class ClockParts : Item { [Constructible] - public ClockParts() : this(1) - { - } - - [Constructible] - public ClockParts(int amount) : base(0x104F) + public ClockParts(int amount = 1) : base(0x104F) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/Clocks.cs b/Scripts/Items/Skill Items/Tinkering/Clocks.cs index fc53ffded..2ef758a5a 100644 --- a/Scripts/Items/Skill Items/Tinkering/Clocks.cs +++ b/Scripts/Items/Skill Items/Tinkering/Clocks.cs @@ -23,12 +23,7 @@ namespace Server.Items private static DateTime WorldStart = new DateTime(1997, 9, 1); [Constructible] - public Clock() : this(0x104B) - { - } - - [Constructible] - public Clock(int itemID) : base(itemID) + public Clock(int itemID = 0x104B) : base(itemID) { Weight = 3.0; } @@ -149,11 +144,6 @@ namespace Server.Items [Flippable(0x104B, 0x104C)] public class ClockRight : Clock { - [Constructible] - public ClockRight() : base(0x104B) - { - } - public ClockRight(Serial serial) : base(serial) { } @@ -199,4 +189,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/Gears.cs b/Scripts/Items/Skill Items/Tinkering/Gears.cs index 1aaecc7b0..0e3596d46 100644 --- a/Scripts/Items/Skill Items/Tinkering/Gears.cs +++ b/Scripts/Items/Skill Items/Tinkering/Gears.cs @@ -4,12 +4,7 @@ namespace Server.Items public class Gears : Item { [Constructible] - public Gears() : this(1) - { - } - - [Constructible] - public Gears(int amount) : base(0x1053) + public Gears(int amount = 1) : base(0x1053) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/Hinge.cs b/Scripts/Items/Skill Items/Tinkering/Hinge.cs index 6dfb89d67..a235323f7 100644 --- a/Scripts/Items/Skill Items/Tinkering/Hinge.cs +++ b/Scripts/Items/Skill Items/Tinkering/Hinge.cs @@ -4,12 +4,7 @@ namespace Server.Items public class Hinge : Item { [Constructible] - public Hinge() : this(1) - { - } - - [Constructible] - public Hinge(int amount) : base(0x1055) + public Hinge(int amount = 1) : base(0x1055) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/SextantParts.cs b/Scripts/Items/Skill Items/Tinkering/SextantParts.cs index 5eeb3d0a8..18400e7d1 100644 --- a/Scripts/Items/Skill Items/Tinkering/SextantParts.cs +++ b/Scripts/Items/Skill Items/Tinkering/SextantParts.cs @@ -4,12 +4,7 @@ namespace Server.Items public class SextantParts : Item { [Constructible] - public SextantParts() : this(1) - { - } - - [Constructible] - public SextantParts(int amount) : base(0x1059) + public SextantParts(int amount = 1) : base(0x1059) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Skill Items/Tinkering/Springs.cs b/Scripts/Items/Skill Items/Tinkering/Springs.cs index a9df9ac4e..afd9eb264 100644 --- a/Scripts/Items/Skill Items/Tinkering/Springs.cs +++ b/Scripts/Items/Skill Items/Tinkering/Springs.cs @@ -4,12 +4,7 @@ namespace Server.Items public class Springs : Item { [Constructible] - public Springs() : this(1) - { - } - - [Constructible] - public Springs(int amount) : base(0x105D) + public Springs(int amount = 1) : base(0x105D) { Stackable = true; Amount = amount; @@ -34,4 +29,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs b/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs index 67cb8ddeb..905c742d8 100644 --- a/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs +++ b/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs @@ -151,17 +151,12 @@ namespace Server.Items public bool HasAccces(Mobile m) { - if (m.AccessLevel >= AccessLevel.GameMaster) - return true; - - BaseHouse house = BaseHouse.FindHouseAt(this); - - return house != null && house.HasAccess(m); + return m.AccessLevel >= AccessLevel.GameMaster || BaseHouse.FindHouseAt(this)?.HasAccess(m) == true; } public void PlayMusic(Mobile m, MusicName music) { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) EndMusic(m); else m_ItemID = ItemID; @@ -172,7 +167,7 @@ namespace Server.Items public void EndMusic(Mobile m) { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); m.Send(StopMusic.Instance); diff --git a/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs b/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs index 39ddf2b1f..21a8a01f8 100644 --- a/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs +++ b/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs @@ -109,7 +109,7 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Gear == null || m_Gear.Deleted) + if (m_Gear?.Deleted != false) return; if (targeted is DawnsMusicBox box) @@ -135,4 +135,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs b/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs index 454df54de..dd919783b 100644 --- a/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs +++ b/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs @@ -5,13 +5,7 @@ namespace Server.Items public class EnhancedBandage : Bandage { [Constructible] - public EnhancedBandage() - : this(1) - { - } - - [Constructible] - public EnhancedBandage(int amount) + public EnhancedBandage(int amount = 1) : base(amount) { Hue = 0x8A5; @@ -61,13 +55,7 @@ namespace Server.Items private Timer m_Timer; [Constructible] - public FountainOfLife() - : this(10) - { - } - - [Constructible] - public FountainOfLife(int charges) + public FountainOfLife(int charges = 10) : base(0x2AC0) { m_Charges = charges; @@ -222,13 +210,7 @@ namespace Server.Items private int m_Charges; [Constructible] - public FountainOfLifeDeed() - : this(10) - { - } - - [Constructible] - public FountainOfLifeDeed(int charges) + public FountainOfLifeDeed(int charges = 10) { LootType = LootType.Blessed; m_Charges = charges; @@ -271,4 +253,4 @@ namespace Server.Items m_Charges = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/AoS Promotional/HoodedShroudOfShadows.cs b/Scripts/Items/Special/AoS Promotional/HoodedShroudOfShadows.cs index bb71049e4..988756787 100644 --- a/Scripts/Items/Special/AoS Promotional/HoodedShroudOfShadows.cs +++ b/Scripts/Items/Special/AoS Promotional/HoodedShroudOfShadows.cs @@ -4,12 +4,7 @@ namespace Server.Items public class HoodedShroudOfShadows : BaseOuterTorso { [Constructible] - public HoodedShroudOfShadows() : this(0x455) - { - } - - [Constructible] - public HoodedShroudOfShadows(int hue) : base(0x2684, hue) + public HoodedShroudOfShadows(int hue = 0x455) : base(0x2684, hue) { LootType = LootType.Blessed; Weight = 3.0; @@ -39,4 +34,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs b/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs index 6c5d084ee..ed8f7f072 100644 --- a/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs +++ b/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs @@ -109,21 +109,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076749, 0x7FFF, false, false); // Please select your broken bed position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076749, 0x7FFF); // Please select your broken bed position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -131,4 +131,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs b/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs index 172891113..419c15241 100644 --- a/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs +++ b/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs @@ -105,22 +105,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076747, 0x7FFF, false, - false); // Please select your broken vanity position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076747, 0x7FFF); // Please select your broken vanity position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -128,4 +127,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs index bd4358644..505cf2246 100644 --- a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs +++ b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs @@ -9,12 +9,7 @@ namespace Server.Items private SkillMod m_SkillMod; [Constructible] - public AncientSmithyHammer(int bonus) : this(bonus, 600) - { - } - - [Constructible] - public AncientSmithyHammer(int bonus, int uses) : base(uses, 0x13E4) + public AncientSmithyHammer(int bonus, int uses = 600) : base(uses, 0x13E4) { m_Bonus = bonus; Weight = 8.0; diff --git a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs index c8d9115fe..7458f7f5c 100644 --- a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs +++ b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs @@ -8,12 +8,7 @@ namespace Server.Items private int m_UsesRemaining; [Constructible] - public PowderOfTemperament() : this(10) - { - } - - [Constructible] - public PowderOfTemperament(int charges) : base(4102) + public PowderOfTemperament(int charges = 10) : base(4102) { Weight = 1.0; Hue = 2419; @@ -105,7 +100,7 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Powder.Deleted || m_Powder.UsesRemaining <= 0) + if (m_Powder?.Deleted != false || m_Powder.UsesRemaining <= 0) { from.SendLocalizedMessage(1049086); // You have used up your powder of temperament. return; @@ -189,4 +184,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs b/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs index 2e593a33f..798bf00e9 100644 --- a/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs +++ b/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs @@ -42,7 +42,7 @@ namespace Server.Items { base.OnAfterDelete(); - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); } @@ -117,7 +117,7 @@ namespace Server.Items protected override void OnTick() { - if (m_Component != null && !m_Component.Deleted) + if (m_Component?.Deleted == false) m_Component.UpdateImage(); } } @@ -181,4 +181,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs b/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs index dba94692e..a499c7843 100644 --- a/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs +++ b/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs @@ -128,32 +128,29 @@ namespace Server.Items { Stop(); } - else + else if (m_Location != m_Mobile.Location) { - if (m_Location != m_Mobile.Location) - { - int amount = Utility.RandomMinMax(0, 7); + int amount = Utility.RandomMinMax(0, 7); - for (int i = 0; i < amount; i++) + for (int i = 0; i < amount; i++) + { + int x = m_Mobile.X + Utility.RandomMinMax(-1, 1); + int y = m_Mobile.Y + Utility.RandomMinMax(-1, 1); + int z = m_Mobile.Z; + + if (!m_Mobile.Map.CanFit(x, y, z, 1, false, false)) { - int x = m_Mobile.X + Utility.RandomMinMax(-1, 1); - int y = m_Mobile.Y + Utility.RandomMinMax(-1, 1); - int z = m_Mobile.Z; + z = m_Mobile.Map.GetAverageZ(x, y); if (!m_Mobile.Map.CanFit(x, y, z, 1, false, false)) - { - z = m_Mobile.Map.GetAverageZ(x, y); - - if (!m_Mobile.Map.CanFit(x, y, z, 1, false, false)) - continue; - } - - Blood blood = new Blood(Utility.RandomMinMax(0x122C, 0x122F)); - blood.MoveToWorld(new Point3D(x, y, z), m_Mobile.Map); + continue; } - m_Location = m_Mobile.Location; + Blood blood = new Blood(Utility.RandomMinMax(0x122C, 0x122F)); + blood.MoveToWorld(new Point3D(x, y, z), m_Mobile.Map); } + + m_Location = m_Mobile.Location; } } } @@ -189,4 +186,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs b/Scripts/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs index 4789560f0..b3a894690 100644 --- a/Scripts/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs +++ b/Scripts/Items/Special/Evil Home Decor Collection/DisturbingPortrait.cs @@ -31,7 +31,7 @@ namespace Server.Items { base.OnAfterDelete(); - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); } @@ -118,4 +118,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs b/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs index 312025ba7..e6312618a 100644 --- a/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs +++ b/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs @@ -110,11 +110,11 @@ namespace Server.Items AddItem(90, 52, 0x2367); AddItem(112, 35, 0x2360); - AddButton(70, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0); // South + AddButton(70, 35, 0x868, 0x869, 1); // South AddItem(220, 35, 0x2352); AddItem(242, 52, 0x2358); - AddButton(185, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0); // East + AddButton(185, 35, 0x868, 0x869, 2); // East } public override void OnResponse(NetState sender, RelayInfo info) @@ -127,4 +127,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs b/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs index 8af58ee00..d3f060e45 100644 --- a/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs +++ b/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs @@ -157,12 +157,7 @@ namespace Server.Items public class RoseOfTrinsicPetal : Item { [Constructible] - public RoseOfTrinsicPetal() : this(1) - { - } - - [Constructible] - public RoseOfTrinsicPetal(int amount) : base(0x1021) + public RoseOfTrinsicPetal(int amount = 1) : base(0x1021) { Stackable = true; Amount = amount; @@ -212,4 +207,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/Curtains.cs b/Scripts/Items/Special/Heritage Items/Curtains.cs index 131ba7d28..860182768 100644 --- a/Scripts/Items/Special/Heritage Items/Curtains.cs +++ b/Scripts/Items/Special/Heritage Items/Curtains.cs @@ -178,21 +178,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076581, 0x7FFF, false, false); // Please select your curtain position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076581, 0x7FFF); // Please select your curtain position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -200,4 +200,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/HangingAxes.cs b/Scripts/Items/Special/Heritage Items/HangingAxes.cs index f682f4c0a..e8a8ae820 100644 --- a/Scripts/Items/Special/Heritage Items/HangingAxes.cs +++ b/Scripts/Items/Special/Heritage Items/HangingAxes.cs @@ -105,21 +105,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076745, 0x7FFF, false, false); // Please select your hanging axe position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076745, 0x7FFF); // Please select your hanging axe position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -127,4 +127,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/HangingSwords.cs b/Scripts/Items/Special/Heritage Items/HangingSwords.cs index c22df3f02..71836fb09 100644 --- a/Scripts/Items/Special/Heritage Items/HangingSwords.cs +++ b/Scripts/Items/Special/Heritage Items/HangingSwords.cs @@ -105,22 +105,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076746, 0x7FFF, false, - false); // Please select your hanging sword position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076746, 0x7FFF); // Please select your hanging sword position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -128,4 +127,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/HouseLadder.cs b/Scripts/Items/Special/Heritage Items/HouseLadder.cs index 03d19c397..9068c93de 100644 --- a/Scripts/Items/Special/Heritage Items/HouseLadder.cs +++ b/Scripts/Items/Special/Heritage Items/HouseLadder.cs @@ -130,42 +130,38 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076780, 0x7FFF, false, - false); // Please select your ladder position.
Use the ladders marked (castle)
for accessing the tops of keeps
and castles. + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076780, 0x7FFF); // Please select your ladder position.
Use the ladders marked (castle)
for accessing the tops of keeps
and castles. AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1076794, 0x7FFF, false, false); // South (Castle) - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1076795, 0x7FFF, false, false); // East (Castle) - AddButton(19, 97, 0x845, 0x846, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 95, 213, 20, 1076792, 0x7FFF, false, false); // North (Castle) - AddButton(19, 121, 0x845, 0x846, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 119, 213, 20, 1076793, 0x7FFF, false, false); // West (Castle) - AddButton(19, 145, 0x845, 0x846, 5, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 143, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 169, 0x845, 0x846, 6, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 167, 213, 20, 1075387, 0x7FFF, false, false); // East - AddButton(19, 193, 0x845, 0x846, 7, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 191, 213, 20, 1075389, 0x7FFF, false, false); // North - AddButton(19, 217, 0x845, 0x846, 8, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 215, 213, 20, 1075390, 0x7FFF, false, false); // West + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1076794, 0x7FFF); // South (Castle) + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1076795, 0x7FFF); // East (Castle) + AddButton(19, 97, 0x845, 0x846, 3); + AddHtmlLocalized(44, 95, 213, 20, 1076792, 0x7FFF); // North (Castle) + AddButton(19, 121, 0x845, 0x846, 4); + AddHtmlLocalized(44, 119, 213, 20, 1076793, 0x7FFF); // West (Castle) + AddButton(19, 145, 0x845, 0x846, 5); + AddHtmlLocalized(44, 143, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 169, 0x845, 0x846, 6); + AddHtmlLocalized(44, 167, 213, 20, 1075387, 0x7FFF); // East + AddButton(19, 193, 0x845, 0x846, 7); + AddHtmlLocalized(44, 191, 213, 20, 1075389, 0x7FFF); // North + AddButton(19, 217, 0x845, 0x846, 8); + AddHtmlLocalized(44, 215, 213, 20, 1075390, 0x7FFF); // West } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0 || info.ButtonID < 1 || info.ButtonID > 8) return; - if (info.ButtonID >= 1 && info.ButtonID <= 8) - { - m_Deed.m_Type = info.ButtonID - 1; - m_Deed.SendTarget(sender.Mobile); - } + m_Deed.m_Type = info.ButtonID - 1; + m_Deed.SendTarget(sender.Mobile); } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/Statue.cs b/Scripts/Items/Special/Heritage Items/Statue.cs index 8148f5aa6..e20d6428c 100644 --- a/Scripts/Items/Special/Heritage Items/Statue.cs +++ b/Scripts/Items/Special/Heritage Items/Statue.cs @@ -107,21 +107,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076579, 0x7FFF, false, false); // Please select your statue position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076579, 0x7FFF); // Please select your statue position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -129,4 +129,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/UnmadeBed.cs b/Scripts/Items/Special/Heritage Items/UnmadeBed.cs index 72d89fcfa..e40633445 100644 --- a/Scripts/Items/Special/Heritage Items/UnmadeBed.cs +++ b/Scripts/Items/Special/Heritage Items/UnmadeBed.cs @@ -109,21 +109,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076580, 0x7FFF, false, false); // Pleae select your unmade bed position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076580, 0x7FFF); // Pleae select your unmade bed position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -131,4 +131,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/Vanity.cs b/Scripts/Items/Special/Heritage Items/Vanity.cs index 1ac5570b4..98358f36b 100644 --- a/Scripts/Items/Special/Heritage Items/Vanity.cs +++ b/Scripts/Items/Special/Heritage Items/Vanity.cs @@ -102,21 +102,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076744, 0x7FFF, false, false); // Please select your vanity position. + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076744, 0x7FFF); // Please select your vanity position. AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -124,4 +124,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs b/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs index ae377e151..f6a593960 100644 --- a/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs +++ b/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs @@ -134,21 +134,21 @@ namespace Server.Items AddImageTiled(10, 40, 253, 244, 0xA40); AddImageTiled(10, 294, 253, 20, 0xA40); AddAlphaRegion(10, 10, 253, 304); - AddButton(10, 294, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL - AddHtmlLocalized(14, 12, 273, 20, 1076748, 0x7FFF, false, false); // Please select your coffin position + AddButton(10, 294, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL + AddHtmlLocalized(14, 12, 273, 20, 1076748, 0x7FFF); // Please select your coffin position AddPage(1); - AddButton(19, 49, 0x845, 0x846, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF, false, false); // South - AddButton(19, 73, 0x845, 0x846, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF, false, false); // East + AddButton(19, 49, 0x845, 0x846, 1); + AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South + AddButton(19, 73, 0x845, 0x846, 2); + AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted || info.ButtonID == 0) + if (m_Deed?.Deleted != false || info.ButtonID == 0) return; m_Deed.m_East = info.ButtonID != 1; @@ -156,4 +156,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs b/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs index 4707cb735..f7de42c69 100644 --- a/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs +++ b/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Multis; @@ -264,7 +263,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_Tree != null && !m_Tree.Deleted) + if (m_Tree?.Deleted == false) m_Tree.OnDoubleClick(from); } @@ -298,4 +297,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Holiday/HolidayFoods.cs b/Scripts/Items/Special/Holiday/HolidayFoods.cs index baa3005ad..f8643b919 100644 --- a/Scripts/Items/Special/Holiday/HolidayFoods.cs +++ b/Scripts/Items/Special/Holiday/HolidayFoods.cs @@ -11,8 +11,7 @@ namespace Server.Items { } - public CandyCane(int itemID) - : base(itemID) + public CandyCane(int itemID) : base(itemID, 1) { Stackable = false; LootType = LootType.Blessed; @@ -81,7 +80,7 @@ namespace Server.Items { --Eaten; - if (Eater == null || Eater.Deleted || Eaten <= 0) + if (Eater?.Deleted != false || Eaten <= 0) { Stop(); m_ToothAches.Remove(Eater); @@ -127,7 +126,7 @@ namespace Server.Items [Constructible] public GingerBreadCookie() - : base(Utility.RandomBool() ? 0x2be1 : 0x2be2) + : base(Utility.RandomBool() ? 0x2be1 : 0x2be2, 1) { Stackable = false; LootType = LootType.Blessed; diff --git a/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs b/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs index 29333aafa..d876aa30e 100644 --- a/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs +++ b/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs @@ -103,24 +103,24 @@ namespace Server.Items AddLabel(45, 15, 0, "Choose a Potted Plant:"); AddItem(45, 75, 0x11C8); - AddButton(55, 50, 0x845, 0x846, 1, GumpButtonType.Reply, 0); + AddButton(55, 50, 0x845, 0x846, 1); AddItem(100, 75, 0x11C9); - AddButton(115, 50, 0x845, 0x846, 2, GumpButtonType.Reply, 0); + AddButton(115, 50, 0x845, 0x846, 2); AddItem(160, 75, 0x11CA); - AddButton(175, 50, 0x845, 0x846, 3, GumpButtonType.Reply, 0); + AddButton(175, 50, 0x845, 0x846, 3); AddItem(225, 75, 0x11CB); - AddButton(235, 50, 0x845, 0x846, 4, GumpButtonType.Reply, 0); + AddButton(235, 50, 0x845, 0x846, 4); AddItem(280, 75, 0x11CC); - AddButton(295, 50, 0x845, 0x846, 5, GumpButtonType.Reply, 0); + AddButton(295, 50, 0x845, 0x846, 5); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted) + if (m_Deed?.Deleted != false) return; Mobile from = sender.Mobile; @@ -150,4 +150,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Holiday/PKHolidayStuff.cs b/Scripts/Items/Special/Holiday/PKHolidayStuff.cs index 841d3a177..fbf6d61c8 100644 --- a/Scripts/Items/Special/Holiday/PKHolidayStuff.cs +++ b/Scripts/Items/Special/Holiday/PKHolidayStuff.cs @@ -64,7 +64,7 @@ namespace Server.Items public class Spam : Food { [Constructible] - public Spam() : base(0x1044) + public Spam() : base(0x1044, 1) { Stackable = false; LootType = LootType.Blessed; @@ -86,4 +86,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Holiday/SnowStatue.cs b/Scripts/Items/Special/Holiday/SnowStatue.cs index 6f91c3460..3e940388a 100644 --- a/Scripts/Items/Special/Holiday/SnowStatue.cs +++ b/Scripts/Items/Special/Holiday/SnowStatue.cs @@ -191,21 +191,21 @@ namespace Server.Items AddLabel(45, 15, 0, "Select One:"); AddItem(35, 75, 0x456E); - AddButton(65, 50, 0x845, 0x846, 1, GumpButtonType.Reply, 0); + AddButton(65, 50, 0x845, 0x846, 1); AddItem(120, 75, 0x4578); - AddButton(135, 50, 0x845, 0x846, 2, GumpButtonType.Reply, 0); + AddButton(135, 50, 0x845, 0x846, 2); AddItem(190, 75, 0x457A); - AddButton(205, 50, 0x845, 0x846, 3, GumpButtonType.Reply, 0); + AddButton(205, 50, 0x845, 0x846, 3); AddItem(250, 75, 0x457C); - AddButton(275, 50, 0x845, 0x846, 4, GumpButtonType.Reply, 0); + AddButton(275, 50, 0x845, 0x846, 4); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted) + if (m_Deed?.Deleted != false) return; Mobile from = sender.Mobile; @@ -216,10 +216,12 @@ namespace Server.Items return; } - Item statue = null; + Item statue; switch (info.ButtonID) { + default: + return; case 1: statue = new SnowStatuePegasus(); break; @@ -234,9 +236,6 @@ namespace Server.Items break; } - if (statue == null) - return; - if (!from.PlaceInBackpack(statue)) { statue.Delete(); @@ -249,4 +248,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Holiday/Snowman.cs b/Scripts/Items/Special/Holiday/Snowman.cs index 776eb38b6..b9853960b 100644 --- a/Scripts/Items/Special/Holiday/Snowman.cs +++ b/Scripts/Items/Special/Holiday/Snowman.cs @@ -6,7 +6,7 @@ namespace Server.Items private string m_Title; [Constructible] - public Snowman() : this(Utility.RandomDyedHue(), GetRandomTitle()) + public Snowman() : this(Utility.RandomDyedHue()) { } @@ -156,4 +156,4 @@ namespace Server.Items Utility.Intern(ref m_Title); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Holiday/Wreath.cs b/Scripts/Items/Special/Holiday/Wreath.cs index 76adde2ae..1cc64e9bc 100644 --- a/Scripts/Items/Special/Holiday/Wreath.cs +++ b/Scripts/Items/Special/Holiday/Wreath.cs @@ -43,7 +43,7 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { if (from.InRange(GetWorldLocation(), 1)) { @@ -101,7 +101,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { if (from.InRange(GetWorldLocation(), 3)) { @@ -129,11 +129,11 @@ namespace Server.Items AddBackground(0, 0, 220, 170, 0x13BE); AddBackground(10, 10, 200, 150, 0xBB8); - AddHtmlLocalized(20, 30, 180, 60, 1062839, false, false); // Do you wish to re-deed this decoration? - AddHtmlLocalized(55, 100, 160, 25, 1011011, false, false); // CONTINUE - AddButton(20, 100, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 125, 160, 25, 1011012, false, false); // CANCEL - AddButton(20, 125, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(20, 30, 180, 60, 1062839); // Do you wish to re-deed this decoration? + AddHtmlLocalized(55, 100, 160, 25, 1011011); // CONTINUE + AddButton(20, 100, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(55, 125, 160, 25, 1011012); // CANCEL + AddButton(20, 125, 0xFA5, 0xFA7, 0); } public override void OnResponse(NetState sender, RelayInfo info) @@ -199,7 +199,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { from.SendLocalizedMessage(1062838); // Where would you like to place this decoration? from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget); @@ -224,7 +224,7 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { bool northWall = BaseAddon.IsWall(loc.X, loc.Y - 1, loc.Z, from.Map); bool westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map); @@ -292,8 +292,8 @@ namespace Server.Items AddItem(90, 30, 0x232D); AddItem(180, 30, 0x232C); - AddButton(50, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0); - AddButton(145, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0); + AddButton(50, 35, 0x868, 0x869, 1); + AddButton(145, 35, 0x868, 0x869, 2); } public override void OnResponse(NetState sender, RelayInfo info) @@ -313,4 +313,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs b/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs index 8832dc86c..f03f70c66 100644 --- a/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs +++ b/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs @@ -10,13 +10,7 @@ namespace Server.Items private Point3D m_PlotLocation; private HouseRaffleStone m_Stone; - [Constructible] - public HouseRaffleDeed() - : this(null, null) - { - } - - public HouseRaffleDeed(HouseRaffleStone stone, Mobile m) : base(0x2830) + public HouseRaffleDeed(HouseRaffleStone stone = null, Mobile m = null) : base(0x2830) { m_Stone = stone; @@ -82,7 +76,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)] - public bool IsExpired => m_Stone == null || m_Stone.Deleted || m_Stone.IsExpired; + public bool IsExpired => m_Stone?.Deleted != false || m_Stone.IsExpired; public override string DefaultName => "a writ of lease"; @@ -186,7 +180,7 @@ namespace Server.Items AddImage(114, 266, 9387); AddImage(171, 266, 9388); - AddHtmlLocalized(30, 48, 229, 20, 1150484, 200, false, false); // WRIT OF LEASE + AddHtmlLocalized(30, 48, 229, 20, 1150484, 200); // WRIT OF LEASE AddHtml(28, 75, 231, 280, FormatDescription(deed), false, true); } @@ -217,4 +211,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs b/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs index 016b6bd20..38e0ecb39 100644 --- a/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs +++ b/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs @@ -23,12 +23,8 @@ namespace Server.Gumps private HouseRaffleStone m_Stone; - public HouseRaffleManagementGump(HouseRaffleStone stone) - : this(stone, SortMethod.Default, 0) - { - } - - public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort, int page) : base(40, 40) + public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort = SortMethod.Default, + int page = 0) : base(40, 40) { m_Stone = stone; m_Page = page; @@ -63,47 +59,47 @@ namespace Server.Gumps AddBackground(0, 0, 618, 354, 9270); AddAlphaRegion(10, 10, 598, 334); - AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor), false, false); + AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor)); - AddHtml(45, 35, 100, 20, Color("Location:", LabelColor), false, false); - AddHtml(145, 35, 250, 20, Color(m_Stone.FormatLocation(), LabelColor), false, false); + AddHtml(45, 35, 100, 20, Color("Location:", LabelColor)); + AddHtml(145, 35, 250, 20, Color(m_Stone.FormatLocation(), LabelColor)); - AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor), false, false); - AddHtml(145, 55, 250, 20, Color(m_Stone.FormatPrice(), LabelColor), false, false); + AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor)); + AddHtml(145, 55, 250, 20, Color(m_Stone.FormatPrice(), LabelColor)); - AddHtml(45, 75, 100, 20, Color("Total Entries:", LabelColor), false, false); - AddHtml(145, 75, 250, 20, Color(m_Stone.Entries.Count.ToString(), LabelColor), false, false); + AddHtml(45, 75, 100, 20, Color("Total Entries:", LabelColor)); + AddHtml(145, 75, 250, 20, Color(m_Stone.Entries.Count.ToString(), LabelColor)); - AddButton(440, 33, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); - AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor), false, false); + AddButton(440, 33, 0xFA5, 0xFA7, 3); + AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor)); - AddButton(440, 53, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); - AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor), false, false); + AddButton(440, 53, 0xFA5, 0xFA7, 4); + AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor)); - AddButton(440, 73, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0); - AddHtml(474, 75, 120, 20, Color("Sort by address", LabelColor), false, false); + AddButton(440, 73, 0xFA5, 0xFA7, 5); + AddHtml(474, 75, 120, 20, Color("Sort by address", LabelColor)); AddImageTiled(13, 99, 592, 242, 9264); AddImageTiled(14, 100, 590, 240, 9274); AddAlphaRegion(14, 100, 590, 240); - AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor), false, false); + AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor)); if (page > 0) - AddButton(567, 104, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 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, GumpButtonType.Reply, 0); + AddButton(584, 104, 0x15E1, 0x15E5, 2); else AddImage(584, 104, 0x25E6); - AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false); - AddHtml(47, 120, 250, 20, Color("Name", LabelColor), false, false); - AddHtml(295, 120, 100, 20, Color(Center("Address"), LabelColor), false, false); - AddHtml(395, 120, 150, 20, Color(Center("Date"), LabelColor), false, false); - AddHtml(545, 120, 60, 20, Color(Center("Num"), LabelColor), false, false); + AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor)); + AddHtml(47, 120, 250, 20, Color("Name", LabelColor)); + AddHtml(295, 120, 100, 20, Color(Center("Address"), LabelColor)); + AddHtml(395, 120, 150, 20, Color(Center("Date"), LabelColor)); + AddHtml(545, 120, 60, 20, Color(Center("Num"), LabelColor)); int idx = 0; Mobile winner = m_Stone.Winner; @@ -115,7 +111,7 @@ namespace Server.Gumps if (entry == null) continue; - AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i, GumpButtonType.Reply, 0); + AddButton(13, 138 + idx * 20, 4002, 4004, 6 + i); int x = 45; int color = winner != null && entry.From == winner ? HighlightColor : LabelColor; @@ -131,19 +127,19 @@ namespace Server.Gumps } if (name != null) - AddHtml(x + 2, 140 + idx * 20, 250, 20, Color(name, color), false, false); + 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), false, false); + AddHtml(x, 140 + idx * 20, 100, 20, Color(Center(entry.Address.ToString()), color)); x += 100; - AddHtml(x, 140 + idx * 20, 150, 20, Color(Center(entry.Date.ToString()), color), false, false); + AddHtml(x, 140 + idx * 20, 150, 20, Color(Center(entry.Date.ToString()), color)); x += 150; - AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color), false, false); + AddHtml(x, 140 + idx * 20, 60, 20, Color(Center("1"), color)); x += 60; } } @@ -190,19 +186,19 @@ namespace Server.Gumps } case 3: // Sort by name { - from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Name, 0)); + from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Name)); break; } case 4: // Sort by account { - from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account, 0)); + from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account)); break; } case 5: // Sort by address { - from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address, 0)); + from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address)); break; } @@ -243,9 +239,7 @@ namespace Server.Gumps int result = Insensitive.Compare(x.From.Name, y.From.Name); - if (result == 0) - return x.Date.CompareTo(y.Date); - return result; + return result == 0 ? x.Date.CompareTo(y.Date) : result; } } @@ -277,9 +271,7 @@ namespace Server.Gumps int result = Insensitive.Compare(a.Username, b.Username); - if (result == 0) - return x.Date.CompareTo(y.Date); - return result; + return result == 0 ? x.Date.CompareTo(y.Date) : result; } } @@ -314,4 +306,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs b/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs index e12da6ef0..ba20c1f90 100644 --- a/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs @@ -16,10 +16,7 @@ namespace Server.Items { From = from; - if (From.NetState != null) - Address = From.NetState.Address; - else - Address = IPAddress.None; + Address = From.NetState?.Address ?? IPAddress.None; Date = DateTime.UtcNow; } @@ -367,9 +364,7 @@ namespace Server.Items public string FormatPrice() { - if (m_TicketPrice == 0) - return "FREE"; - return $"{m_TicketPrice} gold"; + return m_TicketPrice == 0 ? "FREE" : $"{m_TicketPrice} gold"; } public override void GetProperties(ObjectPropertyList list) @@ -462,8 +457,8 @@ namespace Server.Items { Container bank = from.FindBankNoCreate(); - if (m_TicketPrice == 0 || from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), m_TicketPrice) || - bank != null && bank.ConsumeTotal(typeof(Gold), m_TicketPrice)) + if (m_TicketPrice == 0 || from.Backpack?.ConsumeTotal(typeof(Gold), m_TicketPrice) == true || + bank?.ConsumeTotal(typeof(Gold), m_TicketPrice) == true) { Entries.Add(new RaffleEntry(from)); @@ -690,4 +685,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/MiniHouses.cs b/Scripts/Items/Special/MiniHouses.cs index 7e5fbd58f..e5d0cdbb3 100644 --- a/Scripts/Items/Special/MiniHouses.cs +++ b/Scripts/Items/Special/MiniHouses.cs @@ -7,12 +7,7 @@ namespace Server.Items private MiniHouseType m_Type; [Constructible] - public MiniHouseAddon() : this(MiniHouseType.StoneAndPlaster) - { - } - - [Constructible] - public MiniHouseAddon(MiniHouseType type) + public MiniHouseAddon(MiniHouseType type = MiniHouseType.StoneAndPlaster) { m_Type = type; @@ -88,12 +83,7 @@ namespace Server.Items private MiniHouseType m_Type; [Constructible] - public MiniHouseDeed() : this(MiniHouseType.StoneAndPlaster) - { - } - - [Constructible] - public MiniHouseDeed(MiniHouseType type) + public MiniHouseDeed(MiniHouseType type = MiniHouseType.StoneAndPlaster) { m_Type = type; @@ -241,4 +231,4 @@ namespace Server.Items return m_Info[v]; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/MonsterStatuette.cs b/Scripts/Items/Special/MonsterStatuette.cs index cbeed2256..2384fb81f 100644 --- a/Scripts/Items/Special/MonsterStatuette.cs +++ b/Scripts/Items/Special/MonsterStatuette.cs @@ -132,12 +132,8 @@ namespace Server.Items private MonsterStatuetteType m_Type; [Constructible] - public MonsterStatuette() : this(MonsterStatuetteType.Crocodile) - { - } - - [Constructible] - public MonsterStatuette(MonsterStatuetteType type) : base(MonsterStatuetteInfo.GetInfo(type).ItemID) + public MonsterStatuette(MonsterStatuetteType type = MonsterStatuetteType.Crocodile) : + base(MonsterStatuetteInfo.GetInfo(type).ItemID) { LootType = LootType.Blessed; @@ -226,9 +222,7 @@ namespace Server.Items public bool IsOwner(Mobile mob) { - BaseHouse house = BaseHouse.FindHouseAt(this); - - return house != null && house.IsOwner(mob); + return BaseHouse.FindHouseAt(this)?.IsOwner(mob) == true; } public override void OnDoubleClick(Mobile from) @@ -283,14 +277,13 @@ namespace Server.Items AddBackground(0, 0, 300, 150, 0xA28); - AddHtmlLocalized(45, 20, 300, 35, statuette.TurnedOn ? 1011035 : 1011034, false, - false); // [De]Activate this item + AddHtmlLocalized(45, 20, 300, 35, statuette.TurnedOn ? 1011035 : 1011034); // [De]Activate this item - AddButton(40, 53, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(80, 55, 65, 35, 1011036, false, false); // OKAY + AddButton(40, 53, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(80, 55, 65, 35, 1011036); // OKAY - AddButton(150, 53, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(190, 55, 100, 35, 1011012, false, false); // CANCEL + AddButton(150, 53, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(190, 55, 100, 35, 1011012); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -312,4 +305,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs b/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs index a5de858f9..5d83bd08e 100644 --- a/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs +++ b/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs @@ -22,7 +22,7 @@ namespace Server.Items public override void OnAfterDelete() { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); } @@ -30,7 +30,7 @@ namespace Server.Items { if (IsAccessibleTo(from) && !Patched) { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); if (Starting) @@ -107,4 +107,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs b/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs index 859576914..098b5a787 100644 --- a/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs +++ b/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs @@ -18,7 +18,7 @@ namespace Server.Items public override void OnAfterDelete() { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); } @@ -51,7 +51,7 @@ namespace Server.Items protected override void OnTick() { - if (m_Heart == null || m_Heart.Deleted || m_Heart.Owner == null || !m_Heart.Owner.Alive) + if (m_Heart?.Deleted != false || m_Heart.Owner?.Alive != true) { Stop(); return; @@ -76,4 +76,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs b/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs index c5257dc84..80599c4fb 100644 --- a/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs +++ b/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs @@ -76,11 +76,7 @@ namespace Server.Items public class PlagueBeastComponent : PlagueBeastInnard { - public PlagueBeastComponent(int itemID, int hue) : this(itemID, hue, false) - { - } - - public PlagueBeastComponent(int itemID, int hue, bool movable) : base(itemID, hue) + public PlagueBeastComponent(int itemID, int hue, bool movable = false) : base(itemID, hue) { Movable = movable; } @@ -99,10 +95,7 @@ namespace Server.Items public override bool DropToItem(Mobile from, Item target, Point3D p) { - if (target is PlagueBeastBackpack) - return base.DropToItem(from, target, p); - - return false; + return target is PlagueBeastBackpack && base.DropToItem(from, target, p); } public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) @@ -122,8 +115,7 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item dropped) { - if (Organ != null && Organ.OnDropped(from, dropped, this)) - if (dropped is PlagueBeastComponent component) + if (Organ?.OnDropped(from, dropped, this) == true && dropped is PlagueBeastComponent component) Organ.Components.Add(component); return true; @@ -133,10 +125,9 @@ namespace Server.Items { if (IsAccessibleTo(from)) { - if (Organ != null && Organ.OnLifted(from, this)) + if (Organ?.OnLifted(from, this) == true) { - from.SendLocalizedMessage(IsGland ? 1071895 : 1071914, null, - 0x3B2); // * You rip the organ out of the plague beast's flesh * + from.SendLocalizedMessage(IsGland ? 1071895 : 1071914, null); // * You rip the organ out of the plague beast's flesh * if (Organ.Components.Contains(this)) Organ.Components.Remove(this); @@ -169,4 +160,4 @@ namespace Server.Items Organ = reader.ReadItem(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs b/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs index c084e53ed..0330e8496 100644 --- a/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs +++ b/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs @@ -8,17 +8,12 @@ namespace Server.Items { private Timer m_Timer; - public PlagueBeastOrgan() : this(1, 0) - { - Visible = false; - } - - public PlagueBeastOrgan(int itemID, int hue) : base(itemID, hue) + public PlagueBeastOrgan(int itemID = 1, int hue = 0) : base(itemID, hue) { Components = new List(); Opened = false; - Movable = false; + Visible = itemID <= 1; Timer.DelayCall(TimeSpan.Zero, Initialize); } @@ -70,7 +65,7 @@ namespace Server.Items public override void OnAfterDelete() { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); } @@ -116,7 +111,7 @@ namespace Server.Items public class PlagueBeastMaidenOrgan : PlagueBeastOrgan { - public PlagueBeastMaidenOrgan() : base(0x124D, 0x0) + public PlagueBeastMaidenOrgan() : base(0x124D) { } @@ -564,4 +559,4 @@ namespace Server.Items m_Brains = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs b/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs index cbce08871..6cdf4780d 100644 --- a/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs +++ b/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs @@ -38,7 +38,7 @@ namespace Server.Items public override void OnAfterDelete() { - if (m_Timer != null && m_Timer.Running) + if (m_Timer?.Running == true) m_Timer.Stop(); } @@ -75,4 +75,4 @@ namespace Server.Items Cut = reader.ReadBool(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Rares/Containers/Bucket.cs b/Scripts/Items/Special/Rares/Containers/Bucket.cs index 30ed5a87b..f112ffa9a 100644 --- a/Scripts/Items/Special/Rares/Containers/Bucket.cs +++ b/Scripts/Items/Special/Rares/Containers/Bucket.cs @@ -6,13 +6,7 @@ private static int fItemID = 0x2004; [Constructible] - public Bucket() - : this(false) - { - } - - [Constructible] - public Bucket(bool filled) + public Bucket(bool filled = false) : base(filled ? fItemID : vItemID, filled) { } @@ -40,4 +34,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs b/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs index 1a8a63e8a..8e20b5ace 100644 --- a/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs +++ b/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs @@ -6,13 +6,7 @@ private static int fItemID = 0x154d; [Constructible] - public WaterBarrel() - : this(false) - { - } - - [Constructible] - public WaterBarrel(bool filled) + public WaterBarrel(bool filled = false) : base(filled ? fItemID : vItemID, filled) { } @@ -42,4 +36,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Rares/Containers/WaterTub.cs b/Scripts/Items/Special/Rares/Containers/WaterTub.cs index a53f7770b..d92fab12c 100644 --- a/Scripts/Items/Special/Rares/Containers/WaterTub.cs +++ b/Scripts/Items/Special/Rares/Containers/WaterTub.cs @@ -6,13 +6,7 @@ private static int fItemID = 0xe7b; [Constructible] - public Tub() - : this(false) - { - } - - [Constructible] - public Tub(bool filled) + public Tub(bool filled = false) : base(filled ? fItemID : vItemID, filled) { } @@ -40,4 +34,4 @@ int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Solen Items/BallOfSummoning.cs b/Scripts/Items/Special/Solen Items/BallOfSummoning.cs index 562712cfc..356bd5951 100644 --- a/Scripts/Items/Special/Solen Items/BallOfSummoning.cs +++ b/Scripts/Items/Special/Solen Items/BallOfSummoning.cs @@ -37,7 +37,7 @@ namespace Server.Items { get { - if (m_Pet != null && m_Pet.Deleted) + if (m_Pet?.Deleted == true) { m_Pet = null; InternalUpdatePetName(); @@ -475,4 +475,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs b/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs index 716a60512..8fa8deb06 100644 --- a/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs +++ b/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs @@ -49,7 +49,7 @@ namespace Server.Items { get { - if (m_Bound != null && m_Bound.Deleted) + if (m_Bound?.Deleted == true) m_Bound = null; return m_Bound; @@ -380,20 +380,18 @@ namespace Server.Items m_Bracelet.m_Timer = null; m_From.Frozen = false; - if (m_Bracelet.Deleted || m_From.Deleted) + if (m_Bracelet.Deleted || m_From.Deleted || + !m_Bracelet.CheckUse(m_From, false) || + !(m_Bracelet.Bound.RootParent is Mobile boundRoot)) return; - if (m_Bracelet.CheckUse(m_From, false)) - if (m_Bracelet.Bound.RootParent is Mobile boundRoot) - { - m_Bracelet.Charges--; + m_Bracelet.Charges--; - BaseCreature.TeleportPets(m_From, boundRoot.Location, boundRoot.Map, true); + BaseCreature.TeleportPets(m_From, boundRoot.Location, boundRoot.Map, true); - m_From.PlaySound(0x1FC); - m_From.MoveToWorld(boundRoot.Location, boundRoot.Map); - m_From.PlaySound(0x1FC); - } + m_From.PlaySound(0x1FC); + m_From.MoveToWorld(boundRoot.Location, boundRoot.Map); + m_From.PlaySound(0x1FC); } } @@ -472,4 +470,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs b/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs index 614f94200..7fc1ef3e3 100644 --- a/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs +++ b/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs @@ -15,12 +15,7 @@ namespace Server.Items public class PowderOfTranslocation : Item { [Constructible] - public PowderOfTranslocation() : this(1) - { - } - - [Constructible] - public PowderOfTranslocation(int amount) : base(0x26B8) + public PowderOfTranslocation(int amount = 1) : base(0x26B8) { Stackable = true; Weight = 0.1; @@ -112,4 +107,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Solen Items/ZoogiFungus.cs b/Scripts/Items/Special/Solen Items/ZoogiFungus.cs index 9c2766101..841112c0a 100644 --- a/Scripts/Items/Special/Solen Items/ZoogiFungus.cs +++ b/Scripts/Items/Special/Solen Items/ZoogiFungus.cs @@ -3,12 +3,7 @@ namespace Server.Items public class ZoogiFungus : Item, ICommodity { [Constructible] - public ZoogiFungus() : this(1) - { - } - - [Constructible] - public ZoogiFungus(int amount) : base(0x26B7) + public ZoogiFungus(int amount = 1) : base(0x26B7) { Stackable = true; Weight = 0.1; @@ -36,4 +31,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/SoulStone.cs b/Scripts/Items/Special/SoulStone.cs index fd7cd28a7..fd9d672d4 100644 --- a/Scripts/Items/Special/SoulStone.cs +++ b/Scripts/Items/Special/SoulStone.cs @@ -21,22 +21,8 @@ namespace Server.Items private double m_SkillValue; [Constructible] - public SoulStone() : this(null) - { - } - - [Constructible] - public SoulStone(string account) - : this(account, 0x2A93, 0x2A94) - { - } - - public SoulStone(string account, int itemID) - : this(account, itemID, itemID) - { - } - - public SoulStone(string account, int inactiveItemID, int activeItemID) : base(inactiveItemID) + public SoulStone(string account = null, int inactiveItemID = 0x2A93, int activeItemID = 0x2A94) : + base(inactiveItemID) { Light = LightType.Circle300; LootType = LootType.Blessed; @@ -135,12 +121,7 @@ namespace Server.Items list.Add(1070721, "#{0}\t{1:0.0}", AosSkillBonuses.GetLabel(Skill), SkillValue); // Skill stored: ~1_skillname~ ~2_skillamount~ - string name = LastUserName; - - if (name == null) - name = $"#{1074235}"; // Unknown - - list.Add(1041602, "{0}", name); // Owner: ~1_val~ + list.Add(1041602, "{0}", LastUserName ?? $"#{1074235}"); // Owner: ~1_val~ } private static bool CheckCombat(Mobile m, TimeSpan time) @@ -343,11 +324,10 @@ namespace Server.Items AddAlphaRegion(10, 10, 500, 420); - AddHtmlLocalized(10, 12, 500, 20, 1061087, 0x7FFF, false, - false); // Which skill do you wish to transfer to the Soulstone? + AddHtmlLocalized(10, 12, 500, 20, 1061087, 0x7FFF); // Which skill do you wish to transfer to the Soulstone? - AddButton(10, 410, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 410, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF); // CANCEL for (int i = 0, n = 0; i < from.Skills.Length; i++) { @@ -364,7 +344,7 @@ namespace Server.Items if (page > 0) { AddButton(260, 380, 0xFA5, 0xFA6, 0, GumpButtonType.Page, page + 1); - AddHtmlLocalized(305, 382, 200, 20, 1011066, 0x7FFF, false, false); // Next page + AddHtmlLocalized(305, 382, 200, 20, 1011066, 0x7FFF); // Next page } AddPage(page + 1); @@ -372,16 +352,15 @@ namespace Server.Items if (page > 0) { AddButton(10, 380, 0xFAE, 0xFAF, 0, GumpButtonType.Page, page); - AddHtmlLocalized(55, 382, 200, 20, 1011067, 0x7FFF, false, false); // Previous page + AddHtmlLocalized(55, 382, 200, 20, 1011067, 0x7FFF); // Previous page } } int x = p % 2 == 0 ? 10 : 260; int y = p / 2 * 20 + 40; - AddButton(x, y, 0xFA5, 0xFA6, i + 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(x + 45, y + 2, 200, 20, AosSkillBonuses.GetLabel(skill.SkillName), 0x7FFF, false, - false); + AddButton(x, y, 0xFA5, 0xFA6, i + 1); + AddHtmlLocalized(x + 45, y + 2, 200, 20, AosSkillBonuses.GetLabel(skill.SkillName), 0x7FFF); n++; } @@ -428,8 +407,7 @@ namespace Server.Items AddAlphaRegion(10, 10, 500, 420); - AddHtmlLocalized(10, 12, 500, 20, 1070709, 0x7FFF, false, - false); //
Confirm Soulstone Transfer
+ AddHtmlLocalized(10, 12, 500, 20, 1070709, 0x7FFF); //
Confirm Soulstone Transfer
/*
Soulstone

* You are using a Soulstone. This powerful artifact allows you to remove skill points @@ -448,27 +426,26 @@ namespace Server.Items */ AddHtmlLocalized(10, 42, 500, 110, 1061067, 0x7FFF, false, true); - AddHtmlLocalized(10, 200, 390, 20, 1062297, 0x7FFF, false, false); // Skill Chosen: - AddHtmlLocalized(210, 200, 390, 20, AosSkillBonuses.GetLabel(skill.SkillName), 0x7FFF, false, false); + AddHtmlLocalized(10, 200, 390, 20, 1062297, 0x7FFF); // Skill Chosen: + AddHtmlLocalized(210, 200, 390, 20, AosSkillBonuses.GetLabel(skill.SkillName), 0x7FFF); - AddHtmlLocalized(10, 220, 390, 20, 1062298, 0x7FFF, false, false); // Current Value: + AddHtmlLocalized(10, 220, 390, 20, 1062298, 0x7FFF); // Current Value: AddLabel(210, 220, 0x481, skill.Base.ToString("0.0")); - AddHtmlLocalized(10, 240, 390, 20, 1062299, 0x7FFF, false, false); // Current Cap: + AddHtmlLocalized(10, 240, 390, 20, 1062299, 0x7FFF); // Current Cap: AddLabel(210, 240, 0x481, skill.Cap.ToString("0.0")); - AddHtmlLocalized(10, 260, 390, 20, 1062300, 0x7FFF, false, false); // New Value: + AddHtmlLocalized(10, 260, 390, 20, 1062300, 0x7FFF); // New Value: AddLabel(210, 260, 0x481, "0.0"); - AddButton(10, 360, 0xFA5, 0xFA6, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 362, 450, 20, 1070720, 0x7FFF, false, - false); // Activate the stone. I am ready to transfer the skill points to it. + AddButton(10, 360, 0xFA5, 0xFA6, 2); + AddHtmlLocalized(45, 362, 450, 20, 1070720, 0x7FFF); // Activate the stone. I am ready to transfer the skill points to it. - AddButton(10, 380, 0xFA5, 0xFA6, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 382, 450, 20, 1062279, 0x7FFF, false, false); // No, let me make another selection. + AddButton(10, 380, 0xFA5, 0xFA6, 1); + AddHtmlLocalized(45, 382, 450, 20, 1062279, 0x7FFF); // No, let me make another selection. - AddButton(10, 410, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 410, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -543,8 +520,7 @@ namespace Server.Items AddAlphaRegion(10, 10, 500, 420); - AddHtmlLocalized(10, 12, 500, 20, 1070709, 0x7FFF, false, - false); //
Confirm Soulstone Transfer
+ AddHtmlLocalized(10, 12, 500, 20, 1070709, 0x7FFF); //
Confirm Soulstone Transfer
/*
Soulstone

* You are using a Soulstone. This powerful artifact allows you to remove skill points @@ -563,30 +539,28 @@ namespace Server.Items */ AddHtmlLocalized(10, 42, 500, 110, 1061067, 0x7FFF, false, true); - AddHtmlLocalized(10, 200, 390, 20, 1070718, 0x7FFF, false, false); // Skill Stored: - AddHtmlLocalized(210, 200, 390, 20, AosSkillBonuses.GetLabel(stone.Skill), 0x7FFF, false, false); + AddHtmlLocalized(10, 200, 390, 20, 1070718, 0x7FFF); // Skill Stored: + AddHtmlLocalized(210, 200, 390, 20, AosSkillBonuses.GetLabel(stone.Skill), 0x7FFF); Skill fromSkill = from.Skills[stone.Skill]; - AddHtmlLocalized(10, 220, 390, 20, 1062298, 0x7FFF, false, false); // Current Value: + AddHtmlLocalized(10, 220, 390, 20, 1062298, 0x7FFF); // Current Value: AddLabel(210, 220, 0x481, fromSkill.Base.ToString("0.0")); - AddHtmlLocalized(10, 240, 390, 20, 1062299, 0x7FFF, false, false); // Current Cap: + AddHtmlLocalized(10, 240, 390, 20, 1062299, 0x7FFF); // Current Cap: AddLabel(210, 240, 0x481, fromSkill.Cap.ToString("0.0")); - AddHtmlLocalized(10, 260, 390, 20, 1062300, 0x7FFF, false, false); // New Value: + AddHtmlLocalized(10, 260, 390, 20, 1062300, 0x7FFF); // New Value: AddLabel(210, 260, 0x481, stone.SkillValue.ToString("0.0")); - AddButton(10, 360, 0xFA5, 0xFA6, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 362, 450, 20, 1070719, 0x7FFF, false, - false); // Activate the stone. I am ready to retrieve the skill points from it. + AddButton(10, 360, 0xFA5, 0xFA6, 2); + AddHtmlLocalized(45, 362, 450, 20, 1070719, 0x7FFF); // Activate the stone. I am ready to retrieve the skill points from it. - AddButton(10, 380, 0xFA5, 0xFA6, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 382, 450, 20, 1070723, 0x7FFF, false, - false); // Remove all skill points from this stone and DO NOT absorb them. + AddButton(10, 380, 0xFA5, 0xFA6, 1); + AddHtmlLocalized(45, 382, 450, 20, 1070723, 0x7FFF); // Remove all skill points from this stone and DO NOT absorb them. - AddButton(10, 410, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 410, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -755,8 +729,7 @@ namespace Server.Items AddAlphaRegion(10, 10, 500, 420); - AddHtmlLocalized(10, 12, 500, 20, 1070725, 0x7FFF, false, - false); //
Confirm Soulstone Skill Removal
+ AddHtmlLocalized(10, 12, 500, 20, 1070725, 0x7FFF); //
Confirm Soulstone Skill Removal
/* WARNING!

* @@ -767,11 +740,11 @@ namespace Server.Items */ AddHtmlLocalized(10, 42, 500, 110, 1070724, 0x7FFF, false, true); - AddButton(10, 380, 0xFA5, 0xFA6, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 382, 450, 20, 1052072, 0x7FFF, false, false); // Continue + AddButton(10, 380, 0xFA5, 0xFA6, 1); + AddHtmlLocalized(45, 382, 450, 20, 1052072, 0x7FFF); // Continue - AddButton(10, 410, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 410, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -805,15 +778,15 @@ namespace Server.Items AddAlphaRegion(10, 10, 500, 420); - AddHtmlLocalized(10, 12, 500, 20, title, 0x7FFF, false, false); + AddHtmlLocalized(10, 12, 500, 20, title, 0x7FFF); AddHtmlLocalized(10, 42, 500, 110, message, 0x7FFF, false, true); - AddButton(10, 380, 0xFA5, 0xFA6, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 382, 450, 20, 1052072, 0x7FFF, false, false); // Continue + AddButton(10, 380, 0xFA5, 0xFA6, 1); + AddHtmlLocalized(45, 382, 450, 20, 1052072, 0x7FFF); // Continue - AddButton(10, 410, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(10, 410, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 412, 450, 20, 1060051, 0x7FFF); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -838,23 +811,14 @@ namespace Server.Items { private int m_UsesRemaining; - [Constructible] - public SoulstoneFragment() : this(5, null) - { - } - - [Constructible] - public SoulstoneFragment(int usesRemaining) : this(usesRemaining, null) - { - } - [Constructible] public SoulstoneFragment(string account) : this(5, account) { } [Constructible] - public SoulstoneFragment(int usesRemaining, string account) : base(account, Utility.Random(0x2AA1, 9)) + public SoulstoneFragment(int usesRemaining = 5, string account = null) : + base(account, Utility.Random(0x2AA1, 9)) { m_UsesRemaining = usesRemaining; } @@ -940,13 +904,7 @@ namespace Server.Items public class BlueSoulstone : SoulStone { [Constructible] - public BlueSoulstone() - : this(null) - { - } - - [Constructible] - public BlueSoulstone(string account) + public BlueSoulstone(string account = null) : base(account, 0x2ADC, 0x2ADD) { } @@ -995,13 +953,7 @@ namespace Server.Items private bool m_IsRewardItem; [Constructible] - public RedSoulstone() - : this(null) - { - } - - [Constructible] - public RedSoulstone(string account) + public RedSoulstone(string account = null) : base(account, 0x32F3, 0x32F4) { } @@ -1055,4 +1007,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Special Scrolls/PowerScroll.cs b/Scripts/Items/Special/Special Scrolls/PowerScroll.cs index 84e89a760..1e567af7b 100644 --- a/Scripts/Items/Special/Special Scrolls/PowerScroll.cs +++ b/Scripts/Items/Special/Special Scrolls/PowerScroll.cs @@ -67,12 +67,8 @@ namespace Server.Items private static List _Skills = new List(); - public PowerScroll() : this(SkillName.Alchemy, 0.0) - { - } - [Constructible] - public PowerScroll(SkillName skill, double value) : base(skill, value) + public PowerScroll(SkillName skill = SkillName.Alchemy, double value = 0.0) : base(skill, value) { Hue = 0x481; @@ -245,4 +241,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs b/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs index dd11d3a0a..6565b7e8a 100644 --- a/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs +++ b/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs @@ -142,23 +142,23 @@ namespace Server.Items AddHtmlLocalized(40, 48, 387, 100, m_Scroll.Message, true, true); - AddHtmlLocalized(125, 148, 200, 20, 1049478, 0xFFFFFF, false, false); // Do you wish to use this scroll? + AddHtmlLocalized(125, 148, 200, 20, 1049478, 0xFFFFFF); // Do you wish to use this scroll? - AddButton(100, 172, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(135, 172, 120, 20, 1046362, 0xFFFFFF, false, false); // Yes + AddButton(100, 172, 4005, 4007, 1); + AddHtmlLocalized(135, 172, 120, 20, 1046362, 0xFFFFFF); // Yes - AddButton(275, 172, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(310, 172, 120, 20, 1046363, 0xFFFFFF, false, false); // No + AddButton(275, 172, 4005, 4007, 0); + AddHtmlLocalized(310, 172, 120, 20, 1046363, 0xFFFFFF); // No if (m_Scroll.Title != 0) - AddHtmlLocalized(40, 20, 260, 20, m_Scroll.Title, 0xFFFFFF, false, false); + AddHtmlLocalized(40, 20, 260, 20, m_Scroll.Title, 0xFFFFFF); else - AddHtml(40, 20, 260, 20, m_Scroll.DefaultTitle, false, false); + AddHtml(40, 20, 260, 20, m_Scroll.DefaultTitle); if (m_Scroll is StatCapScroll) - AddHtmlLocalized(310, 20, 120, 20, 1038019, 0xFFFFFF, false, false); // Power + AddHtmlLocalized(310, 20, 120, 20, 1038019, 0xFFFFFF); // Power else - AddHtmlLocalized(310, 20, 120, 20, AosSkillBonuses.GetLabel(m_Scroll.Skill), 0xFFFFFF, false, false); + AddHtmlLocalized(310, 20, 120, 20, AosSkillBonuses.GetLabel(m_Scroll.Skill), 0xFFFFFF); } public override void OnResponse(NetState state, RelayInfo info) @@ -168,4 +168,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Special Scrolls/StatScroll.cs b/Scripts/Items/Special/Special Scrolls/StatScroll.cs index 8edbe31f6..b24ed42ad 100644 --- a/Scripts/Items/Special/Special Scrolls/StatScroll.cs +++ b/Scripts/Items/Special/Special Scrolls/StatScroll.cs @@ -4,12 +4,8 @@ namespace Server.Items { public class StatCapScroll : SpecialScroll { - public StatCapScroll() : this(105) - { - } - [Constructible] - public StatCapScroll(int value) : base(SkillName.Alchemy, value) + public StatCapScroll(int value = 105) : base(SkillName.Alchemy, value) { Hue = 0x481; } @@ -132,4 +128,4 @@ namespace Server.Items Insured = false; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Valentines/2007/RedVelvetGiftBox.cs b/Scripts/Items/Special/Valentines/2007/RedVelvetGiftBox.cs index 0e581e3c3..b6018650a 100644 --- a/Scripts/Items/Special/Valentines/2007/RedVelvetGiftBox.cs +++ b/Scripts/Items/Special/Valentines/2007/RedVelvetGiftBox.cs @@ -8,13 +8,7 @@ namespace Server.Items public class RedVelvetGiftBox : BaseContainer { [Constructible] - public RedVelvetGiftBox() - : this(false) - { - } - - [Constructible] - public RedVelvetGiftBox(bool fill) + public RedVelvetGiftBox(bool fill = false) : base(0xE7A) { Hue = 0x20; @@ -60,4 +54,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs b/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs index 9b77fb989..a15105637 100644 --- a/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs +++ b/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs @@ -91,7 +91,7 @@ namespace Server.Items public override void OnClick() { - if (m_Ankh == null || m_Ankh.Deleted) + if (m_Ankh?.Deleted != false) return; Resurrect(m_Mobile as PlayerMobile, m_Ankh); @@ -131,7 +131,7 @@ namespace Server.Items private class AnkhResurrectGump : ResurrectGump { - public AnkhResurrectGump(Mobile owner, ResurrectMessage msg) : base(owner, owner, msg, false) + public AnkhResurrectGump(Mobile owner, ResurrectMessage msg) : base(owner, owner, msg) { } @@ -141,7 +141,7 @@ namespace Server.Items if (info.ButtonID == 1 || info.ButtonID == 2) { - if (from.Map == null || !from.Map.CanFit(from.Location, 16, false, false)) + if (from.Map?.CanFit(from.Location, 16, false, false) != true) { from.SendLocalizedMessage(502391); // Thou can not be resurrected there! return; @@ -241,12 +241,7 @@ namespace Server.Items private bool m_IsRewardItem; [Constructible] - public AnkhOfSacrificeDeed() : this(false) - { - } - - [Constructible] - public AnkhOfSacrificeDeed(bool isRewardItem) + public AnkhOfSacrificeDeed(bool isRewardItem = false) { LootType = LootType.Blessed; @@ -305,7 +300,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -345,4 +340,4 @@ namespace Server.Items m_IsRewardItem = reader.ReadBool(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/Banner.cs b/Scripts/Items/Special/Veteran Rewards/Banner.cs index 295770fcf..29463fe73 100644 --- a/Scripts/Items/Special/Veteran Rewards/Banner.cs +++ b/Scripts/Items/Special/Veteran Rewards/Banner.cs @@ -81,7 +81,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new RewardDemolitionGump(this, 1018318)); // Do you wish to re-deed this banner? @@ -155,14 +155,14 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new InternalGump(this)); @@ -227,7 +227,7 @@ namespace Server.Items for (int j = 0; j < 8; j++, itemID += 2) { AddItem(50 + 60 * j, 70, itemID); - AddButton(50 + 60 * j, 50, 0x845, 0x846, itemID, GumpButtonType.Reply, 0); + AddButton(50 + 60 * j, 50, 0x845, 0x846, itemID); } if (i > 1) @@ -240,17 +240,15 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if ((m_Banner == null) | m_Banner.Deleted) + if (m_Banner?.Deleted != false) return; Mobile m = sender.Mobile; - if (info.ButtonID >= Start && info.ButtonID <= End) - if ((info.ButtonID & 0x1) == 0) - { - m.SendLocalizedMessage(1042037); // Where would you like to place this banner? - m.Target = new InternalTarget(m_Banner, info.ButtonID); - } + 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); } } @@ -267,14 +265,14 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Banner == null || m_Banner.Deleted) + if (m_Banner?.Deleted != false) return; if (m_Banner.IsChildOf(from.Backpack)) { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { IPoint3D p = targeted as IPoint3D; Map map = from.Map; @@ -289,7 +287,7 @@ namespace Server.Items { house = BaseHouse.FindHouseAt(p3d, map, id.Height); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); @@ -362,20 +360,20 @@ namespace Server.Items AddItem(90, 30, itemID + 1); AddItem(180, 30, itemID); - AddButton(50, 35, 0x868, 0x869, (int)Buttons.East, GumpButtonType.Reply, 0); - AddButton(145, 35, 0x868, 0x869, (int)Buttons.South, GumpButtonType.Reply, 0); + AddButton(50, 35, 0x868, 0x869, (int)Buttons.East); + AddButton(145, 35, 0x868, 0x869, (int)Buttons.South); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Banner == null || m_Banner.Deleted || m_House == null) + if (m_Banner?.Deleted != false || m_House == null) return; Banner banner = null; if (info.ButtonID == (int)Buttons.East) banner = new Banner(m_ItemID + 1); - if (info.ButtonID == (int)Buttons.South) + else if (info.ButtonID == (int)Buttons.South) banner = new Banner(m_ItemID); if (banner != null) @@ -398,4 +396,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/BloodyPentagram.cs b/Scripts/Items/Special/Veteran Rewards/BloodyPentagram.cs index 7d713d286..b5137593d 100644 --- a/Scripts/Items/Special/Veteran Rewards/BloodyPentagram.cs +++ b/Scripts/Items/Special/Veteran Rewards/BloodyPentagram.cs @@ -163,7 +163,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; base.OnDoubleClick(from); @@ -195,4 +195,4 @@ namespace Server.Items m_IsRewardItem = reader.ReadBool(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/Brazier.cs b/Scripts/Items/Special/Veteran Rewards/Brazier.cs index e3b826dfd..7f43e8011 100644 --- a/Scripts/Items/Special/Veteran Rewards/Brazier.cs +++ b/Scripts/Items/Special/Veteran Rewards/Brazier.cs @@ -81,7 +81,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { if (m_Fire != null) TurnOff(); @@ -163,7 +163,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -223,35 +223,34 @@ namespace Server.Items AddLabel(45, 15, 0, "Choose a Brazier:"); AddItem(40, 75, 0x19AA); - AddButton(55, 50, 0x845, 0x846, 0x19AA, GumpButtonType.Reply, 0); + AddButton(55, 50, 0x845, 0x846, 0x19AA); AddItem(100, 75, 0x19BB); - AddButton(115, 50, 0x845, 0x846, 0x19BB, GumpButtonType.Reply, 0); + AddButton(115, 50, 0x845, 0x846, 0x19BB); } public override void OnResponse(NetState sender, RelayInfo info) { - if ((m_Brazier == null) | m_Brazier.Deleted) + if (m_Brazier?.Deleted != false) return; Mobile m = sender.Mobile; - if (info.ButtonID == 0x19AA || info.ButtonID == 0x19BB) - { - RewardBrazier brazier = new RewardBrazier(info.ButtonID); - brazier.IsRewardItem = m_Brazier.IsRewardItem; + if (info.ButtonID != 0x19AA && info.ButtonID != 0x19BB) + return; - if (!m.PlaceInBackpack(brazier)) - { - brazier.Delete(); - m.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. - } - else - { - m_Brazier.Delete(); - } + RewardBrazier brazier = new RewardBrazier(info.ButtonID) { IsRewardItem = m_Brazier.IsRewardItem }; + + if (!m.PlaceInBackpack(brazier)) + { + brazier.Delete(); + m.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. + } + else + { + m_Brazier.Delete(); } } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/Cannon.cs b/Scripts/Items/Special/Veteran Rewards/Cannon.cs index a530d5cd5..13634ade1 100644 --- a/Scripts/Items/Special/Veteran Rewards/Cannon.cs +++ b/Scripts/Items/Special/Veteran Rewards/Cannon.cs @@ -175,9 +175,9 @@ namespace Server.Items public int Validate(PotionKeg keg) { - if (keg == null || keg.Deleted || keg.Held != 100) + if (keg?.Deleted != false || keg.Held != 100) return 0; - + switch (keg.Type) { case PotionEffect.ExplosionLesser: @@ -261,7 +261,7 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Cannon == null || m_Cannon.Deleted) + if (m_Cannon?.Deleted != false) return; if (!(targeted is IPoint3D p)) @@ -342,22 +342,18 @@ namespace Server.Items AddBackground(0, 0, 291, 133, 0x13BE); AddImageTiled(5, 5, 280, 100, 0xA40); - AddHtmlLocalized(9, 9, 272, 100, 1076196, cannon.Validate(keg).ToString(), 0x7FFF, false, - false); // You will need a full keg of explosion potions to recharge the cannon. Your keg will provide ~1_CHARGES~ charges. + AddHtmlLocalized(9, 9, 272, 100, 1076196, cannon.Validate(keg).ToString(), 0x7FFF); // You will need a full keg of explosion potions to recharge the cannon. Your keg will provide ~1_CHARGES~ charges. - AddButton(5, 107, 0xFB1, 0xFB2, (int)Buttons.Cancel, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 109, 100, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(5, 107, 0xFB1, 0xFB2, (int)Buttons.Cancel); + AddHtmlLocalized(40, 109, 100, 20, 1060051, 0x7FFF); // CANCEL - AddButton(160, 107, 0xFB7, 0xFB8, (int)Buttons.Recharge, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 109, 120, 20, 1076197, 0x7FFF, false, false); // Recharge + AddButton(160, 107, 0xFB7, 0xFB8, (int)Buttons.Recharge); + AddHtmlLocalized(195, 109, 120, 20, 1076197, 0x7FFF); // Recharge } public override void OnResponse(NetState state, RelayInfo info) { - if (m_Cannon == null || m_Cannon.Deleted) - return; - - if (info.ButtonID == (int)Buttons.Recharge) + if (m_Cannon?.Deleted == false && info.ButtonID == (int)Buttons.Recharge) m_Cannon.Fill(state.Mobile, m_Keg); } @@ -388,17 +384,10 @@ namespace Server.Items public override int LabelNumber => 1076195; // A deed for a cannon - public override BaseAddon Addon + public override BaseAddon Addon => new CannonAddon(m_Direction) { - get - { - CannonAddon addon = new CannonAddon(m_Direction); - addon.Charges = m_Charges; - addon.IsRewardItem = m_IsRewardItem; - - return addon; - } - } + Charges = m_Charges, IsRewardItem = m_IsRewardItem + }; [CommandProperty(AccessLevel.GameMaster)] public int Charges @@ -450,7 +439,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -484,4 +473,4 @@ namespace Server.Items m_IsRewardItem = reader.ReadBool(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs b/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs index c31a93d34..545432dd1 100644 --- a/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs +++ b/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs @@ -11,12 +11,7 @@ namespace Server.Items private bool m_IsRewardItem; [Constructible] - public DecorativeShield() : this(0x156C) - { - } - - [Constructible] - public DecorativeShield(int itemID) : base(itemID) + public DecorativeShield(int itemID = 0x156C) : base(itemID) { Movable = false; } @@ -51,12 +46,9 @@ namespace Server.Items public bool CouldFit(IPoint3D p, Map map) { - if (map == null || !map.CanFit(p.X, p.Y, p.Z, ItemData.Height)) - 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 + return map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) == true && (FacingSouth + && BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map) + || BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map)); } [CommandProperty(AccessLevel.GameMaster)] @@ -84,7 +76,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration? @@ -158,7 +150,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -233,7 +225,7 @@ namespace Server.Items for (int j = 0; j < 9 - i; j++) { AddItem(40 + j * 60, 70, itemID); - AddButton(60 + j * 60, 50, 0x845, 0x846, itemID, GumpButtonType.Reply, 0); + AddButton(60 + j * 60, 50, 0x845, 0x846, itemID); if (itemID < 0x1582) itemID += 2; @@ -255,18 +247,13 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if ((m_Shield == null) | m_Shield.Deleted) + 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; - Mobile m = sender.Mobile; - - if (info.ButtonID >= Start && info.ButtonID <= End) - if ((info.ButtonID & 0x1) == 0 && info.ButtonID < 0x1582 || - info.ButtonID >= 0x1582 && info.ButtonID <= 0x1585) - { - m.SendLocalizedMessage(1049780); // Where would you like to place this decoration? - m.Target = new InternalTarget(m_Shield, info.ButtonID); - } + sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration? + sender.Mobile.Target = new InternalTarget(m_Shield, info.ButtonID); } } @@ -283,72 +270,68 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Shield == null || m_Shield.Deleted) + if (m_Shield?.Deleted != false) return; - if (m_Shield.IsChildOf(from.Backpack)) + if (!m_Shield.IsChildOf(from.Backpack)) { - BaseHouse house = BaseHouse.FindHouseAt(from); + from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + return; + } - if (house != null && house.IsOwner(from)) - { - IPoint3D p = targeted as IPoint3D; - Map map = from.Map; + BaseHouse house = BaseHouse.FindHouseAt(from); - if (p == null || map == null) - return; + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(502092); // You must be in your house to do this. + return; + } - Point3D p3d = new Point3D(p); - ItemData id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; + IPoint3D p = targeted as IPoint3D; + Map map = from.Map; - if (map.CanFit(p3d, id.Height)) - { - house = BaseHouse.FindHouseAt(p3d, map, id.Height); + if (p == null || map == null) + return; - if (house != null && house.IsOwner(from)) - { - bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); - bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); + Point3D p3d = new Point3D(p); + ItemData id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; - if (north && west) - { - from.CloseGump(); - from.SendGump(new FacingGump(m_Shield, m_ItemID, p3d, house)); - } - else if (north || west) - { - DecorativeShield shield = new DecorativeShield(west ? GetWestItemID(m_ItemID) : m_ItemID); + if (!map.CanFit(p3d, id.Height)) + { + from.SendLocalizedMessage(500269); // You cannot build that there. + return; + } - house.Addons.Add(shield); + house = BaseHouse.FindHouseAt(p3d, map, id.Height); - shield.IsRewardItem = m_Shield.IsRewardItem; - shield.MoveToWorld(p3d, map); + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(1042036); // That location is not in your house. + return; + } - m_Shield.Delete(); - } - else - { - from.SendLocalizedMessage(1049781); // This decoration must be placed next to a wall. - } - } - else - { - from.SendLocalizedMessage(1042036); // That location is not in your house. - } - } - else - { - from.SendLocalizedMessage(500269); // You cannot build that there. - } - } - else - { - from.SendLocalizedMessage(502092); // You must be in your house to do this. - } + bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); + bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); + + if (north && west) + { + from.CloseGump(); + from.SendGump(new FacingGump(m_Shield, m_ItemID, p3d, house)); + } + else if (north || west) + { + DecorativeShield shield = new DecorativeShield(west ? GetWestItemID(m_ItemID) : m_ItemID); + + house.Addons.Add(shield); + + shield.IsRewardItem = m_Shield.IsRewardItem; + shield.MoveToWorld(p3d, map); + + m_Shield.Delete(); } else { - from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + from.SendLocalizedMessage(1049781); // This decoration must be placed next to a wall. } } @@ -377,13 +360,13 @@ namespace Server.Items AddItem(90, 30, GetWestItemID(itemID)); AddItem(180, 30, itemID); - AddButton(50, 35, 0x867, 0x869, (int)Buttons.East, GumpButtonType.Reply, 0); - AddButton(145, 35, 0x867, 0x869, (int)Buttons.South, GumpButtonType.Reply, 0); + AddButton(50, 35, 0x867, 0x869, (int)Buttons.East); + AddButton(145, 35, 0x867, 0x869, (int)Buttons.South); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Shield == null || m_Shield.Deleted || m_House == null) + if (m_Shield?.Deleted != false || m_House == null) return; DecorativeShield shield = null; @@ -413,4 +396,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs b/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs index 764c9098f..5e8aad4f6 100644 --- a/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs +++ b/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs @@ -11,12 +11,7 @@ namespace Server.Items private bool m_IsRewardItem; [Constructible] - public FlamingHead() : this(StoneFaceTrapType.NorthWall) - { - } - - [Constructible] - public FlamingHead(StoneFaceTrapType type) + public FlamingHead(StoneFaceTrapType type = StoneFaceTrapType.NorthWall) { LootType = LootType.Blessed; Movable = false; @@ -82,7 +77,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new RewardDemolitionGump(this, 1018329)); // Do you wish to re-deed this skull? @@ -156,14 +151,14 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.SendLocalizedMessage(1042264); // Where would you like to place this head? from.Target = new InternalTarget(this); @@ -208,76 +203,72 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Head == null || m_Head.Deleted) + if (m_Head?.Deleted != false) return; - if (m_Head.IsChildOf(from.Backpack)) + if (!m_Head.IsChildOf(from.Backpack)) { - BaseHouse house = BaseHouse.FindHouseAt(from); + from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + return; + } - if (house != null && house.IsOwner(from)) - { - IPoint3D p = targeted as IPoint3D; - Map map = from.Map; + BaseHouse house = BaseHouse.FindHouseAt(from); - if (p == null || map == null) - return; + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(502115); // You must be in your house to do this. + return; + } - Point3D p3d = new Point3D(p); - ItemData id = TileData.ItemTable[0x10F5]; + IPoint3D p = targeted as IPoint3D; + Map map = from.Map; - house = BaseHouse.FindHouseAt(p3d, map, id.Height); + if (p == null || map == null) + return; - if (house != null && house.IsOwner(from)) - { - if (map.CanFit(p3d, id.Height)) - { - bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); - bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); + Point3D p3d = new Point3D(p); + ItemData id = TileData.ItemTable[0x10F5]; - FlamingHead head = null; + house = BaseHouse.FindHouseAt(p3d, map, id.Height); - if (north && west) - head = new FlamingHead(StoneFaceTrapType.NorthWestWall); - else if (north) - head = new FlamingHead(StoneFaceTrapType.NorthWall); - else if (west) - head = new FlamingHead(StoneFaceTrapType.WestWall); + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(1042036); // That location is not in your house. + return; + } - if (north || west) - { - house.Addons.Add(head); + if (!map.CanFit(p3d, id.Height)) + { + from.SendLocalizedMessage(1042266); // The head must be placed next to a wall. + return; + } - head.IsRewardItem = m_Head.IsRewardItem; - head.MoveToWorld(p3d, map); + bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); + bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); - m_Head.Delete(); - } - else - { - from.SendLocalizedMessage(1042266); // The head must be placed next to a wall. - } - } - else - { - from.SendLocalizedMessage(1042266); // The head must be placed next to a wall. - } - } - else - { - from.SendLocalizedMessage(1042036); // That location is not in your house. - } - } - else - { - from.SendLocalizedMessage(502115); // You must be in your house to do this. - } + 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) + { + house.Addons.Add(head); + + head.IsRewardItem = m_Head.IsRewardItem; + head.MoveToWorld(p3d, map); + + m_Head.Delete(); } else { - from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + from.SendLocalizedMessage(1042266); // The head must be placed next to a wall. } } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs index a2ff0091d..53ec046e0 100644 --- a/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs +++ b/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs @@ -11,12 +11,7 @@ namespace Server.Items private bool m_IsRewardItem; [Constructible] - public HangingSkeleton() : this(0x1596) - { - } - - [Constructible] - public HangingSkeleton(int itemID) : base(itemID) + public HangingSkeleton(int itemID = 0x1596) : base(itemID) { LootType = LootType.Blessed; Movable = false; @@ -86,7 +81,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration? @@ -160,14 +155,14 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new InternalGump(this)); @@ -231,34 +226,29 @@ namespace Server.Items AddPage(1); AddItem(130, 70, 0x1A03); - AddButton(150, 50, 0x845, 0x846, 0x1A03, GumpButtonType.Reply, 0); + AddButton(150, 50, 0x845, 0x846, 0x1A03); AddItem(190, 70, 0x1A05); - AddButton(210, 50, 0x845, 0x846, 0x1A05, GumpButtonType.Reply, 0); + AddButton(210, 50, 0x845, 0x846, 0x1A05); AddItem(250, 70, 0x1A09); - AddButton(270, 50, 0x845, 0x846, 0x1A09, GumpButtonType.Reply, 0); + AddButton(270, 50, 0x845, 0x846, 0x1A09); AddItem(310, 70, 0x1B1E); - AddButton(330, 50, 0x845, 0x846, 0x1B1E, GumpButtonType.Reply, 0); + AddButton(330, 50, 0x845, 0x846, 0x1B1E); AddItem(370, 70, 0x1B7F); - AddButton(390, 50, 0x845, 0x846, 0x1B7F, GumpButtonType.Reply, 0); + AddButton(390, 50, 0x845, 0x846, 0x1B7F); } public override void OnResponse(NetState sender, RelayInfo info) { - if ((m_Skeleton == null) | m_Skeleton.Deleted) + if (m_Skeleton?.Deleted != false || info.ButtonID != 0x1A03 && info.ButtonID != 0x1A05 && + info.ButtonID != 0x1A09 && info.ButtonID != 0x1B1E && info.ButtonID != 0x1B7F) return; - Mobile m = sender.Mobile; - - if (info.ButtonID == 0x1A03 || info.ButtonID == 0x1A05 || info.ButtonID == 0x1A09 || - info.ButtonID == 0x1B1E || info.ButtonID == 0x1B7F) - { - m.SendLocalizedMessage(1049780); // Where would you like to place this decoration? - m.Target = new InternalTarget(m_Skeleton, info.ButtonID); - } + sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration? + sender.Mobile.Target = new InternalTarget(m_Skeleton, info.ButtonID); } } @@ -275,72 +265,68 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Skeleton == null || m_Skeleton.Deleted) + if (m_Skeleton?.Deleted != false) return; - if (m_Skeleton.IsChildOf(from.Backpack)) + if (!m_Skeleton.IsChildOf(from.Backpack)) { - BaseHouse house = BaseHouse.FindHouseAt(from); + from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + return; + } - if (house != null && house.IsOwner(from)) - { - IPoint3D p = targeted as IPoint3D; - Map map = from.Map; + BaseHouse house = BaseHouse.FindHouseAt(from); - if (p == null || map == null) - return; + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(502092); // You must be in your house to do this. + return; + } - Point3D p3d = new Point3D(p); - ItemData id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; + IPoint3D p = targeted as IPoint3D; + Map map = from.Map; - if (map.CanFit(p3d, id.Height)) - { - house = BaseHouse.FindHouseAt(p3d, map, id.Height); + if (p == null || map == null) + return; - if (house != null && house.IsOwner(from)) - { - bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); - bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); + Point3D p3d = new Point3D(p); + ItemData id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue]; - if (north && west) - { - from.CloseGump(); - from.SendGump(new FacingGump(m_Skeleton, m_ItemID, p3d, house)); - } - else if (north || west) - { - HangingSkeleton banner = new HangingSkeleton(west ? GetWestItemID(m_ItemID) : m_ItemID); + if (!map.CanFit(p3d, id.Height)) + { + from.SendLocalizedMessage(500269); // You cannot build that there. + return; + } - house.Addons.Add(banner); + house = BaseHouse.FindHouseAt(p3d, map, id.Height); - banner.IsRewardItem = m_Skeleton.IsRewardItem; - banner.MoveToWorld(p3d, map); + if (house?.IsOwner(from) != true) + { + from.SendLocalizedMessage(1042036); // That location is not in your house. + return; + } - m_Skeleton.Delete(); - } - else - { - from.SendLocalizedMessage(1042039); // The banner must be placed next to a wall. - } - } - else - { - from.SendLocalizedMessage(1042036); // That location is not in your house. - } - } - else - { - from.SendLocalizedMessage(500269); // You cannot build that there. - } - } - else - { - from.SendLocalizedMessage(502092); // You must be in your house to do this. - } + bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); + bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); + + if (north && west) + { + from.CloseGump(); + from.SendGump(new FacingGump(m_Skeleton, m_ItemID, p3d, house)); + } + else if (north || west) + { + HangingSkeleton banner = new HangingSkeleton(west ? GetWestItemID(m_ItemID) : m_ItemID); + + house.Addons.Add(banner); + + banner.IsRewardItem = m_Skeleton.IsRewardItem; + banner.MoveToWorld(p3d, map); + + m_Skeleton.Delete(); } else { - from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. + from.SendLocalizedMessage(1042039); // The banner must be placed next to a wall. } } @@ -370,13 +356,13 @@ namespace Server.Items AddItem(90, 30, GetWestItemID(itemID)); AddItem(180, 30, itemID); - AddButton(50, 35, 0x868, 0x869, (int)Buttons.East, GumpButtonType.Reply, 0); - AddButton(145, 35, 0x868, 0x869, (int)Buttons.South, GumpButtonType.Reply, 0); + AddButton(50, 35, 0x868, 0x869, (int)Buttons.East); + AddButton(145, 35, 0x868, 0x869, (int)Buttons.South); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Skeleton == null || m_Skeleton.Deleted || m_House == null) + if (m_Skeleton?.Deleted != false || m_House == null) return; HangingSkeleton banner = null; @@ -406,4 +392,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/MiningCart.cs b/Scripts/Items/Special/Veteran Rewards/MiningCart.cs index 3a5a775a1..ab9255efd 100644 --- a/Scripts/Items/Special/Veteran Rewards/MiningCart.cs +++ b/Scripts/Items/Special/Veteran Rewards/MiningCart.cs @@ -139,7 +139,7 @@ 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. - else if (house != null && house.HasSecureAccess(from, SecureLevel.Friends)) + else if (house?.HasSecureAccess(from, SecureLevel.Friends) == true) switch (CartType) { case MiningCartType.OreSouth: @@ -404,7 +404,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -440,4 +440,4 @@ namespace Server.Items Ore = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/MinotaurStatue.cs b/Scripts/Items/Special/Veteran Rewards/MinotaurStatue.cs index 53dede4a0..55cb44c96 100644 --- a/Scripts/Items/Special/Veteran Rewards/MinotaurStatue.cs +++ b/Scripts/Items/Special/Veteran Rewards/MinotaurStatue.cs @@ -145,7 +145,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -185,4 +185,4 @@ namespace Server.Items m_IsRewardItem = reader.ReadBool(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs b/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs index d1d2ac356..f6c196d6c 100644 --- a/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs +++ b/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs @@ -90,7 +90,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -151,47 +151,44 @@ namespace Server.Items AddLabel(45, 15, 0, "Choose a Potted Cactus:"); AddItem(45, 75, 0x1E0F); - AddButton(55, 50, 0x845, 0x846, 0x1E0F, GumpButtonType.Reply, 0); + AddButton(55, 50, 0x845, 0x846, 0x1E0F); AddItem(105, 75, 0x1E10); - AddButton(115, 50, 0x845, 0x846, 0x1E10, GumpButtonType.Reply, 0); + AddButton(115, 50, 0x845, 0x846, 0x1E10); AddItem(160, 75, 0x1E14); - AddButton(175, 50, 0x845, 0x846, 0x1E14, GumpButtonType.Reply, 0); + AddButton(175, 50, 0x845, 0x846, 0x1E14); AddItem(220, 75, 0x1E11); - AddButton(235, 50, 0x845, 0x846, 0x1E11, GumpButtonType.Reply, 0); + AddButton(235, 50, 0x845, 0x846, 0x1E11); AddItem(280, 75, 0x1E12); - AddButton(295, 50, 0x845, 0x846, 0x1E12, GumpButtonType.Reply, 0); + AddButton(295, 50, 0x845, 0x846, 0x1E12); AddItem(340, 75, 0x1E13); - AddButton(355, 50, 0x845, 0x846, 0x1E13, GumpButtonType.Reply, 0); + AddButton(355, 50, 0x845, 0x846, 0x1E13); } public override void OnResponse(NetState sender, RelayInfo info) { - if ((m_Cactus == null) | m_Cactus.Deleted) + if (m_Cactus?.Deleted != false || info.ButtonID < 0x1E0F || info.ButtonID > 0x1E14) return; - Mobile m = sender.Mobile; - - if (info.ButtonID >= 0x1E0F && info.ButtonID <= 0x1E14) + RewardPottedCactus cactus = new RewardPottedCactus(info.ButtonID) { - RewardPottedCactus cactus = new RewardPottedCactus(info.ButtonID); - cactus.IsRewardItem = m_Cactus.IsRewardItem; + IsRewardItem = m_Cactus.IsRewardItem + }; - if (!m.PlaceInBackpack(cactus)) - { - cactus.Delete(); - m.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. - } - else - { - m_Cactus.Delete(); - } + if (!sender.Mobile.PlaceInBackpack(cactus)) + { + cactus.Delete(); + sender.Mobile.SendLocalizedMessage(1078837); // Your backpack is full! Please make room and try again. + } + else + { + m_Cactus.Delete(); } } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs b/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs index fb3acdc51..d48c73219 100644 --- a/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs +++ b/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs @@ -46,12 +46,7 @@ namespace Server.Items private bool m_IsRewardItem; [Constructible] - public StoneAnkh() : this(true) - { - } - - [Constructible] - public StoneAnkh(bool east) + public StoneAnkh(bool east = true) { if (east) { @@ -110,7 +105,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsOwner(from)) + if (house?.IsOwner(from) == true) { from.CloseGump(); from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration? @@ -187,7 +182,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -251,23 +246,20 @@ namespace Server.Items AddItem(90, 30, 0x4); AddItem(112, 30, 0x5); - AddButton(50, 35, 0x867, 0x869, (int)Buttons.South, GumpButtonType.Reply, 0); // South + AddButton(50, 35, 0x867, 0x869, (int)Buttons.South); // South AddItem(170, 30, 0x2); AddItem(192, 30, 0x3); - AddButton(145, 35, 0x867, 0x869, (int)Buttons.East, GumpButtonType.Reply, 0); // East + AddButton(145, 35, 0x867, 0x869, (int)Buttons.East); // East } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed == null || m_Deed.Deleted) + if (m_Deed?.Deleted != false || info.ButtonID == (int)Buttons.Cancel) return; - if (info.ButtonID != (int)Buttons.Cancel) - { - m_Deed.m_East = info.ButtonID == (int)Buttons.East; - m_Deed.SendTarget(sender.Mobile); - } + m_Deed.m_East = info.ButtonID == (int)Buttons.East; + m_Deed.SendTarget(sender.Mobile); } private enum Buttons @@ -278,4 +270,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/TreeStump.cs b/Scripts/Items/Special/Veteran Rewards/TreeStump.cs index 38ec47364..5e17e6956 100644 --- a/Scripts/Items/Special/Veteran Rewards/TreeStump.cs +++ b/Scripts/Items/Special/Veteran Rewards/TreeStump.cs @@ -92,7 +92,7 @@ namespace Server.Items { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } - else if (house != null && house.HasSecureAccess(from, SecureLevel.Friends)) + else if (house?.HasSecureAccess(from, SecureLevel.Friends) == true) { if (m_Logs > 0) { @@ -275,7 +275,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -309,4 +309,4 @@ namespace Server.Items m_Logs = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/WallBanner.cs b/Scripts/Items/Special/Veteran Rewards/WallBanner.cs index 48bcd1fce..bf3a270f4 100644 --- a/Scripts/Items/Special/Veteran Rewards/WallBanner.cs +++ b/Scripts/Items/Special/Veteran Rewards/WallBanner.cs @@ -312,7 +312,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (IsChildOf(from.Backpack)) @@ -372,27 +372,27 @@ namespace Server.Items AddItem(55, 110, 0x161D); AddItem(75, 90, 0x161E); AddItem(95, 70, 0x161F); - AddButton(70, 50, 0x845, 0x846, 1, GumpButtonType.Reply, 0); + AddButton(70, 50, 0x845, 0x846, 1); AddItem(105, 70, 0x1586); AddItem(125, 90, 0x1587); AddItem(145, 110, 0x1588); - AddButton(145, 50, 0x845, 0x846, 2, GumpButtonType.Reply, 0); + AddButton(145, 50, 0x845, 0x846, 2); AddItem(200, 110, 0x1620); AddItem(220, 90, 0x1621); AddItem(240, 70, 0x1622); - AddButton(220, 50, 0x845, 0x846, 3, GumpButtonType.Reply, 0); + AddButton(220, 50, 0x845, 0x846, 3); AddItem(250, 70, 0x1589); AddItem(270, 90, 0x158A); AddItem(290, 110, 0x158B); - AddButton(300, 50, 0x845, 0x846, 4, GumpButtonType.Reply, 0); + AddButton(300, 50, 0x845, 0x846, 4); AddItem(350, 110, 0x1623); AddItem(370, 90, 0x1624); AddItem(390, 70, 0x1625); - AddButton(365, 50, 0x845, 0x846, 5, GumpButtonType.Reply, 0); + AddButton(365, 50, 0x845, 0x846, 5); AddItem(400, 70, 0x158C); AddItem(420, 90, 0x158D); AddItem(440, 110, 0x158E); - AddButton(445, 50, 0x845, 0x846, 6, GumpButtonType.Reply, 0); + AddButton(445, 50, 0x845, 0x846, 6); AddButton(455, 205, 0x8B0, 0x8B0, 0, GumpButtonType.Page, 2); AddPage(2); @@ -400,27 +400,27 @@ namespace Server.Items AddItem(52, 110, 0x1626); AddItem(72, 90, 0x1627); AddItem(95, 70, 0x1628); - AddButton(70, 50, 0x845, 0x846, 7, GumpButtonType.Reply, 0); + AddButton(70, 50, 0x845, 0x846, 7); AddItem(105, 70, 0x1590); AddItem(125, 90, 0x1591); AddItem(145, 110, 0x158F); - AddButton(145, 50, 0x845, 0x846, 8, GumpButtonType.Reply, 0); + AddButton(145, 50, 0x845, 0x846, 8); AddItem(197, 110, 0x1626); AddItem(217, 90, 0x1629); AddItem(240, 70, 0x162A); - AddButton(220, 50, 0x845, 0x846, 9, GumpButtonType.Reply, 0); + AddButton(220, 50, 0x845, 0x846, 9); AddItem(250, 70, 0x1592); AddItem(270, 90, 0x1593); AddItem(290, 110, 0x158F); - AddButton(300, 50, 0x845, 0x846, 10, GumpButtonType.Reply, 0); + AddButton(300, 50, 0x845, 0x846, 10); AddItem(340, 110, 0x162B); AddItem(363, 90, 0x162C); AddItem(385, 70, 0x162D); - AddButton(365, 50, 0x845, 0x846, 11, GumpButtonType.Reply, 0); + AddButton(365, 50, 0x845, 0x846, 11); AddItem(395, 70, 0x1594); AddItem(417, 90, 0x1595); AddItem(439, 111, 0x1596); - AddButton(445, 50, 0x845, 0x846, 12, GumpButtonType.Reply, 0); + AddButton(445, 50, 0x845, 0x846, 12); AddButton(70, 205, 0x8AF, 0x8AF, 0, GumpButtonType.Page, 1); AddButton(455, 205, 0x8B0, 0x8B0, 0, GumpButtonType.Page, 3); @@ -429,25 +429,25 @@ namespace Server.Items AddItem(55, 110, 0x162E); AddItem(75, 93, 0x1631); AddItem(95, 70, 0x1632); - AddButton(70, 50, 0x845, 0x846, 13, GumpButtonType.Reply, 0); + AddButton(70, 50, 0x845, 0x846, 13); AddItem(118, 70, 0x1598); AddItem(138, 94, 0x159B); AddItem(159, 113, 0x159C); - AddButton(160, 50, 0x845, 0x846, 14, GumpButtonType.Reply, 0); + AddButton(160, 50, 0x845, 0x846, 14); AddItem(219, 111, 0x162F); AddItem(238, 94, 0x1630); AddItem(258, 70, 0x1633); - AddButton(240, 50, 0x845, 0x846, 15, GumpButtonType.Reply, 0); + AddButton(240, 50, 0x845, 0x846, 15); AddItem(279, 70, 0x1599); AddItem(298, 93, 0x159A); AddItem(319, 113, 0x159D); - AddButton(320, 50, 0x845, 0x846, 16, GumpButtonType.Reply, 0); + AddButton(320, 50, 0x845, 0x846, 16); AddItem(380, 90, 0x160F); AddItem(400, 70, 0x1610); - AddButton(390, 50, 0x845, 0x846, 17, GumpButtonType.Reply, 0); + AddButton(390, 50, 0x845, 0x846, 17); AddItem(420, 70, 0x15A0); AddItem(440, 90, 0x15A1); - AddButton(455, 50, 0x845, 0x846, 18, GumpButtonType.Reply, 0); + AddButton(455, 50, 0x845, 0x846, 18); AddButton(70, 205, 0x8AF, 0x8AF, 0, GumpButtonType.Page, 2); AddButton(455, 205, 0x8B0, 0x8B0, 0, GumpButtonType.Page, 4); @@ -455,22 +455,22 @@ namespace Server.Items AddItem(55, 90, 0x1611); AddItem(75, 70, 0x1612); - AddButton(70, 50, 0x845, 0x846, 19, GumpButtonType.Reply, 0); + AddButton(70, 50, 0x845, 0x846, 19); AddItem(105, 70, 0x15A2); AddItem(125, 90, 0x15A3); - AddButton(145, 50, 0x845, 0x846, 20, GumpButtonType.Reply, 0); + AddButton(145, 50, 0x845, 0x846, 20); AddItem(200, 84, 0x1613); AddItem(220, 70, 0x1614); - AddButton(215, 50, 0x845, 0x846, 21, GumpButtonType.Reply, 0); + AddButton(215, 50, 0x845, 0x846, 21); AddItem(250, 70, 0x15A4); AddItem(270, 84, 0x15A5); - AddButton(290, 50, 0x845, 0x846, 22, GumpButtonType.Reply, 0); + AddButton(290, 50, 0x845, 0x846, 22); AddItem(350, 90, 0x1615); AddItem(370, 70, 0x1616); - AddButton(365, 50, 0x845, 0x846, 23, GumpButtonType.Reply, 0); + AddButton(365, 50, 0x845, 0x846, 23); AddItem(400, 70, 0x15A6); AddItem(420, 90, 0x15A7); - AddButton(445, 50, 0x845, 0x846, 24, GumpButtonType.Reply, 0); + AddButton(445, 50, 0x845, 0x846, 24); AddButton(70, 205, 0x8AF, 0x8AF, 0, GumpButtonType.Page, 3); AddButton(455, 205, 0x8B0, 0x8B0, 0, GumpButtonType.Page, 5); @@ -478,33 +478,32 @@ namespace Server.Items AddItem(55, 90, 0x1617); AddItem(77, 70, 0x1618); - AddButton(70, 50, 0x845, 0x846, 25, GumpButtonType.Reply, 0); + AddButton(70, 50, 0x845, 0x846, 25); AddItem(105, 70, 0x15A8); AddItem(127, 90, 0x15A9); - AddButton(145, 50, 0x845, 0x846, 26, GumpButtonType.Reply, 0); + AddButton(145, 50, 0x845, 0x846, 26); AddItem(200, 90, 0x1619); AddItem(222, 70, 0x161A); - AddButton(220, 50, 0x845, 0x846, 27, GumpButtonType.Reply, 0); + AddButton(220, 50, 0x845, 0x846, 27); AddItem(250, 70, 0x15AA); AddItem(272, 90, 0x15AB); - AddButton(300, 50, 0x845, 0x846, 28, GumpButtonType.Reply, 0); + AddButton(300, 50, 0x845, 0x846, 28); AddItem(350, 90, 0x161B); AddItem(372, 70, 0x161C); - AddButton(365, 50, 0x845, 0x846, 29, GumpButtonType.Reply, 0); + AddButton(365, 50, 0x845, 0x846, 29); AddItem(400, 70, 0x15AC); AddItem(422, 90, 0x15AD); - AddButton(445, 50, 0x845, 0x846, 30, GumpButtonType.Reply, 0); + AddButton(445, 50, 0x845, 0x846, 30); AddButton(70, 205, 0x8AF, 0x8AF, 0, GumpButtonType.Page, 4); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_WallBanner == null || m_WallBanner.Deleted) + if (m_WallBanner?.Deleted != false || info.ButtonID <= 0 || info.ButtonID >= 31) return; - if (info.ButtonID > 0 && info.ButtonID < 31) - m_WallBanner.Use(sender.Mobile, info.ButtonID); + m_WallBanner.Use(sender.Mobile, info.ButtonID); } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs b/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs index cb4566041..403059879 100644 --- a/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs +++ b/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs @@ -13,12 +13,7 @@ namespace Server.Items private int m_UsesRemaining; [Constructible] - public WeaponEngravingTool() : this(10) - { - } - - [Constructible] - public WeaponEngravingTool(int uses) : base(0x32F8) + public WeaponEngravingTool(int uses = 10) : base(0x32F8) { LootType = LootType.Blessed; Weight = 1.0; @@ -62,7 +57,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) + if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) return; if (m_UsesRemaining > 0) @@ -130,7 +125,7 @@ namespace Server.Items { if (from.Backpack == null) return; - + BlueDiamond diamond = from.Backpack.FindItemByType(); if (guildmaster != null) @@ -206,7 +201,7 @@ namespace Server.Items protected override void OnTarget(Mobile from, object targeted) { - if (m_Tool == null || m_Tool.Deleted) + if (m_Tool?.Deleted != false) return; if (targeted is BaseWeapon item) @@ -240,11 +235,11 @@ namespace Server.Items AddPage(0); - AddHtmlLocalized(50, 70, 400, 20, 1072359, 0x0, false, false); //
Engraving Tool
+ AddHtmlLocalized(50, 70, 400, 20, 1072359, 0x0); //
Engraving Tool
AddHtmlLocalized(75, 95, 350, 145, 1076229, 0x0, true, true); // Please enter the text to add to the selected object. Leave the text area blank to remove any existing text. Removing text does not use a charge. - AddButton(125, 300, 0x81A, 0x81B, (int)Buttons.Okay, GumpButtonType.Reply, 0); - AddButton(320, 300, 0x819, 0x818, (int)Buttons.Cancel, GumpButtonType.Reply, 0); + AddButton(125, 300, 0x81A, 0x81B, (int)Buttons.Okay); + AddButton(320, 300, 0x819, 0x818, (int)Buttons.Cancel); AddImageTiled(75, 245, 350, 40, 0xDB0); AddImageTiled(76, 245, 350, 2, 0x23C5); AddImageTiled(75, 245, 2, 40, 0x23C3); @@ -256,38 +251,34 @@ namespace Server.Items public override void OnResponse(NetState state, RelayInfo info) { - if (m_Tool == null || m_Tool.Deleted || m_Target == null || m_Target.Deleted) + if (m_Tool?.Deleted != false || m_Target?.Deleted != false) return; - if (info.ButtonID == (int)Buttons.Okay) - { + if (info.ButtonID != (int)Buttons.Okay) + { + state.Mobile.SendLocalizedMessage(1072363); // The object was not engraved. + return; + } + TextRelay relay = info.GetTextEntry((int)Buttons.Text); - if (relay != null) + if (relay == null) + return; + + if (string.IsNullOrEmpty(relay.Text)) { - if (string.IsNullOrEmpty(relay.Text)) - { m_Target.EngravedText = null; state.Mobile.SendLocalizedMessage(1072362); // You remove the engraving from the object. - } - else - { - if (relay.Text.Length > 64) - m_Target.EngravedText = Utility.FixHtml(relay.Text.Substring(0, 64)); - else - m_Target.EngravedText = Utility.FixHtml(relay.Text); - + } + else + { + m_Target.EngravedText = Utility.FixHtml(relay.Text.Length > 64 ? + relay.Text.Substring(0, 64) : relay.Text); state.Mobile.SendLocalizedMessage(1072361); // You engraved the object. m_Target.InvalidateProperties(); m_Tool.UsesRemaining -= 1; m_Tool.InvalidateProperties(); - } } - } - else - { - state.Mobile.SendLocalizedMessage(1072363); // The object was not engraved. - } } private enum Buttons @@ -320,29 +311,26 @@ namespace Server.Items if (guildmaster != null) { - AddHtmlLocalized(9, 9, 272, 100, 1076169, 0x7FFF, false, - false); // It will cost you 100,000 gold and a blue diamond to recharge your weapon engraver with 10 charges. - AddHtmlLocalized(195, 109, 120, 20, 1076172, 0x7FFF, false, false); // Recharge it + AddHtmlLocalized(9, 9, 272, 100, 1076169, 0x7FFF); // It will cost you 100,000 gold and a blue diamond to recharge your weapon engraver with 10 charges. + AddHtmlLocalized(195, 109, 120, 20, 1076172, 0x7FFF); // Recharge it } else { - AddHtmlLocalized(9, 9, 272, 100, 1076176, 0x7FFF, false, - false); // You will need a blue diamond to repair the tip of the engraver. A successful repair will give the engraver 10 charges. - AddHtmlLocalized(195, 109, 120, 20, 1076177, 0x7FFF, false, false); // Replace the tip. + AddHtmlLocalized(9, 9, 272, 100, 1076176, 0x7FFF); // You will need a blue diamond to repair the tip of the engraver. A successful repair will give the engraver 10 charges. + AddHtmlLocalized(195, 109, 120, 20, 1076177, 0x7FFF); // Replace the tip. } - AddButton(160, 107, 0xFB7, 0xFB8, (int)Buttons.Confirm, GumpButtonType.Reply, 0); - AddButton(5, 107, 0xFB1, 0xFB2, (int)Buttons.Cancel, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 109, 100, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(160, 107, 0xFB7, 0xFB8, (int)Buttons.Confirm); + AddButton(5, 107, 0xFB1, 0xFB2, (int)Buttons.Cancel); + AddHtmlLocalized(40, 109, 100, 20, 1060051, 0x7FFF); // CANCEL } public override void OnResponse(NetState state, RelayInfo info) { - if (m_Engraver == null || m_Engraver.Deleted) + if (m_Engraver?.Deleted != false || info.ButtonID != (int)Buttons.Confirm) return; - if (info.ButtonID == (int)Buttons.Confirm) - m_Engraver.Recharge(state.Mobile, m_Guildmaster); + m_Engraver.Recharge(state.Mobile, m_Guildmaster); } private enum Buttons @@ -352,4 +340,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Suits/BaseSuit.cs b/Scripts/Items/Suits/BaseSuit.cs index 63ecdf70b..d824c571e 100644 --- a/Scripts/Items/Suits/BaseSuit.cs +++ b/Scripts/Items/Suits/BaseSuit.cs @@ -47,15 +47,12 @@ namespace Server.Items public bool Validate() { - object root = RootParent; + if (!(RootParent is Mobile mobile) || mobile.AccessLevel >= AccessLevel) + return true; - if (root is Mobile mobile && mobile.AccessLevel < AccessLevel) - { - Delete(); - return false; - } + Delete(); + return false; - return true; } public override void OnSingleClick(Mobile from) @@ -83,4 +80,4 @@ namespace Server.Items return from.AccessLevel >= AccessLevel; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Talismans/BaseTalisman.cs b/Scripts/Items/Talismans/BaseTalisman.cs index be0f82ae3..1450952b7 100644 --- a/Scripts/Items/Talismans/BaseTalisman.cs +++ b/Scripts/Items/Talismans/BaseTalisman.cs @@ -124,7 +124,8 @@ namespace Server.Items Mobile m = e.Mobile; int count = e.GetInt32(0); - for (int i = 0; i < count; i++) m.AddToBackpack(Loot.RandomTalisman()); + for (int i = 0; i < count; i++) + m.AddToBackpack(Loot.RandomTalisman()); } public override void OnAfterDuped(Item newItem) @@ -180,7 +181,7 @@ namespace Server.Items SkillBonuses.Remove(); Attributes.RemoveStatBonuses(from); - if (m_Creature != null && !m_Creature.Deleted) + if (m_Creature?.Deleted == false) { Effects.SendLocationParticles( EffectItem.Create(m_Creature.Location, m_Creature.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, @@ -201,108 +202,110 @@ namespace Server.Items if (from.Talisman != this) { from.SendLocalizedMessage(502641); // You must equip this item to use it. + return; } - else if (m_ChargeTime > 0) + + if (m_ChargeTime > 0) { from.SendLocalizedMessage(1074882, m_ChargeTime.ToString()); // You must wait ~1_val~ seconds for this to recharge. + return; } - else if (m_Charges == 0 && m_MaxCharges > 0) + + if (m_Charges == 0 && m_MaxCharges > 0) { from.SendLocalizedMessage(1042544); // This item is out of charges. + return; } - else + + Type type = GetSummoner(); + + if (m_Summoner?.IsEmpty == false) + type = m_Summoner.Type; + + if (type != null) { - Type type = GetSummoner(); + object obj; - if (m_Summoner != null && !m_Summoner.IsEmpty) - type = m_Summoner.Type; - - if (type != null) + try { - object obj; - - try - { - obj = Activator.CreateInstance(type); - } - catch - { - obj = null; - } - - if (obj is Item item) - { - int count = 1; - - if (m_Summoner != null && 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 || - from.Backpack.Items.Count + count > from.Backpack.MaxItems) - { - from.SendLocalizedMessage(500720); // You don't have enough room in your backpack! - item.Delete(); - item = null; - return; - } - - for (int i = 0; i < count; i++) - { - from.PlaceInBackpack(item); - - if (i + 1 < count) - item = Activator.CreateInstance(type) as Item; - } - - if (item is Board) - from.SendLocalizedMessage(1075000); // You have been given some wooden boards. - else if (item is IronIngot) - from.SendLocalizedMessage(1075001); // You have been given some ingots. - else if (item is Bandage) - 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~ - } - else if (obj is BaseCreature mob) - { - if (m_Creature != null && !m_Creature.Deleted || - from.Followers + mob.ControlSlots > from.FollowersMax) - { - from.SendLocalizedMessage(1074270); // You have too many followers to summon another one. - mob.Delete(); - return; - } - - BaseCreature.Summon(mob, from, from.Location, mob.BaseSoundID, TimeSpan.FromMinutes(10)); - Effects.SendLocationParticles(EffectItem.Create(mob.Location, mob.Map, EffectItem.DefaultDuration), - 0x3728, 1, 10, 0x26B6); - - mob.Summoned = false; - mob.ControlOrder = OrderType.Friend; - - m_Creature = mob; - } - - OnAfterUse(from); + obj = Activator.CreateInstance(type); + } + catch + { + obj = null; } - if (m_Removal != TalismanRemoval.None) from.Target = new TalismanTarget(this); + if (obj is Item item) + { + int count = 1; + + 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 || + from.Backpack.Items.Count + count > from.Backpack.MaxItems) + { + from.SendLocalizedMessage(500720); // You don't have enough room in your backpack! + item.Delete(); + return; + } + + for (int i = 0; i < count; i++) + { + from.PlaceInBackpack(item); + + if (i + 1 < count) + item = Activator.CreateInstance(type) as Item; + } + + if (item is Board) + from.SendLocalizedMessage(1075000); // You have been given some wooden boards. + else if (item is IronIngot) + from.SendLocalizedMessage(1075001); // You have been given some ingots. + else if (item is Bandage) + 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~ + } + else if (obj is BaseCreature mob) + { + if (m_Creature?.Deleted == false || from.Followers + mob.ControlSlots > from.FollowersMax) + { + from.SendLocalizedMessage(1074270); // You have too many followers to summon another one. + mob.Delete(); + return; + } + + BaseCreature.Summon(mob, from, from.Location, mob.BaseSoundID, TimeSpan.FromMinutes(10)); + Effects.SendLocationParticles(EffectItem.Create(mob.Location, mob.Map, EffectItem.DefaultDuration), + 0x3728, 1, 10, 0x26B6); + + mob.Summoned = false; + mob.ControlOrder = OrderType.Friend; + + m_Creature = mob; + } + + OnAfterUse(from); } + + if (m_Removal != TalismanRemoval.None) + from.Target = new TalismanTarget(this); } public override void AddNameProperty(ObjectPropertyList list) { if (ForceShowName) base.AddNameProperty(list); - else if (m_Summoner != null && !m_Summoner.IsEmpty) + else if (m_Summoner?.IsEmpty == false) list.Add(1072400, - m_Summoner.Name != null ? m_Summoner.Name.ToString() : "Unknown"); // Talisman of ~1_name~ Summoning + 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 @@ -332,7 +335,7 @@ namespace Server.Items list.Add(1075085); // Requirement: Mondain's Legacy - if (m_Killer != null && !m_Killer.IsEmpty && m_Killer.Amount > 0) + if (m_Killer?.IsEmpty == false && m_Killer.Amount > 0) list.Add(1072388, "{0}\t{1}", m_Killer.Name != null ? m_Killer.Name.ToString() : "Unknown", m_Killer.Amount); // ~1_NAME~ Killer: +~2_val~% @@ -452,9 +455,9 @@ namespace Server.Items SetSaveFlag(ref flags, SaveFlag.Attributes, !Attributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !SkillBonuses.IsEmpty); - SetSaveFlag(ref flags, SaveFlag.Protection, m_Protection != null && !m_Protection.IsEmpty); - SetSaveFlag(ref flags, SaveFlag.Killer, m_Killer != null && !m_Killer.IsEmpty); - SetSaveFlag(ref flags, SaveFlag.Summoner, m_Summoner != null && !m_Summoner.IsEmpty); + SetSaveFlag(ref flags, SaveFlag.Protection, m_Protection?.IsEmpty == false); + SetSaveFlag(ref flags, SaveFlag.Killer, m_Killer?.IsEmpty == false); + SetSaveFlag(ref flags, SaveFlag.Summoner, m_Summoner?.IsEmpty == false); SetSaveFlag(ref flags, SaveFlag.Removal, m_Removal != TalismanRemoval.None); SetSaveFlag(ref flags, SaveFlag.Skill, (int)m_Skill != 0); SetSaveFlag(ref flags, SaveFlag.SuccessBonus, m_SuccessBonus != 0); @@ -523,34 +526,18 @@ namespace Server.Items { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.Attributes)) - Attributes = new AosAttributes(this, reader); - else - Attributes = new AosAttributes(this); - - if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) - SkillBonuses = new AosSkillBonuses(this, reader); - else - SkillBonuses = new AosSkillBonuses(this); + Attributes = GetSaveFlag(flags, SaveFlag.Attributes) ? new AosAttributes(this, reader) : new AosAttributes(this); + SkillBonuses = GetSaveFlag(flags, SaveFlag.SkillBonuses) + ? new AosSkillBonuses(this, reader) + : new AosSkillBonuses(this); // Backward compatibility if (GetSaveFlag(flags, SaveFlag.Owner)) BlessedFor = reader.ReadMobile(); - if (GetSaveFlag(flags, SaveFlag.Protection)) - m_Protection = new TalismanAttribute(reader); - else - m_Protection = new TalismanAttribute(); - - if (GetSaveFlag(flags, SaveFlag.Killer)) - m_Killer = new TalismanAttribute(reader); - else - m_Killer = new TalismanAttribute(); - - if (GetSaveFlag(flags, SaveFlag.Summoner)) - m_Summoner = new TalismanAttribute(reader); - else - m_Summoner = new TalismanAttribute(); + m_Protection = GetSaveFlag(flags, SaveFlag.Protection) ? new TalismanAttribute(reader) : new TalismanAttribute(); + m_Killer = GetSaveFlag(flags, SaveFlag.Killer) ? new TalismanAttribute(reader) : new TalismanAttribute(); + m_Summoner = GetSaveFlag(flags, SaveFlag.Summoner) ? new TalismanAttribute(reader) : new TalismanAttribute(); if (GetSaveFlag(flags, SaveFlag.Removal)) m_Removal = (TalismanRemoval)reader.ReadEncodedInt(); @@ -666,116 +653,119 @@ namespace Server.Items protected override void OnTarget(Mobile from, object o) { - if (m_Talisman == null || m_Talisman.Deleted) + if (m_Talisman?.Deleted != false) return; - Mobile target = o as Mobile; - if (from.Talisman != m_Talisman) { from.SendLocalizedMessage(502641); // You must equip this item to use it. + return; } - else if (target == null) + + if (!(o is Mobile target)) { from.SendLocalizedMessage(1046439); // That is not a valid target. + return; } - else if (m_Talisman.ChargeTime > 0) + + if (m_Talisman.ChargeTime > 0) { from.SendLocalizedMessage(1074882, m_Talisman.ChargeTime.ToString()); // You must wait ~1_val~ seconds for this to recharge. + return; } - else if (m_Talisman.Charges == 0 && m_Talisman.MaxCharges > 0) + + if (m_Talisman.Charges == 0 && m_Talisman.MaxCharges > 0) { from.SendLocalizedMessage(1042544); // This item is out of charges. + return; } - else + + switch (m_Talisman.Removal) { - switch (m_Talisman.Removal) - { - case TalismanRemoval.Curse: - target.PlaySound(0xF6); - target.PlaySound(0x1F7); - target.FixedParticles(0x3709, 1, 30, 9963, 13, 3, EffectLayer.Head); + case TalismanRemoval.Curse: + target.PlaySound(0xF6); + target.PlaySound(0x1F7); + target.FixedParticles(0x3709, 1, 30, 9963, 13, 3, EffectLayer.Head); - IEntity mfrom = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z - 10), - from.Map); - IEntity mto = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z + 50), from.Map); - Effects.SendMovingParticles(mfrom, mto, 0x2255, 1, 0, false, false, 13, 3, 9501, 1, 0, - EffectLayer.Head, 0x100); + IEntity mfrom = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z - 10), + from.Map); + IEntity mto = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z + 50), from.Map); + Effects.SendMovingParticles(mfrom, mto, 0x2255, 1, 0, false, false, 13, 3, 9501, 1, 0, + EffectLayer.Head, 0x100); - StatMod mod; + StatMod mod; - mod = target.GetStatMod("[Magic] Str Offset"); - if (mod != null && mod.Offset < 0) - target.RemoveStatMod("[Magic] Str Offset"); + mod = target.GetStatMod("[Magic] Str Offset"); + if (mod?.Offset < 0) + target.RemoveStatMod("[Magic] Str Offset"); - mod = target.GetStatMod("[Magic] Dex Offset"); - if (mod != null && mod.Offset < 0) - target.RemoveStatMod("[Magic] Dex Offset"); + mod = target.GetStatMod("[Magic] Dex Offset"); + if (mod?.Offset < 0) + target.RemoveStatMod("[Magic] Dex Offset"); - mod = target.GetStatMod("[Magic] Int Offset"); - if (mod != null && mod.Offset < 0) - target.RemoveStatMod("[Magic] Int Offset"); + mod = target.GetStatMod("[Magic] Int Offset"); + if (mod?.Offset < 0) + target.RemoveStatMod("[Magic] Int Offset"); - target.Paralyzed = false; + target.Paralyzed = false; - EvilOmenSpell.TryEndEffect(target); - StrangleSpell.RemoveCurse(target); - CorpseSkinSpell.RemoveCurse(target); - CurseSpell.RemoveEffect(target); + EvilOmenSpell.TryEndEffect(target); + StrangleSpell.RemoveCurse(target); + CorpseSkinSpell.RemoveCurse(target); + CurseSpell.RemoveEffect(target); - BuffInfo.RemoveBuff(target, BuffIcon.Clumsy); - BuffInfo.RemoveBuff(target, BuffIcon.FeebleMind); - BuffInfo.RemoveBuff(target, BuffIcon.Weaken); - BuffInfo.RemoveBuff(target, BuffIcon.MassCurse); + BuffInfo.RemoveBuff(target, BuffIcon.Clumsy); + BuffInfo.RemoveBuff(target, BuffIcon.FeebleMind); + BuffInfo.RemoveBuff(target, BuffIcon.Weaken); + BuffInfo.RemoveBuff(target, BuffIcon.MassCurse); - target.SendLocalizedMessage(1072408); // Any curses on you have been lifted + target.SendLocalizedMessage(1072408); // Any curses on you have been lifted - if (target != from) - from.SendLocalizedMessage(1072409); // Your targets curses have been lifted + if (target != from) + from.SendLocalizedMessage(1072409); // Your targets curses have been lifted - break; - case TalismanRemoval.Damage: - target.PlaySound(0x201); - Effects.SendLocationParticles( - EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 1, 13, - 0x834, 0, 0x13B2, 0); + break; + case TalismanRemoval.Damage: + target.PlaySound(0x201); + Effects.SendLocationParticles( + EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 1, 13, + 0x834, 0, 0x13B2, 0); - BleedAttack.EndBleed(target, true); - MortalStrike.EndWound(target); + BleedAttack.EndBleed(target, true); + MortalStrike.EndWound(target); - BuffInfo.RemoveBuff(target, BuffIcon.Bleed); - BuffInfo.RemoveBuff(target, BuffIcon.MortalStrike); + BuffInfo.RemoveBuff(target, BuffIcon.Bleed); + BuffInfo.RemoveBuff(target, BuffIcon.MortalStrike); - target.SendLocalizedMessage(1072405); // Your lasting damage effects have been removed! + target.SendLocalizedMessage(1072405); // Your lasting damage effects have been removed! - if (target != from) - from.SendLocalizedMessage(1072406); // Your Targets lasting damage effects have been removed! + if (target != from) + from.SendLocalizedMessage(1072406); // Your Targets lasting damage effects have been removed! - break; - case TalismanRemoval.Ward: - target.PlaySound(0x201); - Effects.SendLocationParticles( - EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 1, 13, - 0x834, 0, 0x13B2, 0); + break; + case TalismanRemoval.Ward: + target.PlaySound(0x201); + Effects.SendLocationParticles( + EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 1, 13, + 0x834, 0, 0x13B2, 0); - MagicReflectSpell.EndReflect(target); - ReactiveArmorSpell.EndArmor(target); - ProtectionSpell.EndProtection(target); + MagicReflectSpell.EndReflect(target); + ReactiveArmorSpell.EndArmor(target); + ProtectionSpell.EndProtection(target); - target.SendLocalizedMessage(1072402); // Your wards have been removed! + target.SendLocalizedMessage(1072402); // Your wards have been removed! - if (target != from) - from.SendLocalizedMessage(1072403); // Your target's wards have been removed! + if (target != from) + from.SendLocalizedMessage(1072403); // Your target's wards have been removed! - break; - case TalismanRemoval.Wildfire: - // TODO - break; - } - - m_Talisman.OnAfterUse(from); + break; + case TalismanRemoval.Wildfire: + // TODO + break; } + + m_Talisman.OnAfterUse(from); } } @@ -919,7 +909,6 @@ namespace Server.Items public virtual void StopTimer() { m_Timer?.Stop(); - m_Timer = null; } @@ -1010,16 +999,14 @@ namespace Server.Items public static TalismanAttribute GetRandomSummoner() { - if (0.025 > Utility.RandomDouble()) - { - int num = Utility.Random(m_Summons.Length); + if (0.025 <= Utility.RandomDouble()) + return new TalismanAttribute(); - if (num > 14) - return new TalismanAttribute(m_Summons[num], m_SummonLabels[num], 10); - return new TalismanAttribute(m_Summons[num], m_SummonLabels[num]); - } + int num = Utility.Random(m_Summons.Length); - return new TalismanAttribute(); + return num > 14 + ? new TalismanAttribute(m_Summons[num], m_SummonLabels[num], 10) + : new TalismanAttribute(m_Summons[num], m_SummonLabels[num]); } public static TalismanRemoval GetRandomRemoval() @@ -1144,7 +1131,7 @@ namespace Server.Items public static TalismanSlayerName GetRandomSlayer() { - return 0.01 > Utility.RandomDouble() ? (TalismanSlayerName)Utility.RandomMinMax(1, 9) : TalismanSlayerName.None; + return 0.01 > Utility.RandomDouble() ? (TalismanSlayerName)Utility.RandomMinMax(1, 9) : TalismanSlayerName.None; } public static int GetRandomCharges() @@ -1154,4 +1141,4 @@ namespace Server.Items #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Items/Talismans/Items/RunedSwitch.cs b/Scripts/Items/Talismans/Items/RunedSwitch.cs index 647233ce6..c6546ddcb 100644 --- a/Scripts/Items/Talismans/Items/RunedSwitch.cs +++ b/Scripts/Items/Talismans/Items/RunedSwitch.cs @@ -1,81 +1,81 @@ -using Server.Targeting; - -namespace Server.Items -{ - public class RunedSwitch : Item - { - [Constructible] - public RunedSwitch() : base(0x2F61) - { - Weight = 1.0; - } - - public RunedSwitch(Serial serial) : base(serial) - { - } - - public override int LabelNumber => 1072896; // runed switch - - public override void OnDoubleClick(Mobile from) - { - if (IsChildOf(from.Backpack)) - { - from.SendLocalizedMessage(1075101); // Please select an item to recharge. - from.Target = new InternalTarget(this); - } - else - { - from.SendLocalizedMessage(1060640); // The item must be in your backpack to use it. - } - } - - public override void Serialize(GenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(GenericReader reader) - { - base.Deserialize(reader); - - int version = reader.ReadInt(); - } - - private class InternalTarget : Target - { - private RunedSwitch m_Item; - - public InternalTarget(RunedSwitch item) : base(0, false, TargetFlags.None) - { - m_Item = item; - } - - protected override void OnTarget(Mobile from, object o) - { - if (m_Item == null || m_Item.Deleted) - return; - - if (o is BaseTalisman talisman) - { - if (talisman.Charges == 0) - { - talisman.Charges = talisman.MaxCharges; - m_Item.Delete(); - from.SendLocalizedMessage(1075100); // The item has been recharged. - } - else - { - from.SendLocalizedMessage( - 1075099); // You cannot recharge that item until all of its current charges have been used. - } - } - else - { - from.SendLocalizedMessage(1046439); // That is not a valid target. - } - } - } - } -} \ No newline at end of file +using Server.Targeting; + +namespace Server.Items +{ + public class RunedSwitch : Item + { + [Constructible] + public RunedSwitch() : base(0x2F61) + { + Weight = 1.0; + } + + public RunedSwitch(Serial serial) : base(serial) + { + } + + public override int LabelNumber => 1072896; // runed switch + + public override void OnDoubleClick(Mobile from) + { + if (IsChildOf(from.Backpack)) + { + from.SendLocalizedMessage(1075101); // Please select an item to recharge. + from.Target = new InternalTarget(this); + } + else + { + from.SendLocalizedMessage(1060640); // The item must be in your backpack to use it. + } + } + + public override void Serialize(GenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); // version + } + + public override void Deserialize(GenericReader reader) + { + base.Deserialize(reader); + + int version = reader.ReadInt(); + } + + private class InternalTarget : Target + { + private RunedSwitch m_Item; + + public InternalTarget(RunedSwitch item) : base(0, false, TargetFlags.None) + { + m_Item = item; + } + + protected override void OnTarget(Mobile from, object o) + { + if (m_Item?.Deleted != false) + return; + + if (o is BaseTalisman talisman) + { + if (talisman.Charges == 0) + { + talisman.Charges = talisman.MaxCharges; + m_Item.Delete(); + from.SendLocalizedMessage(1075100); // The item has been recharged. + } + else + { + from.SendLocalizedMessage( + 1075099); // You cannot recharge that item until all of its current charges have been used. + } + } + else + { + from.SendLocalizedMessage(1046439); // That is not a valid target. + } + } + } + } +} diff --git a/Scripts/Items/Talismans/TalismanAttribute.cs b/Scripts/Items/Talismans/TalismanAttribute.cs index 87321e1b5..971c0a9bf 100644 --- a/Scripts/Items/Talismans/TalismanAttribute.cs +++ b/Scripts/Items/Talismans/TalismanAttribute.cs @@ -5,7 +5,7 @@ namespace Server.Items [PropertyObject] public class TalismanAttribute { - public TalismanAttribute() : this(null, 0, 0) + public TalismanAttribute() : this(null, 0) { } @@ -19,11 +19,7 @@ namespace Server.Items } } - public TalismanAttribute(Type type, TextDefinition name) : this(type, name, 0) - { - } - - public TalismanAttribute(Type type, TextDefinition name, int amount) + public TalismanAttribute(Type type, TextDefinition name, int amount = 0) { Type = type; Name = name; @@ -59,14 +55,11 @@ namespace Server.Items public bool IsEmpty => Type == null; [CommandProperty(AccessLevel.GameMaster)] - public bool IsItem => Type != null && Type.Namespace.Equals("Server.Items"); + public bool IsItem => Type?.Namespace.Equals("Server.Items") == true; public override string ToString() { - if (Type != null) - return Type.Name; - - return "None"; + return Type?.Name ?? "None"; } private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) @@ -104,10 +97,7 @@ namespace Server.Items public int DamageBonus(Mobile to) { - if (to != null && to.GetType() == Type) // Verified: only works on the exact type - return Amount; - - return 0; + return to?.GetType() == Type ? Amount : 0; } [Flags] @@ -119,4 +109,4 @@ namespace Server.Items Amount = 0x00000004 } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Traps/FlameSpurtTrap.cs b/Scripts/Items/Traps/FlameSpurtTrap.cs index 95021c258..977014e94 100644 --- a/Scripts/Items/Traps/FlameSpurtTrap.cs +++ b/Scripts/Items/Traps/FlameSpurtTrap.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Spells; namespace Server.Items @@ -35,7 +36,7 @@ namespace Server.Items { Map map = Map; - if (map != null && map.GetSector(GetWorldLocation()).Active) + if (map?.GetSector(GetWorldLocation()).Active == true) StartTimer(); else StopTimer(); @@ -81,27 +82,16 @@ namespace Server.Items if (Deleted) return; - bool foundPlayer = false; - - foreach (Mobile mob in GetMobilesInRange(3)) - { - if (!mob.Player || !mob.Alive || mob.AccessLevel > AccessLevel.Player) - continue; - - if (Z + 8 >= mob.Z && mob.Z + 16 > Z) - { - foundPlayer = true; - break; - } - } + bool foundPlayer = GetMobilesInRange(3) + .Where(mob => mob.Player && mob.Alive && mob.AccessLevel <= AccessLevel.Player) + .Any(mob => Z + 8 >= mob.Z && mob.Z + 16 > Z); if (!foundPlayer) { m_Spurt?.Delete(); - m_Spurt = null; } - else if (m_Spurt == null || m_Spurt.Deleted) + else if (m_Spurt?.Deleted != false) { m_Spurt = new Static(0x3709); m_Spurt.MoveToWorld(Location, Map); @@ -115,13 +105,13 @@ namespace Server.Items if (m.AccessLevel > AccessLevel.Player) return true; - if (m.Player && m.Alive) - { - CheckTimer(); + if (!(m.Player && m.Alive)) + return false; - SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 30)); - m.PlaySound(m.Female ? 0x327 : 0x437); - } + CheckTimer(); + + SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 30)); + m.PlaySound(m.Female ? 0x327 : 0x437); return false; } @@ -130,19 +120,17 @@ namespace Server.Items { base.OnMovement(m, oldLocation); - if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player) + if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player + || !CheckRange(m.Location, oldLocation, 1)) return; - if (CheckRange(m.Location, oldLocation, 1)) - { - CheckTimer(); + CheckTimer(); - SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 10)); - m.PlaySound(m.Female ? 0x327 : 0x437); + SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 10)); + m.PlaySound(m.Female ? 0x327 : 0x437); - if (m.Body.IsHuman) - m.Animate(20, 1, 1, true, false, 0); - } + if (m.Body.IsHuman) + m.Animate(20, 1, 1, true, false, 0); } public override void Serialize(GenericWriter writer) @@ -175,4 +163,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Traps/GasTrap.cs b/Scripts/Items/Traps/GasTrap.cs index d7967ac8e..f27d4b99b 100644 --- a/Scripts/Items/Traps/GasTrap.cs +++ b/Scripts/Items/Traps/GasTrap.cs @@ -13,22 +13,17 @@ namespace Server.Items public class GasTrap : BaseTrap { [Constructible] - public GasTrap() : this(GasTrapType.Floor) + public GasTrap() : this(Poison.Lesser) { } [Constructible] - public GasTrap(GasTrapType type) : this(type, Poison.Lesser) + public GasTrap(Poison poison) : this(GasTrapType.Floor, poison) { } [Constructible] - public GasTrap(Poison poison) : this(GasTrapType.Floor, Poison.Lesser) - { - } - - [Constructible] - public GasTrap(GasTrapType type, Poison poison) : base(GetBaseID(type)) + public GasTrap(GasTrapType type, Poison poison = null) : base(GetBaseID(type)) { Poison = poison; } @@ -112,4 +107,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Traps/SawTrap.cs b/Scripts/Items/Traps/SawTrap.cs index 3d10165f0..ca6419dea 100644 --- a/Scripts/Items/Traps/SawTrap.cs +++ b/Scripts/Items/Traps/SawTrap.cs @@ -15,12 +15,7 @@ namespace Server.Items public class SawTrap : BaseTrap { [Constructible] - public SawTrap() : this(SawTrapType.NorthFloor) - { - } - - [Constructible] - public SawTrap(SawTrapType type) : base(GetBaseID(type)) + public SawTrap(SawTrapType type = SawTrapType.NorthFloor) : base(GetBaseID(type)) { } @@ -91,4 +86,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Traps/SpikeTrap.cs b/Scripts/Items/Traps/SpikeTrap.cs index cb7811e38..2c54beb08 100644 --- a/Scripts/Items/Traps/SpikeTrap.cs +++ b/Scripts/Items/Traps/SpikeTrap.cs @@ -15,12 +15,7 @@ namespace Server.Items public class SpikeTrap : BaseTrap { [Constructible] - public SpikeTrap() : this(SpikeTrapType.WestFloor) - { - } - - [Constructible] - public SpikeTrap(SpikeTrapType type) : base(GetBaseID(type)) + public SpikeTrap(SpikeTrapType type = SpikeTrapType.WestFloor) : base(GetBaseID(type)) { } @@ -153,4 +148,4 @@ namespace Server.Items Extended = false; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Wands/BaseWand.cs b/Scripts/Items/Wands/BaseWand.cs index d73d741d4..1f079c219 100644 --- a/Scripts/Items/Wands/BaseWand.cs +++ b/Scripts/Items/Wands/BaseWand.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Network; using Server.Spells; diff --git a/Scripts/Items/Weapons/Abilities/BleedAttack.cs b/Scripts/Items/Weapons/Abilities/BleedAttack.cs index ce134afce..a96bb777b 100644 --- a/Scripts/Items/Weapons/Abilities/BleedAttack.cs +++ b/Scripts/Items/Weapons/Abilities/BleedAttack.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Mobiles; using Server.Network; diff --git a/Scripts/Items/Weapons/Abilities/Block.cs b/Scripts/Items/Weapons/Abilities/Block.cs index 59c3efebc..06aea5584 100644 --- a/Scripts/Items/Weapons/Abilities/Block.cs +++ b/Scripts/Items/Weapons/Abilities/Block.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Items diff --git a/Scripts/Items/Weapons/Abilities/Disarm.cs b/Scripts/Items/Weapons/Abilities/Disarm.cs index 5074d6124..4284dae7c 100644 --- a/Scripts/Items/Weapons/Abilities/Disarm.cs +++ b/Scripts/Items/Weapons/Abilities/Disarm.cs @@ -23,7 +23,7 @@ namespace Server.Items Skill skill = from.Skills.ArmsLore; - if ( skill != null && skill.Base >= 80.0 ) + if ( skill?.Base >= 80.0 ) return true; from.SendLocalizedMessage( 1061812 ); // You lack the required skill in armslore to perform that attack! @@ -48,16 +48,16 @@ namespace Server.Items Item toDisarm = defender.FindItemOnLayer(Layer.OneHanded); - if (toDisarm == null || !toDisarm.Movable) + if (toDisarm?.Movable == false) toDisarm = defender.FindItemOnLayer(Layer.TwoHanded); Container pack = defender.Backpack; - if (pack == null || toDisarm != null && !toDisarm.Movable) + if (pack == null || toDisarm?.Movable == false) { attacker.SendLocalizedMessage(1004001); // You cannot disarm your opponent. } - else if (toDisarm == null || toDisarm is BaseShield || toDisarm is Spellbook && !Core.ML) + else if (!Core.ML && toDisarm == null || toDisarm is BaseShield || toDisarm is Spellbook) { attacker.SendLocalizedMessage(1060849); // Your target is already unarmed! } @@ -75,4 +75,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/Abilities/Disrobe.cs b/Scripts/Items/Weapons/Abilities/Disrobe.cs index 2baaf5952..598236c8a 100644 --- a/Scripts/Items/Weapons/Abilities/Disrobe.cs +++ b/Scripts/Items/Weapons/Abilities/Disrobe.cs @@ -19,12 +19,12 @@ namespace Server.Items ClearCurrentAbility(attacker); Item toDisrobe = defender.FindItemOnLayer(Layer.InnerTorso); - if (toDisrobe == null || !toDisrobe.Movable) + if (toDisrobe?.Movable == false) toDisrobe = defender.FindItemOnLayer(Layer.OuterTorso); Container pack = defender.Backpack; - if (pack == null || toDisrobe == null || !toDisrobe.Movable) + if (pack == null || toDisrobe?.Movable == false) { attacker.SendLocalizedMessage(1004001); // You cannot disarm your opponent. } @@ -42,4 +42,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/Abilities/DoubleStrike.cs b/Scripts/Items/Weapons/Abilities/DoubleStrike.cs index 8a2f9bc3d..ba0e9bd99 100644 --- a/Scripts/Items/Weapons/Abilities/DoubleStrike.cs +++ b/Scripts/Items/Weapons/Abilities/DoubleStrike.cs @@ -34,19 +34,13 @@ namespace Server.Items IWeapon weapon = attacker.Weapon; - if (weapon == null) + if (!(weapon != null && attacker.InRange(defender, weapon.MaxRange) &&attacker.InLOS(defender))) return; - if (!attacker.InRange(defender, weapon.MaxRange)) - return; - - if (attacker.InLOS(defender)) - { - BaseWeapon.InDoubleStrike = true; - attacker.RevealingAction(); - attacker.NextCombatTime = Core.TickCount + (int)weapon.OnSwing(attacker, defender).TotalMilliseconds; - BaseWeapon.InDoubleStrike = false; - } + BaseWeapon.InDoubleStrike = true; + attacker.RevealingAction(); + attacker.NextCombatTime = Core.TickCount + (int)weapon.OnSwing(attacker, defender).TotalMilliseconds; + BaseWeapon.InDoubleStrike = false; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/Abilities/DualWield.cs b/Scripts/Items/Weapons/Abilities/DualWield.cs index f9cb9b074..2b972e6f2 100644 --- a/Scripts/Items/Weapons/Abilities/DualWield.cs +++ b/Scripts/Items/Weapons/Abilities/DualWield.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Items diff --git a/Scripts/Items/Weapons/Abilities/Feint.cs b/Scripts/Items/Weapons/Abilities/Feint.cs index 0559a9758..1421da2d9 100644 --- a/Scripts/Items/Weapons/Abilities/Feint.cs +++ b/Scripts/Items/Weapons/Abilities/Feint.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Items diff --git a/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs b/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs index 5401190c8..fec1d0d80 100644 --- a/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs +++ b/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using Server.Spells; namespace Server.Items @@ -38,30 +38,10 @@ namespace Server.Items if (!(map != null && attacker.Weapon is BaseWeapon weapon)) return; - List list = new List(); - - foreach (Mobile m in attacker.GetMobilesInRange(1)) - list.Add(m); - - List targets = new List(); - - for (int i = 0; i < list.Count; ++i) - { - Mobile m = list[i]; - - if (m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m)) - { - if (m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee(m) || - !attacker.CanBeHarmful(m)) - continue; - - if (!attacker.InRange(m, weapon.MaxRange)) - continue; - - if (attacker.InLOS(m)) - targets.Add(m); - } - } + List targets = attacker.GetMobilesInRange(1).Where(m => + m?.Deleted == false && m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m) && + m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) && + attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m)).ToList(); if (targets.Count == 0 || !CheckMana(attacker, true)) return; diff --git a/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs b/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs index 4bfa6b8e4..a7e49c16c 100644 --- a/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs +++ b/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Items @@ -29,7 +28,7 @@ namespace Server.Items Skill skill = from.Skills.Anatomy; - if ( skill != null && skill.Base >= 80.0 ) + if ( skill?.Base >= 80.0 ) return true; from.SendLocalizedMessage( 1061811 ); // You lack the required anatomy skill to perform that attack! diff --git a/Scripts/Items/Weapons/Abilities/ShadowStrike.cs b/Scripts/Items/Weapons/Abilities/ShadowStrike.cs index 5a5cb0d65..8ca36679f 100644 --- a/Scripts/Items/Weapons/Abilities/ShadowStrike.cs +++ b/Scripts/Items/Weapons/Abilities/ShadowStrike.cs @@ -22,7 +22,7 @@ namespace Server.Items Skill skill = from.Skills.Stealth; - if (skill != null && skill.Value >= 80.0) + if (skill?.Value >= 80.0) return true; from.SendLocalizedMessage(1060183); // You lack the required stealth to perform that attack @@ -51,4 +51,4 @@ namespace Server.Items attacker.Hidden = true; } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/Abilities/WeaponAbility.cs b/Scripts/Items/Weapons/Abilities/WeaponAbility.cs index 1b1259c90..0cc25c81e 100644 --- a/Scripts/Items/Weapons/Abilities/WeaponAbility.cs +++ b/Scripts/Items/Weapons/Abilities/WeaponAbility.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.ConPVP; using Server.Mobiles; @@ -184,7 +183,7 @@ namespace Server.Items return false; } - if (skill != null && skill.Base >= reqSkill) + if (skill?.Base >= reqSkill) return true; /* */ @@ -209,15 +208,7 @@ namespace Server.Items return CheckWeaponSkill(from); } - public virtual double GetSkill(Mobile from, SkillName skillName) - { - Skill skill = from.Skills[skillName]; - - if (skill == null) - return 0.0; - - return skill.Value; - } + public virtual double GetSkill(Mobile from, SkillName skillName) => from.Skills[skillName]?.Value ?? 0.0; public virtual bool CheckMana(Mobile from, bool consume) { @@ -381,7 +372,7 @@ namespace Server.Items return false; } - if (a != null && !a.Validate(m)) + if (a?.Validate(m) == false) { ClearCurrentAbility(m); return false; @@ -394,7 +385,6 @@ namespace Server.Items else { SpecialMove.ClearCurrentMove(m); - Table[m] = a; } diff --git a/Scripts/Items/Weapons/Abilities/WhirlwindAttack.cs b/Scripts/Items/Weapons/Abilities/WhirlwindAttack.cs index 0be076f81..656bfca78 100644 --- a/Scripts/Items/Weapons/Abilities/WhirlwindAttack.cs +++ b/Scripts/Items/Weapons/Abilities/WhirlwindAttack.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using Server.Spells; namespace Server.Items @@ -34,51 +34,31 @@ namespace Server.Items attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); - List list = new List(); + List targets = attacker.GetMobilesInRange(1).Where(m => + m?.Deleted == false && m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m) && + m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) && + attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m)).ToList(); - foreach (Mobile m in attacker.GetMobilesInRange(1)) - list.Add(m); + if (targets.Count <= 0) + return; - List targets = new List(); + double bushido = attacker.Skills.Bushido.Value; + double damageBonus = 1.0 + Math.Pow(targets.Count * bushido / 60, 2) / 100; - for (int i = 0; i < list.Count; ++i) + if (damageBonus > 2.0) + damageBonus = 2.0; + + attacker.RevealingAction(); + + for (int i = 0; i < targets.Count; ++i) { - Mobile m = list[i]; + Mobile m = targets[i]; - if (m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m)) - { - if (m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee(m) || - !attacker.CanBeHarmful(m)) - continue; + attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target! + m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage! - if (!attacker.InRange(m, weapon.MaxRange)) - continue; - - if (attacker.InLOS(m)) - targets.Add(m); - } - } - - if (targets.Count > 0) - { - double bushido = attacker.Skills.Bushido.Value; - double damageBonus = 1.0 + Math.Pow(targets.Count * bushido / 60, 2) / 100; - - if (damageBonus > 2.0) - damageBonus = 2.0; - - attacker.RevealingAction(); - - for (int i = 0; i < targets.Count; ++i) - { - Mobile m = targets[i]; - - attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target! - m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage! - - weapon.OnHit(attacker, m, damageBonus); - } + weapon.OnHit(attacker, m, damageBonus); } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/BaseWeapon.cs b/Scripts/Items/Weapons/BaseWeapon.cs index 39467ce37..dd3a8c502 100644 --- a/Scripts/Items/Weapons/BaseWeapon.cs +++ b/Scripts/Items/Weapons/BaseWeapon.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Engines.Craft; using Server.Ethics; using Server.Factions; @@ -117,7 +118,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; if (tool is BaseRunicTool runicTool) @@ -151,7 +152,7 @@ namespace Server.Items CraftContext context = craftSystem.GetContext(from); - if (context != null && context.DoNotColor) + if (context?.DoNotColor == true) Hue = 0; switch (thisResource) @@ -247,14 +248,10 @@ namespace Server.Items public virtual void OnBeforeSwing(Mobile attacker, Mobile defender) { - WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker); - - if (a != null && !a.OnBeforeSwing(attacker, defender)) + if (WeaponAbility.GetCurrentAbility(attacker)?.OnBeforeSwing(attacker, defender) == false) WeaponAbility.ClearCurrentAbility(attacker); - SpecialMove move = SpecialMove.GetCurrentMove(attacker); - - if (move != null && !move.OnBeforeSwing(attacker, defender)) + if (SpecialMove.GetCurrentMove(attacker)?.OnBeforeSwing(attacker, defender) == false) SpecialMove.ClearCurrentMove(attacker); } @@ -380,10 +377,8 @@ namespace Server.Items public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) { - if (!Ethic.CheckTrade(from, to, newOwner, this)) - return false; - - return base.AllowSecureTrade(from, to, newOwner, accepted); + return Ethic.CheckTrade(from, to, newOwner, this) && + base.AllowSecureTrade(from, to, newOwner, accepted); } public override bool CanEquip(Mobile from) @@ -419,9 +414,7 @@ namespace Server.Items return false; } - if (!from.CanBeginAction()) return false; - - return base.CanEquip(from); + return from.CanBeginAction() && base.CanEquip(from); } public override bool OnEquip(Mobile from) @@ -806,11 +799,8 @@ namespace Server.Items } #region Dueling - - if (attacker is PlayerMobile pm) - if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this)) - canSwing = false; - + if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false) + canSwing = false; #endregion if (canSwing && attacker.HarmfulCheck(defender)) @@ -852,11 +842,11 @@ namespace Server.Items double parry = defender.Skills.Parry.Value; double bushidoNonRacial = defender.Skills.Bushido.NonRacialValue; double bushido = defender.Skills.Bushido.Value; + double chance; if (shield != null) { - double - chance = (parry - bushidoNonRacial) / + chance = (parry - bushidoNonRacial) / 400.0; // As per OSI, no genitive effect from the Racial stuffs, ie, 120 parry and '0' bushido with humans if (chance < 0) // chance shouldn't go below 0 @@ -877,44 +867,42 @@ namespace Server.Items return defender.CheckSkill(SkillName.Parry, chance); } - if (!(defender.Weapon is Fists) && !(defender.Weapon is BaseRanged)) + if (defender.Weapon is Fists || defender.Weapon is BaseRanged) + return false; + + BaseWeapon weapon = defender.Weapon as BaseWeapon; + + double divisor = weapon.Layer == Layer.OneHanded ? 48000.0 : 41140.0; + + chance = parry * bushido / divisor; + + double aosChance = parry / 800.0; + + // Parry or Bushido over 100 grant a 5% bonus. + if (parry >= 100.0) { - BaseWeapon weapon = defender.Weapon as BaseWeapon; - - double divisor = weapon.Layer == Layer.OneHanded ? 48000.0 : 41140.0; - - double chance = parry * bushido / divisor; - - double aosChance = parry / 800.0; - - // Parry or Bushido over 100 grant a 5% bonus. - if (parry >= 100.0) - { - chance += 0.05; - aosChance += 0.05; - } - else if (bushido >= 100.0) - { - chance += 0.05; - } - - // Evasion grants a variable bonus post ML. 50% prior. - if (Evasion.IsEvading(defender)) - chance *= Evasion.GetParryScalar(defender); - - // Low dexterity lowers the chance. - if (defender.Dex < 80) - chance = chance * (20 + defender.Dex) / 100; - - if (chance > aosChance) - return defender.CheckSkill(SkillName.Parry, chance); - - return - aosChance > Utility - .RandomDouble(); // Only skillcheck if wielding a shield & there's no effect from Bushido + chance += 0.05; + aosChance += 0.05; + } + else if (bushido >= 100.0) + { + chance += 0.05; } - return false; + // Evasion grants a variable bonus post ML. 50% prior. + if (Evasion.IsEvading(defender)) + chance *= Evasion.GetParryScalar(defender); + + // Low dexterity lowers the chance. + if (defender.Dex < 80) + chance = chance * (20 + defender.Dex) / 100; + + if (chance > aosChance) + return defender.CheckSkill(SkillName.Parry, chance); + + return + aosChance > Utility + .RandomDouble(); // Only skillcheck if wielding a shield & there's no effect from Bushido } public virtual int AbsorbDamageAOS(Mobile attacker, Mobile defender, int damage) @@ -1049,44 +1037,18 @@ namespace Server.Items if (!(attacker is BaseCreature bc) || bc.PackInstinct == PackInstinct.None || !bc.Controlled && !bc.Summoned) return 0; - Mobile master = bc.ControlMaster; - - if (master == null) - master = bc.SummonMaster; + Mobile master = bc.ControlMaster ?? bc.SummonMaster; if (master == null) return 0; - int inPack = 1; - IPooledEnumerable eable = defender.GetMobilesInRange(1); - foreach (BaseCreature m in eable) - if (m != attacker) - { - if ((m.PackInstinct & bc.PackInstinct) == 0 || !m.Controlled && !m.Summoned) - continue; - - Mobile theirMaster = m.ControlMaster; - - if (theirMaster == null) - theirMaster = m.SummonMaster; - - if (master == theirMaster && m.Combatant == defender) - ++inPack; - } + int inPack = 1 + eable.Where(m => m != attacker && (m.PackInstinct & bc.PackInstinct) != 0 && (m.Controlled || m.Summoned)) + .Count(m => master == (m.ControlMaster ?? m.SummonMaster) && m.Combatant == defender); eable.Free(); - if (inPack >= 5) - return 100; - if (inPack >= 4) - return 75; - if (inPack >= 3) - return 50; - if (inPack >= 2) - return 25; - - return 0; + return inPack >= 5 ? 100 : inPack >= 4 ? 75 : inPack >= 3 ? 50 : inPack >= 2 ? 25 : 0; } public virtual void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1.0) @@ -1095,7 +1057,7 @@ namespace Server.Items { IPooledEnumerable eable = defender.GetMobilesInRange(4); foreach (Clone m in eable) - if (m != null && m.Summoned && m.SummonMaster == defender) + if (m?.Summoned == true && m.SummonMaster == defender) { attacker.SendLocalizedMessage( 1063141); // Your attack has been diverted to a nearby mirror image of your target! @@ -1214,7 +1176,7 @@ namespace Server.Items if (!Core.AOS && damage < 1) damage = 1; else if (Core.AOS && damage == 0) // parried - if (a != null && a.Validate(attacker) /*&& a.CheckMana( attacker, true )*/ + if (a?.Validate(attacker) == true /*&& a.CheckMana( attacker, true )*/ ) // Parried special moves have no mana cost { a = null; @@ -1279,19 +1241,19 @@ namespace Server.Items int damageGiven = damage; - if (a != null && !a.OnBeforeDamage(attacker, defender)) + if (a?.OnBeforeDamage(attacker, defender) == false) { WeaponAbility.ClearCurrentAbility(attacker); a = null; } - if (move != null && !move.OnBeforeDamage(attacker, defender)) + if (move?.OnBeforeDamage(attacker, defender) == false) { SpecialMove.ClearCurrentMove(attacker); move = null; } - bool ignoreArmor = a is ArmorIgnore || move != null && move.IgnoreArmor(attacker); + bool ignoreArmor = a is ArmorIgnore || move?.IgnoreArmor(attacker) == true; damageGiven = AOS.Damage(defender, attacker, damage, ignoreArmor, phys, fire, cold, pois, nrgy, chaos, direct, false, this is BaseRanged); @@ -1322,10 +1284,10 @@ namespace Server.Items context = TransformationSpellHelper.GetContext(attacker); - if (context != null && context.Type == typeof(VampiricEmbraceSpell)) + if (context?.Type == typeof(VampiricEmbraceSpell)) lifeLeech += 20; // Vampiric embrace gives an additional 20% life leech - if (context != null && context.Type == typeof(WraithFormSpell)) + if (context?.Type == typeof(WraithFormSpell)) { wraithLeech = 5 + (int)(15 * attacker.Skills.SpiritSpeak.Value / @@ -1516,7 +1478,7 @@ namespace Server.Items if (atkWeapon is ButchersWarCleaver && TalismanSlayer.Slays(TalismanSlayerName.Bovine, defender)) return CheckSlayerResult.Slayer; - if (atkSlayer != null && atkSlayer.Slays(defender) || atkSlayer2 != null && atkSlayer2.Slays(defender)) + if (atkSlayer?.Slays(defender) == true || atkSlayer2?.Slays(defender) == true) return CheckSlayerResult.Slayer; if (attacker.Talisman is BaseTalisman talisman && TalismanSlayer.Slays(talisman.Slayer, defender)) @@ -1524,18 +1486,15 @@ namespace Server.Items if (!Core.SE) { - ISlayer defISlayer = Spellbook.FindEquippedSpellbook(defender); - - if (defISlayer == null) - defISlayer = defender.Weapon as ISlayer; + ISlayer defISlayer = Spellbook.FindEquippedSpellbook(defender) ?? defender.Weapon as ISlayer; if (defISlayer != null) { SlayerEntry defSlayer = SlayerGroup.GetEntryByName(defISlayer.Slayer); SlayerEntry defSlayer2 = SlayerGroup.GetEntryByName(defISlayer.Slayer2); - if (defSlayer != null && defSlayer.Group.OppositionSuperSlays(attacker) || - defSlayer2 != null && defSlayer2.Group.OppositionSuperSlays(attacker)) + if (defSlayer?.Group.OppositionSuperSlays(attacker) == true || + defSlayer2?.Group.OppositionSuperSlays(attacker) == true) return CheckSlayerResult.Opposition; } } @@ -1545,18 +1504,18 @@ namespace Server.Items public virtual void AddBlood(Mobile attacker, Mobile defender, int damage) { - if (damage > 0) - { - new Blood().MoveToWorld(defender.Location, defender.Map); + if (damage <= 0) + return; - int extraBlood = Core.SE ? Utility.RandomMinMax(3, 4) : Utility.RandomMinMax(0, 1); + new Blood().MoveToWorld(defender.Location, defender.Map); - for (int i = 0; i < extraBlood; i++) - new Blood().MoveToWorld(new Point3D( - defender.X + Utility.RandomMinMax(-1, 1), - defender.Y + Utility.RandomMinMax(-1, 1), - defender.Z), defender.Map); - } + int extraBlood = Core.SE ? Utility.RandomMinMax(3, 4) : Utility.RandomMinMax(0, 1); + + for (int i = 0; i < extraBlood; i++) + new Blood().MoveToWorld(new Point3D( + defender.X + Utility.RandomMinMax(-1, 1), + defender.Y + Utility.RandomMinMax(-1, 1), + defender.Z), defender.Map); } public virtual void GetDamageTypes(Mobile wielder, out int phys, out int fire, out int cold, out int pois, @@ -2024,12 +1983,7 @@ namespace Server.Items private string GetNameString() { - string name = Name; - - if (name == null) - name = $"#{LabelNumber}"; - - return name; + return Name ?? $"#{LabelNumber}"; } public int GetElementalDamageHue() @@ -3072,7 +3026,7 @@ namespace Server.Items attacker.DoHarmful(defender); - MagerySpell sp = new DispelSpell(attacker, null); + MagerySpell sp = new DispelSpell(attacker); if (sp.CheckResisted(defender)) { @@ -3114,15 +3068,12 @@ namespace Server.Items if (map == null) return; - List list = new List(); - int range = Core.ML ? 5 : 10; IPooledEnumerable eable = from.GetMobilesInRange(range); - foreach (Mobile m in eable) - if (from != m && defender != m && SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false) && - (!Core.ML || from.InLOS(m))) - list.Add(m); + List list = eable.Where(m => + from != m && defender != m && SpellHelper.ValidIndirectTarget(from, m) + && from.CanBeHarmful(m, false) && (!Core.ML || from.InLOS(m))).ToList(); eable.Free(); if (list.Count == 0) diff --git a/Scripts/Items/Weapons/Fists.cs b/Scripts/Items/Weapons/Fists.cs index f2f146475..bd52849e7 100644 --- a/Scripts/Items/Weapons/Fists.cs +++ b/Scripts/Items/Weapons/Fists.cs @@ -115,12 +115,12 @@ namespace Server.Items { Item toDisarm = defender.FindItemOnLayer(Layer.OneHanded); - if (toDisarm == null || !toDisarm.Movable) + if (toDisarm?.Movable == false) toDisarm = defender.FindItemOnLayer(Layer.TwoHanded); Container pack = defender.Backpack; - if (pack == null || toDisarm == null || !toDisarm.Movable) + if (pack == null || toDisarm?.Movable == false) { attacker.SendLocalizedMessage(1004001); // You cannot disarm your opponent. } @@ -213,10 +213,7 @@ namespace Server.Items { Item item = m.FindItemOnLayer(Layer.OneHanded); - if (item != null && !(item is Spellbook)) - return false; - - return m.FindItemOnLayer(Layer.TwoHanded) == null; + return (item == null || item is Spellbook) && m.FindItemOnLayer(Layer.TwoHanded) == null; } private static void EventSink_DisarmRequest(DisarmRequestEventArgs e) @@ -313,4 +310,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/HitLower.cs b/Scripts/Items/Weapons/HitLower.cs index 723b3ff09..a170d3fd5 100644 --- a/Scripts/Items/Weapons/HitLower.cs +++ b/Scripts/Items/Weapons/HitLower.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Items diff --git a/Scripts/Items/Weapons/Maces/FireworksWand.cs b/Scripts/Items/Weapons/Maces/FireworksWand.cs index 5c6a17527..37389667e 100644 --- a/Scripts/Items/Weapons/Maces/FireworksWand.cs +++ b/Scripts/Items/Weapons/Maces/FireworksWand.cs @@ -7,12 +7,7 @@ namespace Server.Items private int m_Charges; [Constructible] - public FireworksWand() : this(100) - { - } - - [Constructible] - public FireworksWand(int charges) + public FireworksWand(int charges = 100) { m_Charges = charges; LootType = LootType.Blessed; @@ -132,4 +127,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/Ranged/BaseRanged.cs b/Scripts/Items/Weapons/Ranged/BaseRanged.cs index 9a9298f1a..7c87a4199 100644 --- a/Scripts/Items/Weapons/Ranged/BaseRanged.cs +++ b/Scripts/Items/Weapons/Ranged/BaseRanged.cs @@ -69,15 +69,13 @@ namespace Server.Items { canSwing = !attacker.Paralyzed && !attacker.Frozen; - if (canSwing) canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement; + if (canSwing) + canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement; } #region Dueling - - if (attacker is PlayerMobile pm) - if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this)) - canSwing = false; - + if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false) + canSwing = false; #endregion if (canSwing && attacker.HarmfulCheck(defender)) @@ -175,9 +173,9 @@ namespace Server.Items if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost) { // consume ammo - if (quiver != null && quiver.ConsumeTotal(AmmoType, 1)) + if (quiver?.ConsumeTotal(AmmoType) == true) quiver.InvalidateWeight(); - else if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) + else if (pack?.ConsumeTotal(AmmoType) != true) return false; } else if (quiver.FindItemByType(AmmoType) == null && pack?.FindItemByType(AmmoType) == null) @@ -237,4 +235,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs b/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs index 95896f455..df6f0cfb4 100644 --- a/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs +++ b/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs @@ -116,7 +116,7 @@ namespace Server.Items { ChampionSpawn spawn = region.ChampionSpawn; - if (spawn != null && spawn.IsChampionSpawn(bc)) + if (spawn?.IsChampionSpawn(bc) == true) { Type t = bc.GetType(); @@ -166,4 +166,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/AOS.cs b/Scripts/Misc/AOS.cs index 702445c02..5c5f56900 100644 --- a/Scripts/Misc/AOS.cs +++ b/Scripts/Misc/AOS.cs @@ -54,7 +54,7 @@ namespace Server public static int Damage(Mobile m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy, int chaos = 0, int direct = 0, bool keepAlive = false, bool archer = false, bool deathStrike = false) { - if (m == null || m.Deleted || !m.Alive || damage <= 0) + if (m?.Deleted != false || !m.Alive || damage <= 0) return 0; if (phys == 0 && fire == 100 && cold == 0 && pois == 0 && nrgy == 0) @@ -149,7 +149,7 @@ namespace Server #region Dragon Barding - if ((from == null || !from.Player) && m.Player && m.Mount is SwampDragon pet) + if ((from?.Player != true) && m.Player && m.Mount is SwampDragon pet) if (pet.HasBarding) { int percent = pet.BardingExceptional ? 20 : 10; @@ -172,14 +172,14 @@ namespace Server if (keepAlive && totalDamage > m.Hits) totalDamage = m.Hits; - if (from != null && !from.Deleted && from.Alive) + if (from?.Deleted == false && from.Alive) { int reflectPhys = AosAttributes.GetValue(m, AosAttribute.ReflectPhysical); if (reflectPhys != 0) { - if (from is ExodusMinion minion && minion.FieldActive || - from is ExodusOverseer overseer && overseer.FieldActive) + if ((from as ExodusMinion)?.FieldActive == true || + (from as ExodusOverseer)?.FieldActive == true) { from.FixedParticles(0x376A, 20, 10, 0x2530, EffectLayer.Waist); from.PlaySound(0x2F4); @@ -1019,13 +1019,10 @@ namespace Server public void GetProperties(ObjectPropertyList list) { - SkillName skill; for (int i = 0; i < 5; ++i) { - if (!GetValues(i, out skill, out double bonus)) - continue; - - list.Add(1060451 + i, "#{0}\t{1}", GetLabel(skill), bonus); + if (GetValues(i, out SkillName skill, out double bonus)) + list.Add(1060451 + i, "#{0}\t{1}", GetLabel(skill), bonus); } } @@ -1495,4 +1492,4 @@ namespace Server return index; } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/AutoSave.cs b/Scripts/Misc/AutoSave.cs index ebb44ca9a..07e4f260f 100644 --- a/Scripts/Misc/AutoSave.cs +++ b/Scripts/Misc/AutoSave.cs @@ -126,6 +126,7 @@ namespace Server.Misc } catch { + // ignored } } else @@ -136,6 +137,7 @@ namespace Server.Misc } catch { + // ignored } } } diff --git a/Scripts/Misc/Broadcasts.cs b/Scripts/Misc/Broadcasts.cs index 2286a385d..59e39472b 100644 --- a/Scripts/Misc/Broadcasts.cs +++ b/Scripts/Misc/Broadcasts.cs @@ -16,6 +16,7 @@ namespace Server.Misc } catch { + // ignored } } @@ -27,6 +28,7 @@ namespace Server.Misc } catch { + // ignored } } } diff --git a/Scripts/Misc/CharacterCreation.cs b/Scripts/Misc/CharacterCreation.cs index baf8bc17b..64fcdd999 100644 --- a/Scripts/Misc/CharacterCreation.cs +++ b/Scripts/Misc/CharacterCreation.cs @@ -222,7 +222,7 @@ namespace Server.Misc PlaceItemIn(cont, 45, 105, new Spellbook(ulong.MaxValue)); PlaceItemIn(cont, 65, 105, new NecromancerSpellbook((ulong)0xFFFF)); - PlaceItemIn(cont, 85, 105, new BookOfChivalry((ulong)0x3FF)); + PlaceItemIn(cont, 85, 105, new BookOfChivalry()); PlaceItemIn(cont, 105, 105, new BookOfBushido()); //Default ctor = full PlaceItemIn(cont, 125, 105, new BookOfNinjitsu()); //Default ctor = full @@ -462,7 +462,7 @@ namespace Server.Misc bank.DropItem(new TreasureMap(5, Map.Trammel)); // Bag containing 50 of each reagent - bank.DropItem(new BagOfReagents(50)); + bank.DropItem(new BagOfReagents()); // Craft tools bank.DropItem(MakeNewbie(new Scissors())); @@ -1004,7 +1004,7 @@ namespace Server.Misc } case 4: // Necromancer { - Container regs = new BagOfNecroReagents(50); + Container regs = new BagOfNecroReagents(); if (!Core.AOS) foreach (Item item in regs.Items) @@ -1076,7 +1076,7 @@ namespace Server.Misc EquipItem(new BodySash(0xCF)); } - Spellbook book = new BookOfChivalry((ulong)0x3FF); + Spellbook book = new BookOfChivalry(); PackItem(book); @@ -1161,7 +1161,7 @@ namespace Server.Misc if (!Core.AOS) item.LootType = LootType.Newbied; - if (m_Mobile != null && m_Mobile.EquipItem(item)) + if (m_Mobile?.EquipItem(item) == true) return; Container pack = m_Mobile.Backpack; @@ -1472,7 +1472,7 @@ namespace Server.Misc case SkillName.Chivalry: { if (Core.ML) - PackItem(new BookOfChivalry((ulong)0x3FF)); + PackItem(new BookOfChivalry()); break; } @@ -1620,7 +1620,7 @@ namespace Server.Misc { if (Core.ML) { - Container regs = new BagOfNecroReagents(50); + Container regs = new BagOfNecroReagents(); PackItem(regs); @@ -1748,4 +1748,4 @@ namespace Server.Misc } } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/Cleanup.cs b/Scripts/Misc/Cleanup.cs index 6ba6d8fd8..407f1d0a0 100644 --- a/Scripts/Misc/Cleanup.cs +++ b/Scripts/Misc/Cleanup.cs @@ -66,9 +66,7 @@ namespace Server.Misc } else if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) { - object rootParent = item.RootParent; - - if (rootParent is Mobile rootMobile) + if (item.RootParent is Mobile rootMobile) { if (item.Parent != rootMobile && rootMobile.AccessLevel == AccessLevel.Player) { @@ -164,4 +162,4 @@ namespace Server.Misc return false; } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/CrashGuard.cs b/Scripts/Misc/CrashGuard.cs index b397b9577..ce1e60e16 100644 --- a/Scripts/Misc/CrashGuard.cs +++ b/Scripts/Misc/CrashGuard.cs @@ -119,6 +119,7 @@ namespace Server.Misc } catch { + // ignored } } @@ -197,6 +198,7 @@ namespace Server.Misc } catch { + // ignored } try @@ -205,6 +207,7 @@ namespace Server.Misc } catch { + // ignored } op.WriteLine("Exception:"); diff --git a/Scripts/Misc/Emitter.cs b/Scripts/Misc/Emitter.cs index 5c7f1518f..67369af61 100644 --- a/Scripts/Misc/Emitter.cs +++ b/Scripts/Misc/Emitter.cs @@ -503,9 +503,9 @@ namespace Server * Bleh. */ - Type[] ifaces = active.FindInterfaces((type, obj) => (type.IsGenericType) - && (type.GetGenericTypeDefinition() == typeof(IComparable<>)) - && (type.GetGenericArguments()[0].IsAssignableFrom(active)), null ); + Type[] ifaces = active.FindInterfaces((type, obj) => type.IsGenericType + && type.GetGenericTypeDefinition() == typeof(IComparable<>) + && type.GetGenericArguments()[0].IsAssignableFrom(active), null ); if ( ifaces.Length > 0 ) { @@ -513,10 +513,7 @@ namespace Server } else { - ifaces = active.FindInterfaces( delegate( Type type, object obj ) - { - return ( type == typeof( IComparable ) ); - }, null ); + ifaces = active.FindInterfaces((type, obj) => type == typeof(IComparable), null ); if ( ifaces.Length > 0 ) compareTo = ifaces[0].GetMethod( "CompareTo", new[] { active } ); @@ -668,7 +665,7 @@ namespace Server if ( ( call.type.IsValueType || call.type.IsByRef ) && call.method.DeclaringType != call.type ) Generator.Emit( OpCodes.Constrained, call.type ); - if ( call.method.DeclaringType.IsValueType || call.method.IsStatic ) + if ( call.method.DeclaringType?.IsValueType == true || call.method.IsStatic ) Generator.Emit( OpCodes.Call, call.method ); else Generator.Emit( OpCodes.Callvirt, call.method ); diff --git a/Scripts/Misc/FoodDecay.cs b/Scripts/Misc/FoodDecay.cs index 709141d29..a3ccad80f 100644 --- a/Scripts/Misc/FoodDecay.cs +++ b/Scripts/Misc/FoodDecay.cs @@ -31,14 +31,14 @@ namespace Server.Misc public static void HungerDecay(Mobile m) { - if (m != null && m.Hunger >= 1) + if (m?.Hunger >= 1) m.Hunger -= 1; } public static void ThirstDecay(Mobile m) { - if (m != null && m.Thirst >= 1) + if (m?.Thirst >= 1) m.Thirst -= 1; } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs b/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs index 8f70bcd35..e05ab2b46 100644 --- a/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs +++ b/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs @@ -24,14 +24,9 @@ namespace Server.Items }; [Constructible] - public LightOfTheWinterSolstice() : this(m_StaffNames[Utility.Random(m_StaffNames.Length)]) + public LightOfTheWinterSolstice(string dipper = null) : base(0x236E) { - } - - [Constructible] - public LightOfTheWinterSolstice(string dipper) : base(0x236E) - { - Dipper = dipper; + Dipper = dipper ?? m_StaffNames[Utility.Random(m_StaffNames.Length)]; Weight = 1.0; LootType = LootType.Blessed; @@ -95,4 +90,4 @@ namespace Server.Items Dipper = string.Intern(Dipper); } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs b/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs index 3bc58969b..d6ab59855 100644 --- a/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs +++ b/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs @@ -43,7 +43,7 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { if (from.InRange(GetWorldLocation(), 1)) { @@ -101,7 +101,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { if (from.InRange(GetWorldLocation(), 3)) { @@ -129,29 +129,26 @@ namespace Server.Items AddBackground(0, 0, 220, 170, 0x13BE); AddBackground(10, 10, 200, 150, 0xBB8); - AddHtmlLocalized(20, 30, 180, 60, 1062839, false, false); // Do you wish to re-deed this decoration? - AddHtmlLocalized(55, 100, 160, 25, 1011011, false, false); // CONTINUE - AddButton(20, 100, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(55, 125, 160, 25, 1011012, false, false); // CANCEL - AddButton(20, 125, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0); + AddHtmlLocalized(20, 30, 180, 60, 1062839); // Do you wish to re-deed this decoration? + AddHtmlLocalized(55, 100, 160, 25, 1011011); // CONTINUE + AddButton(20, 100, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(55, 125, 160, 25, 1011012); // CANCEL + AddButton(20, 125, 0xFA5, 0xFA7, 0); } public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Addon.Deleted) + if (m_Addon.Deleted || info.ButtonID != 1) return; - if (info.ButtonID == 1) + if (m_From.InRange(m_Addon.GetWorldLocation(), 3)) { - if (m_From.InRange(m_Addon.GetWorldLocation(), 3)) - { - m_From.AddToBackpack(m_Addon.Deed); - m_Addon.Delete(); - } - else - { - m_From.SendLocalizedMessage(500295); // You are too far away to do that. - } + m_From.AddToBackpack(m_Addon.Deed); + m_Addon.Delete(); + } + else + { + m_From.SendLocalizedMessage(500295); // You are too far away to do that. } } } @@ -161,12 +158,7 @@ namespace Server.Items public class MistletoeDeed : Item { [Constructible] - public MistletoeDeed() : this(0) - { - } - - [Constructible] - public MistletoeDeed(int hue) : base(0x14F0) + public MistletoeDeed(int hue = 0) : base(0x14F0) { Hue = hue; Weight = 1.0; @@ -213,7 +205,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(from); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { from.SendLocalizedMessage(1062838); // Where would you like to place this decoration? from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget); @@ -238,7 +230,7 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16); - if (house != null && house.IsCoOwner(from)) + if (house?.IsCoOwner(from) == true) { bool northWall = BaseAddon.IsWall(loc.X, loc.Y - 1, loc.Z, from.Map); bool westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map); @@ -306,8 +298,8 @@ namespace Server.Items AddItem(90, 30, 0x2375); AddItem(180, 30, 0x2374); - AddButton(50, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0); - AddButton(145, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0); + AddButton(50, 35, 0x868, 0x869, 1); + AddButton(145, 35, 0x868, 0x869, 2); } public override void OnResponse(NetState sender, RelayInfo info) @@ -327,4 +319,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/Guild.cs b/Scripts/Misc/Guild.cs index 24b759523..23e76fc11 100644 --- a/Scripts/Misc/Guild.cs +++ b/Scripts/Misc/Guild.cs @@ -443,10 +443,10 @@ namespace Server.Guilds { get { - if (Opponent == null || Opponent.Disbanded) + if (Opponent?.Disbanded != false) return WarStatus.Win; - if (Guild == null || Guild.Disbanded) + if (Guild?.Disbanded != false) return WarStatus.Lose; WarDeclaration w = Opponent.FindActiveWar(Guild); @@ -572,7 +572,7 @@ namespace Server.Guilds { get { - if (m_Leader == null || m_Leader.Deleted || m_Leader.Guild != this) + if (Disbanded || m_Leader.Guild != this) CalculateGuildmaster(); return m_Leader; @@ -582,7 +582,7 @@ namespace Server.Guilds if (value != null) AddMember(value); //Also removes from old guild. - if (m_Leader is PlayerMobile leader && leader?.Guild == this) + if (m_Leader is PlayerMobile leader && leader.Guild == this) leader.GuildRank = RankDefinition.Member; m_Leader = value; @@ -593,7 +593,7 @@ namespace Server.Guilds } - public override bool Disbanded => m_Leader == null || m_Leader.Deleted; + public override bool Disbanded => m_Leader?.Deleted != false; public static void Configure() { @@ -605,22 +605,20 @@ namespace Server.Guilds public void InvalidateMemberProperties(bool onlyOPL = false) { - if (Members != null) - for (int i = 0; i < Members.Count; i++) - { - Mobile m = Members[i]; - m.InvalidateProperties(); + for (int i = 0; i < Members?.Count; i++) + { + Mobile m = Members[i]; + m.InvalidateProperties(); - if (!onlyOPL) - m.Delta(MobileDelta.Noto); - } + if (!onlyOPL) + m.Delta(MobileDelta.Noto); + } } public void InvalidateMemberNotoriety() { - if (Members != null) - for (int i = 0; i < Members.Count; i++) - Members[i].Delta(MobileDelta.Noto); + for (int i = 0; i < Members?.Count; i++) + Members[i].Delta(MobileDelta.Noto); } public void InvalidateWarNotoriety() @@ -735,7 +733,7 @@ namespace Server.Guilds if (o is Guildstone stone) { - if (stone.Guild == null || stone.Guild.Disbanded) + if (stone?.Guild.Disbanded != false) { from.SendMessage("The guild associated with that Guildstone no longer exists"); return; @@ -893,7 +891,7 @@ namespace Server.Guilds bool inAlliance = myAlliance?.IsMember(this) == true; AllianceInfo otherAlliance = g?.Alliance; - bool otherInAlliance = otherAlliance != null && otherAlliance.IsMember(this); + bool otherInAlliance = otherAlliance?.IsMember(this) == true; if (inAlliance) { @@ -910,24 +908,24 @@ namespace Server.Guilds AcceptedWars.Remove(w); - if (g != null) + if (g == null) + continue; + + if (status != WarStatus.Draw) + status = (WarStatus)((int)status + 1 % 2); + + if (otherInAlliance) { - if (status != WarStatus.Draw) - status = (WarStatus)((int)status + 1 % 2); - - if (otherInAlliance) - { - otherAlliance.AllianceMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name); - otherAlliance.InvalidateMemberProperties(); - } - else - { - g.GuildMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name); - g.InvalidateMemberProperties(); - } - - g.AcceptedWars.Remove(g.FindActiveWar(this)); + otherAlliance.AllianceMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name); + otherAlliance.InvalidateMemberProperties(); } + else + { + g.GuildMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name); + g.InvalidateMemberProperties(); + } + + g.AcceptedWars.Remove(g.FindActiveWar(this)); } } @@ -998,17 +996,12 @@ namespace Server.Guilds public bool IsAlly(Guild g) { - if (NewGuildSystem) return Alliance != null && Alliance.IsMember(this) && Alliance.IsMember(g); - - return Allies.Contains(g); + return NewGuildSystem ? Alliance?.IsMember(this) == true && Alliance.IsMember(g) : Allies.Contains(g); } public bool IsEnemy(Guild g) { - if (Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type) - return true; - - return IsWar(g); + return Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type || IsWar(g); } public bool IsWar(Guild g) @@ -1016,18 +1009,14 @@ namespace Server.Guilds if (g == null) return false; - if (NewGuildSystem) - { - Guild guild = GetAllianceLeader(this); - Guild otherGuild = GetAllianceLeader(g); + if (!NewGuildSystem) + return Enemies.Contains(g); - if (guild.FindActiveWar(otherGuild) != null) - return true; + Guild guild = GetAllianceLeader(this); + Guild otherGuild = GetAllianceLeader(g); - return false; - } + return guild.FindActiveWar(otherGuild) != null; - return Enemies.Contains(g); } #endregion @@ -1216,7 +1205,7 @@ namespace Server.Guilds alliance = Alliance; //CheckLeader could possibly change the value of this.Alliance - if (alliance != null && !alliance.IsMember(this) && !alliance.IsPendingMember(this) + if (alliance?.IsMember(this) == false && !alliance.IsPendingMember(this) ) //This block is there to fix a bug in the code in an older version. Alliance = null; //Will call Alliance.RemoveGuild which will set it null & perform all the pertient checks as far as alliacne disbanding } @@ -1309,7 +1298,7 @@ namespace Server.Guilds public void RemoveEnemy(Guild g) { - if (Enemies != null && Enemies.Contains(g)) + if (Enemies.Contains(g)) { Enemies.Remove(g); @@ -1389,9 +1378,7 @@ namespace Server.Guilds public void GuildChat(Mobile from, string text) { - PlayerMobile pm = from as PlayerMobile; - - GuildChat(from, pm?.GuildMessageHue ?? 0x3B2, text); + GuildChat(from, (from as PlayerMobile)?.GuildMessageHue ?? 0x3B2, text); } #endregion @@ -1400,20 +1387,13 @@ namespace Server.Guilds public bool CanVote(Mobile m) { - if (NewGuildSystem) - if (!(m is PlayerMobile pm) || !pm.GuildRank.GetFlag(RankFlags.CanVote)) - return false; - - return m != null && !m.Deleted && m.Guild == this; + return (!NewGuildSystem || m is PlayerMobile pm && pm.GuildRank.GetFlag(RankFlags.CanVote)) && + m?.Deleted == false && m.Guild == this; } public bool CanBeVotedFor(Mobile m) { - if (NewGuildSystem) - if (!(m is PlayerMobile pm) || pm.LastOnline + InactiveTime < DateTime.UtcNow) - return false; - - return m != null && !m.Deleted && m.Guild == this; + return (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow) && m?.Deleted == false && m.Guild == this; } public void CalculateGuildmaster() @@ -1433,7 +1413,7 @@ namespace Server.Guilds if (!CanBeVotedFor(m)) { - if (m_Leader != null && !m_Leader.Deleted && m_Leader.Guild == this) + if (!Disbanded && m_Leader.Guild == this) m = m_Leader; else m = memb; @@ -1461,8 +1441,8 @@ namespace Server.Guilds } } - if (NewGuildSystem && highVotes * 100 / Math.Max(votingMembers, 1) < MajorityPercentage && m_Leader != null && - winner != m_Leader && !m_Leader.Deleted && m_Leader.Guild == this) + if (NewGuildSystem && highVotes * 100 / Math.Max(votingMembers, 1) < MajorityPercentage && !Disbanded && + winner != m_Leader && m_Leader.Guild == this) winner = m_Leader; if (m_Leader != winner && winner != null) diff --git a/Scripts/Misc/LootPack.cs b/Scripts/Misc/LootPack.cs index 826a5b0d5..3a39afbed 100644 --- a/Scripts/Misc/LootPack.cs +++ b/Scripts/Misc/LootPack.cs @@ -534,12 +534,12 @@ namespace Server private bool m_AtSpawnTime; public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, string quantity) : this(atSpawnTime, - items, chance, new LootPackDice(quantity), 0, 0, 0) + items, chance, new LootPackDice(quantity)) { } public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, int quantity) : this(atSpawnTime, items, - chance, new LootPackDice(0, 0, quantity), 0, 0, 0) + chance, new LootPackDice(0, 0, quantity)) { } @@ -555,8 +555,8 @@ namespace Server { } - public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, LootPackDice quantity, int maxProps, - int minIntensity, int maxIntensity) + public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, LootPackDice quantity, int maxProps = 0, + int minIntensity = 0, int maxIntensity = 0) { m_AtSpawnTime = atSpawnTime; Items = items; @@ -901,6 +901,7 @@ namespace Server } catch { + // ignored } return null; diff --git a/Scripts/Misc/NameList.cs b/Scripts/Misc/NameList.cs index 140b690d5..88d7baa9a 100644 --- a/Scripts/Misc/NameList.cs +++ b/Scripts/Misc/NameList.cs @@ -90,10 +90,11 @@ namespace Server m_Table[type] = list; } - catch - { - } - } + catch + { + // ignored + } + } } } } diff --git a/Scripts/Misc/Notoriety.cs b/Scripts/Misc/Notoriety.cs index 2b76f63ee..5df415155 100644 --- a/Scripts/Misc/Notoriety.cs +++ b/Scripts/Misc/Notoriety.cs @@ -67,19 +67,16 @@ namespace Server.Misc PlayerMobile pmFrom = from as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile; - if (pmFrom == null && from is BaseCreature bcFrom) - if (bcFrom.Summoned) - pmFrom = bcFrom.SummonMaster as PlayerMobile; + if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned) + pmFrom = bcFrom.SummonMaster as PlayerMobile; - if (pmTarg == null && target is BaseCreature bcTarg) - if (bcTarg.Summoned) - pmTarg = bcTarg.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 != null && pmFrom.DuelContext.Started || - pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) + (pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true)) return false; if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && @@ -87,27 +84,25 @@ namespace Server.Misc pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated)) return false; - if (pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null && - pmFrom.DuelContext.IsSuddenDeath) + if (pmFrom.DuelPlayer?.Eliminated == false && pmFrom.DuelContext?.IsSuddenDeath == true) return false; if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && - pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && + pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant) return false; - if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started) + if (pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext) return true; } - if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started || - pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) + if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true) return false; if (from.Region.IsPartOf() || target.Region.IsPartOf()) return false; - + #endregion Map map = from.Map; @@ -123,7 +118,7 @@ namespace Server.Misc #endregion - if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0) + if ((map?.Rules & MapRules.BeneficialRestrictions) == 0) return true; // In felucca, anything goes if (!from.Player) @@ -163,8 +158,7 @@ namespace Server.Misc if (pmFrom != null && pmTarg != null) { if (pmFrom.DuelContext != pmTarg.DuelContext && - (pmFrom.DuelContext != null && pmFrom.DuelContext.Started || - pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) + (pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true)) return false; if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && @@ -173,17 +167,16 @@ namespace Server.Misc return false; if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && - pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && + pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant) return false; - if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started) + if ( pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext) return true; } - if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started || - pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) + if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true) return false; if (from.Region.IsPartOf() || target.Region.IsPartOf()) @@ -193,7 +186,7 @@ namespace Server.Misc Map map = from.Map; - if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0) + if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) return true; // In felucca, anything goes if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null && @@ -219,11 +212,7 @@ namespace Server.Misc if (target.Player) return false; // Cannot harm other players - if (bcTarg?.InitialInnocent != true) - if (Notoriety.Compute(from, target) == Notoriety.Innocent) - return false; // Cannot harm innocent mobiles - - return true; + return bcTarg?.InitialInnocent == true || Notoriety.Compute(from, target) != Notoriety.Innocent; } public static Guild GetGuildFor(Guild def, Mobile m) @@ -344,7 +333,7 @@ namespace Server.Misc { Mobile master = bcTarg.GetMaster(); - if (master != null && master.AccessLevel > AccessLevel.Player) + if (master?.AccessLevel > AccessLevel.Player) return Notoriety.CanBeAttacked; master = bcTarg.ControlMaster; @@ -407,7 +396,7 @@ namespace Server.Misc if (CheckAggressed(source.Aggressed, target)) return Notoriety.CanBeAttacked; - if (bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard && + if (bcTarg?.Controlled == true && bcTarg.ControlOrder == OrderType.Guard && bcTarg.ControlTarget == source) return Notoriety.CanBeAttacked; @@ -427,26 +416,24 @@ namespace Server.Misc { BaseHouse house = BaseHouse.FindHouseAt(p, map, 16); - if (house == null || house.Public || !house.IsFriend(from)) + if (house?.Public != false || !house.IsFriend(from)) return false; if (m != null && house.IsFriend(m)) return false; - if (m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null) - return !house.IsFriend(c.ControlMaster); - - return true; + return !(m is BaseCreature c) || c.Deleted || !c.Controlled || c.ControlMaster == null || + !house.IsFriend(c.ControlMaster); } public static bool IsPet(BaseCreature c) { - return c != null && c.Controlled; + return c?.Controlled == true; } public static bool IsSummoned(BaseCreature c) { - return c != null && /*c.Controlled &&*/ c.Summoned; + return c?.Summoned == true; } public static bool CheckAggressor(List list, Mobile target) @@ -478,4 +465,4 @@ namespace Server.Misc Waring } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/Profile.cs b/Scripts/Misc/Profile.cs index 5967995c1..98731f549 100644 --- a/Scripts/Misc/Profile.cs +++ b/Scripts/Misc/Profile.cs @@ -63,9 +63,7 @@ namespace Server.Misc TimeSpan ts = DateTime.UtcNow - a.Created; - string v; - - if (Format(ts.TotalDays, "This account is {0} day{1} old.", out v)) + if (Format(ts.TotalDays, "This account is {0} day{1} old.", out string v)) return v; if (Format(ts.TotalHours, "This account is {0} hour{1} old.", out v)) diff --git a/Scripts/Misc/RegenRates.cs b/Scripts/Misc/RegenRates.cs index 1cfa1bce5..26054fb8c 100644 --- a/Scripts/Misc/RegenRates.cs +++ b/Scripts/Misc/RegenRates.cs @@ -55,7 +55,7 @@ namespace Server.Misc BaseCreature bc = from as BaseCreature; - if (bc != null && !bc.IsAnimatedDead) + if (bc?.IsAnimatedDead == false) points += 4; if (bc?.IsParagon == true || from is Leviathan) @@ -217,4 +217,4 @@ namespace Server.Misc } } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/ResourceInfo.cs b/Scripts/Misc/ResourceInfo.cs index b7290d500..b408138d9 100644 --- a/Scripts/Misc/ResourceInfo.cs +++ b/Scripts/Misc/ResourceInfo.cs @@ -423,7 +423,7 @@ namespace Server.Items new CraftResourceInfo( 0x8A5, 1053104, "Gold", CraftAttributeInfo.Golden, CraftResource.Gold, typeof( GoldIngot ), typeof( GoldOre ), typeof( GoldGranite ) ), new CraftResourceInfo( 0x979, 1053103, "Agapite", CraftAttributeInfo.Agapite, CraftResource.Agapite, typeof( AgapiteIngot ), typeof( AgapiteOre ), typeof( AgapiteGranite ) ), new CraftResourceInfo( 0x89F, 1053102, "Verite", CraftAttributeInfo.Verite, CraftResource.Verite, typeof( VeriteIngot ), typeof( VeriteOre ), typeof( VeriteGranite ) ), - new CraftResourceInfo( 0x8AB, 1053101, "Valorite", CraftAttributeInfo.Valorite, CraftResource.Valorite, typeof( ValoriteIngot ), typeof( ValoriteOre ), typeof( ValoriteGranite ) ), + new CraftResourceInfo( 0x8AB, 1053101, "Valorite", CraftAttributeInfo.Valorite, CraftResource.Valorite, typeof( ValoriteIngot ), typeof( ValoriteOre ), typeof( ValoriteGranite ) ) }; private static CraftResourceInfo[] m_ScaleInfo = { @@ -446,7 +446,7 @@ namespace Server.Items new CraftResourceInfo( 0x000, 1049353, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularLeather, typeof( Leather ), typeof( Hides ) ), new CraftResourceInfo( 0x8AC, 1049354, "Spined", CraftAttributeInfo.Spined, CraftResource.SpinedLeather, typeof( SpinedLeather ), typeof( SpinedHides ) ), new CraftResourceInfo( 0x845, 1049355, "Horned", CraftAttributeInfo.Horned, CraftResource.HornedLeather, typeof( HornedLeather ), typeof( HornedHides ) ), - new CraftResourceInfo( 0x851, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof( BarbedLeather ), typeof( BarbedHides ) ), + new CraftResourceInfo( 0x851, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof( BarbedLeather ), typeof( BarbedHides ) ) }; private static CraftResourceInfo[] m_WoodInfo = { @@ -563,7 +563,7 @@ namespace Server.Items if ( start == CraftResource.None ) return 0; - return (int)(resource - start); + return resource - start; } /// diff --git a/Scripts/Misc/ServerList.cs b/Scripts/Misc/ServerList.cs index b251642c0..be4298ebe 100644 --- a/Scripts/Misc/ServerList.cs +++ b/Scripts/Misc/ServerList.cs @@ -114,6 +114,7 @@ namespace Server.Misc } catch { + // ignored } } diff --git a/Scripts/Misc/ShardPoller.cs b/Scripts/Misc/ShardPoller.cs index 7aa424694..51d724ed0 100644 --- a/Scripts/Misc/ShardPoller.cs +++ b/Scripts/Misc/ShardPoller.cs @@ -153,7 +153,7 @@ namespace Server.Misc private static void EventSink_Login_Callback(Mobile from) { NetState ns = from.NetState; - + if (ns == null) return; @@ -409,15 +409,15 @@ namespace Server.Misc else title = "Shard Poll"; - AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32), false, false); + AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32)); if (editing) { - AddHtml(22, 22, 294, 20, Color($"{totalVotes} total", LabelColor32), false, false); - AddButton(287, 23, 0x2622, 0x2623, 2, GumpButtonType.Reply, 0); + AddHtml(22, 22, 294, 20, Color($"{totalVotes} total", LabelColor32)); + AddButton(287, 23, 0x2622, 0x2623, 2); } - AddHtml(22, 50, 294, 40, Color(poller.Title, 0x99CC66), false, false); + AddHtml(22, 50, 294, 40, Color(poller.Title, 0x99CC66)); AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(42, 90, 264, 1, 9157); @@ -433,7 +433,7 @@ namespace Server.Misc { double perc = option.Votes / (double)totalVotes; - text = string.Format("[{1}: {2}%] {0}", text, option.Votes, (int)(perc * 100)); + text = $"[{option.Votes}: {(int)(perc * 100)}%] {text}"; } int optHeight = option.ComputeHeight(); @@ -445,7 +445,7 @@ namespace Server.Misc else AddRadio(24, y - 15, 0x25F9, 0x25FC, false, 1 + i); - AddHtml(60, y - 9 * option.LineBreaks, 250, 18 * option.LineBreaks, Color(text, LabelColor32), false, false); + AddHtml(60, y - 9 * option.LineBreaks, 250, 18 * option.LineBreaks, Color(text, LabelColor32)); y += optHeight / 2; y += 5; @@ -454,11 +454,11 @@ namespace Server.Misc if (editing && !isViewingResults) { AddRadio(24, y + 15 - 15, 0x25F9, 0x25FC, false, 1 + poller.Options.Length); - AddHtml(60, y + 15 - 9, 250, 18, Color("Create new option.", 0x99CC66), false, false); + AddHtml(60, y + 15 - 9, 250, 18, Color("Create new option.", 0x99CC66)); } - AddButton(314, height - 73, 247, 248, 1, GumpButtonType.Reply, 0); - AddButton(314, height - 47, 242, 241, 0, GumpButtonType.Reply, 0); + AddButton(314, height - 73, 247, 248, 1); + AddButton(314, height - 47, 242, 241, 0); } public bool Editing{ get; } @@ -568,7 +568,7 @@ namespace Server.Misc } else if (m.Groups[2].Success) { - return string.Format("{0}", m.Groups[2].Value); + return $"{m.Groups[2].Value}"; } return m.Value; @@ -606,4 +606,4 @@ namespace Server.Misc from.SendGump(new ShardPollGump(from, m_Poller, true, null)); } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/ShrinkTable.cs b/Scripts/Misc/ShrinkTable.cs index 3876d2401..d78ad3cf5 100644 --- a/Scripts/Misc/ShrinkTable.cs +++ b/Scripts/Misc/ShrinkTable.cs @@ -77,6 +77,7 @@ namespace Server } catch { + // ignored } } } diff --git a/Scripts/Misc/TextDefinition.cs b/Scripts/Misc/TextDefinition.cs index 34f027606..560b02e56 100644 --- a/Scripts/Misc/TextDefinition.cs +++ b/Scripts/Misc/TextDefinition.cs @@ -7,19 +7,11 @@ namespace Server [Parsable] public class TextDefinition { - public TextDefinition() : this(0, null) - { - } - - public TextDefinition(int number) : this(number, null) - { - } - public TextDefinition(string text) : this(0, text) { } - public TextDefinition(int number, string text) + public TextDefinition(int number = 0, string text = null) { Number = number; String = text; @@ -31,34 +23,17 @@ namespace Server public bool IsEmpty => Number <= 0 && String == null; - public override string ToString() - { - if (Number > 0) - return string.Concat("#", Number.ToString()); - if (String != null) - return String; - - return ""; - } + public override string ToString() => Number > 0 ? $"#{Number}" : String ?? ""; public string Format(bool propsGump) { - if (Number > 0) - return string.Format("{0} (0x{0:X})", Number); - if (String != null) - return $"\"{String}\""; - - return propsGump ? "-empty-" : "empty"; + return Number > 0 ? $"{Number} (0x{Number:X})" : + String != null ? $"\"{String}\"" : propsGump ? "-empty-" : "empty"; } public string GetValue() { - if (Number > 0) - return Number.ToString(); - if (String != null) - return String; - - return ""; + return Number > 0 ? Number.ToString() : String ?? ""; } public static void Serialize(GenericWriter writer, TextDefinition def) @@ -120,10 +95,7 @@ namespace Server public static implicit operator int(TextDefinition m) { - if (m == null) - return 0; - - return m.Number; + return m?.Number ?? 0; } public static implicit operator string(TextDefinition m) @@ -201,14 +173,11 @@ namespace Server int i; bool isInteger; - if (value.StartsWith("0x")) - isInteger = int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i); - else - isInteger = int.TryParse(value, out i); + isInteger = value.StartsWith("0x") ? + int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i) : + int.TryParse(value, out i); - if (isInteger) - return new TextDefinition(i); - return new TextDefinition(value); + return isInteger ? new TextDefinition(i) : new TextDefinition(value); } public static bool IsNullOrEmpty(TextDefinition def) @@ -216,4 +185,4 @@ namespace Server return def == null || def.IsEmpty; } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/Titles.cs b/Scripts/Misc/Titles.cs index 31813a197..c156ac6d1 100644 --- a/Scripts/Misc/Titles.cs +++ b/Scripts/Misc/Titles.cs @@ -320,7 +320,7 @@ namespace Server.Misc { Skill highest = GetHighestSkill(mob); // beheld.Skills.Highest; - if (highest != null && highest.BaseFixedPoint >= 300) + if (highest?.BaseFixedPoint >= 300) { string skillLevel = GetSkillLevel(highest); string skillTitle = highest.Info.Title; @@ -403,4 +403,4 @@ namespace Server.Misc m_Title = title; } } -} \ No newline at end of file +} diff --git a/Scripts/Misc/VendorGenerator.cs b/Scripts/Misc/VendorGenerator.cs index a8a38f218..e3ad910f6 100644 --- a/Scripts/Misc/VendorGenerator.cs +++ b/Scripts/Misc/VendorGenerator.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Server.Commands; @@ -261,82 +260,28 @@ namespace Server private static bool IsClothes(int itemID) { - if (itemID >= 0x1515 && itemID <= 0x1518) - return true; - - if (itemID >= 0x152E && itemID <= 0x1531) - return true; - - if (itemID >= 0x1537 && itemID <= 0x154C) - return true; - - if (itemID >= 0x1EFD && itemID <= 0x1F04) - return true; - - if (itemID >= 0x170B && itemID <= 0x171C) - return true; - - return false; + return itemID >= 0x1515 && itemID <= 0x1518 || itemID >= 0x152E && itemID <= 0x1531 || itemID >= 0x1537 + && itemID <= 0x154C || itemID >= 0x1EFD && itemID <= 0x1F04 || itemID >= 0x170B && itemID <= 0x171C; } private static bool IsArmor(int itemID) { - if (itemID >= 0x13BB && itemID <= 0x13E2) - return true; - - if (itemID >= 0x13E5 && itemID <= 0x13F2) - return true; - - if (itemID >= 0x1408 && itemID <= 0x141A) - return true; - - if (itemID >= 0x144E && itemID <= 0x1457) - return true; - - return false; + return itemID >= 0x13BB && itemID <= 0x13E2 || itemID >= 0x13E5 && itemID <= 0x13F2 || + itemID >= 0x1408 && itemID <= 0x141A || itemID >= 0x144E && itemID <= 0x1457; } private static bool IsMetalWeapon(int itemID) { - if (itemID >= 0xF43 && itemID <= 0xF4E) - return true; - - if (itemID >= 0xF51 && itemID <= 0xF52) - return true; - - if (itemID >= 0xF5C && itemID <= 0xF63) - return true; - - if (itemID >= 0x13AF && itemID <= 0x13B0) - return true; - - if (itemID >= 0x13B5 && itemID <= 0x13BA) - return true; - - if (itemID >= 0x13FA && itemID <= 0x13FB) - return true; - - if (itemID >= 0x13FE && itemID <= 0x1407) - return true; - - if (itemID >= 0x1438 && itemID <= 0x1443) - return true; - - return false; + return itemID >= 0xF43 && itemID <= 0xF4E || itemID >= 0xF51 && itemID <= 0xF52 || + itemID >= 0xF5C && itemID <= 0xF63 || itemID >= 0x13AF && itemID <= 0x13B0 || + itemID >= 0x13B5 && itemID <= 0x13BA || itemID >= 0x13FA && itemID <= 0x13FB || + itemID >= 0x13FE && itemID <= 0x1407 || itemID >= 0x1438 && itemID <= 0x1443; } private static bool IsArcheryWeapon(int itemID) { - if (itemID >= 0xF4F && itemID <= 0xF50) - return true; - - if (itemID >= 0x13B1 && itemID <= 0x13B2) - return true; - - if (itemID >= 0x13FC && itemID <= 0x13FD) - return true; - - return false; + return itemID >= 0xF4F && itemID <= 0xF50 || itemID >= 0x13B1 && itemID <= 0x13B2 || + itemID >= 0x13FC && itemID <= 0x13FD; } private static ShopFlags ProcessDisplayedItem(int itemID) @@ -481,9 +426,9 @@ namespace Server floor.Add(p); for (int xo = -1; xo <= 1; ++xo) - for (int yo = -1; yo <= 1; ++yo) - if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false)) - RecurseFindFloor(map, x + xo, y + yo, floor); + for (int 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/Scripts/Misc/Weather.cs b/Scripts/Misc/Weather.cs index c1f34a70b..97f7e5e8a 100644 --- a/Scripts/Misc/Weather.cs +++ b/Scripts/Misc/Weather.cs @@ -344,7 +344,7 @@ namespace Server.Misc { base.Serialize( writer ); - writer.Write( (int) 0 ); + writer.Write( 0 ); } public override void Deserialize( GenericReader reader ) diff --git a/Scripts/Misc/WebStatus.cs b/Scripts/Misc/WebStatus.cs index 891cb0a75..8bc920bec 100644 --- a/Scripts/Misc/WebStatus.cs +++ b/Scripts/Misc/WebStatus.cs @@ -75,6 +75,7 @@ namespace Server.Misc } catch { + // ignored } Listen(); diff --git a/Scripts/Misc/uoamVendors.cs b/Scripts/Misc/uoamVendors.cs index 998d96ee0..f1efc58f6 100644 --- a/Scripts/Misc/uoamVendors.cs +++ b/Scripts/Misc/uoamVendors.cs @@ -12,11 +12,11 @@ namespace Server { //configuration private const int - NPCCount = 2; //2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total) + NPCCount = 2; // 2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total) - private const int HomeRange = 5; //How far should they wander? - private const bool TotalRespawn = true; //Should we spawn them up right away? - private const int Team = 0; //"team" the npcs are on + private const int HomeRange = 5; // How far should they wander? + private const bool TotalRespawn = true; // Should we spawn them up right away? + private const int Team = 0; // "team" the npcs are on private static int m_Count; private static TimeSpan MinTime = TimeSpan.FromMinutes(2.5); //min spawn time private static TimeSpan MaxTime = TimeSpan.FromMinutes(10.0); //max spawn time @@ -38,209 +38,208 @@ namespace Server string vendor_path = Path.Combine(Core.BaseDirectory, "Data/Common.map"); m_Count = 0; - if (File.Exists(vendor_path)) - { - from.SendMessage("Generating Vendors..."); - - using (StreamReader ip = new StreamReader(vendor_path)) - { - string line; - - while ((line = ip.ReadLine()) != null) - { - int indexOf = line.IndexOf(':'); - - if (indexOf == -1) - continue; - - string type = line.Substring(0, ++indexOf).Trim(); - string sub = line.Substring(indexOf).Trim(); - - string[] split = sub.Split(' '); - - if (split.Length < 3) - continue; - - split = new[] { type, split[0], split[1], split[2] }; - - switch (split[0].ToLower()) - { - case "-healer:": - PlaceNPC(split[1], split[2], split[3], "Healer", "HealerGuildmaster"); - break; - case "-baker:": - PlaceNPC(split[1], split[2], split[3], "Baker"); - break; - case "-vet:": - PlaceNPC(split[1], split[2], split[3], "Veterinarian"); - break; - case "-gypsymaiden:": - PlaceNPC(split[1], split[2], split[3], "GypsyMaiden"); - break; - case "-gypsybank:": - PlaceNPC(split[1], split[2], split[3], "GypsyBanker"); - break; - case "-bank:": - PlaceNPC(split[1], split[2], split[3], "Banker", "Minter"); - break; - case "-inn:": - PlaceNPC(split[1], split[2], split[3], "Innkeeper"); - break; - case "-provisioner:": - PlaceNPC(split[1], split[2], split[3], "Provisioner", "Cobbler"); - break; - case "-tailor:": - PlaceNPC(split[1], split[2], split[3], "Tailor", "Weaver", "TailorGuildmaster"); - break; - case "-tavern:": - PlaceNPC(split[1], split[2], split[3], "Tavernkeeper", "Waiter", "Cook", "Barkeeper"); - break; - case "-reagents:": - PlaceNPC(split[1], split[2], split[3], "Herbalist", "Alchemist", "CustomHairstylist"); - break; - case "-fortuneteller:": - PlaceNPC(split[1], split[2], split[3], "FortuneTeller"); - break; - case "-holymage:": - PlaceNPC(split[1], split[2], split[3], "HolyMage"); - break; - case "-chivalrykeeper:": - PlaceNPC(split[1], split[2], split[3], "KeeperOfChivalry"); - break; - case "-mage:": - PlaceNPC(split[1], split[2], split[3], "Mage", "Alchemist", "MageGuildmaster"); - break; - case "-arms:": - PlaceNPC(split[1], split[2], split[3], "Armorer", "Weaponsmith"); - break; - case "-tinker:": - PlaceNPC(split[1], split[2], split[3], "Tinker", "TinkerGuildmaster"); - break; - case "-gypsystable:": - PlaceNPC(split[1], split[2], split[3], "GypsyAnimalTrainer"); - break; - case "-stable:": - PlaceNPC(split[1], split[2], split[3], "AnimalTrainer"); - break; - case "-blacksmith:": - PlaceNPC(split[1], split[2], split[3], "Blacksmith", "BlacksmithGuildmaster"); - break; - case "-bowyer:": - case "-fletcher:": - PlaceNPC(split[1], split[2], split[3], "Bowyer"); - break; - case "-carpenter:": - PlaceNPC(split[1], split[2], split[3], "Carpenter", "Architect", "RealEstateBroker"); - break; - case "-butcher:": - PlaceNPC(split[1], split[2], split[3], "Butcher"); - break; - case "-jeweler:": - PlaceNPC(split[1], split[2], split[3], "Jeweler"); - break; - case "-tanner:": - PlaceNPC(split[1], split[2], split[3], "Tanner", "Furtrader"); - break; - case "-bard:": - PlaceNPC(split[1], split[2], split[3], "Bard", "BardGuildmaster"); - break; - case "-market:": - PlaceNPC(split[1], split[2], split[3], "Butcher", "Farmer"); - break; - case "-library:": - PlaceNPC(split[1], split[2], split[3], "Scribe"); - break; - case "-shipwright:": - PlaceNPC(split[1], split[2], split[3], "Shipwright", "Mapmaker"); - break; - case "-docks:": - PlaceNPC(split[1], split[2], split[3], "Fisherman"); - break; - - case "-beekeeper:": - PlaceNPC(split[1], split[2], split[3], "Beekeeper"); - break; - - - // Guilds & Misc - case "-tinkers guild:": - PlaceNPC(split[1], split[2], split[3], "TinkerGuildmaster"); - break; - case "-blacksmiths guild:": - PlaceNPC(split[1], split[2], split[3], "BlacksmithGuildmaster"); - break; - case "-sorcerors guild:": - PlaceNPC(split[1], split[2], split[3], "MageGuildmaster"); - break; - case "-customs:": break; - case "-painter:": break; - case "-theater:": break; - case "-warriors guild:": - PlaceNPC(split[1], split[2], split[3], "WarriorGuildmaster"); - break; - case "-archers guild:": - PlaceNPC(split[1], split[2], split[3], "RangerGuildmaster"); - break; - case "-thieves guild:": - PlaceNPC(split[1], split[2], split[3], "ThiefGuildmaster"); - break; - case "-miners guild:": - PlaceNPC(split[1], split[2], split[3], "MinerGuildmaster"); - break; - case "-fishermans guild:": - PlaceNPC(split[1], split[2], split[3], "FisherGuildmaster"); - break; - case "-merchants guild:": - PlaceNPC(split[1], split[2], split[3], "MerchantGuildmaster"); - break; - case "-illusionists guild:": break; - case "-armourers guild:": break; - case "-sorcerers guild:": break; - case "-mages guild:": - PlaceNPC(split[1], split[2], split[3], "MageGuildmaster"); - break; - case "-weapons guild:": break; - case "-bardic guild:": - PlaceNPC(split[1], split[2], split[3], "BardGuildmaster"); - break; - case "-rogues guild:": - break; - - // Skip - case "+landmark:": - case "-point of interest:": - case "+shrine:": - case "+moongate:": - case "+dungeon:": - case "+scenic:": - case "-gate:": - case "+Body of Water:": - case "+ruins:": - case "+teleporter:": - case "+Terrain:": - case "-exit:": - case "-bridge:": - case "-other:": - case "+champion:": - case "-stairs:": - case "-guild:": - case "+graveyard:": - case "+Island:": - case "+town:": - break; - /*default: - Console.WriteLine(split[0]); - break;*/ - } - } - } - - from.SendMessage("Done, added {0} spawners", m_Count); - } - else + if (!File.Exists(vendor_path)) { from.SendMessage("{0} not found!", vendor_path); + return; } + + from.SendMessage("Generating Vendors..."); + + using (StreamReader ip = new StreamReader(vendor_path)) + { + string line; + + while ((line = ip.ReadLine()) != null) + { + int indexOf = line.IndexOf(':'); + + if (indexOf == -1) + continue; + + string type = line.Substring(0, ++indexOf).Trim(); + string sub = line.Substring(indexOf).Trim(); + + string[] split = sub.Split(' '); + + if (split.Length < 3) + continue; + + split = new[] { type, split[0], split[1], split[2] }; + + switch (split[0].ToLower()) + { + case "-healer:": + PlaceNPC(split[1], split[2], split[3], "Healer", "HealerGuildmaster"); + break; + case "-baker:": + PlaceNPC(split[1], split[2], split[3], "Baker"); + break; + case "-vet:": + PlaceNPC(split[1], split[2], split[3], "Veterinarian"); + break; + case "-gypsymaiden:": + PlaceNPC(split[1], split[2], split[3], "GypsyMaiden"); + break; + case "-gypsybank:": + PlaceNPC(split[1], split[2], split[3], "GypsyBanker"); + break; + case "-bank:": + PlaceNPC(split[1], split[2], split[3], "Banker", "Minter"); + break; + case "-inn:": + PlaceNPC(split[1], split[2], split[3], "Innkeeper"); + break; + case "-provisioner:": + PlaceNPC(split[1], split[2], split[3], "Provisioner", "Cobbler"); + break; + case "-tailor:": + PlaceNPC(split[1], split[2], split[3], "Tailor", "Weaver", "TailorGuildmaster"); + break; + case "-tavern:": + PlaceNPC(split[1], split[2], split[3], "Tavernkeeper", "Waiter", "Cook", "Barkeeper"); + break; + case "-reagents:": + PlaceNPC(split[1], split[2], split[3], "Herbalist", "Alchemist", "CustomHairstylist"); + break; + case "-fortuneteller:": + PlaceNPC(split[1], split[2], split[3], "FortuneTeller"); + break; + case "-holymage:": + PlaceNPC(split[1], split[2], split[3], "HolyMage"); + break; + case "-chivalrykeeper:": + PlaceNPC(split[1], split[2], split[3], "KeeperOfChivalry"); + break; + case "-mage:": + PlaceNPC(split[1], split[2], split[3], "Mage", "Alchemist", "MageGuildmaster"); + break; + case "-arms:": + PlaceNPC(split[1], split[2], split[3], "Armorer", "Weaponsmith"); + break; + case "-tinker:": + PlaceNPC(split[1], split[2], split[3], "Tinker", "TinkerGuildmaster"); + break; + case "-gypsystable:": + PlaceNPC(split[1], split[2], split[3], "GypsyAnimalTrainer"); + break; + case "-stable:": + PlaceNPC(split[1], split[2], split[3], "AnimalTrainer"); + break; + case "-blacksmith:": + PlaceNPC(split[1], split[2], split[3], "Blacksmith", "BlacksmithGuildmaster"); + break; + case "-bowyer:": + case "-fletcher:": + PlaceNPC(split[1], split[2], split[3], "Bowyer"); + break; + case "-carpenter:": + PlaceNPC(split[1], split[2], split[3], "Carpenter", "Architect", "RealEstateBroker"); + break; + case "-butcher:": + PlaceNPC(split[1], split[2], split[3], "Butcher"); + break; + case "-jeweler:": + PlaceNPC(split[1], split[2], split[3], "Jeweler"); + break; + case "-tanner:": + PlaceNPC(split[1], split[2], split[3], "Tanner", "Furtrader"); + break; + case "-bard:": + PlaceNPC(split[1], split[2], split[3], "Bard", "BardGuildmaster"); + break; + case "-market:": + PlaceNPC(split[1], split[2], split[3], "Butcher", "Farmer"); + break; + case "-library:": + PlaceNPC(split[1], split[2], split[3], "Scribe"); + break; + case "-shipwright:": + PlaceNPC(split[1], split[2], split[3], "Shipwright", "Mapmaker"); + break; + case "-docks:": + PlaceNPC(split[1], split[2], split[3], "Fisherman"); + break; + + case "-beekeeper:": + PlaceNPC(split[1], split[2], split[3], "Beekeeper"); + break; + + + // Guilds & Misc + case "-tinkers guild:": + PlaceNPC(split[1], split[2], split[3], "TinkerGuildmaster"); + break; + case "-blacksmiths guild:": + PlaceNPC(split[1], split[2], split[3], "BlacksmithGuildmaster"); + break; + case "-sorcerors guild:": + PlaceNPC(split[1], split[2], split[3], "MageGuildmaster"); + break; + case "-customs:": break; + case "-painter:": break; + case "-theater:": break; + case "-warriors guild:": + PlaceNPC(split[1], split[2], split[3], "WarriorGuildmaster"); + break; + case "-archers guild:": + PlaceNPC(split[1], split[2], split[3], "RangerGuildmaster"); + break; + case "-thieves guild:": + PlaceNPC(split[1], split[2], split[3], "ThiefGuildmaster"); + break; + case "-miners guild:": + PlaceNPC(split[1], split[2], split[3], "MinerGuildmaster"); + break; + case "-fishermans guild:": + PlaceNPC(split[1], split[2], split[3], "FisherGuildmaster"); + break; + case "-merchants guild:": + PlaceNPC(split[1], split[2], split[3], "MerchantGuildmaster"); + break; + case "-illusionists guild:": break; + case "-armourers guild:": break; + case "-sorcerers guild:": break; + case "-mages guild:": + PlaceNPC(split[1], split[2], split[3], "MageGuildmaster"); + break; + case "-weapons guild:": break; + case "-bardic guild:": + PlaceNPC(split[1], split[2], split[3], "BardGuildmaster"); + break; + case "-rogues guild:": + break; + + // Skip + case "+landmark:": + case "-point of interest:": + case "+shrine:": + case "+moongate:": + case "+dungeon:": + case "+scenic:": + case "-gate:": + case "+Body of Water:": + case "+ruins:": + case "+teleporter:": + case "+Terrain:": + case "-exit:": + case "-bridge:": + case "-other:": + case "+champion:": + case "-stairs:": + case "-guild:": + case "+graveyard:": + case "+Island:": + case "+town:": + break; + /*default: + Console.WriteLine(split[0]); + break;*/ + } + } + } + + from.SendMessage("Done, added {0} spawners", m_Count); } public static void PlaceNPC(string sx, string sy, string sm, params string[] types) @@ -283,7 +282,7 @@ namespace Server if (map.CanFit(x, y, z, 16, false, false)) return z; - for (int i = 1; i <= 20; ++i) + for (int i = 1; i <= 5; ++i) { if (map.CanFit(x, y, z + i, 16, false, false)) return z + i; @@ -319,32 +318,36 @@ namespace Server ClearSpawners(x, y, z, map); + Spawner sp = new Spawner + { + MinDelay = MinTime, + MaxDelay = MaxTime, + Team = Team, + HomeRange = HomeRange + }; + + int count = 0; + for (int i = 0; i < types.Length; ++i) { - bool isGuildmaster = types[i].EndsWith("Guildmaster"); + bool isGuildMaster = types[i].EndsWith("Guildmaster"); + count += isGuildMaster ? 1 : NPCCount; + if (isGuildMaster) + count++; - Spawner sp = new Spawner(types[i]); - - if (isGuildmaster) - sp.Count = 1; - else - sp.Count = NPCCount; - - sp.MinDelay = MinTime; - sp.MaxDelay = MaxTime; - sp.Team = Team; - sp.HomeRange = HomeRange; - - sp.MoveToWorld(new Point3D(x, y, z), map); - - if (TotalRespawn) - { - sp.Respawn(); - sp.BringToHome(); - } - - ++m_Count; + sp.AddEntry(types[i], 100, isGuildMaster ? 1 : NPCCount); } + + sp.Count = count; + sp.MoveToWorld(new Point3D(x, y, z), map); + + if (TotalRespawn) + { + sp.Respawn(); + sp.BringToHome(); + } + + m_Count += types.Length; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/AnimalAI.cs b/Scripts/Mobiles/AI/AnimalAI.cs index a1e69315c..c9ebc1260 100644 --- a/Scripts/Mobiles/AI/AnimalAI.cs +++ b/Scripts/Mobiles/AI/AnimalAI.cs @@ -4,7 +4,7 @@ // More your close, the more it can panic /* * AnimalHunterAI, AnimalHidingAI, AnimalDomesticAI... - * + * */ namespace Server.Mobiles @@ -26,7 +26,7 @@ namespace Server.Mobiles } else if ( m_Mobile.IsHurt() || m_Mobile.Combatant != null ) { - m_Mobile.DebugSay( "I am hurt or being attacked, I flee" ); + m_Mobile.DebugSay( "I am hurt or being attacked, I flee" ); Action = ActionType.Flee; } else @@ -66,7 +66,7 @@ namespace Server.Mobiles { Mobile combatant = m_Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map) + if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map) { m_Mobile.DebugSay("My combatant is gone.."); @@ -147,4 +147,4 @@ namespace Server.Mobiles return base.DoActionFlee(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/ArcherAI.cs b/Scripts/Mobiles/AI/ArcherAI.cs index b6842f62d..49522294f 100644 --- a/Scripts/Mobiles/AI/ArcherAI.cs +++ b/Scripts/Mobiles/AI/ArcherAI.cs @@ -30,7 +30,7 @@ namespace Server.Mobiles public override bool DoActionCombat() { - if (m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted || !m_Mobile.Combatant.Alive || + if (m_Mobile.Combatant?.Deleted != false || !m_Mobile.Combatant.Alive || m_Mobile.Combatant.IsDeadBondedPet) { m_Mobile.DebugSay("My combatant is deleted"); @@ -117,4 +117,4 @@ namespace Server.Mobiles return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/BaseAI.cs b/Scripts/Mobiles/AI/BaseAI.cs index 6d3ba83f5..562653f29 100644 --- a/Scripts/Mobiles/AI/BaseAI.cs +++ b/Scripts/Mobiles/AI/BaseAI.cs @@ -340,7 +340,7 @@ namespace Server.Mobiles Skill skill = ourSkills[i]; Skill theirSkill = theirSkills[i]; - if (skill != null && theirSkill != null && skill.Base >= 60.0 && + if (skill != null && skill?.Base >= 60.0 && m_Mobile.CheckTeach(skill.SkillName, e.Mobile)) { double toTeach = skill.Base / 3.0; @@ -813,7 +813,7 @@ namespace Server.Mobiles { m_Mobile.DebugSay("I will go to the next waypoint"); m_Mobile.CurrentWayPoint = point.NextPoint; - if (point.NextPoint != null && point.NextPoint.Deleted) + if (point.NextPoint?.Deleted == true) m_Mobile.CurrentWayPoint = point.NextPoint = point.NextPoint.NextPoint; } } @@ -833,7 +833,7 @@ namespace Server.Mobiles WalkRandomInHome(2, 2, 1); } - if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && + if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && !m_Mobile.Combatant.IsDeadBondedPet) m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); return true; @@ -849,7 +849,7 @@ namespace Server.Mobiles { Mobile c = m_Mobile.Combatant; - if (c == null || c.Deleted || c.Map != m_Mobile.Map || !c.Alive || c.IsDeadBondedPet) + if (c?.Deleted != false || c.Map != m_Mobile.Map || !c.Alive || c.IsDeadBondedPet) Action = ActionType.Wander; else m_Mobile.Direction = m_Mobile.GetDirectionTo(c); @@ -882,7 +882,7 @@ namespace Server.Mobiles { Mobile from = m_Mobile.FocusMob; - if (from == null || from.Deleted || from.Map != m_Mobile.Map) + if (from?.Deleted != false || from.Map != m_Mobile.Map) { m_Mobile.DebugSay("I have lost him"); Action = ActionType.Guard; @@ -964,7 +964,7 @@ namespace Server.Mobiles public virtual void OnCurrentOrderChanged() { - if (m_Mobile.Deleted || m_Mobile.ControlMaster == null || m_Mobile.ControlMaster.Deleted) + if (m_Mobile.Deleted || m_Mobile.ControlMaster?.Deleted != false) return; switch (m_Mobile.ControlOrder) @@ -1077,7 +1077,7 @@ namespace Server.Mobiles WalkRandomInHome(3, 2, 1); - if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && + if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && !m_Mobile.Combatant.IsDeadBondedPet) { m_Mobile.Warmode = true; @@ -1093,35 +1093,35 @@ namespace Server.Mobiles public virtual bool DoOrderCome() { - if (m_Mobile.ControlMaster != null && !m_Mobile.ControlMaster.Deleted) + if (m_Mobile.ControlMaster?.Deleted != false) + return true; + + int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlMaster); + + if (iCurrDist > m_Mobile.RangePerception) { - int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlMaster); + m_Mobile.DebugSay("I have lost my master. I stay here"); + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.None; + } + else + { + m_Mobile.DebugSay("My master told me come"); - if (iCurrDist > m_Mobile.RangePerception) + // Not exactly OSI style, but better than nothing. + bool bRun = iCurrDist > 5; + + if (WalkMobileRange(m_Mobile.ControlMaster, 1, bRun, 0, 1)) { - m_Mobile.DebugSay("I have lost my master. I stay here"); - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.None; - } - else - { - m_Mobile.DebugSay("My master told me come"); - - // Not exactly OSI style, but better than nothing. - bool bRun = iCurrDist > 5; - - if (WalkMobileRange(m_Mobile.ControlMaster, 1, bRun, 0, 1)) + if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && + !m_Mobile.Combatant.IsDeadBondedPet) { - if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && - !m_Mobile.Combatant.IsDeadBondedPet) - { - m_Mobile.Warmode = true; - m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); - } - else - { - m_Mobile.Warmode = false; - } + m_Mobile.Warmode = true; + m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant); + } + else + { + m_Mobile.Warmode = false; } } } @@ -1140,7 +1140,7 @@ namespace Server.Mobiles if (pack != null) { - List list = pack.Items; + List list = pack?.Items; for (int i = list.Count - 1; i >= 0; --i) if (i < list.Count) @@ -1196,7 +1196,7 @@ namespace Server.Mobiles { m_Mobile.DebugSay("Praise the shepherd!"); } - else if (m_Mobile.ControlTarget != null && !m_Mobile.ControlTarget.Deleted && m_Mobile.ControlTarget != m_Mobile) + else if (m_Mobile.ControlTarget?.Deleted == false && m_Mobile.ControlTarget != m_Mobile) { int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlTarget); @@ -1204,7 +1204,7 @@ namespace Server.Mobiles { m_Mobile.DebugSay("I have lost the one to follow. I stay here"); - if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && + if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && !m_Mobile.Combatant.IsDeadBondedPet) { m_Mobile.Warmode = true; @@ -1224,7 +1224,7 @@ namespace Server.Mobiles if (WalkMobileRange(m_Mobile.ControlTarget, 1, bRun, 0, 1)) { - if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && + if (m_Mobile.Combatant?.Deleted == false && m_Mobile.Combatant.Alive && !m_Mobile.Combatant.IsDeadBondedPet) { m_Mobile.Warmode = true; @@ -1254,7 +1254,7 @@ namespace Server.Mobiles Mobile from = m_Mobile.ControlMaster; Mobile to = m_Mobile.ControlTarget; - if (from == null || to == null || from == to || from.Deleted || to.Deleted || !to.Player) + if (from?.Deleted != false || to?.Deleted != false || from == to || !to.Player) { m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused* } @@ -1326,7 +1326,7 @@ namespace Server.Mobiles Mobile from = m_Mobile.ControlMaster; Mobile to = m_Mobile.ControlTarget; - if (from == null || to == null || from == to || from.Deleted || to.Deleted || !to.Player) + if (from?.Deleted != false || to?.Deleted != false || from == to || !to.Player) { m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, 502039); // *looks confused* } @@ -1360,7 +1360,7 @@ namespace Server.Mobiles Mobile controlMaster = m_Mobile.ControlMaster; - if (controlMaster == null || controlMaster.Deleted) + if (controlMaster?.Deleted != false) return true; Mobile combatant = m_Mobile.Combatant; @@ -1374,7 +1374,7 @@ namespace Server.Mobiles AggressorInfo info = aggressors[i]; Mobile attacker = info.Attacker; - if (attacker != null && !attacker.Deleted && + if (attacker?.Deleted == false && attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception) if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) < combatant.GetDistanceToSqrt(controlMaster)) @@ -1385,7 +1385,7 @@ namespace Server.Mobiles m_Mobile.DebugSay("Crap, my master has been attacked! I will attack one of those bastards!"); } - if (combatant != null && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && !combatant.Deleted && + if (combatant?.Deleted == false && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && combatant.Alive && !combatant.IsDeadBondedPet && m_Mobile.CanSee(combatant) && m_Mobile.CanBeHarmful(combatant, false) && combatant.Map == m_Mobile.Map) { @@ -1420,9 +1420,8 @@ namespace Server.Mobiles if (m_Mobile.IsDeadPet) return true; - if (m_Mobile.ControlTarget == null || m_Mobile.ControlTarget.Deleted || - m_Mobile.ControlTarget.Map != m_Mobile.Map || !m_Mobile.ControlTarget.Alive || - m_Mobile.ControlTarget.IsDeadBondedPet) + if (m_Mobile.ControlTarget?.Deleted != false || m_Mobile.ControlTarget.Map != m_Mobile.Map || + !m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet) { m_Mobile.DebugSay( "I think he might be dead. He's not anywhere around here at least. That's cool. I'm glad he's dead."); @@ -1527,7 +1526,7 @@ namespace Server.Mobiles public virtual bool DoOrderStop() { - if (m_Mobile.ControlMaster == null || m_Mobile.ControlMaster.Deleted) + if (m_Mobile.ControlMaster?.Deleted != false) return true; m_Mobile.DebugSay("My master told me to stop."); @@ -1553,7 +1552,7 @@ namespace Server.Mobiles Mobile from = m_Mobile.ControlMaster; Mobile to = m_Mobile.ControlTarget; - if (from != to && from != null && !from.Deleted && to != null && !to.Deleted && to.Player) + if (from?.Deleted == false && to?.Deleted == false && from != to && to.Player) { m_Mobile.DebugSay("Begin transfer with {0}", to.Name); @@ -1639,10 +1638,9 @@ namespace Server.Mobiles public virtual bool DoBardProvoked() { - if (DateTime.UtcNow >= m_Mobile.BardEndTime && (m_Mobile.BardMaster == null || m_Mobile.BardMaster.Deleted || - m_Mobile.BardMaster.Map != m_Mobile.Map || - m_Mobile.GetDistanceToSqrt(m_Mobile.BardMaster) > - m_Mobile.RangePerception)) + if (DateTime.UtcNow >= m_Mobile.BardEndTime && (m_Mobile.BardMaster?.Deleted != false || + m_Mobile.BardMaster.Map != m_Mobile.Map || m_Mobile.GetDistanceToSqrt(m_Mobile.BardMaster) > + m_Mobile.RangePerception)) { m_Mobile.DebugSay("I have lost my provoker"); m_Mobile.BardProvoked = false; @@ -1654,7 +1652,7 @@ namespace Server.Mobiles } else { - if (m_Mobile.BardTarget == null || m_Mobile.BardTarget.Deleted || m_Mobile.BardTarget.Map != m_Mobile.Map || + if (m_Mobile.BardTarget?.Deleted != false || m_Mobile.BardTarget.Map != m_Mobile.Map || m_Mobile.GetDistanceToSqrt(m_Mobile.BardTarget) > m_Mobile.RangePerception) { m_Mobile.DebugSay("I have lost my provoke target"); @@ -2056,7 +2054,7 @@ namespace Server.Mobiles public virtual bool MoveTo(Mobile m, bool run, int range) { - if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == null || m.Deleted) + if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m?.Deleted != false) return false; if (m_Mobile.InRange(m, range)) @@ -2065,7 +2063,7 @@ namespace Server.Mobiles return true; } - if (m_Path != null && m_Path.Goal == m) + if (m_Path?.Goal == m) { if (m_Path.Follow(run, 1)) { @@ -2184,7 +2182,7 @@ namespace Server.Mobiles if (m_Mobile.BardProvoked) { - if (m_Mobile.BardTarget == null || m_Mobile.BardTarget.Deleted) + if (m_Mobile.BardTarget?.Deleted != false) { m_Mobile.FocusMob = null; return false; @@ -2196,7 +2194,7 @@ namespace Server.Mobiles if (m_Mobile.Controlled) { - if (m_Mobile.ControlTarget == null || m_Mobile.ControlTarget.Deleted || m_Mobile.ControlTarget.Hidden || + if (m_Mobile.ControlTarget?.Deleted != false || m_Mobile.ControlTarget.Hidden || !m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet || !m_Mobile.InRange(m_Mobile.ControlTarget, m_Mobile.RangePerception * 2)) { @@ -2386,6 +2384,7 @@ namespace Server.Mobiles return; IPooledEnumerable eable = m_Mobile.GetMobilesInRange(m_Mobile.RangePerception); + foreach (Mobile trg in eable) if (trg != m_Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player && m_Mobile.InLOS(trg)) @@ -2599,7 +2598,7 @@ namespace Server.Mobiles if (!base.AllowSecureTrade(from, to, newOwner, accepted)) return false; - if (Deleted || m_Creature == null || m_Creature.Deleted || m_Creature.ControlMaster != from || + if (Deleted || m_Creature?.Deleted != false || m_Creature.ControlMaster != from || !from.CheckAlive() || !to.CheckAlive()) return false; @@ -2661,7 +2660,7 @@ namespace Server.Mobiles Delete(); - if (m_Creature == null || m_Creature.Deleted || m_Creature.ControlMaster != from || !from.CheckAlive() || + if (m_Creature?.Deleted != false || m_Creature.ControlMaster != from || !from.CheckAlive() || !to.CheckAlive()) return; @@ -2795,4 +2794,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/BerserkAI.cs b/Scripts/Mobiles/AI/BerserkAI.cs index f81a704a5..3893e00af 100644 --- a/Scripts/Mobiles/AI/BerserkAI.cs +++ b/Scripts/Mobiles/AI/BerserkAI.cs @@ -28,7 +28,7 @@ namespace Server.Mobiles public override bool DoActionCombat() { - if (m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted) + if (m_Mobile.Combatant?.Deleted != false) { m_Mobile.DebugSay("My combatant is deleted"); Action = ActionType.Guard; @@ -79,4 +79,4 @@ namespace Server.Mobiles return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/HealerAI.cs b/Scripts/Mobiles/AI/HealerAI.cs index e05638eb9..b0ec783e4 100644 --- a/Scripts/Mobiles/AI/HealerAI.cs +++ b/Scripts/Mobiles/AI/HealerAI.cs @@ -1,3 +1,4 @@ +using Server.Spells; using Server.Spells.First; using Server.Spells.Fourth; using Server.Spells.Second; @@ -28,11 +29,13 @@ namespace Server.Mobiles if (targ != null) { - if (targ is CureSpell.InternalTarget) + ISpellTarget spellTarg = targ as ISpellTarget; + + if (spellTarg?.Spell is CureSpell) ProcessTarget(targ, m_ACure); - else if (targ is GreaterHealSpell.InternalTarget) + else if (spellTarg?.Spell is GreaterHealSpell) ProcessTarget(targ, m_AGHeal); - else if (targ is HealSpell.InternalTarget) + else if (spellTarg?.Spell is HealSpell) ProcessTarget(targ, m_ALHeal); else targ.Cancel(m_Mobile, TargetCancelType.Canceled); @@ -48,23 +51,23 @@ namespace Server.Mobiles if (m_Mobile.Debug) m_Mobile.DebugSay("{0} needs a cure", toHelp.Name); - if (!new CureSpell(m_Mobile, null).Cast()) - new CureSpell(m_Mobile, null).Cast(); + 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, null).Cast()) - new HealSpell(m_Mobile, null).Cast(); + 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, null).Cast(); + new HealSpell(m_Mobile).Cast(); } } else @@ -151,4 +154,4 @@ namespace Server.Mobiles private delegate bool NeedDelegate(Mobile m); } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/MageAI.cs b/Scripts/Mobiles/AI/MageAI.cs index cec77c5c8..6d8a3f138 100644 --- a/Scripts/Mobiles/AI/MageAI.cs +++ b/Scripts/Mobiles/AI/MageAI.cs @@ -120,7 +120,7 @@ namespace Server.Mobiles { // If I'm poisoned, always attempt to cure. if (m_Mobile.Poisoned) - return new CureSpell(m_Mobile, null); + return new CureSpell(m_Mobile); // Summoned creatures never heal themselves. if (m_Mobile.Summoned) @@ -150,11 +150,11 @@ namespace Server.Mobiles m_Mobile.UseSkill(SkillName.SpiritSpeak); } else - spell = new GreaterHealSpell(m_Mobile, null); + spell = new GreaterHealSpell(m_Mobile); } else if (m_Mobile.Hits < m_Mobile.HitsMax - 10) { - spell = new HealSpell(m_Mobile, null); + spell = new HealSpell(m_Mobile); } double delay; @@ -213,7 +213,7 @@ namespace Server.Mobiles { m_Mobile.Target?.Cancel(m_Mobile, TargetCancelType.Canceled); - new TeleportSpell(m_Mobile, null).Cast(); + new TeleportSpell(m_Mobile).Cast(); m_Mobile.DebugSay("I am stuck, I'm going to try teleporting away"); } @@ -265,19 +265,19 @@ namespace Server.Mobiles { case 0: m_Mobile.DebugSay("Pain Spike"); - return new PainSpikeSpell(m_Mobile, null); + return new PainSpikeSpell(m_Mobile); case 1: m_Mobile.DebugSay("Poison Strike"); - return new PoisonStrikeSpell(m_Mobile, null); + return new PoisonStrikeSpell(m_Mobile); case 2: m_Mobile.DebugSay("Strangle"); - return new StrangleSpell(m_Mobile, null); + return new StrangleSpell(m_Mobile); case 3: m_Mobile.DebugSay("Wither"); - return new WitherSpell(m_Mobile, null); + return new WitherSpell(m_Mobile); default: m_Mobile.DebugSay("Vengeful Spirit"); - return new VengefulSpiritSpell(m_Mobile, null); + return new VengefulSpiritSpell(m_Mobile); } } @@ -293,18 +293,18 @@ namespace Server.Mobiles switch (Utility.Random(maxCircle * 2)) { case 0: - case 1: return new MagicArrowSpell(m_Mobile, null); + case 1: return new MagicArrowSpell(m_Mobile); case 2: - case 3: return new HarmSpell(m_Mobile, null); + case 3: return new HarmSpell(m_Mobile); case 4: - case 5: return new FireballSpell(m_Mobile, null); + case 5: return new FireballSpell(m_Mobile); case 6: - case 7: return new LightningSpell(m_Mobile, null); + case 7: return new LightningSpell(m_Mobile); case 8: - case 9: return new MindBlastSpell(m_Mobile, null); - case 10: return new EnergyBoltSpell(m_Mobile, null); - case 11: return new ExplosionSpell(m_Mobile, null); - default: return new FlameStrikeSpell(m_Mobile, null); + case 9: return new MindBlastSpell(m_Mobile); + case 10: return new EnergyBoltSpell(m_Mobile); + case 11: return new ExplosionSpell(m_Mobile); + default: return new FlameStrikeSpell(m_Mobile); } } @@ -319,38 +319,38 @@ namespace Server.Mobiles { case 0: m_Mobile.DebugSay("Blood Oath"); - return new BloodOathSpell(m_Mobile, null); + return new BloodOathSpell(m_Mobile); case 1: m_Mobile.DebugSay("Corpse Skin"); - return new CorpseSkinSpell(m_Mobile, null); + return new CorpseSkinSpell(m_Mobile); case 2: m_Mobile.DebugSay("Evil Omen"); - return new EvilOmenSpell(m_Mobile, null); + return new EvilOmenSpell(m_Mobile); default: m_Mobile.DebugSay("Mind Rot"); - return new MindRotSpell(m_Mobile, null); + return new MindRotSpell(m_Mobile); } } public virtual Spell GetRandomCurseSpellMage() { if (m_Mobile.Skills.Magery.Value >= 40.0 && Utility.Random(4) == 0) - return new CurseSpell(m_Mobile, null); + return new CurseSpell(m_Mobile); switch (Utility.Random(3)) { - case 0: return new WeakenSpell(m_Mobile, null); - case 1: return new ClumsySpell(m_Mobile, null); - default: return new FeeblemindSpell(m_Mobile, null); + case 0: return new WeakenSpell(m_Mobile); + case 1: return new ClumsySpell(m_Mobile); + default: return new FeeblemindSpell(m_Mobile); } } public virtual Spell GetRandomManaDrainSpell() { if (m_Mobile.Skills.Magery.Value >= 80.0 && Utility.RandomBool()) - return new ManaVampireSpell(m_Mobile, null); + return new ManaVampireSpell(m_Mobile); - return new ManaDrainSpell(m_Mobile, null); + return new ManaDrainSpell(m_Mobile); } public virtual Spell DoDispel(Mobile toDispel) @@ -358,7 +358,7 @@ namespace Server.Mobiles if (!SmartAI) { if (ScaleBySkill(DispelChance, SkillName.Magery) > Utility.RandomDouble()) - return new DispelSpell(m_Mobile, null); + return new DispelSpell(m_Mobile); return ChooseSpell(toDispel); } @@ -368,11 +368,11 @@ namespace Server.Mobiles if (spell == null) { if (!m_Mobile.DisallowAllMoves && Utility.Random((int)m_Mobile.GetDistanceToSqrt(toDispel)) == 0) - spell = new TeleportSpell(m_Mobile, null); + 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, null); + spell = new ParalyzeSpell(m_Mobile); else - spell = new DispelSpell(m_Mobile, null); + spell = new DispelSpell(m_Mobile); } return spell; @@ -380,7 +380,7 @@ namespace Server.Mobiles public virtual Spell ChooseSpell(Mobile c) { - Spell spell = null; + Spell spell; if (!SmartAI) { @@ -396,7 +396,7 @@ namespace Server.Mobiles (c.Player ? 18 : 30); if (psDamage > c.Hits) - return new PainSpikeSpell(m_Mobile, null); + return new PainSpikeSpell(m_Mobile); } switch (Utility.Random(16)) @@ -409,14 +409,14 @@ namespace Server.Mobiles m_Mobile.DebugSay("Attempting to poison"); - spell = new PoisonSpell(m_Mobile, null); + spell = new PoisonSpell(m_Mobile); break; } case 2: // Bless ourselves { m_Mobile.DebugSay("Blessing myself"); - spell = new BlessSpell(m_Mobile, null); + spell = new BlessSpell(m_Mobile); break; } case 3: @@ -434,7 +434,7 @@ namespace Server.Mobiles m_Mobile.DebugSay("Attempting to paralyze"); - spell = new ParalyzeSpell(m_Mobile, null); + spell = new ParalyzeSpell(m_Mobile); break; } case 6: // Drain mana @@ -451,7 +451,7 @@ namespace Server.Mobiles m_Mobile.DebugSay("Attempting to invis myself"); - spell = new InvisibilitySpell(m_Mobile, null); + spell = new InvisibilitySpell(m_Mobile); break; } default: // Damage them @@ -478,7 +478,7 @@ namespace Server.Mobiles if (c.Poisoned) goto case 1; - spell = new PoisonSpell(m_Mobile, null); + spell = new PoisonSpell(m_Mobile); break; } case 1: // Deal some damage @@ -499,7 +499,7 @@ namespace Server.Mobiles } else if (!c.Poisoned) { - spell = new ParalyzeSpell(m_Mobile, null); + spell = new ParalyzeSpell(m_Mobile); } } else if (m_Mobile.Mana > 60) @@ -507,12 +507,12 @@ namespace Server.Mobiles if (Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned) { m_Combo = 0; - spell = new ParalyzeSpell(m_Mobile, null); + spell = new ParalyzeSpell(m_Mobile); } else { m_Combo = 1; - spell = new ExplosionSpell(m_Mobile, null); + spell = new ExplosionSpell(m_Mobile); } } @@ -529,20 +529,20 @@ namespace Server.Mobiles if (m_Combo == 0) { - spell = new ExplosionSpell(m_Mobile, null); + spell = new ExplosionSpell(m_Mobile); ++m_Combo; // Move to next spell } else if (m_Combo == 1) { - spell = new WeakenSpell(m_Mobile, null); + spell = new WeakenSpell(m_Mobile); ++m_Combo; // Move to next spell } else if (m_Combo == 2) { if (!c.Poisoned) - spell = new PoisonSpell(m_Mobile, null); + spell = new PoisonSpell(m_Mobile); else if (IsNecromancer) - spell = new StrangleSpell(m_Mobile, null); + spell = new StrangleSpell(m_Mobile); ++m_Combo; // Move to next spell } @@ -554,9 +554,9 @@ namespace Server.Mobiles case 0: { if (c.Int < c.Dex) - spell = new FeeblemindSpell(m_Mobile, null); + spell = new FeeblemindSpell(m_Mobile); else - spell = new ClumsySpell(m_Mobile, null); + spell = new ClumsySpell(m_Mobile); ++m_Combo; // Move to next spell @@ -564,19 +564,19 @@ namespace Server.Mobiles } case 1: { - spell = new EnergyBoltSpell(m_Mobile, null); + spell = new EnergyBoltSpell(m_Mobile); m_Combo = -1; // Reset combo state break; } case 2: { - spell = new FlameStrikeSpell(m_Mobile, null); + spell = new FlameStrikeSpell(m_Mobile); m_Combo = -1; // Reset combo state break; } default: { - spell = new PainSpikeSpell(m_Mobile, null); + spell = new PainSpikeSpell(m_Mobile); m_Combo = -1; // Reset combo state break; } @@ -584,7 +584,7 @@ namespace Server.Mobiles } else if (m_Combo == 4 && spell == null) { - spell = new MindBlastSpell(m_Mobile, null); + spell = new MindBlastSpell(m_Mobile); m_Combo = -1; } @@ -607,7 +607,7 @@ namespace Server.Mobiles Mobile c = m_Mobile.Combatant; m_Mobile.Warmode = true; - if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || + if (c?.Deleted != false || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them @@ -710,7 +710,7 @@ namespace Server.Mobiles { m_Mobile.DebugSay("I am going to cure myself"); - spell = new CureSpell(m_Mobile, null); + spell = new CureSpell(m_Mobile); } else if (toDispel != null) // Something dispellable is attacking us { @@ -725,7 +725,7 @@ namespace Server.Mobiles else if (SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned ) // They have a heal spell out { - spell = new PoisonSpell(m_Mobile, null); + spell = new PoisonSpell(m_Mobile); } else { @@ -764,7 +764,7 @@ namespace Server.Mobiles public override bool DoActionGuard() { - if (m_LastTarget != null && m_LastTarget.Hidden) + if (m_LastTarget?.Hidden == true) { Map map = m_Mobile.Map; @@ -777,7 +777,7 @@ namespace Server.Mobiles m_Mobile.DebugSay("I am going to reveal my last target"); m_RevealTarget = new LandTarget(m_LastTargetLoc, map); - Spell spell = new RevealSpell(m_Mobile, null); + Spell spell = new RevealSpell(m_Mobile); if (spell.Cast()) m_LastTarget = null; // only do it once @@ -827,7 +827,7 @@ namespace Server.Mobiles m_Mobile.FocusMob = null; if (m_Mobile.Poisoned && Utility.Random(0, 5) == 0) - new CureSpell(m_Mobile, null).Cast(); + new CureSpell(m_Mobile).Cast(); } else { @@ -855,7 +855,7 @@ namespace Server.Mobiles Mobile comb = m_Mobile.Combatant; - if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && + if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, Core.ML ? 10 : 12) && CanDispel(comb)) { active = comb; @@ -917,7 +917,7 @@ namespace Server.Mobiles Mobile comb = m_Mobile.Combatant; - if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb)) + if (comb?.Deleted == false && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb)) { active = inactive = comb; actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb); @@ -960,11 +960,13 @@ namespace Server.Mobiles if (targ == null) return false; - bool isReveal = targ is RevealSpell.InternalTarget; - bool isDispel = targ is DispelSpell.InternalTarget; - bool isParalyze = targ is ParalyzeSpell.InternalTarget; - bool isTeleport = targ is TeleportSpell.InternalTarget; - bool isInvisible = targ is InvisibilitySpell.InternalTarget; + ISpellTarget spellTarg = targ as ISpellTarget; + + bool isReveal = spellTarg?.Spell is RevealSpell; + bool isDispel = spellTarg?.Spell is DispelSpell; + bool isParalyze = spellTarg?.Spell is ParalyzeSpell; + bool isTeleport = spellTarg?.Spell is TeleportSpell; + bool isInvisible = spellTarg?.Spell is InvisibilitySpell; bool teleportAway = false; Mobile toTarget; @@ -1100,4 +1102,4 @@ namespace Server.Mobiles return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/MeleeAI.cs b/Scripts/Mobiles/AI/MeleeAI.cs index ebf0b3f54..94c6b571e 100644 --- a/Scripts/Mobiles/AI/MeleeAI.cs +++ b/Scripts/Mobiles/AI/MeleeAI.cs @@ -35,7 +35,7 @@ namespace Server.Mobiles { Mobile combatant = m_Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map || !combatant.Alive || + if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map || !combatant.Alive || combatant.IsDeadBondedPet) { m_Mobile.DebugSay("My combatant is gone, so my guard is up"); @@ -174,4 +174,4 @@ namespace Server.Mobiles return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/PredatorAI.cs b/Scripts/Mobiles/AI/PredatorAI.cs index 6b382c623..8cf04c365 100644 --- a/Scripts/Mobiles/AI/PredatorAI.cs +++ b/Scripts/Mobiles/AI/PredatorAI.cs @@ -1,7 +1,7 @@ /* * PredatorAI, its an animal that can attack * Dont flee but dont attack if not hurt or attacked - * + * */ namespace Server.Mobiles @@ -36,7 +36,7 @@ namespace Server.Mobiles { Mobile combatant = m_Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map) + if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map) { m_Mobile.DebugSay("My combatant is gone, so my guard is up"); Action = ActionType.Wander; @@ -89,4 +89,4 @@ namespace Server.Mobiles return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/ThiefAI.cs b/Scripts/Mobiles/AI/ThiefAI.cs index e24ce828b..552ab0610 100644 --- a/Scripts/Mobiles/AI/ThiefAI.cs +++ b/Scripts/Mobiles/AI/ThiefAI.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles { Mobile combatant = m_Mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != m_Mobile.Map) + if (combatant?.Deleted != false || combatant.Map != m_Mobile.Map) { m_Mobile.DebugSay("My combatant is gone, so my guard is up"); @@ -50,24 +50,15 @@ namespace Server.Mobiles if (WalkMobileRange(combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight)) { m_Mobile.Direction = m_Mobile.GetDirectionTo(combatant); - if (m_toDisarm == null) - m_toDisarm = combatant.FindItemOnLayer(Layer.OneHanded); - if (m_toDisarm == null) - m_toDisarm = combatant.FindItemOnLayer(Layer.TwoHanded); - - if (m_toDisarm != null && m_toDisarm.IsChildOf(m_Mobile.Backpack)) - { - m_toDisarm = combatant.FindItemOnLayer(Layer.OneHanded); - if (m_toDisarm == null) - m_toDisarm = combatant.FindItemOnLayer(Layer.TwoHanded); - } + 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(new DisarmRequestEventArgs(m_Mobile)); - if (m_toDisarm != null && m_toDisarm.IsChildOf(combatant.Backpack) && + if (m_toDisarm?.IsChildOf(combatant.Backpack) == true && Core.TickCount - m_Mobile.NextSkillTime >= 0 && m_toDisarm.LootType != LootType.Blessed && m_toDisarm.LootType != LootType.Newbied) { @@ -126,31 +117,28 @@ namespace Server.Mobiles m_Mobile.DebugSay("I should be closer to {0}", combatant.Name); } - if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 && m_Mobile.CanFlee) + if (m_Mobile.Hits >= m_Mobile.HitsMax * 20 / 100 || !m_Mobile.CanFlee) + return true; + // We are low on health, should we flee? + + bool flee; + + if (m_Mobile.Hits < combatant.Hits) { - // We are low on health, should we flee? + // We are more hurt than them + int diff = combatant.Hits - m_Mobile.Hits; - bool flee = false; + flee = Utility.Random(0, 100) > 10 + diff; // (10 + diff)% chance to flee + } + else + { + flee = Utility.Random(0, 100) > 10; // 10% chance to flee + } - if (m_Mobile.Hits < combatant.Hits) - { - // We are more hurt than them - - int diff = combatant.Hits - m_Mobile.Hits; - - flee = Utility.Random(0, 100) > 10 + diff; // (10 + diff)% chance to flee - } - else - { - flee = Utility.Random(0, 100) > 10; // 10% chance to flee - } - - if (flee) - { - m_Mobile.DebugSay("I am going to flee from {0}", combatant.Name); - - Action = ActionType.Flee; - } + if (flee) + { + m_Mobile.DebugSay("I am going to flee from {0}", combatant.Name); + Action = ActionType.Flee; } return true; @@ -189,4 +177,4 @@ namespace Server.Mobiles return true; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/AI/VendorAI.cs b/Scripts/Mobiles/AI/VendorAI.cs index 7ad649015..5038711a2 100644 --- a/Scripts/Mobiles/AI/VendorAI.cs +++ b/Scripts/Mobiles/AI/VendorAI.cs @@ -60,7 +60,7 @@ namespace Server.Mobiles return true; } - if (customer == null || customer.Deleted || customer.Map != m_Mobile.Map) + if (customer?.Deleted != false || customer.Map != m_Mobile.Map) { m_Mobile.DebugSay("My customer have disapeared"); m_Mobile.FocusMob = null; @@ -147,4 +147,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/BaseMount.cs b/Scripts/Mobiles/Animals/Mounts/BaseMount.cs index d5deaa511..f307189a3 100644 --- a/Scripts/Mobiles/Animals/Mounts/BaseMount.cs +++ b/Scripts/Mobiles/Animals/Mounts/BaseMount.cs @@ -111,19 +111,16 @@ namespace Server.Mobiles if (m_Rider == null) return; - Mobile attacker = from; - if (attacker == null) - attacker = m_Rider.FindMostRecentDamager(true); + Mobile attacker = from ?? m_Rider.FindMostRecentDamager(true); - if (!(attacker == this || attacker == m_Rider || willKill || DateTime.UtcNow < NextMountAbility)) - if (DoMountAbility(amount, from)) + if (!(attacker == this || attacker == m_Rider || willKill || DateTime.UtcNow < NextMountAbility) + && DoMountAbility(amount, from)) NextMountAbility = DateTime.UtcNow + MountAbilityDelay; } public override bool OnBeforeDeath() { Rider = null; - return base.OnBeforeDeath(); } @@ -351,4 +348,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/Beetle.cs b/Scripts/Mobiles/Animals/Mounts/Beetle.cs index 9133993f3..c1313c59c 100644 --- a/Scripts/Mobiles/Animals/Mounts/Beetle.cs +++ b/Scripts/Mobiles/Animals/Mounts/Beetle.cs @@ -7,12 +7,8 @@ namespace Server.Mobiles public class Beetle : BaseMount { [Constructible] - public Beetle() : this("a giant beetle") - { - } - - [Constructible] - public Beetle(string name) : base(name, 0x317, 0x3EBC, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.25, 0.5) + public Beetle(string name = "a giant beetle") : + base(name, 0x317, 0x3EBC, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.25, 0.5) { SetStr(300); SetDex(100); @@ -172,4 +168,4 @@ namespace Server.Mobiles #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs b/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs index 49a44a60a..990dfc012 100644 --- a/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs +++ b/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class DesertOstard : BaseMount { [Constructible] - public DesertOstard() : this("a desert ostard") - { - } - - [Constructible] - public DesertOstard(string name) : base(name, 0xD2, 0x3EA3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public DesertOstard(string name = "a desert ostard") : + base(name, 0xD2, 0x3EA3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x270; @@ -62,4 +58,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/Ethereals.cs b/Scripts/Mobiles/Animals/Mounts/Ethereals.cs index 4c1e6edd4..b5bbed780 100644 --- a/Scripts/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Scripts/Mobiles/Animals/Mounts/Ethereals.cs @@ -143,7 +143,7 @@ namespace Server.Mobiles if (m_Rider != null) m_Rider.Followers -= FollowerSlots; - if (m_Rider != null && m_Rider.Followers < 0) + if (m_Rider?.Followers < 0) m_Rider.Followers = 0; } @@ -161,8 +161,9 @@ namespace Server.Mobiles return false; } - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null)) return false; - if (!BaseMount.CheckMountAllowed(from)) return false; + if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this) || !BaseMount.CheckMountAllowed(from)) + return false; + if (from.Mounted) { from.SendLocalizedMessage(1005583); // Please dismount first. @@ -187,9 +188,7 @@ namespace Server.Mobiles return false; } - if (!DesignContext.Check(from)) return false; - - return true; + return DesignContext.Check(from); } public override void OnDoubleClick(Mobile from) @@ -202,10 +201,7 @@ namespace Server.Mobiles { base.OnSingleClick(from); - if (m_IsDonationItem) - LabelTo(from, "Donation Ethereal"); - else - LabelTo(from, "Veteran Reward"); + LabelTo(from, m_IsDonationItem ? "Donation Ethereal" : "Veteran Reward"); } public override void Serialize(GenericWriter writer) @@ -840,4 +836,4 @@ namespace Server.Mobiles if (version <= 1 && Hue != 0) Hue = 0; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/FireSteed.cs b/Scripts/Mobiles/Animals/Mounts/FireSteed.cs index 707f5385e..d17df2a8a 100644 --- a/Scripts/Mobiles/Animals/Mounts/FireSteed.cs +++ b/Scripts/Mobiles/Animals/Mounts/FireSteed.cs @@ -6,12 +6,8 @@ namespace Server.Mobiles public class FireSteed : BaseMount { [Constructible] - public FireSteed() : this("a fire steed") - { - } - - [Constructible] - public FireSteed(string name) : base(name, 0xBE, 0x3E9E, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public FireSteed(string name = "a fire steed") : + base(name, 0xBE, 0x3E9E, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { BaseSoundID = 0xA8; @@ -85,4 +81,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs b/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs index af7b8da22..e11fd7573 100644 --- a/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs +++ b/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class ForestOstard : BaseMount { [Constructible] - public ForestOstard() : this("a forest ostard") - { - } - - [Constructible] - public ForestOstard(string name) : base(name, 0xDB, 0x3EA5, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public ForestOstard(string name = "a forest ostard") : + base(name, 0xDB, 0x3EA5, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { Hue = Utility.RandomSlimeHue() | 0x8000; @@ -63,4 +59,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs b/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs index feeab5f15..5333da29d 100644 --- a/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs +++ b/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class FrenziedOstard : BaseMount { [Constructible] - public FrenziedOstard() : this("a frenzied ostard") - { - } - - [Constructible] - public FrenziedOstard(string name) : base(name, 0xDA, 0x3EA4, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public FrenziedOstard(string name = "a frenzied ostard") : + base(name, 0xDA, 0x3EA4, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Hue = Race.Human.RandomHairHue() | 0x8000; @@ -66,4 +62,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/HellSteed.cs b/Scripts/Mobiles/Animals/Mounts/HellSteed.cs index 9a31ca23a..82793df98 100644 --- a/Scripts/Mobiles/Animals/Mounts/HellSteed.cs +++ b/Scripts/Mobiles/Animals/Mounts/HellSteed.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class HellSteed : BaseMount { [Constructible] - public HellSteed() : this("a hellsteed") - { - } - - [Constructible] - public HellSteed(string name) : base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public HellSteed(string name = "a hellsteed") : + base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { SetStats(this); } @@ -61,4 +57,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/Hiryu.cs b/Scripts/Mobiles/Animals/Mounts/Hiryu.cs index aef3335e4..00d484fb2 100644 --- a/Scripts/Mobiles/Animals/Mounts/Hiryu.cs +++ b/Scripts/Mobiles/Animals/Mounts/Hiryu.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Animals/Mounts/Horse.cs b/Scripts/Mobiles/Animals/Mounts/Horse.cs index e9c9644b0..f856d77cc 100644 --- a/Scripts/Mobiles/Animals/Mounts/Horse.cs +++ b/Scripts/Mobiles/Animals/Mounts/Horse.cs @@ -13,12 +13,8 @@ namespace Server.Mobiles }; [Constructible] - public Horse() : this("a horse") - { - } - - [Constructible] - public Horse(string name) : base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public Horse(string name = "a horse") : + base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { int random = Utility.Random(4); @@ -75,4 +71,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/Kirin.cs b/Scripts/Mobiles/Animals/Mounts/Kirin.cs index bf4736d8a..a1325f300 100644 --- a/Scripts/Mobiles/Animals/Mounts/Kirin.cs +++ b/Scripts/Mobiles/Animals/Mounts/Kirin.cs @@ -7,12 +7,8 @@ namespace Server.Mobiles public class Kirin : BaseMount { [Constructible] - public Kirin() : this("a ki-rin") - { - } - - [Constructible] - public Kirin(string name) : base(name, 132, 0x3EAD, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) + public Kirin(string name = "a ki-rin") : + base(name, 132, 0x3EAD, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3C5; @@ -129,4 +125,4 @@ namespace Server.Mobiles AI = AIType.AI_Mage; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs b/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs index fb8e36110..42d015590 100644 --- a/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs +++ b/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Animals/Mounts/Nightmare.cs b/Scripts/Mobiles/Animals/Mounts/Nightmare.cs index 2093d409d..0341a817f 100644 --- a/Scripts/Mobiles/Animals/Mounts/Nightmare.cs +++ b/Scripts/Mobiles/Animals/Mounts/Nightmare.cs @@ -5,12 +5,8 @@ namespace Server.Mobiles public class Nightmare : BaseMount { [Constructible] - public Nightmare() : this("a nightmare") - { - } - - [Constructible] - public Nightmare(string name) : base(name, 0x74, 0x3EA7, AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) + public Nightmare(string name = "a nightmare") : + base(name, 0x74, 0x3EA7, AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) { BaseSoundID = Core.AOS ? 0xA8 : 0x16A; @@ -120,4 +116,4 @@ namespace Server.Mobiles BaseSoundID = 0x16A; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs b/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs index 9b55f150b..31b86eb19 100644 --- a/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs +++ b/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class RidableLlama : BaseMount { [Constructible] - public RidableLlama() : this("a ridable llama") - { - } - - [Constructible] - public RidableLlama(string name) : base(name, 0xDC, 0x3EA6, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public RidableLlama(string name = "a ridable llama") : + base(name, 0xDC, 0x3EA6, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3F3; @@ -65,4 +61,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs b/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs index 6ee813222..7827fcfe4 100644 --- a/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs +++ b/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class Ridgeback : BaseMount { [Constructible] - public Ridgeback() : this("a ridgeback") - { - } - - [Constructible] - public Ridgeback(string name) : base(name, 187, 0x3EBA, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public Ridgeback(string name = "a ridgeback") : + base(name, 187, 0x3EBA, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3F3; @@ -76,4 +72,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs b/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs index b63763ce3..8f41123d2 100644 --- a/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs +++ b/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class SavageRidgeback : BaseMount { [Constructible] - public SavageRidgeback() : this("a savage ridgeback") - { - } - - [Constructible] - public SavageRidgeback(string name) : base(name, 188, 0x3EB8, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SavageRidgeback(string name = "a savage ridgeback") : + base(name, 188, 0x3EB8, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3F3; @@ -76,4 +72,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs b/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs index b92069e95..441eb60ea 100644 --- a/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs +++ b/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs @@ -3,13 +3,8 @@ namespace Server.Mobiles public class ScaledSwampDragon : BaseMount { [Constructible] - public ScaledSwampDragon() : this("a swamp dragon") - { - } - - [Constructible] - public ScaledSwampDragon(string name) : base(name, 0x31F, 0x3EBE, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, - 0.4) + public ScaledSwampDragon(string name = "a swamp dragon") : + base(name, 0x31F, 0x3EBE, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { SetStr(201, 300); SetDex(66, 85); @@ -74,4 +69,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs b/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs index cbc0d2809..9d01c3c7a 100644 --- a/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs +++ b/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class SeaHorse : BaseMount { [Constructible] - public SeaHorse() : this("a sea horse") - { - } - - [Constructible] - public SeaHorse(string name) : base(name, 0x90, 0x3EB3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SeaHorse(string name = "a sea horse") : + base(name, 0x90, 0x3EB3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { InitStats(Utility.Random(50, 30), Utility.Random(50, 30), 10); Skills.MagicResist.Base = 25.0 + Utility.RandomDouble() * 5.0; @@ -36,4 +32,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs b/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs index a4b536a8c..e2a4bc0ac 100644 --- a/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs +++ b/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class SilverSteed : BaseMount { [Constructible] - public SilverSteed() : this("a silver steed") - { - } - - [Constructible] - public SilverSteed(string name) : base(name, 0x75, 0x3EA8, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SilverSteed(string name = "a silver steed") : + base(name, 0x75, 0x3EA8, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { InitStats(Utility.Random(50, 30), Utility.Random(50, 30), 10); Skills.MagicResist.Base = 25.0 + Utility.RandomDouble() * 5.0; @@ -40,4 +36,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs b/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs index 156170c47..11837cf5f 100644 --- a/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs +++ b/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs @@ -3,12 +3,8 @@ namespace Server.Mobiles public class SkeletalMount : BaseMount { [Constructible] - public SkeletalMount() : this(null) - { - } - - [Constructible] - public SkeletalMount(string name) : base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SkeletalMount(string name = null) : + base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { SetStr(91, 100); SetDex(46, 55); @@ -69,4 +65,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs b/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs index 1ee7989c8..27968bc3d 100644 --- a/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs +++ b/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs @@ -11,12 +11,8 @@ namespace Server.Mobiles private bool m_HasBarding; [Constructible] - public SwampDragon() : this("a swamp dragon") - { - } - - [Constructible] - public SwampDragon(string name) : base(name, 0x31A, 0x3EBD, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SwampDragon(string name = "a swamp dragon") : + base(name, 0x31A, 0x3EBD, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x16A; @@ -220,4 +216,4 @@ namespace Server.Mobiles BaseSoundID = 0x16A; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Animals/Mounts/Unicorn.cs b/Scripts/Mobiles/Animals/Mounts/Unicorn.cs index b4ec80f75..8a223354e 100644 --- a/Scripts/Mobiles/Animals/Mounts/Unicorn.cs +++ b/Scripts/Mobiles/Animals/Mounts/Unicorn.cs @@ -7,12 +7,8 @@ namespace Server.Mobiles public class Unicorn : BaseMount { [Constructible] - public Unicorn() : this("a unicorn") - { - } - - [Constructible] - public Unicorn(string name) : base(name, 0x7A, 0x3EB4, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) + public Unicorn(string name = "a unicorn") : + base(name, 0x7A, 0x3EB4, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) { BaseSoundID = 0x4BC; @@ -134,4 +130,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/BaseCreature.cs b/Scripts/Mobiles/BaseCreature.cs index ef0f2394d..8fb55e7d9 100644 --- a/Scripts/Mobiles/BaseCreature.cs +++ b/Scripts/Mobiles/BaseCreature.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Server.ContextMenus; using Server.Engines.ConPVP; @@ -117,7 +118,7 @@ namespace Server.Mobiles #endregion - public class DamageStore : IComparable + public class DamageStore : IComparable { public int m_Damage; public bool m_HasRight; @@ -129,12 +130,9 @@ namespace Server.Mobiles m_Damage = damage; } - public int CompareTo(object obj) + public int CompareTo(DamageStore ds) { - if (!(obj is DamageStore ds)) - return -1; - - return ds.m_Damage - m_Damage; + return ds?.m_Damage ?? 0 - m_Damage; } } @@ -156,11 +154,7 @@ namespace Server.Mobiles object[] objs = t.GetCustomAttributes(typeof(FriendlyNameAttribute), false); if (objs.Length > 0) - { - FriendlyNameAttribute friendly = objs[0] as FriendlyNameAttribute; - - return friendly?.FriendlyName ?? ""; - } + return (objs[0] as FriendlyNameAttribute)?.FriendlyName ?? ""; } return t.Name; @@ -293,7 +287,7 @@ namespace Server.Mobiles return base.Name; } - set { base.Name = value == DefaultName ? null : value; } + set => base.Name = value == DefaultName ? null : value; } public virtual InhumanSpeech SpeechType => null; @@ -463,19 +457,17 @@ namespace Server.Mobiles { get { - if (HitsMaxSeed > 0) - { - int value = HitsMaxSeed + GetStatOffset(StatType.Str); + if (HitsMaxSeed <= 0) + return Str; - if (value < 1) - value = 1; - else if (value > 65000) - value = 65000; + int value = HitsMaxSeed + GetStatOffset(StatType.Str); - return value; - } + if (value < 1) + value = 1; + else if (value > 65000) + value = 65000; - return Str; + return value; } } @@ -487,19 +479,18 @@ namespace Server.Mobiles { get { - if (StamMaxSeed > 0) - { - int value = StamMaxSeed + GetStatOffset(StatType.Dex); + if (StamMaxSeed <= 0) + return Dex; - if (value < 1) - value = 1; - else if (value > 65000) - value = 65000; + int value = StamMaxSeed + GetStatOffset(StatType.Dex); - return value; - } + if (value < 1) + value = 1; + else if (value > 65000) + value = 65000; + + return value; - return Dex; } } @@ -511,19 +502,18 @@ namespace Server.Mobiles { get { - if (ManaMaxSeed > 0) - { - int value = ManaMaxSeed + GetStatOffset(StatType.Int); + if (ManaMaxSeed <= 0) + return Int; - if (value < 1) - value = 1; - else if (value > 65000) - value = 65000; + int value = ManaMaxSeed + GetStatOffset(StatType.Int); - return value; - } + if (value < 1) + value = 1; + else if (value > 65000) + value = 65000; + + return value; - return Int; } } @@ -537,7 +527,6 @@ namespace Server.Mobiles public virtual bool CanDestroyObstacles => false; /* - Seems this actually was removed on OSI somewhere between the original bug report and now. We will call it ML, until we can get better information. I suspect it was on the OSI TC when originally it taken out of RunUO, and not implemented on OSIs production shards until more @@ -580,7 +569,6 @@ namespace Server.Mobiles set { m_Team = value; - OnTeamChange(); } } @@ -609,19 +597,12 @@ namespace Server.Mobiles [CommandProperty(AccessLevel.GameMaster)] public double CurrentSpeed { - get - { - if (TargetLocation != null) - return 0.3; - - return m_CurrentSpeed; - } + get => TargetLocation != null ? 0.3 : m_CurrentSpeed; set { if (m_CurrentSpeed != value) { m_CurrentSpeed = value; - AIObject?.OnCurrentSpeedChanged(); } } @@ -840,7 +821,7 @@ namespace Server.Mobiles Ethic ourEthic = EthicAllegiance; Player pl = Ethics.Player.Find(m, true); - if (pl != null && pl.IsShielded && (ourEthic == null || ourEthic == pl.Ethic)) + if (pl?.IsShielded == true && (ourEthic == null || ourEthic == pl.Ethic)) return false; if (m is PlayerMobile mobile && mobile.HonorActive) @@ -906,7 +887,7 @@ namespace Server.Mobiles (int)((useBaseSkill ? m.Skills.AnimalTaming.Base : m.Skills.AnimalTaming.Value) * 10); int lore = (int)((useBaseSkill ? m.Skills.AnimalLore.Base : m.Skills.AnimalLore.Value) * 10); - int bonus = 0, chance = 700; + int bonus, chance = 700; if (Core.ML) { @@ -1008,15 +989,8 @@ namespace Server.Mobiles public override bool CheckPoisonImmunity(Mobile from, Poison poison) { - if (base.CheckPoisonImmunity(from, poison)) - return true; - - Poison p = PoisonImmune; - - if (m_Paragon) - p = PoisonImpl.IncreaseLevel(p); - - return p != null && p.Level >= poison.Level; + return base.CheckPoisonImmunity(from, poison) || + (m_Paragon ? PoisonImpl.IncreaseLevel(PoisonImmune) : PoisonImmune)?.Level >= poison.Level; } public void Unpacify() @@ -1045,7 +1019,7 @@ namespace Server.Mobiles //NPCs can use bandages too! if (!Core.AOS) disruptThreshold = 0; - else if (from != null && from.Player) + else if (from?.Player == true) disruptThreshold = 18; else disruptThreshold = 25; @@ -1353,9 +1327,9 @@ namespace Server.Mobiles writer.Write(m_Paragon); // Version 13 - writer.Write(Friends != null && Friends.Count > 0); + writer.Write(Friends?.Count > 0); - if (Friends != null && Friends.Count > 0) + if (Friends?.Count > 0) writer.Write(Friends, true); // Version 14 @@ -1735,13 +1709,13 @@ namespace Server.Mobiles else if (m_SummonMaster != null) { m_SummonMaster.Followers -= ControlSlots; - if (m_SummonMaster is PlayerMobile mobile) mobile.AllFollowers.Remove(this); + (m_SummonMaster as PlayerMobile)?.AllFollowers.Remove(this); } - if (m_ControlMaster != null && m_ControlMaster.Followers < 0) + if (m_ControlMaster?.Followers < 0) m_ControlMaster.Followers = 0; - if (m_SummonMaster != null && m_SummonMaster.Followers < 0) + if (m_SummonMaster?.Followers < 0) m_SummonMaster.Followers = 0; } @@ -1750,12 +1724,14 @@ namespace Server.Mobiles if (m_ControlMaster != null) { m_ControlMaster.Followers += ControlSlots; - if (m_ControlMaster is PlayerMobile mobile) mobile.AllFollowers.Add(this); + if (m_ControlMaster is PlayerMobile mobile) + mobile.AllFollowers.Add(this); } else if (m_SummonMaster != null) { m_SummonMaster.Followers += ControlSlots; - if (m_SummonMaster is PlayerMobile mobile) mobile.AllFollowers.Add(this); + if (m_SummonMaster is PlayerMobile mobile) + mobile.AllFollowers.Add(this); } } @@ -1797,7 +1773,6 @@ namespace Server.Mobiles if (AIObject != null) { AIObject.m_Timer?.Stop(); - AIObject = null; } @@ -1839,20 +1814,20 @@ namespace Server.Mobiles public virtual double GetFightModeRanking(Mobile m, FightMode acqType, bool bPlayerOnly) { - if (bPlayerOnly && m.Player || !bPlayerOnly) - switch (acqType) - { - case FightMode.Strongest: - return m.Skills.Tactics.Value + m.Str; //returns strongest mobile + if (bPlayerOnly && !m.Player) + return double.MinValue; - case FightMode.Weakest: - return -m.Hits; // returns weakest mobile + switch (acqType) + { + case FightMode.Strongest: + return m.Skills.Tactics.Value + m.Str; //returns strongest mobile - default: - return -GetDistanceToSqrt(m); // returns closest mobile - } + case FightMode.Weakest: + return -m.Hits; // returns weakest mobile - return double.MinValue; + default: + return -GetDistanceToSqrt(m); // returns closest mobile + } } // Turn, - for left, + for right @@ -1897,9 +1872,8 @@ namespace Server.Mobiles { base.AggressiveAction(aggressor, criminal); - if (ControlMaster != null) - if (NotorietyHandlers.CheckAggressor(ControlMaster.Aggressors, aggressor)) - aggressor.Aggressors.Add(AggressorInfo.Create(this, aggressor, true)); + if (ControlMaster != null && NotorietyHandlers.CheckAggressor(ControlMaster.Aggressors, aggressor)) + aggressor.Aggressors.Add(AggressorInfo.Create(this, aggressor, true)); OrderType ct = m_ControlOrder; @@ -1925,7 +1899,7 @@ namespace Server.Mobiles { Player pl = Ethics.Player.Find(aggressor, true); - if (pl != null && pl.IsShielded) + if (pl?.IsShielded == true) pl.FinishShield(); } @@ -1952,8 +1926,8 @@ namespace Server.Mobiles #region Dueling if (Region.IsPartOf() && m is PlayerMobile pm && - (pm.DuelContext == null || pm.DuelPlayer == null || !pm.DuelContext.Started || pm.DuelContext.Finished || - pm.DuelPlayer.Eliminated)) + (pm.DuelContext?.Started != true || pm.DuelContext.Finished || + pm.DuelPlayer?.Eliminated != false)) return true; #endregion @@ -1987,7 +1961,7 @@ namespace Server.Mobiles Skill skill = ourSkills[i]; Skill theirSkill = theirSkills[i]; - if (skill != null && theirSkill != null && skill.Base >= 60.0 && CheckTeach(skill.SkillName, from)) + if (skill?.Base >= 60.0 && CheckTeach(skill.SkillName, from)) { int toTeach = skill.BaseFixedPoint / 3; @@ -2002,19 +1976,15 @@ namespace Server.Mobiles public override bool HandlesOnSpeech(Mobile from) { - InhumanSpeech speechType = SpeechType; - - if (speechType != null && (speechType.Flags & IHSFlags.OnSpeech) != 0 && from.InRange(this, 3)) - return true; - - return AIObject != null && AIObject.HandlesOnSpeech(from) && from.InRange(this, RangePerception); + return (SpeechType?.Flags & IHSFlags.OnSpeech) != 0 && from.InRange(this, 3) || + AIObject?.HandlesOnSpeech(from) == true && from.InRange(this, RangePerception); } public override void OnSpeech(SpeechEventArgs e) { InhumanSpeech speechType = SpeechType; - if (speechType != null && speechType.OnSpeech(this, e.Mobile, e.Speech)) + if (speechType?.OnSpeech(this, e.Mobile, e.Speech) == true) e.Handled = true; else if (!e.Handled && AIObject != null && e.Mobile.InRange(this, RangePerception)) AIObject.OnSpeech(e); @@ -2022,16 +1992,9 @@ namespace Server.Mobiles public override bool IsHarmfulCriminal(Mobile target) { - if (Controlled && target == m_ControlMaster || Summoned && target == m_SummonMaster) - return false; - - if (target is BaseCreature creature && creature.InitialInnocent && !creature.Controlled) - return false; - - if (target is PlayerMobile mobile && mobile.PermaFlags.Count > 0) - return false; - - return base.IsHarmfulCriminal(target); + return (!Controlled || target != m_ControlMaster) && (!Summoned || target != m_SummonMaster) && + (!(target is BaseCreature creature) || !creature.InitialInnocent || creature.Controlled) && + (!(target is PlayerMobile mobile) || mobile.PermaFlags.Count <= 0) && base.IsHarmfulCriminal(target); } public override void CriminalAction(bool message) @@ -2161,14 +2124,15 @@ namespace Server.Mobiles public virtual void CheckedAnimate(int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay) { - if (!Mounted) base.Animate(action, frameCount, repeatCount, forward, repeat, delay); + if (!Mounted) + base.Animate(action, frameCount, repeatCount, forward, repeat, delay); } private void CheckAIActive() { Map map = Map; - if (PlayerRangeSensitive && AIObject != null && map != null && map.GetSector(Location).Active) + if (PlayerRangeSensitive && AIObject != null && map?.GetSector(Location).Active == true) AIObject.Activate(); } @@ -2176,9 +2140,10 @@ namespace Server.Mobiles { base.OnCombatantChange(); - Warmode = Combatant != null && !Combatant.Deleted && Combatant.Alive; + Warmode = Combatant?.Deleted == false && Combatant.Alive; - if (CanFly && Warmode) Flying = false; + if (CanFly && Warmode) + Flying = false; } protected override void OnMapChange(Map oldMap) @@ -2204,15 +2169,13 @@ namespace Server.Mobiles { if (AcquireOnApproach && !Controlled && !Summoned && FightMode != FightMode.Aggressor) { - if (InRange(m.Location, AcquireOnApproachRange) && !InRange(oldLocation, AcquireOnApproachRange)) - if (CanBeHarmful(m) && IsEnemy(m)) - { - Combatant = FocusMob = m; - - AIObject?.MoveTo(m, true, 1); - - DoHarmful(m); - } + if (InRange(m.Location, AcquireOnApproachRange) && !InRange(oldLocation, AcquireOnApproachRange) && + CanBeHarmful(m) && IsEnemy(m)) + { + Combatant = FocusMob = m; + AIObject?.MoveTo(m, true, 1); + DoHarmful(m); + } } else if (ReacquireOnMovement) { @@ -2225,14 +2188,14 @@ namespace Server.Mobiles /* Begin notice sound */ if ((!m.Hidden || m.AccessLevel == AccessLevel.Player) && m.Player && FightMode != FightMode.Aggressor && - FightMode != FightMode.None && Combatant == null && !Controlled && !Summoned) - if (InRange(m.Location, 18) && !InRange(oldLocation, 18)) - { - if (Body.IsMonster) - Animate(11, 5, 1, true, false, 1); + FightMode != FightMode.None && Combatant == null && !Controlled && !Summoned && + InRange(m.Location, 18) && !InRange(oldLocation, 18)) + { + if (Body.IsMonster) + Animate(11, 5, 1, true, false, 1); - PlaySound(GetAngerSound()); - } + PlaySound(GetAngerSound()); + } /* End notice sound */ if (MLQuestSystem.Enabled && CanShout && m is PlayerMobile mobile) @@ -2441,9 +2404,7 @@ namespace Server.Mobiles Effects.SendLocationEffect(Location, Map, 0x3728, 13, 1, 0x461, 4); InhumanSpeech speechType = SpeechType; - speechType?.OnDeath(this); - ReceivedHonorContext?.OnTargetKilled(); return base.OnBeforeDeath(); @@ -2498,37 +2459,36 @@ namespace Server.Mobiles List respList = de.Responsible; - if (respList != null) - for (int j = 0; j < respList.Count; ++j) + for (int j = 0; j < respList?.Count; ++j) + { + DamageEntry subEntry = respList[j]; + Mobile master = subEntry.Damager; + + if (master?.Deleted != false || !master.Player) + continue; + + bool needNewSubEntry = true; + + for (int k = 0; needNewSubEntry && k < rights.Count; ++k) { - DamageEntry subEntry = respList[j]; - Mobile master = subEntry.Damager; + DamageStore ds = rights[k]; - if (master == null || master.Deleted || !master.Player) - continue; - - bool needNewSubEntry = true; - - for (int k = 0; needNewSubEntry && k < rights.Count; ++k) + if (ds.m_Mobile == master) { - DamageStore ds = rights[k]; - - if (ds.m_Mobile == master) - { - ds.m_Damage += subEntry.DamageGiven; - needNewSubEntry = false; - } + ds.m_Damage += subEntry.DamageGiven; + needNewSubEntry = false; } - - if (needNewSubEntry) - rights.Add(new DamageStore(master, subEntry.DamageGiven)); - - damage -= subEntry.DamageGiven; } + if (needNewSubEntry) + rights.Add(new DamageStore(master, subEntry.DamageGiven)); + + damage -= subEntry.DamageGiven; + } + Mobile m = de.Damager; - if (m == null || m.Deleted || !m.Player) + if (m?.Deleted != false || !m.Player) continue; if (damage <= 0) @@ -2654,7 +2614,7 @@ namespace Server.Mobiles Mobile owner = ControlMaster; - if (owner == null || owner.Deleted || owner.Map != Map || !owner.InRange(this, 12) || !CanSee(owner) || + if (owner?.Deleted != false || owner.Map != Map || !owner.InRange(this, 12) || !CanSee(owner) || !InLOS(owner)) { if (OwnerAbandonTime == DateTime.MinValue) @@ -2785,14 +2745,11 @@ namespace Server.Mobiles public override void OnDelete() { Mobile m = m_ControlMaster; - SetControlMaster(null); + SummonMaster = null; - ReceivedHonorContext?.Cancel(); - base.OnDelete(); - m?.InvalidateProperties(); } @@ -2961,15 +2918,12 @@ namespace Server.Mobiles { Mobile target = Combatant; - if (target != null && target.Alive && !target.IsDeadBondedPet && CanBeHarmful(target) && target.Map == Map && + if (target?.Alive == true && !target.IsDeadBondedPet && CanBeHarmful(target) && target.Map == Map && !IsDeadBondedPet && target.InRange(this, BreathRange) && InLOS(target) && !BardPacified) { if (Core.TickCount - m_NextBreathTime < 30000 && Utility.RandomBool()) BreathStart(target); - m_NextBreathTime = tc + (int)TimeSpan - .FromSeconds(BreathMinDelay + - Utility.RandomDouble() * (BreathMaxDelay - BreathMinDelay)) - .TotalMilliseconds; + m_NextBreathTime = tc + (int)TimeSpan.FromSeconds(BreathMinDelay + Utility.RandomDouble() * (BreathMaxDelay - BreathMinDelay)).TotalMilliseconds; } } @@ -3022,24 +2976,15 @@ namespace Server.Mobiles public virtual bool Rummage() { - Corpse toRummage = null; - IPooledEnumerable eable = GetItemsInRange(2); - foreach (Corpse item in eable) - if (item.Items.Count > 0) - { - toRummage = item; - break; - } + Corpse toRummage = eable.FirstOrDefault(item => item.Items.Count > 0); eable.Free(); if (toRummage == null) return false; - Container pack = Backpack; - - if (pack == null) + if (Backpack == null) return false; List items = toRummage.Items; @@ -3048,7 +2993,7 @@ namespace Server.Mobiles { Item item = items[Utility.Random(items.Count)]; - Lift(item, item.Amount, out bool rejected, out LRReason reason); + Lift(item, item.Amount, out bool rejected, out LRReason _); if (!rejected && Drop(this, new Point3D(-1, -1, 0))) { @@ -3193,7 +3138,7 @@ namespace Server.Mobiles Mobile owner = ControlMaster; - if (owner == null || owner.Deleted || owner.Map != Map || !owner.InRange(this, 12) || !CanSee(owner) || + if (owner?.Deleted != false || owner.Map != Map || !owner.InRange(this, 12) || !CanSee(owner) || !InLOS(owner)) { if (OwnerAbandonTime == DateTime.MinValue) @@ -3412,12 +3357,12 @@ namespace Server.Mobiles MLQuestContext context = MLQuestSystem.GetContext(pm); - if (context != null && context.IsFull) + if (context?.IsFull == true) return; MLQuest quest = MLQuestSystem.RandomStarterQuest(this, pm, context); - if (quest == null || !quest.Activated || context != null && context.IsDoingQuest(quest)) + if (quest?.Activated != true || context?.IsDoingQuest(quest) == true) return; Shout(pm); @@ -3869,7 +3814,7 @@ namespace Server.Mobiles public virtual bool IsPetFriend(Mobile m) { - return Friends != null && Friends.Contains(m); + return Friends.Contains(m); } public virtual void AddPetFriend(Mobile m) @@ -3887,15 +3832,8 @@ namespace Server.Mobiles public virtual bool IsFriend(Mobile m) { - OppositionGroup g = OppositionGroup; - - if (g != null && g.IsEnemy(this, m)) - return false; - - if (!(m is BaseCreature c)) - return false; - - return m_Team == c.m_Team && (m_bSummoned || m_Controlled) == (c.m_bSummoned || c.m_Controlled); + return OppositionGroup?.IsEnemy(this, m) != true && m is BaseCreature c && m_Team == c.m_Team + && (m_bSummoned || m_Controlled) == (c.m_bSummoned || c.m_Controlled); } #endregion @@ -4666,12 +4604,7 @@ namespace Server.Mobiles PackItem(Loot.RandomScroll(min, min + 7, SpellbookType.Regular)); } - public void PackMagicItems(int minLevel, int maxLevel) - { - PackMagicItems(minLevel, maxLevel, 0.30, 0.15); - } - - public void PackMagicItems(int minLevel, int maxLevel, double armorChance, double weaponChance) + public void PackMagicItems(int minLevel, int maxLevel, double armorChance = 0.30, double weaponChance = 0.15) { if (!PackArmor(minLevel, maxLevel, armorChance)) PackWeapon(minLevel, maxLevel, weaponChance); @@ -4874,12 +4807,7 @@ namespace Server.Mobiles return val; } - public bool PackSlayer() - { - return PackSlayer(0.05); - } - - public bool PackSlayer(double chance) + public bool PackSlayer(double chance = 0.05) { if (chance <= Utility.RandomDouble()) return false; @@ -4908,12 +4836,7 @@ namespace Server.Mobiles return true; } - public bool PackWeapon(int minLevel, int maxLevel) - { - return PackWeapon(minLevel, maxLevel, 1.0); - } - - public bool PackWeapon(int minLevel, int maxLevel, double chance) + public bool PackWeapon(int minLevel, int maxLevel, double chance = 1.0) { if (chance <= Utility.RandomDouble()) return false; @@ -4984,17 +4907,12 @@ namespace Server.Mobiles PackItem(Loot.RandomStatue()); } - public void PackGem() - { - PackGem(1); - } - public void PackGem(int min, int max) { PackGem(Utility.RandomMinMax(min, max)); } - public void PackGem(int amount) + public void PackGem(int amount = 1) { if (amount <= 0) return; @@ -5207,23 +5125,11 @@ namespace Server.Mobiles if (!Alive || IsDeadBondedPet) return; - List list = new List(); + IPooledEnumerable eable = GetMobilesInRange(AuraRange); - foreach (Mobile m in GetMobilesInRange(AuraRange)) - { - 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) - { - list.Add(m); - } - } + IEnumerable list = eable.Where(m => + m != this && CanBeHarmful(m, false) && (Core.AOS || InLOS(m)) && + (m is BaseCreature bc && (bc.Controlled || bc.Summoned || bc.Team != Team) || m.Player)); foreach (Mobile m in list) { @@ -5231,6 +5137,8 @@ namespace Server.Mobiles AuraEnergyDamage, AuraChaosDamage); AuraEffect(m); } + + eable.Free(); } public virtual void AuraEffect(Mobile m) @@ -5284,7 +5192,7 @@ namespace Server.Mobiles { Mobile owner = c.ControlMaster; - if (!c.IsStabled && (owner == null || owner.Deleted || owner.Map != c.Map || + if (!c.IsStabled && (owner?.Deleted != false || owner.Map != c.Map || !owner.InRange(c, 12) || !c.CanSee(owner) || !c.InLOS(owner))) { if (c.OwnerAbandonTime == DateTime.MinValue) diff --git a/Scripts/Mobiles/Familiars/BaseFamiliar.cs b/Scripts/Mobiles/Familiars/BaseFamiliar.cs index 2adf698e7..3157f0ddb 100644 --- a/Scripts/Mobiles/Familiars/BaseFamiliar.cs +++ b/Scripts/Mobiles/Familiars/BaseFamiliar.cs @@ -25,37 +25,38 @@ namespace Server.Mobiles public virtual void RangeCheck() { - if (!Deleted && ControlMaster != null && !ControlMaster.Deleted) + if (Deleted || ControlMaster?.Deleted != false) + return; + + int range = RangeHome - 2; + + if (InRange(ControlMaster.Location, RangeHome)) + return; + + Mobile master = ControlMaster; + + Point3D m_Loc = Point3D.Zero; + + if (Map != master.Map) + return; + + int x = X > master.X ? master.X + range : master.X - range; + int y = Y > master.Y ? master.Y + range : master.Y - range; + + for (int i = 0; i < 10; i++) { - int range = RangeHome - 2; + m_Loc.X = x + Utility.RandomMinMax(-1, 1); + m_Loc.Y = y + Utility.RandomMinMax(-1, 1); - if (!InRange(ControlMaster.Location, RangeHome)) - { - Mobile master = ControlMaster; + m_Loc.Z = Map.GetAverageZ(m_Loc.X, m_Loc.Y); - Point3D m_Loc = Point3D.Zero; + if (Map.CanSpawnMobile(m_Loc)) break; - if (Map == master.Map) - { - int x = X > master.X ? master.X + range : master.X - range; - int y = Y > master.Y ? master.Y + range : master.Y - range; - - for (int i = 0; i < 10; i++) - { - m_Loc.X = x + Utility.RandomMinMax(-1, 1); - m_Loc.Y = y + Utility.RandomMinMax(-1, 1); - - m_Loc.Z = Map.GetAverageZ(m_Loc.X, m_Loc.Y); - - if (Map.CanSpawnMobile(m_Loc)) break; - - m_Loc = master.Location; - } - - if (!Deleted) SetLocation(m_Loc, true); - } - } + m_Loc = master.Location; } + + if (!Deleted) + SetLocation(m_Loc, true); } public override void OnThink() @@ -63,7 +64,7 @@ namespace Server.Mobiles Mobile master = ControlMaster; if (Deleted) return; - if (master == null || master.Deleted) + if (master?.Deleted != false) { DropPackContents(); EndRelease(null); @@ -75,7 +76,7 @@ namespace Server.Mobiles if (m_LastHidden != master.Hidden) Hidden = m_LastHidden = master.Hidden; - if (AIObject != null && AIObject.WalkMobileRange(master, 5, true, 1, 1)) + if (AIObject?.WalkMobileRange(master, 5, true, 1, 1) == true) { Warmode = master.Warmode; Combatant = master.Combatant; @@ -107,7 +108,7 @@ namespace Server.Mobiles public virtual void EndRelease(Mobile from) { - if (from == null || !Deleted && Controlled && from == ControlMaster && from.CheckAlive()) + if (from?.CheckAlive() != false && !Deleted && Controlled && from == ControlMaster) { Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3728, 1, 13, 2100, 3, 5042, 0); @@ -171,4 +172,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Familiars/DarkWolf.cs b/Scripts/Mobiles/Familiars/DarkWolf.cs index 4a88e5faf..ddec625ea 100644 --- a/Scripts/Mobiles/Familiars/DarkWolf.cs +++ b/Scripts/Mobiles/Familiars/DarkWolf.cs @@ -52,10 +52,7 @@ namespace Server.Mobiles m_NextRestore = DateTime.UtcNow + TimeSpan.FromSeconds(2.0); - Mobile caster = ControlMaster; - - if (caster == null) - caster = SummonMaster; + Mobile caster = ControlMaster ?? SummonMaster; if (caster != null) ++caster.Stam; diff --git a/Scripts/Mobiles/Familiars/HordeMinion.cs b/Scripts/Mobiles/Familiars/HordeMinion.cs index a1d05a894..77c44bf05 100644 --- a/Scripts/Mobiles/Familiars/HordeMinion.cs +++ b/Scripts/Mobiles/Familiars/HordeMinion.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using Server.ContextMenus; using Server.Gumps; using Server.Items; @@ -73,18 +73,12 @@ namespace Server.Mobiles if (pack == null) return; - List list = new List(); - - foreach (Item item in GetItemsInRange(2)) - if (item.Movable && item.Stackable) - list.Add(item); + IEnumerable eable = GetItemsInRange(2).Where(item => item.Movable && item.Stackable); int pickedUp = 0; - for (int i = 0; i < list.Count; ++i) + foreach (Item item in eable) { - Item item = list[i]; - if (!pack.CheckHold(this, item, false, true)) return; @@ -193,4 +187,4 @@ namespace Server.Mobiles #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Familiars/ShadowWisp.cs b/Scripts/Mobiles/Familiars/ShadowWisp.cs index b24973421..48c5d706a 100644 --- a/Scripts/Mobiles/Familiars/ShadowWisp.cs +++ b/Scripts/Mobiles/Familiars/ShadowWisp.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; namespace Server.Mobiles { @@ -62,19 +62,13 @@ namespace Server.Mobiles private void Flare() { - Mobile caster = ControlMaster; - - if (caster == null) - caster = SummonMaster; + Mobile caster = ControlMaster ?? SummonMaster; if (caster == null) return; - List list = new List(); - - foreach (Mobile m in GetMobilesInRange(5)) - if (m.Player && m.Alive && !m.IsDeadBondedPet && m.Karma <= 0 && m.AccessLevel < AccessLevel.Counselor) - list.Add(m); + List list = GetMobilesInRange(5).Where(m => + m.Player && m.Alive && !m.IsDeadBondedPet && m.Karma <= 0 && m.AccessLevel < AccessLevel.Counselor).ToList(); for (int i = 0; i < list.Count; ++i) { @@ -109,4 +103,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Guards/ArcherGuard.cs b/Scripts/Mobiles/Guards/ArcherGuard.cs index 7347a9585..d618ce25b 100644 --- a/Scripts/Mobiles/Guards/ArcherGuard.cs +++ b/Scripts/Mobiles/Guards/ArcherGuard.cs @@ -9,12 +9,7 @@ namespace Server.Mobiles private Mobile m_Focus; - [Constructible] - public ArcherGuard() : this(null) - { - } - - public ArcherGuard(Mobile target) : base(target) + public ArcherGuard(Mobile target = null) : base(target) { InitStats(100, 125, 25); Title = "the guard"; @@ -99,7 +94,7 @@ namespace Server.Mobiles Combatant = value; - if (oldFocus != null && !oldFocus.Alive) + if (oldFocus?.Alive == false) Say("Thou hast suffered thy punishment, scoundrel."); if (value != null) @@ -139,7 +134,7 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { - if (m_Focus != null && m_Focus.Alive) + if (m_Focus?.Alive == true) new AvengeTimer(m_Focus).Start(); // If a guard dies, three more guards will spawn return base.OnBeforeDeath(); @@ -396,4 +391,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Guards/BaseGuard.cs b/Scripts/Mobiles/Guards/BaseGuard.cs index c77ebf422..187318cd8 100644 --- a/Scripts/Mobiles/Guards/BaseGuard.cs +++ b/Scripts/Mobiles/Guards/BaseGuard.cs @@ -22,14 +22,9 @@ namespace Server.Mobiles public abstract Mobile Focus{ get; set; } - public static void Spawn(Mobile caller, Mobile target) + public static void Spawn(Mobile caller, Mobile target, int amount = 1, bool onlyAdditional = false) { - Spawn(caller, target, 1, false); - } - - public static void Spawn(Mobile caller, Mobile target, int amount, bool onlyAdditional) - { - if (target == null || target.Deleted) + if (target?.Deleted != false) return; foreach (Mobile m in target.GetMobilesInRange(15)) diff --git a/Scripts/Mobiles/Guards/WarriorGuard.cs b/Scripts/Mobiles/Guards/WarriorGuard.cs index 75cefad0d..ce759f260 100644 --- a/Scripts/Mobiles/Guards/WarriorGuard.cs +++ b/Scripts/Mobiles/Guards/WarriorGuard.cs @@ -9,12 +9,7 @@ namespace Server.Mobiles private Mobile m_Focus; - [Constructible] - public WarriorGuard() : this(null) - { - } - - public WarriorGuard(Mobile target) : base(target) + public WarriorGuard(Mobile target = null) : base(target) { InitStats(1000, 1000, 1000); Title = "the guard"; @@ -135,7 +130,7 @@ namespace Server.Mobiles Combatant = value; - if (oldFocus != null && !oldFocus.Alive) + if (oldFocus?.Alive == false) Say("Thou hast suffered thy punishment, scoundrel."); if (value != null) @@ -175,7 +170,7 @@ namespace Server.Mobiles public override bool OnBeforeDeath() { - if (m_Focus != null && m_Focus.Alive) + if (m_Focus?.Alive == true) new AvengeTimer(m_Focus).Start(); // If a guard dies, three more guards will spawn return base.OnBeforeDeath(); @@ -386,4 +381,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Healers/BaseHealer.cs b/Scripts/Mobiles/Healers/BaseHealer.cs index af49235cf..23144ecd8 100644 --- a/Scripts/Mobiles/Healers/BaseHealer.cs +++ b/Scripts/Mobiles/Healers/BaseHealer.cs @@ -11,7 +11,7 @@ namespace Server.Mobiles private DateTime m_NextResurrect; - public BaseHealer() : base(null) + public BaseHealer() { if (!IsInvulnerable) { @@ -155,4 +155,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Healers/PricedHealer.cs b/Scripts/Mobiles/Healers/PricedHealer.cs index 1669827a7..b28d4066e 100644 --- a/Scripts/Mobiles/Healers/PricedHealer.cs +++ b/Scripts/Mobiles/Healers/PricedHealer.cs @@ -5,12 +5,7 @@ namespace Server.Mobiles public class PricedHealer : BaseHealer { [Constructible] - public PricedHealer() : this(5000) - { - } - - [Constructible] - public PricedHealer(int price) + public PricedHealer(int price = 5000) { Price = price; @@ -74,4 +69,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs b/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs index 1e9c1c916..65ef359f2 100644 --- a/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs +++ b/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs @@ -171,7 +171,7 @@ namespace Server.Mobiles Container pack = to.Backpack; - if (pack == null || !pack.TryDropItem(to, artifact, false)) + if (pack?.TryDropItem(to, artifact, false) != true) to.BankBox.DropItem(artifact); to.SendLocalizedMessage( @@ -287,4 +287,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/AOS/Revenant.cs b/Scripts/Mobiles/Monsters/AOS/Revenant.cs index e748ac6d0..d30a3087f 100644 --- a/Scripts/Mobiles/Monsters/AOS/Revenant.cs +++ b/Scripts/Mobiles/Monsters/AOS/Revenant.cs @@ -51,20 +51,8 @@ namespace Server.Mobiles VirtualArmor = 32; - Item shroud = new DeathShroud(); - - shroud.Hue = 0x455; - - shroud.Movable = false; - - AddItem(shroud); - - Halberd weapon = new Halberd(); - - weapon.Hue = 1; - weapon.Movable = false; - - AddItem(weapon); + AddItem(new DeathShroud { Hue = 0x455, Movable = false }); + AddItem(new Halberd { Hue = 1, Movable = false }); } public Revenant(Serial serial) : base(serial) @@ -181,4 +169,4 @@ namespace Server.Mobiles Delete(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs b/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs index 5433f261d..bdfd7c0b4 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs @@ -145,7 +145,7 @@ namespace Server.Mobiles { Mobile combatant = Combatant; - if (DateTime.UtcNow < m_NextAbilityTime || combatant == null || combatant.Deleted || combatant.Map != Map || + if (DateTime.UtcNow < m_NextAbilityTime || combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 3) || !CanBeHarmful(combatant) || !InLOS(combatant)) return; @@ -176,4 +176,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs b/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs index 8684ed760..e5226954b 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs @@ -65,14 +65,15 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { - if (from != null && from.Alive && 0.4 > Utility.RandomDouble()) ThrowHatchet(from); + if (from?.Alive == true && 0.4 > Utility.RandomDouble()) + ThrowHatchet(from); } public override void OnGotMeleeAttack(Mobile attacker) { base.OnGotMeleeAttack(attacker); - if (attacker != null && attacker.Alive && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) + if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) ThrowHatchet(attacker); } @@ -96,4 +97,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs b/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs index 26a2b71b3..63bf68194 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs @@ -1,7 +1,5 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Linq; using Server.Items; using Server.Spells; diff --git a/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs b/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs index 4ae0bc2ba..30b10fc1f 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs @@ -1,5 +1,3 @@ -using System.Collections; - namespace Server.Mobiles { public class Succubus : BaseCreature diff --git a/Scripts/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs b/Scripts/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs index fec566b1a..a3de4e72f 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Melee/ElfBrigand.cs @@ -94,7 +94,7 @@ namespace Server.Mobiles break; } - Utility.AssignRandomHair(this, true); + Utility.AssignRandomHair(this); } public ElfBrigand(Serial serial) : base(serial) @@ -132,4 +132,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs b/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs index 4f0e0c02d..1db807d48 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; @@ -77,8 +76,8 @@ namespace Server.Mobiles Mobile m = e.Mobile; Mobile lastKiller = m.LastKiller; - if (lastKiller is BaseCreature) - lastKiller = ((BaseCreature)lastKiller).GetMaster(); + if (lastKiller is BaseCreature creature) + lastKiller = creature.GetMaster(); if (IsInsideKhaldun(m) && IsInsideKhaldun(lastKiller) && lastKiller.Player && !m_Set.Contains(lastKiller)) foreach (AggressorInfo ai in m.Aggressors) diff --git a/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs b/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs index b769d8c30..290c45c8c 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs @@ -98,7 +98,7 @@ namespace Server.Mobiles { Mobile combatant = Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != Map || !InRange(combatant, 12) || + if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) || !CanBeHarmful(combatant) || !InLOS(combatant)) return; @@ -154,4 +154,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs b/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs index 9f48955c0..64fa198cf 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs @@ -110,16 +110,16 @@ namespace Server.Mobiles return; IPooledEnumerable eable = GetMobilesInRange(10); - int orcs = eable.Count(); - eable.Free(); - if (orcs < 10) + if (eable.Count() < 10) { BaseCreature orc = new SpawnedOrcishLord{ Team = Team }; orc.MoveToWorld(map.GetRandomNearbyLocation(target.Location), map); orc.Combatant = target; } + + eable.Free(); } public override void Serialize(GenericWriter writer) diff --git a/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs b/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs index 25f412e5c..17d4eb230 100644 --- a/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs +++ b/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs @@ -115,7 +115,7 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { - if (from != null && from.Alive && 0.4 > Utility.RandomDouble()) SendEBolt(from); + if (from?.Alive == true && 0.4 > Utility.RandomDouble()) SendEBolt(from); if (!FieldActive) { @@ -144,7 +144,7 @@ namespace Server.Mobiles attacker.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier"); } - if (attacker != null && attacker.Alive && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) + if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) SendEBolt(attacker); } @@ -192,4 +192,4 @@ namespace Server.Mobiles Name = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs b/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs index 096ac5e8f..b15f26207 100644 --- a/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs +++ b/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs @@ -105,7 +105,7 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { - if (from != null && from.Alive && 0.4 > Utility.RandomDouble()) SendEBolt(from); + if (from?.Alive == true && 0.4 > Utility.RandomDouble()) SendEBolt(from); if (!FieldActive) { @@ -134,7 +134,7 @@ namespace Server.Mobiles attacker.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier"); } - if (attacker != null && attacker.Alive && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) + if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) SendEBolt(attacker); } @@ -182,4 +182,4 @@ namespace Server.Mobiles Name = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs b/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs index 727412237..04c21ea30 100644 --- a/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs +++ b/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs @@ -74,7 +74,7 @@ namespace Server.Mobiles public override void OnDamage(int amount, Mobile from, bool willKill) { - if (from != null && !willKill && amount > 5 && from.Player && 5 > Utility.Random(100)) + if (!willKill && amount > 5 && from?.Player == true && 5 > Utility.Random(100)) { string[] toSay = { @@ -122,4 +122,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs b/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs index 030aec022..8212fa2fc 100644 --- a/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs +++ b/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs @@ -217,7 +217,7 @@ namespace Server.Mobiles public override void OnThink() { - if (SummonMaster == null || SummonMaster.Deleted) + if (SummonMaster?.Deleted != false) { Delete(); } @@ -252,10 +252,7 @@ namespace Server.Mobiles private bool Combat(Mobile mobile) { Mobile combatant = mobile.Combatant; - if (combatant == null || combatant.Deleted || combatant.IsDeadBondedPet || !combatant.Alive) - return false; - - return true; + return combatant?.Deleted == false && !combatant.IsDeadBondedPet && combatant.Alive; } public override void OnSingleClick(Mobile from) @@ -282,4 +279,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs b/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs index c9b91e79e..239b2e436 100644 --- a/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs +++ b/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs @@ -1,7 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; using Server.Items; using Server.Spells; diff --git a/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs b/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs index 135eae333..57f3ca6a8 100644 --- a/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs +++ b/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; @@ -95,9 +94,7 @@ namespace Server.Mobiles private void DoAreaLeech_Finish() { IPooledEnumerable eable = GetMobilesInRange(6); - List list = eable.Where(m => CanBeHarmful(m) && IsEnemy(m)).ToList(); - eable.Free(); if (list.Count == 0) diff --git a/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs b/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs index c81f316b1..c1b84caff 100644 --- a/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs +++ b/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; using Server.Network; @@ -96,7 +95,7 @@ namespace Server.Mobiles m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30)); if (combatant is BaseCreature bc) - if (bc.Controlled && bc.ControlMaster != null && !bc.ControlMaster.Deleted && bc.ControlMaster.Alive) + 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; diff --git a/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs b/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs index 80f410b5c..df1e683ea 100644 --- a/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs +++ b/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs @@ -5,12 +5,8 @@ namespace Server.Mobiles public class CuSidhe : BaseMount { [Constructible] - public CuSidhe() : this(null) - { - } - - [Constructible] - public CuSidhe(string name) : base(name, 277, 0x3E91, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public CuSidhe(string name = null) : + base(name, 277, 0x3E91, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { double chance = Utility.RandomDouble() * 23301; @@ -150,4 +146,4 @@ namespace Server.Mobiles Name = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs b/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs index 5f34955e7..9cfd6064c 100644 --- a/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs +++ b/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/InterredGrizzle .cs @@ -1,3 +1,5 @@ +using System.Linq; + namespace Server.Mobiles { public class InterredGrizzle : BaseCreature @@ -134,16 +136,8 @@ namespace Server.Mobiles for (int j = 0; j < 5; j++) { p = GetSpawnPosition(2); - bool found = false; - foreach (Item item in Map.GetItemsInRange(p, 0)) - if (item is StainedOoze) - { - found = true; - break; - } - - if (!found) + if (!Map.GetItemsInRange(p, 0).OfType().Any()) break; } @@ -171,4 +165,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs b/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs index 8501b26be..404cacd4f 100644 --- a/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs +++ b/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs @@ -116,11 +116,8 @@ namespace Server.Mobiles public bool IsValidTarget(PlayerMobile m) { - if (m != null && m.PeacedUntil < DateTime.UtcNow && !m.Hidden && m.AccessLevel == AccessLevel.Player && - CanBeHarmful(m)) - return true; - - return false; + return m?.PeacedUntil < DateTime.UtcNow && !m.Hidden && m.AccessLevel == AccessLevel.Player && + CanBeHarmful(m); } #endregion @@ -135,7 +132,7 @@ namespace Server.Mobiles return; foreach (Mobile m in GetMobilesInRange(RangePerception)) - if (m != null && m.Player && !m.Female && !m.Hidden && m.AccessLevel == AccessLevel.Player && + if (m?.Player == true && !m.Female && !m.Hidden && m.AccessLevel == AccessLevel.Player && CanBeHarmful(m)) { UndressItem(m, Layer.OuterTorso); @@ -155,10 +152,10 @@ namespace Server.Mobiles { Item item = m.FindItemOnLayer(layer); - if (item != null && item.Movable) + if (item?.Movable == true) m.PlaceInBackpack(item); } #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs b/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs index be3243175..c30a17384 100644 --- a/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs +++ b/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using Server.Engines.CannedEvil; using Server.Items; using Server.Network; @@ -265,16 +265,8 @@ namespace Server.Mobiles for (int j = 0; j < 5; j++) { p = GetSpawnPosition(2); - bool found = false; - foreach (Item item in Map.GetItemsInRange(p, 0)) - if (item is StainedOoze) - { - found = true; - break; - } - - if (!found) + if (!Map.GetItemsInRange(p, 0).OfType().Any()) break; } diff --git a/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs b/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs index 0af62c7b9..a3bde8c16 100644 --- a/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs +++ b/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using Server.Engines.CannedEvil; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs b/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs index 299921cd4..bd289098d 100644 --- a/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs +++ b/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Mobiles diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs b/Scripts/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs index 558207fed..3a1798d77 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs b/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs index 7b63f4863..659521426 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs b/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs index 0d2d2b195..f8765d5d5 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs @@ -9,12 +9,8 @@ namespace Server.Mobiles private bool m_Stunning; [Constructible] - public Golem() : this(false, 1.0) - { - } - - [Constructible] - public Golem(bool summoned, double scalar) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.4, 0.8) + public Golem(bool summoned = false, double scalar = 1.0) : + base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.4, 0.8) { Body = 752; @@ -192,12 +188,9 @@ namespace Server.Mobiles { if (Controlled || Summoned) { - Mobile master = ControlMaster; + Mobile master = ControlMaster ?? SummonMaster; - if (master == null) - master = SummonMaster; - - if (master != null && master.Player && master.Map == Map && master.InRange(Location, 20)) + if (master?.Player == true && master.Map == Map && master.InRange(Location, 20)) { if (master.Mana >= amount) { @@ -227,4 +220,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs index 719e8af04..9acd29f7a 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs @@ -205,10 +205,10 @@ namespace Server.Mobiles foreach (Corpse item in eable) // Ensure that the corpse was killed by us - if (item.Killer == this && item.Owner != null) - if (!item.DevourCorpse() && !item.Devoured) - PublicOverheadMessage(MessageType.Emote, 0x3B2, - 1053032); // * The plague beast attempts to absorb the remains, but cannot! * + 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(); } @@ -245,4 +245,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs index ae773754c..89c468515 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs @@ -92,7 +92,7 @@ namespace Server.Mobiles { Mobile m = state.Mobile; - if (m != null && m.Player && m != from) + if (m?.Player == true && m != from) PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1071919, from.Name, m.NetState); // * ~1_VAL~ slices through the plague beast's amorphous tissue * } @@ -305,7 +305,7 @@ namespace Server.Mobiles protected override void OnTick() { - if (m_Lord == null || m_Lord.Deleted) + if (m_Lord?.Deleted != false) { Stop(); return; @@ -350,4 +350,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs index fc4697473..40eeebf38 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs @@ -6,12 +6,8 @@ namespace Server.Mobiles { public class PlagueSpawn : BaseCreature { - [Constructible] - public PlagueSpawn() : this(null) - { - } - - public PlagueSpawn(Mobile owner) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public PlagueSpawn(Mobile owner = null) : + base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Owner = owner; ExpireTime = DateTime.UtcNow + TimeSpan.FromMinutes(1.0); @@ -132,4 +128,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs b/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs index 3a062b50f..19cd517ad 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs @@ -57,7 +57,7 @@ namespace Server.Mobiles { Mobile combatant = Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != Map || !InRange(combatant, 12) || + if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) || !CanBeHarmful(combatant) || !InLOS(combatant)) return; @@ -109,4 +109,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/AgapiteElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/AgapiteElemental.cs index 96ed6b501..df6264eea 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/AgapiteElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/AgapiteElemental.cs @@ -5,12 +5,7 @@ namespace Server.Mobiles public class AgapiteElemental : BaseCreature { [Constructible] - public AgapiteElemental() : this(2) - { - } - - [Constructible] - public AgapiteElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public AgapiteElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 107; BaseSoundID = 268; @@ -74,4 +69,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs index 3f57cff16..a567566ce 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs @@ -5,12 +5,8 @@ namespace Server.Mobiles public class BronzeElemental : BaseCreature { [Constructible] - public BronzeElemental() : this(2) - { - } - - [Constructible] - public BronzeElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public BronzeElemental(int oreAmount = 2) : + base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { // TODO: Gas attack Body = 108; @@ -76,4 +72,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/CopperElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/CopperElemental.cs index 35bf90d39..027217628 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/CopperElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/CopperElemental.cs @@ -5,12 +5,7 @@ namespace Server.Mobiles public class CopperElemental : BaseCreature { [Constructible] - public CopperElemental() : this(2) - { - } - - [Constructible] - public CopperElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public CopperElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 109; BaseSoundID = 268; @@ -79,4 +74,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs index cc4ec0d86..4f1b0fcdc 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs @@ -5,12 +5,8 @@ namespace Server.Mobiles public class DullCopperElemental : BaseCreature { [Constructible] - public DullCopperElemental() : this(2) - { - } - - [Constructible] - public DullCopperElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public DullCopperElemental(int oreAmount = 2) : + base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 110; BaseSoundID = 268; @@ -74,4 +70,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs index 1848d76c6..68cfc12bf 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs @@ -5,12 +5,8 @@ namespace Server.Mobiles public class GoldenElemental : BaseCreature { [Constructible] - public GoldenElemental() : this(2) - { - } - - [Constructible] - public GoldenElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public GoldenElemental(int oreAmount = 2) : + base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 166; BaseSoundID = 268; @@ -74,4 +70,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs index c7d313843..a7b13ea68 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/ShadowIronElemental.cs @@ -5,12 +5,7 @@ namespace Server.Mobiles public class ShadowIronElemental : BaseCreature { [Constructible] - public ShadowIronElemental() : this(2) - { - } - - [Constructible] - public ShadowIronElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public ShadowIronElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 111; BaseSoundID = 268; @@ -92,4 +87,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs index 5338526fc..6577f98fa 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/ValoriteElemental.cs @@ -5,12 +5,7 @@ namespace Server.Mobiles public class ValoriteElemental : BaseCreature { [Constructible] - public ValoriteElemental() : this(2) - { - } - - [Constructible] - public ValoriteElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public ValoriteElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { // TODO: Gas attack Body = 112; @@ -90,4 +85,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Ore Elementals/VeriteElemental.cs b/Scripts/Mobiles/Monsters/Ore Elementals/VeriteElemental.cs index 373fb9c63..ce6e91a4e 100644 --- a/Scripts/Mobiles/Monsters/Ore Elementals/VeriteElemental.cs +++ b/Scripts/Mobiles/Monsters/Ore Elementals/VeriteElemental.cs @@ -5,12 +5,7 @@ namespace Server.Mobiles public class VeriteElemental : BaseCreature { [Constructible] - public VeriteElemental() : this(2) - { - } - - [Constructible] - public VeriteElemental(int oreAmount) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public VeriteElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 113; BaseSoundID = 268; @@ -75,4 +70,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs b/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs index 717c133fc..1aea731c1 100644 --- a/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs +++ b/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs @@ -1,5 +1,3 @@ -using System.Collections; -using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs b/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs index 9a208b62c..10302822f 100644 --- a/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs +++ b/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs @@ -6,12 +6,8 @@ namespace Server.Mobiles public class Leviathan : BaseCreature { [Constructible] - public Leviathan() : this(null) - { - } - - [Constructible] - public Leviathan(Mobile fisher) : base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) + public Leviathan(Mobile fisher = null) : + base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) { Fisher = fisher; @@ -171,4 +167,4 @@ namespace Server.Mobiles Fisher = null; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs b/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs index d737001e5..43b4a76f6 100644 --- a/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs +++ b/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/SE/DeathWatchBeetle.cs b/Scripts/Mobiles/Monsters/SE/DeathWatchBeetle.cs index 99c2aecc5..21c2d9f30 100644 --- a/Scripts/Mobiles/Monsters/SE/DeathWatchBeetle.cs +++ b/Scripts/Mobiles/Monsters/SE/DeathWatchBeetle.cs @@ -128,7 +128,7 @@ namespace Server.Mobiles { Mobile combatant = Combatant; - if (combatant == null || combatant.Deleted || combatant.Map != Map || !InRange(combatant, 12) || + if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) || !CanBeHarmful(combatant) || !InLOS(combatant)) return; @@ -158,4 +158,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Monsters/SE/FanDancer.cs b/Scripts/Mobiles/Monsters/SE/FanDancer.cs index 39fee4b9a..8791d86e1 100644 --- a/Scripts/Mobiles/Monsters/SE/FanDancer.cs +++ b/Scripts/Mobiles/Monsters/SE/FanDancer.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/SE/Kappa.cs b/Scripts/Mobiles/Monsters/SE/Kappa.cs index 190b98f53..32995363c 100644 --- a/Scripts/Mobiles/Monsters/SE/Kappa.cs +++ b/Scripts/Mobiles/Monsters/SE/Kappa.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/SE/KazeKemono.cs b/Scripts/Mobiles/Monsters/SE/KazeKemono.cs index 2f7985960..db46dbc51 100644 --- a/Scripts/Mobiles/Monsters/SE/KazeKemono.cs +++ b/Scripts/Mobiles/Monsters/SE/KazeKemono.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Mobiles diff --git a/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs b/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs index 6d72626b1..ed155c33d 100644 --- a/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs +++ b/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/SE/RaiJu.cs b/Scripts/Mobiles/Monsters/SE/RaiJu.cs index 62be99714..888db681c 100644 --- a/Scripts/Mobiles/Monsters/SE/RaiJu.cs +++ b/Scripts/Mobiles/Monsters/SE/RaiJu.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Mobiles diff --git a/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs b/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs index 9466d4074..87e738932 100644 --- a/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs +++ b/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs b/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs index f8eb7706f..0b3deb7e0 100644 --- a/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs +++ b/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Monsters/SE/Yamandon.cs b/Scripts/Mobiles/Monsters/SE/Yamandon.cs index a5e4db79c..07664587d 100644 --- a/Scripts/Mobiles/Monsters/SE/Yamandon.cs +++ b/Scripts/Mobiles/Monsters/SE/Yamandon.cs @@ -1,4 +1,3 @@ -using System.Collections; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 8646e6f6e..f950be625 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Server.Accounting; @@ -259,6 +258,7 @@ namespace Server.Mobiles } catch { + // ignored } } } @@ -283,6 +283,7 @@ namespace Server.Mobiles } catch { + // ignored } } } @@ -445,12 +446,13 @@ namespace Server.Mobiles { IPooledEnumerable mobiles = Map.GetMobilesInRange(location, 0); - foreach (Mobile m in mobiles) - if (m.Z >= location.Z && m.Z < location.Z + 16 && (!m.Hidden || m.AccessLevel == AccessLevel.Player)) - { - mobiles.Free(); - return false; - } + bool found = mobiles.Any(m => + m.Z >= location.Z && m.Z < location.Z + 16 && (!m.Hidden || m.AccessLevel == AccessLevel.Player)); + + mobiles.Free(); + + if (found) + return false; mobiles.Free(); } @@ -819,12 +821,7 @@ namespace Server.Mobiles if (drop) { - string name = weapon.Name; - - if (name == null) - name = $"#{weapon.LabelNumber}"; - - from.SendLocalizedMessage(1062001, name); // You can no longer wield your ~1_WEAPON~ + from.SendLocalizedMessage(1062001, weapon.Name ?? $"#{weapon.LabelNumber}"); // You can no longer wield your ~1_WEAPON~ from.AddToBackpack(weapon); moved = true; } @@ -861,10 +858,7 @@ namespace Server.Mobiles if (drop) { - string name = armor.Name; - - if (name == null) - name = $"#{armor.LabelNumber}"; + string name = armor.Name ?? $"#{armor.LabelNumber}"; if (armor is BaseShield) from.SendLocalizedMessage(1062003, name); // You can no longer equip your ~1_SHIELD~ @@ -902,12 +896,7 @@ namespace Server.Mobiles if (drop) { - string name = clothing.Name; - - if (name == null) - name = $"#{clothing.LabelNumber}"; - - from.SendLocalizedMessage(1062002, name); // You can no longer wear your ~1_ARMOR~ + from.SendLocalizedMessage(1062002, clothing.Name ?? $"#{clothing.LabelNumber}"); // You can no longer wear your ~1_ARMOR~ from.AddToBackpack(clothing); moved = true; @@ -1200,10 +1189,8 @@ namespace Server.Mobiles public override bool AllowItemUse(Item item) { #region Dueling - - if (DuelContext != null && !DuelContext.AllowItemUse(this, item)) + if (DuelContext?.AllowItemUse(this, item) == false) return false; - #endregion return DesignContext.Check(this); @@ -1220,10 +1207,8 @@ namespace Server.Mobiles } #region Dueling - - if (DuelContext != null && !DuelContext.AllowSkillUse(this, skill)) + if (DuelContext?.AllowSkillUse(this, skill) == false) return false; - #endregion return DesignContext.Check(this); @@ -1324,7 +1309,7 @@ namespace Server.Mobiles { NetState ns = from.NetState; - if (ns != null && ns.ExtendedStatus) + if (ns?.ExtendedStatus == true) list.Add(new CallbackEntry(RefuseTrades ? 1154112 : 1154113, ToggleTrades)); // Allow Trades / Refuse Trades } @@ -1383,7 +1368,7 @@ namespace Server.Mobiles { BaseHouse house = BaseHouse.FindHouseAt(this); - if (CheckAlive() && house != null && house.IsOwner(this) && house.InternalizedVendors.Count > 0) + if (CheckAlive() && house?.IsOwner(this) == true && house.InternalizedVendors.Count > 0) { CloseGump(); SendGump(new ReclaimVendorGump(house)); @@ -1432,7 +1417,7 @@ namespace Server.Mobiles #region Dueling - if (DuelContext != null && !DuelContext.AllowItemEquip(this, item)) + if (DuelContext?.AllowItemEquip(this, item) == false) return false; #endregion @@ -1524,9 +1509,9 @@ namespace Server.Mobiles plusWeight += cont.TotalWeight; } - if (Backpack == null || !Backpack.CheckHold(this, item, false, checkItems, plusItems, plusWeight)) + if (Backpack?.CheckHold(this, item, false, checkItems, plusItems, plusWeight) != true) msgNum = 1004040; // You would not be able to hold this if the trade failed. - else if (to.Backpack == null || !to.Backpack.CheckHold(to, item, false, checkItems, plusItems, plusWeight)) + else if (to.Backpack?.CheckHold(to, item, false, checkItems, plusItems, plusWeight) != true) msgNum = 1004039; // The recipient of this trade would not be able to carry this. else msgNum = CheckContentForTrade(item); @@ -1698,7 +1683,7 @@ namespace Server.Mobiles if (!Core.AOS) disruptThreshold = 0; - else if (from != null && from.Player) + else if (from?.Player == true) disruptThreshold = 18; else disruptThreshold = 25; @@ -1759,7 +1744,7 @@ namespace Server.Mobiles DropHolding(); - if (Core.AOS && Backpack != null && !Backpack.Deleted) + if (Core.AOS && Backpack?.Deleted == false) { Backpack.FindItemsByType(FindItems_Callback).ForEach(item => Backpack.AddItem(item)); } @@ -1798,8 +1783,8 @@ namespace Server.Mobiles #region Dueling - if (m_DuelPlayer != null && DuelContext != null && DuelContext.Registered && DuelContext.Started && - !m_DuelPlayer.Eliminated) + if (DuelContext?.Registered == true && DuelContext.Started && + m_DuelPlayer?.Eliminated != true) return true; #endregion @@ -2060,7 +2045,7 @@ namespace Server.Mobiles { Mobile mob = ns.Mobile; - if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel) + if (mob?.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel) { if (p == null) p = Packet.Acquire(new UnicodeMessage(from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, @@ -2634,8 +2619,7 @@ namespace Server.Mobiles if (m is PlayerMobile mobile && mobile.VisibilityList.Contains(this)) return true; - if (DuelContext != null && m_DuelPlayer != null && !DuelContext.Finished && DuelContext.m_Tournament != null && - !m_DuelPlayer.Eliminated) + if (DuelContext?.Finished == false && DuelContext.m_Tournament != null && m_DuelPlayer?.Eliminated == false) { Mobile owner = m; @@ -2662,10 +2646,7 @@ namespace Server.Mobiles public override bool CanSee(Item item) { - if (DesignContext != null && DesignContext.Foundation.IsHiddenToCustomizer(item)) - return false; - - return base.CanSee(item); + return DesignContext?.Foundation.IsHiddenToCustomizer(item) != true && base.CanSee(item); } public override void OnAfterDelete() @@ -2820,11 +2801,10 @@ namespace Server.Mobiles continue; } - if (pet is IMount mount && mount.Rider != null) + if ((pet as IMount)?.Rider != null) continue; - if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack != null && - pet.Backpack.Items.Count > 0) + if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack?.Items.Count > 0) continue; if (pet is BaseEscortable) @@ -2969,24 +2949,11 @@ namespace Server.Mobiles public bool NinjaWepCooldown{ get; set; } - public List AllFollowers - { - get - { - if (m_AllFollowers == null) - m_AllFollowers = new List(); - return m_AllFollowers; - } - } + public List AllFollowers => m_AllFollowers ?? (m_AllFollowers = new List()); public RankDefinition GuildRank { - get - { - if (AccessLevel >= AccessLevel.GameMaster) - return RankDefinition.Leader; - return m_GuildRank; - } + get => AccessLevel >= AccessLevel.GameMaster ? RankDefinition.Leader : m_GuildRank; set => m_GuildRank = value; } @@ -3456,14 +3423,13 @@ namespace Server.Mobiles AddImageTiled(6, 116, 228, 20, 0xA40); AddAlphaRegion(6, 6, 228, 142); - AddHtmlLocalized(8, 8, 228, 100, 1071021, 0x7FFF, false, - false); // You are about to disable inventory insurance auto-renewal. + AddHtmlLocalized(8, 8, 228, 100, 1071021, 0x7FFF); // You are about to disable inventory insurance auto-renewal. - AddButton(6, 116, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 118, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(6, 116, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(40, 118, 450, 20, 1060051, 0x7FFF); // CANCEL - AddButton(114, 116, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(148, 118, 450, 20, 1071022, 0x7FFF, false, false); // DISABLE IT! + AddButton(114, 116, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(148, 118, 450, 20, 1071022, 0x7FFF); // DISABLE IT! } public override void OnResponse(NetState sender, RelayInfo info) @@ -3550,24 +3516,24 @@ namespace Server.Mobiles AddImageTiled(10, 415, 500, 80, 0xA40); AddAlphaRegion(10, 10, 500, 485); - AddButton(15, 470, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 472, 80, 20, 1011012, 0x7FFF, false, false); // CANCEL + AddButton(15, 470, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(50, 472, 80, 20, 1011012, 0x7FFF); // CANCEL if (from.AutoRenewInsurance) - AddButton(360, 10, 9723, 9724, 1, GumpButtonType.Reply, 0); + AddButton(360, 10, 9723, 9724, 1); else - AddButton(360, 10, 9720, 9722, 1, GumpButtonType.Reply, 0); + AddButton(360, 10, 9720, 9722, 1); - AddHtmlLocalized(395, 14, 105, 20, 1114122, 0x7FFF, false, false); // AUTO REINSURE + AddHtmlLocalized(395, 14, 105, 20, 1114122, 0x7FFF); // AUTO REINSURE - AddButton(395, 470, 0xFA5, 0xFA6, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(430, 472, 50, 20, 1006044, 0x7FFF, false, false); // OK + AddButton(395, 470, 0xFA5, 0xFA6, 2); + AddHtmlLocalized(430, 472, 50, 20, 1006044, 0x7FFF); // OK - AddHtmlLocalized(10, 14, 150, 20, 1114121, 0x7FFF, false, false); //
ITEM INSURANCE MENU
+ AddHtmlLocalized(10, 14, 150, 20, 1114121, 0x7FFF); //
ITEM INSURANCE MENU
- AddHtmlLocalized(45, 54, 70, 20, 1062214, 0x7FFF, false, false); // Item - AddHtmlLocalized(250, 54, 70, 20, 1061038, 0x7FFF, false, false); // Cost - AddHtmlLocalized(400, 54, 70, 20, 1114311, 0x7FFF, false, false); // Insured + AddHtmlLocalized(45, 54, 70, 20, 1062214, 0x7FFF); // Item + AddHtmlLocalized(250, 54, 70, 20, 1061038, 0x7FFF); // Cost + AddHtmlLocalized(400, 54, 70, 20, 1114311, 0x7FFF); // Insured int balance = Banker.GetBalance(from); int cost = 0; @@ -3576,14 +3542,14 @@ namespace Server.Mobiles if (insure[i]) cost += GetInsuranceCost(items[i]); - AddHtmlLocalized(15, 420, 300, 20, 1114310, 0x7FFF, false, false); // GOLD AVAILABLE: + AddHtmlLocalized(15, 420, 300, 20, 1114310, 0x7FFF); // GOLD AVAILABLE: AddLabel(215, 420, 0x481, balance.ToString()); - AddHtmlLocalized(15, 435, 300, 20, 1114123, 0x7FFF, false, false); // TOTAL COST OF INSURANCE: + AddHtmlLocalized(15, 435, 300, 20, 1114123, 0x7FFF); // TOTAL COST OF INSURANCE: AddLabel(215, 435, 0x481, cost.ToString()); if (cost != 0) { - AddHtmlLocalized(15, 450, 300, 20, 1114125, 0x7FFF, false, false); // NUMBER OF DEATHS PAYABLE: + AddHtmlLocalized(15, 450, 300, 20, 1114125, 0x7FFF); // NUMBER OF DEATHS PAYABLE: AddLabel(215, 450, 0x481, (balance / cost).ToString()); } @@ -3598,26 +3564,26 @@ namespace Server.Mobiles if (insure[i]) { - AddButton(400, y, 9723, 9724, 100 + i, GumpButtonType.Reply, 0); + AddButton(400, y, 9723, 9724, 100 + i); AddLabel(250, y, 0x481, GetInsuranceCost(item).ToString()); } else { - AddButton(400, y, 9720, 9722, 100 + i, GumpButtonType.Reply, 0); + AddButton(400, y, 9720, 9722, 100 + i); AddLabel(250, y, 0x66C, GetInsuranceCost(item).ToString()); } } if (page >= 1) { - AddButton(15, 380, 0xFAE, 0xFAF, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 380, 450, 20, 1044044, 0x7FFF, false, false); // PREV PAGE + AddButton(15, 380, 0xFAE, 0xFAF, 3); + AddHtmlLocalized(50, 380, 450, 20, 1044044, 0x7FFF); // PREV PAGE } if ((page + 1) * 4 < items.Length) { - AddButton(400, 380, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(435, 380, 70, 20, 1044045, 0x7FFF, false, false); // NEXT PAGE + AddButton(400, 380, 0xFA5, 0xFA7, 4); + AddHtmlLocalized(435, 380, 70, 20, 1044045, 0x7FFF); // NEXT PAGE } } @@ -3703,14 +3669,13 @@ namespace Server.Mobiles AddImageTiled(6, 116, 228, 20, 0xA40); AddAlphaRegion(6, 6, 228, 142); - AddHtmlLocalized(8, 8, 228, 100, 1114300, 0x7FFF, false, - false); // Do you wish to insure all newly selected items? + AddHtmlLocalized(8, 8, 228, 100, 1114300, 0x7FFF); // Do you wish to insure all newly selected items? - AddButton(6, 116, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(40, 118, 450, 20, 1060051, 0x7FFF, false, false); // CANCEL + AddButton(6, 116, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(40, 118, 450, 20, 1060051, 0x7FFF); // CANCEL - AddButton(114, 116, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(148, 118, 450, 20, 1073996, 0x7FFF, false, false); // ACCEPT + AddButton(114, 116, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(148, 118, 450, 20, 1073996, 0x7FFF); // ACCEPT } public override void OnResponse(NetState sender, RelayInfo info) @@ -3870,7 +3835,7 @@ namespace Server.Mobiles get => m_DuelPlayer; set { - bool wasInTourney = DuelContext != null && !DuelContext.Finished && DuelContext.m_Tournament != null; + bool wasInTourney = DuelContext?.Finished == false && DuelContext.m_Tournament != null; m_DuelPlayer = value; @@ -3879,7 +3844,7 @@ namespace Server.Mobiles else DuelContext = m_DuelPlayer.Participant.Context; - bool isInTourney = DuelContext != null && !DuelContext.Finished && DuelContext.m_Tournament != null; + bool isInTourney = DuelContext?.Finished == false && DuelContext.m_Tournament != null; if (wasInTourney != isInTourney) SendEverything(); @@ -3999,7 +3964,7 @@ namespace Server.Mobiles TransformContext context = TransformationSpellHelper.GetContext(this); - if (context != null && context.Type == typeof(ReaperFormSpell)) + if (context?.Type == typeof(ReaperFormSpell)) return WalkFoot; bool running = (dir & Direction.Running) != 0; @@ -4008,7 +3973,7 @@ namespace Server.Mobiles AnimalFormContext animalContext = AnimalForm.GetContext(this); - if (onHorse || animalContext != null && animalContext.SpeedBoost) + if (onHorse || animalContext?.SpeedBoost == true) return running ? RunMount : WalkMount; return running ? RunFoot : WalkFoot; @@ -4262,7 +4227,7 @@ namespace Server.Mobiles if (from is BaseCreature creature && creature.IgnoreYoungProtection) return false; - if (Quest != null && Quest.IgnoreYoungProtection(from)) + if (Quest?.IgnoreYoungProtection(from) == true) return false; if (DateTime.UtcNow - m_LastYoungMessage > TimeSpan.FromMinutes(1.0)) diff --git a/Scripts/Mobiles/Special/Barracoon.cs b/Scripts/Mobiles/Special/Barracoon.cs index b86537ccb..5454d2b3a 100644 --- a/Scripts/Mobiles/Special/Barracoon.cs +++ b/Scripts/Mobiles/Special/Barracoon.cs @@ -107,12 +107,12 @@ namespace Server.Mobiles { Item disarm = m.FindItemOnLayer(Layer.OneHanded); - if (disarm != null && disarm.Movable) + if (disarm?.Movable == true) m.AddToBackpack(disarm); disarm = m.FindItemOnLayer(Layer.TwoHanded); - if (disarm != null && disarm.Movable) + if (disarm?.Movable == true) m.AddToBackpack(disarm); m.BodyMod = 42; @@ -166,7 +166,7 @@ namespace Server.Mobiles public void DoSpecialAbility(Mobile target) { - if (target == null || target.Deleted) //sanity + if (target?.Deleted != false) //sanity return; if (0.6 >= Utility.RandomDouble()) // 60% chance to polymorph attacker into a ratman diff --git a/Scripts/Mobiles/Special/BaseChampion.cs b/Scripts/Mobiles/Special/BaseChampion.cs index d38329a10..b8ffcdea7 100644 --- a/Scripts/Mobiles/Special/BaseChampion.cs +++ b/Scripts/Mobiles/Special/BaseChampion.cs @@ -7,11 +7,8 @@ namespace Server.Mobiles { public abstract class BaseChampion : BaseCreature { - public BaseChampion(AIType aiType) : this(aiType, FightMode.Closest) - { - } - - public BaseChampion(AIType aiType, FightMode mode) : base(aiType, mode, 18, 1, 0.1, 0.2) + public BaseChampion(AIType aiType, FightMode mode = FightMode.Closest) : + base(aiType, mode, 18, 1, 0.1, 0.2) { } @@ -166,54 +163,56 @@ namespace Server.Mobiles } else { - if (m.Corpse != null && !m.Corpse.Deleted) + if (m.Corpse?.Deleted == false) m.Corpse.DropItem(ps); else m.AddToBackpack(ps); } - if (m is PlayerMobile pm) - for (int j = 0; j < pm.JusticeProtectors.Count; ++j) + if (!(m is PlayerMobile pm)) + return; + + for (int j = 0; j < pm.JusticeProtectors.Count; ++j) + { + Mobile prot = pm.JusticeProtectors[j]; + + if (prot.Map != pm.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(pm, prot)) + continue; + + int chance = 0; + + switch (VirtueHelper.GetLevel(prot, VirtueName.Justice)) { - Mobile prot = pm.JusticeProtectors[j]; + case VirtueLevel.Seeker: + chance = 60; + break; + case VirtueLevel.Follower: + chance = 80; + break; + case VirtueLevel.Knight: + chance = 100; + break; + } - if (prot.Map != pm.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(pm, prot)) - continue; + if (chance > Utility.Random(100)) + { + PowerScroll powerScroll = new PowerScroll(ps.Skill, ps.Value); - int chance = 0; + prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice! - switch (VirtueHelper.GetLevel(prot, VirtueName.Justice)) + if (!Core.SE || prot.Alive) { - case VirtueLevel.Seeker: - chance = 60; - break; - case VirtueLevel.Follower: - chance = 80; - break; - case VirtueLevel.Knight: - chance = 100; - break; + prot.AddToBackpack(powerScroll); } - - if (chance > Utility.Random(100)) + else { - PowerScroll powerScroll = new PowerScroll(ps.Skill, ps.Value); - - prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice! - - if (!Core.SE || prot.Alive) - { - prot.AddToBackpack(powerScroll); - } + if (prot.Corpse?.Deleted == false) + prot.Corpse.DropItem(powerScroll); else - { - if (prot.Corpse != null && !prot.Corpse.Deleted) - prot.Corpse.DropItem(powerScroll); - else - prot.AddToBackpack(powerScroll); - } + prot.AddToBackpack(powerScroll); } } + } } public override bool OnBeforeDeath() @@ -328,4 +327,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Special/Harrower.cs b/Scripts/Mobiles/Special/Harrower.cs index 57add926e..f7e09dcb4 100644 --- a/Scripts/Mobiles/Special/Harrower.cs +++ b/Scripts/Mobiles/Special/Harrower.cs @@ -1,6 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using Server.Items; using Server.Spells; @@ -388,7 +388,7 @@ namespace Server.Mobiles public void RegisterDamage(Mobile from, int amount) { - if (from == null || !from.Player) + if (from?.Player != true) return; m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out int value) ? value : 0); @@ -437,7 +437,7 @@ namespace Server.Mobiles Container pack = to.Backpack; - if (pack == null || !pack.TryDropItem(to, artifact, false)) + if (pack?.TryDropItem(to, artifact, false) != true) artifact.Delete(); else to.SendLocalizedMessage( @@ -446,8 +446,8 @@ namespace Server.Mobiles public bool IsEligible(Mobile m, Item Artifact) { - return m.Player && m.Alive && m.InRange(Location, 32) && m.Backpack != null && - m.Backpack.CheckHold(m, Artifact, false); + return m.Player && m.Alive && m.InRange(Location, 32) && + m.Backpack?.CheckHold(m, Artifact, false) == true; } public Item GetArtifact() @@ -526,61 +526,55 @@ namespace Server.Mobiles if (0.25 < Utility.RandomDouble()) return; - Mobile toTeleport = null; + Mobile toTeleport = m_Owner.GetMobilesInRange(16) + .FirstOrDefault(mob => mob != m_Owner && mob.Player && m_Owner.CanBeHarmful(mob) && m_Owner.CanSee(mob)); - foreach (Mobile m in m_Owner.GetMobilesInRange(16)) - if (m != m_Owner && m.Player && m_Owner.CanBeHarmful(m) && m_Owner.CanSee(m)) + if (toTeleport == null) + return; + + int offset = Utility.Random(8) * 2; + + Point3D to = m_Owner.Location; + + for (int i = 0; i < m_Offsets.Length; i += 2) + { + int x = m_Owner.X + m_Offsets[(offset + i) % m_Offsets.Length]; + int y = m_Owner.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; + + if (map.CanSpawnMobile(x, y, m_Owner.Z)) { - toTeleport = m; + to = new Point3D(x, y, m_Owner.Z); break; } - if (toTeleport != null) - { - int offset = Utility.Random(8) * 2; + int z = map.GetAverageZ(x, y); - Point3D to = m_Owner.Location; - - for (int i = 0; i < m_Offsets.Length; i += 2) + if (map.CanSpawnMobile(x, y, z)) { - int x = m_Owner.X + m_Offsets[(offset + i) % m_Offsets.Length]; - int y = m_Owner.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; - - if (map.CanSpawnMobile(x, y, m_Owner.Z)) - { - to = new Point3D(x, y, m_Owner.Z); - break; - } - - int z = map.GetAverageZ(x, y); - - if (map.CanSpawnMobile(x, y, z)) - { - to = new Point3D(x, y, z); - break; - } + to = new Point3D(x, y, z); + break; } - - Mobile m = toTeleport; - - Point3D from = m.Location; - - m.Location = to; - - SpellHelper.Turn(m_Owner, toTeleport); - SpellHelper.Turn(toTeleport, m_Owner); - - m.ProcessDelta(); - - Effects.SendLocationParticles(EffectItem.Create(from, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, - 2023); - Effects.SendLocationParticles(EffectItem.Create(to, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, - 5023); - - m.PlaySound(0x1FE); - - m_Owner.Combatant = toTeleport; } + + Mobile m = toTeleport; + + Point3D from = m.Location; + + m.Location = to; + + SpellHelper.Turn(m_Owner, toTeleport); + SpellHelper.Turn(toTeleport, m_Owner); + + m.ProcessDelta(); + + Effects.SendLocationParticles(EffectItem.Create(from, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, + 2023); + Effects.SendLocationParticles(EffectItem.Create(to, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, + 5023); + + m.PlaySound(0x1FE); + + m_Owner.Combatant = toTeleport; } } diff --git a/Scripts/Mobiles/Special/HarrowerTentacles.cs b/Scripts/Mobiles/Special/HarrowerTentacles.cs index 46d800b89..b8d9fd978 100644 --- a/Scripts/Mobiles/Special/HarrowerTentacles.cs +++ b/Scripts/Mobiles/Special/HarrowerTentacles.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; namespace Server.Mobiles { @@ -8,12 +6,8 @@ namespace Server.Mobiles { private DrainTimer m_Timer; - [Constructible] - public HarrowerTentacles() : this(null) - { - } - - public HarrowerTentacles(Mobile harrower) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public HarrowerTentacles(Mobile harrower = null) : + base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Harrower = harrower; Body = 129; diff --git a/Scripts/Mobiles/Special/Rikktor.cs b/Scripts/Mobiles/Special/Rikktor.cs index 1e763eae4..3f3c3b4c8 100644 --- a/Scripts/Mobiles/Special/Rikktor.cs +++ b/Scripts/Mobiles/Special/Rikktor.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using Server.Engines.CannedEvil; using Server.Items; diff --git a/Scripts/Mobiles/Special/Semidar.cs b/Scripts/Mobiles/Special/Semidar.cs index 178b16f7e..4f01a0747 100644 --- a/Scripts/Mobiles/Special/Semidar.cs +++ b/Scripts/Mobiles/Special/Semidar.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using Server.Engines.CannedEvil; using Server.Items; diff --git a/Scripts/Mobiles/Special/Serado.cs b/Scripts/Mobiles/Special/Serado.cs index 42fbb5be5..dd824ad51 100644 --- a/Scripts/Mobiles/Special/Serado.cs +++ b/Scripts/Mobiles/Special/Serado.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using Server.Engines.CannedEvil; using Server.Engines.Plants; using Server.Items; diff --git a/Scripts/Mobiles/Townfolk/Banker.cs b/Scripts/Mobiles/Townfolk/Banker.cs index 6edf3ac54..3b8fb6c70 100644 --- a/Scripts/Mobiles/Townfolk/Banker.cs +++ b/Scripts/Mobiles/Townfolk/Banker.cs @@ -287,7 +287,7 @@ namespace Server.Mobiles { Say(500381); // Thou canst not withdraw so much at one time! } - else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) || + else if (pack?.Deleted != false || !(pack.TotalWeight < pack.MaxWeight) || !(pack.TotalItems < pack.MaxItems)) { Say(1048147); // Your backpack can't hold anything else. @@ -426,4 +426,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Townfolk/BaseEscortable.cs b/Scripts/Mobiles/Townfolk/BaseEscortable.cs index 5a86f1420..4616034ba 100644 --- a/Scripts/Mobiles/Townfolk/BaseEscortable.cs +++ b/Scripts/Mobiles/Townfolk/BaseEscortable.cs @@ -302,15 +302,13 @@ namespace Server.Mobiles { base.OnSpeech(e); - EDI dest = GetDestination(); + if (GetDestination() == null || e.Handled || !e.Mobile.InRange(Location, 3)) + return; - if (dest != null && !e.Handled && e.Mobile.InRange(Location, 3)) - { - if (e.HasKeyword(0x1D)) // *destination* - e.Handled = SayDestinationTo(e.Mobile); - else if (e.HasKeyword(0x1E)) // *i will take thee* - e.Handled = AcceptEscorter(e.Mobile); - } + if (e.HasKeyword(0x1D)) // *destination* + e.Handled = SayDestinationTo(e.Mobile); + else if (e.HasKeyword(0x1E)) // *i will take thee* + e.Handled = AcceptEscorter(e.Mobile); } public override void OnAfterDelete() @@ -600,7 +598,7 @@ namespace Server.Mobiles picked = possible[Utility.Random(possible.Length)]; EDI test = EDI.Find(picked); - if (test != null && test.Contains(Location)) + if (test.Contains(Location)) picked = null; } @@ -673,10 +671,7 @@ namespace Server.Mobiles foreach (Region r in list) { - if (r.Name == null) - continue; - - if (r is DungeonRegion || r is TownRegion) + if (r.Name != null && (r is DungeonRegion || r is TownRegion)) m_Table[r.Name] = new EscortDestinationInfo(r.Name, r); } } diff --git a/Scripts/Mobiles/Townfolk/TownCrier.cs b/Scripts/Mobiles/Townfolk/TownCrier.cs index d0702845a..7109790d7 100644 --- a/Scripts/Mobiles/Townfolk/TownCrier.cs +++ b/Scripts/Mobiles/Townfolk/TownCrier.cs @@ -21,16 +21,7 @@ namespace Server.Mobiles { private static GlobalTownCrierEntryList m_Instance; - public static GlobalTownCrierEntryList Instance - { - get - { - if (m_Instance == null) - m_Instance = new GlobalTownCrierEntryList(); - - return m_Instance; - } - } + public static GlobalTownCrierEntryList Instance => m_Instance ?? (m_Instance = new GlobalTownCrierEntryList()); public bool IsEmpty => Entries == null || Entries.Count == 0; @@ -225,13 +216,12 @@ namespace Server.Mobiles AddImageTiled(0, 0, 300, 38 + (count == 0 ? 20 : count * 85), 0xA40); AddAlphaRegion(1, 1, 298, 36 + (count == 0 ? 20 : count * 85)); - AddHtml(8, 8, 300 - 8 - 30, 20, "
TOWN CRIER MESSAGES
", false, - false); + AddHtml(8, 8, 300 - 8 - 30, 20, "
TOWN CRIER MESSAGES
"); - AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0); + AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1); if (count == 0) - AddHtml(8, 30, 284, 20, "The crier has no news.", false, false); + AddHtml(8, 30, 284, 20, "The crier has no news."); else for (int i = 0; i < entries.Count; ++i) { @@ -272,7 +262,7 @@ namespace Server.Mobiles AddHtml(8, 35 + i * 85, 254, 80, sb.ToString(), true, true); - AddButton(300 - 8 - 26, 35 + i * 85, 0x15E1, 0x15E5, 2 + i, GumpButtonType.Reply, 0); + AddButton(300 - 8 - 26, 35 + i * 85, 0x15E1, 0x15E5, 2 + i); } } @@ -544,4 +534,4 @@ namespace Server.Mobiles NameHue = -1; } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Vendors/BaseVendor.cs b/Scripts/Mobiles/Vendors/BaseVendor.cs index c9b61d3f1..09c03a2de 100644 --- a/Scripts/Mobiles/Vendors/BaseVendor.cs +++ b/Scripts/Mobiles/Vendors/BaseVendor.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.ContextMenus; using Server.Engines.BulkOrders; @@ -30,7 +29,7 @@ namespace Server.Mobiles private List m_ArmorBuyInfo = new List(); private List m_ArmorSellInfo = new List(); - public BaseVendor(string title) + public BaseVendor(string title = null) : base(AIType.AI_Vendor, FightMode.None, 2, 1, 0.5, 2) { LoadSBInfo(); @@ -219,9 +218,7 @@ namespace Server.Mobiles buyer.PlaySound(0x32); - cont = buyer.Backpack; - if (cont == null) - cont = buyer.BankBox; + cont = buyer.Backpack ?? buyer.BankBox; foreach (BuyItemResponse buy in validBuy) { diff --git a/Scripts/Mobiles/Vendors/GenericBuy.cs b/Scripts/Mobiles/Vendors/GenericBuy.cs index f32c2ffe6..f79c5e251 100644 --- a/Scripts/Mobiles/Vendors/GenericBuy.cs +++ b/Scripts/Mobiles/Vendors/GenericBuy.cs @@ -225,7 +225,7 @@ namespace Server.Mobiles { get { - if (m_Cache == null || m_Cache.Deleted) + if (m_Cache?.Deleted != false) m_Cache = new DisplayCache(); return m_Cache; diff --git a/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs b/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs index 76c898f0e..7984c4740 100644 --- a/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs +++ b/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs @@ -103,7 +103,7 @@ namespace Server.Mobiles { BaseCreature pet = from.Stabled[i] as BaseCreature; - if (pet == null || pet.Deleted) + if (pet?.Deleted != false) { pet.IsStabled = false; pet.StabledBy = null; @@ -123,7 +123,7 @@ namespace Server.Mobiles public void EndClaimList(Mobile from, BaseCreature pet) { - if (pet == null || pet.Deleted || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive()) + if (pet?.Deleted != false || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive()) return; if (!from.InRange(this, 14)) @@ -153,8 +153,8 @@ namespace Server.Mobiles Container bank = from.FindBankNoCreate(); - if ((from.Backpack == null || from.Backpack.GetAmount(typeof(Gold)) < 30) && - (bank == null || bank.GetAmount(typeof(Gold)) < 30)) + if (!(from.Backpack?.GetAmount(typeof(Gold)) >= 30) && + !(bank?.GetAmount(typeof(Gold)) >= 30)) { SayTo(from, 1042556); // Thou dost not have enough gold, not even in thy bank account. } @@ -201,8 +201,7 @@ namespace Server.Mobiles SayTo( from, 1048053 ); // You can't stable that! } */ - else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack != null && - pet.Backpack.Items.Count > 0) + else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack?.Items.Count > 0) { SayTo(from, 1042563); // You need to unload your pet. } @@ -218,8 +217,8 @@ namespace Server.Mobiles { Container bank = from.FindBankNoCreate(); - if (from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), 30) || - bank != null && bank.ConsumeTotal(typeof(Gold), 30)) + if (from.Backpack?.ConsumeTotal(typeof(Gold), 30) == true || + bank?.ConsumeTotal(typeof(Gold), 30) == true) { pet.ControlTarget = null; pet.ControlOrder = OrderType.Stay; @@ -248,12 +247,7 @@ namespace Server.Mobiles } } - public void Claim(Mobile from) - { - Claim(from, null); - } - - public void Claim(Mobile from, string petName) + public void Claim(Mobile from, string petName = null) { if (Deleted || !from.CheckAlive()) return; @@ -267,7 +261,7 @@ namespace Server.Mobiles { BaseCreature pet = from.Stabled[i] as BaseCreature; - if (pet == null || pet.Deleted) + if (pet?.Deleted != false) { pet.IsStabled = false; pet.StabledBy = null; @@ -414,18 +408,17 @@ namespace Server.Mobiles AddBackground(0, 0, 325, 50 + list.Count * 20, 9250); AddAlphaRegion(5, 5, 315, 40 + list.Count * 20); - AddHtml(15, 15, 275, 20, "Select a pet to retrieve from the stables:", - false, false); + AddHtml(15, 15, 275, 20, "Select a pet to retrieve from the stables:"); for (int i = 0; i < list.Count; ++i) { BaseCreature pet = list[i]; - if (pet == null || pet.Deleted) + if (pet?.Deleted != false) continue; - AddButton(15, 39 + i * 20, 10006, 10006, i + 1, GumpButtonType.Reply, 0); - AddHtml(32, 35 + i * 20, 275, 18, $"{pet.Name}", false, false); + AddButton(15, 39 + i * 20, 10006, 10006, i + 1); + AddHtml(32, 35 + i * 20, 275, 18, $"{pet.Name}"); } } @@ -475,4 +468,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs b/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs index bc0f6648e..178a6003d 100644 --- a/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs +++ b/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs @@ -153,7 +153,7 @@ namespace Server.Mobiles AddBackground(50, 10, 450, 100 + canAfford * 25, 2600); - AddHtmlLocalized(100, 40, 350, 20, 1018356, false, false); // Choose your hairstyle change: + AddHtmlLocalized(100, 40, 350, 20, 1018356); // Choose your hairstyle change: int index = 0; @@ -161,11 +161,11 @@ namespace Server.Mobiles if (balance >= sellList[i].Price && (!sellList[i].FacialHair || !isFemale)) { if (sellList[i].TitleString != null) - AddHtml(140, 75 + index * 25, 300, 20, sellList[i].TitleString, false, false); + AddHtml(140, 75 + index * 25, 300, 20, sellList[i].TitleString); else - AddHtmlLocalized(140, 75 + index * 25, 300, 20, sellList[i].Title, false, false); + AddHtmlLocalized(140, 75 + index * 25, 300, 20, sellList[i].Title); - AddButton(100, 75 + index++ * 25, 4005, 4007, 1 + i, GumpButtonType.Reply, 0); + AddButton(100, 75 + index++ * 25, 4005, 4007, 1 + i); } } @@ -205,6 +205,7 @@ namespace Server.Mobiles } catch { + // ignored } else m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); @@ -291,10 +292,10 @@ namespace Server.Mobiles AddBackground(100, 10, 350, 370, 2600); AddBackground(120, 54, 110, 270, 5100); - AddHtmlLocalized(155, 25, 240, 30, 1011013, false, false); //
Hair Color Selection Menu
+ AddHtmlLocalized(155, 25, 240, 30, 1011013); //
Hair Color Selection Menu
- AddHtmlLocalized(150, 330, 220, 35, 1011014, false, false); // Dye my hair this color! - AddButton(380, 330, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(150, 330, 220, 35, 1011014); // Dye my hair this color! + AddButton(380, 330, 4005, 4007, 1); for (int i = 0; i < entries.Length; ++i) { @@ -447,18 +448,16 @@ namespace Server.Mobiles AddBackground(0, 0, 81 + tableWidth * offsetWidth, 105 + tableHeight * offsetHeight, 2600); - AddButton(45, 45 + tableHeight * offsetHeight, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(77, 45 + tableHeight * offsetHeight, 90, 35, 1006044, false, false); // Ok + AddButton(45, 45 + tableHeight * offsetHeight, 4005, 4007, 1); + AddHtmlLocalized(77, 45 + tableHeight * offsetHeight, 90, 35, 1006044); // Ok - AddButton(81 + tableWidth * offsetWidth - 180, 45 + tableHeight * offsetHeight, 4005, 4007, 0, - GumpButtonType.Reply, 0); - AddHtmlLocalized(81 + tableWidth * offsetWidth - 148, 45 + tableHeight * offsetHeight, 90, 35, 1006045, false, - false); // Cancel + AddButton(81 + tableWidth * offsetWidth - 180, 45 + tableHeight * offsetHeight, 4005, 4007, 0); + AddHtmlLocalized(81 + tableWidth * offsetWidth - 148, 45 + tableHeight * offsetHeight, 90, 35, 1006045); // Cancel if (!facialHair) - AddHtmlLocalized(50, 15, 350, 20, 1018353, false, false); //
New Hairstyle
+ AddHtmlLocalized(50, 15, 350, 20, 1018353); //
New Hairstyle
else - AddHtmlLocalized(55, 15, 200, 20, 1018354, false, false); //
New Beard
+ AddHtmlLocalized(55, 15, 200, 20, 1018354); //
New Beard
for (int i = 0; i < entries.Length; ++i) { @@ -475,13 +474,12 @@ namespace Server.Mobiles else if (!facialHair) { AddRadio(40 + (xTable + 1) * offsetWidth, 240, 208, 209, false, i); - AddHtmlLocalized(60 + (xTable + 1) * offsetWidth, 240, 85, 35, 1011064, false, false); // Bald + AddHtmlLocalized(60 + (xTable + 1) * offsetWidth, 240, 85, 35, 1011064); // Bald } else { AddRadio(40 + xTable * offsetWidth, 70 + yTable * offsetHeight, 208, 209, false, i); - AddHtmlLocalized(60 + xTable * offsetWidth, 70 + yTable * offsetHeight, 85, 35, 1011064, false, - false); // Bald + AddHtmlLocalized(60 + xTable * offsetWidth, 70 + yTable * offsetHeight, 85, 35, 1011064); // Bald } } } @@ -573,4 +571,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs b/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs index 2cde91d5b..c2a78516b 100644 --- a/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs +++ b/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs @@ -62,12 +62,12 @@ namespace Server.Mobiles public override void OnClick() { - if (!Core.ML || m_Vendor == null || m_Vendor.Deleted) + if (!Core.ML || m_Vendor?.Deleted != false) return; WeaponEngravingTool tool = WeaponEngravingTool.Find(m_From); - if (tool != null && tool.UsesRemaining <= 0) + if (tool?.UsesRemaining <= 0) { if (Banker.GetBalance(m_From) >= 100000) m_From.SendGump(new WeaponEngravingTool.ConfirmGump(tool, m_Vendor)); @@ -82,4 +82,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs b/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs index 387558f7d..568ab270b 100644 --- a/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs +++ b/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs @@ -78,7 +78,7 @@ namespace Server.Mobiles if (Banker.Deposit(from, price)) { // For the deed I have placed gold in your bankbox : - PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString(), ""); + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString()); deed.Delete(); return true; @@ -104,7 +104,7 @@ namespace Server.Mobiles if (price > 0) { // I will pay you gold for this deed : - PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008001, AffixType.Append, price.ToString(), ""); + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008001, AffixType.Append, price.ToString()); PublicOverheadMessage(MessageType.Regular, 0x3B2, 500610); // Simply hand me the deed if you wish to sell it. diff --git a/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs b/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs index b4bd87800..430e14ddb 100644 --- a/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs +++ b/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs @@ -303,7 +303,7 @@ namespace Server.Mobiles { if (!(dropped is Gold g)) return false; - + if (g.Amount > 50) { PrivateOverheadMessage(MessageType.Regular, 0x3B2, false, "I cannot accept so large a tip!", @@ -334,7 +334,7 @@ namespace Server.Mobiles public bool IsOwner(Mobile from) { - if (from == null || from.Deleted || Deleted) + if (from?.Deleted != false || Deleted) return false; if (from.AccessLevel > AccessLevel.GameMaster) @@ -604,7 +604,7 @@ namespace Server.Mobiles new Entry("Waiter", true), new Entry("Warrior"), new Entry("Watchman"), - new Entry("No Title", null, false) + new Entry("No Title", null) }; private PlayerBarkeeper m_Barkeeper; @@ -664,7 +664,7 @@ namespace Server.Mobiles AddImage(180, 25, 10460); AddImage(434, 25, 10460); - AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU", false, false); + AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU"); AddBackground(243, 433, 150, 30, 5054); AddImage(240, 433, 10460); @@ -673,22 +673,22 @@ namespace Server.Mobiles AddImage(80, 398, 2151); AddItem(72, 406, 2543); - AddHtml(110, 412, 180, 25, "sells food and drink", false, false); + AddHtml(110, 412, 180, 25, "sells food and drink"); } private void RenderPage(Entry[] entries, int page) { AddPage(1 + page); - AddHtml(430, 70, 180, 25, $"Page {page + 1} of {(entries.Length + 19) / 20}", false, false); + AddHtml(430, 70, 180, 25, $"Page {page + 1} of {(entries.Length + 19) / 20}"); for (int count = 0, i = page * 20; count < 20 && i < entries.Length; ++count, ++i) { Entry entry = entries[i]; - AddButton(80 + count / 10 * 260, 100 + count % 10 * 30, 4005, 4007, 2 + i, GumpButtonType.Reply, 0); + AddButton(80 + count / 10 * 260, 100 + count % 10 * 30, 4005, 4007, 2 + i); AddHtml(120 + count / 10 * 260, 100 + count % 10 * 30, entry.m_Vendor ? 148 : 180, 25, entry.m_Description, - true, false); + true); if (entry.m_Vendor) { @@ -698,10 +698,10 @@ namespace Server.Mobiles } AddButton(340, 400, 4005, 4007, 0, GumpButtonType.Page, 1 + (page + 1) % ((entries.Length + 19) / 20)); - AddHtml(380, 400, 180, 25, "More Job Titles", false, false); + AddHtml(380, 400, 180, 25, "More Job Titles"); - AddButton(338, 437, 4014, 4016, 1, GumpButtonType.Reply, 0); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddButton(338, 437, 4014, 4016, 1); + AddHtml(290, 440, 35, 40, "Back"); } public override void OnResponse(NetState sender, RelayInfo info) @@ -732,15 +732,11 @@ namespace Server.Mobiles public string m_Title; public bool m_Vendor; - public Entry(string desc) : this(desc, $"the {desc.ToLower()}", false) + public Entry(string desc, bool vendor = false) : this(desc, $"the {desc.ToLower()}", vendor) { } - public Entry(string desc, bool vendor) : this(desc, $"the {desc.ToLower()}", vendor) - { - } - - public Entry(string desc, string title, bool vendor) + public Entry(string desc, string title, bool vendor = false) { m_Description = desc; m_Title = title; @@ -807,7 +803,7 @@ namespace Server.Mobiles AddImage(434, 25, 10460); AddImage(560, 20, 1417); - AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU", false, false); + AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU"); AddBackground(243, 433, 150, 30, 5054); AddImage(240, 433, 10460); @@ -819,16 +815,16 @@ namespace Server.Mobiles AddPage(1); AddButton(130, 120, 4005, 4007, 0, GumpButtonType.Page, 2); - AddHtml(170, 120, 200, 40, "Message Control", false, false); + AddHtml(170, 120, 200, 40, "Message Control"); AddButton(130, 200, 4005, 4007, 0, GumpButtonType.Page, 8); - AddHtml(170, 200, 200, 40, "Customize your barkeep", false, false); + AddHtml(170, 200, 200, 40, "Customize your barkeep"); AddButton(130, 280, 4005, 4007, 0, GumpButtonType.Page, 3); - AddHtml(170, 280, 200, 40, "Dismiss your barkeep", false, false); + AddHtml(170, 280, 200, 40, "Dismiss your barkeep"); - AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Reply, 0); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddButton(338, 437, 4014, 4016, 0); + AddHtml(290, 440, 35, 40, "Back"); AddItem(574, 43, 5360); } @@ -838,19 +834,19 @@ namespace Server.Mobiles AddPage(2); AddButton(130, 120, 4005, 4007, 0, GumpButtonType.Page, 4); - AddHtml(170, 120, 380, 20, "Add or change a message and keyword", false, false); + AddHtml(170, 120, 380, 20, "Add or change a message and keyword"); AddButton(130, 200, 4005, 4007, 0, GumpButtonType.Page, 5); - AddHtml(170, 200, 380, 20, "Remove a message and keyword from your barkeep", false, false); + AddHtml(170, 200, 380, 20, "Remove a message and keyword from your barkeep"); AddButton(130, 280, 4005, 4007, 0, GumpButtonType.Page, 6); - AddHtml(170, 280, 380, 20, "Add or change your barkeeper's tip message", false, false); + AddHtml(170, 280, 380, 20, "Add or change your barkeeper's tip message"); AddButton(130, 360, 4005, 4007, 0, GumpButtonType.Page, 7); - AddHtml(170, 360, 380, 20, "Delete your barkeepers tip message", false, false); + AddHtml(170, 360, 380, 20, "Delete your barkeepers tip message"); AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 1); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); AddItem(580, 46, 4030); } @@ -859,16 +855,16 @@ namespace Server.Mobiles { AddPage(3); - AddHtml(170, 160, 380, 20, "Are you sure you want to dismiss your barkeeper?", false, false); + AddHtml(170, 160, 380, 20, "Are you sure you want to dismiss your barkeeper?"); - AddButton(205, 280, 4005, 4007, GetButtonID(0, 0), GumpButtonType.Reply, 0); - AddHtml(240, 280, 100, 20, @"Yes", false, false); + AddButton(205, 280, 4005, 4007, GetButtonID(0, 0)); + AddHtml(240, 280, 100, 20, @"Yes"); - AddButton(395, 280, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtml(430, 280, 100, 20, "No", false, false); + AddButton(395, 280, 4005, 4007, 0); + AddHtml(430, 280, 100, 20, "No"); AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 1); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); AddItem(574, 43, 5360); AddItem(584, 34, 6579); @@ -878,7 +874,7 @@ namespace Server.Mobiles { AddPage(4); - AddHtml(250, 60, 500, 25, "Add or change a message", false, false); + AddHtml(250, 60, 500, 25, "Add or change a message"); BarkeeperRumor[] rumors = m_Barkeeper.Rumors; @@ -886,16 +882,16 @@ namespace Server.Mobiles { BarkeeperRumor rumor = rumors[i]; - AddHtml(100, 70 + i * 120, 50, 20, "Message", false, false); - AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true, false); - AddHtml(100, 130 + i * 120, 50, 20, "Keyword", false, false); - AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true, false); + AddHtml(100, 70 + i * 120, 50, 20, "Message"); + AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true); + AddHtml(100, 130 + i * 120, 50, 20, "Keyword"); + AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true); - AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(1, i), GumpButtonType.Reply, 0); + AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(1, i)); } AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); AddItem(580, 46, 4030); } @@ -904,7 +900,7 @@ namespace Server.Mobiles { AddPage(5); - AddHtml(190, 60, 500, 25, "Choose the message you would like to remove", false, false); + AddHtml(190, 60, 500, 25, "Choose the message you would like to remove"); BarkeeperRumor[] rumors = m_Barkeeper.Rumors; @@ -912,16 +908,16 @@ namespace Server.Mobiles { BarkeeperRumor rumor = rumors[i]; - AddHtml(100, 70 + i * 120, 50, 20, "Message", false, false); - AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true, false); - AddHtml(100, 130 + i * 120, 50, 20, "Keyword", false, false); - AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true, false); + AddHtml(100, 70 + i * 120, 50, 20, "Message"); + AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true); + AddHtml(100, 130 + i * 120, 50, 20, "Keyword"); + AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true); - AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(2, i), GumpButtonType.Reply, 0); + AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(2, i)); } AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); AddItem(580, 46, 4030); } @@ -935,14 +931,14 @@ namespace Server.Mobiles { AddPage(6); - AddHtml(250, 95, 500, 20, "Change this tip message", false, false); - AddHtml(100, 190, 50, 20, "Message", false, false); - AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true, false); + AddHtml(250, 95, 500, 20, "Change this tip message"); + AddHtml(100, 190, 50, 20, "Message"); + AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true); - AddButton(60, 210, 4005, 4007, GetButtonID(3, 0), GumpButtonType.Reply, 0); + AddButton(60, 210, 4005, 4007, GetButtonID(3, 0)); AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); AddItem(580, 46, 4030); } @@ -951,14 +947,14 @@ namespace Server.Mobiles { AddPage(7); - AddHtml(250, 95, 500, 20, "Remove this tip message", false, false); - AddHtml(100, 190, 50, 20, "Message", false, false); - AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true, false); + AddHtml(250, 95, 500, 20, "Remove this tip message"); + AddHtml(100, 190, 50, 20, "Message"); + AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true); - AddButton(60, 210, 4005, 4007, GetButtonID(4, 0), GumpButtonType.Reply, 0); + AddButton(60, 210, 4005, 4007, GetButtonID(4, 0)); AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); AddItem(580, 46, 4030); } @@ -967,19 +963,19 @@ namespace Server.Mobiles { AddPage(8); - AddButton(130, 120, 4005, 4007, GetButtonID(5, 0), GumpButtonType.Reply, 0); - AddHtml(170, 120, 120, 20, "Title", false, false); + AddButton(130, 120, 4005, 4007, GetButtonID(5, 0)); + AddHtml(170, 120, 120, 20, "Title"); if (m_Barkeeper.BodyValue != 0x340 && m_Barkeeper.BodyValue != 0x402) { - AddButton(130, 200, 4005, 4007, GetButtonID(5, 1), GumpButtonType.Reply, 0); - AddHtml(170, 200, 120, 20, "Appearance", false, false); + AddButton(130, 200, 4005, 4007, GetButtonID(5, 1)); + AddHtml(170, 200, 120, 20, "Appearance"); - AddButton(130, 280, 4005, 4007, GetButtonID(5, 2), GumpButtonType.Reply, 0); - AddHtml(170, 280, 120, 20, "Male / Female", false, false); + AddButton(130, 280, 4005, 4007, GetButtonID(5, 2)); + AddHtml(170, 280, 120, 20, "Male / Female"); AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 1); - AddHtml(290, 440, 35, 40, "Back", false, false); + AddHtml(290, 440, 35, 40, "Back"); } AddItem(580, 44, 4033); @@ -1053,4 +1049,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Mobiles/Vendors/PlayerVendor.cs b/Scripts/Mobiles/Vendors/PlayerVendor.cs index 272df6a94..521c5a94c 100644 --- a/Scripts/Mobiles/Vendors/PlayerVendor.cs +++ b/Scripts/Mobiles/Vendors/PlayerVendor.cs @@ -26,14 +26,8 @@ namespace Server.Mobiles { Item = item; Price = price; - - if (description != null) - m_Description = description; - else - m_Description = ""; - + m_Description = description ?? ""; Created = created; - Valid = true; } @@ -57,10 +51,7 @@ namespace Server.Mobiles get => m_Description; set { - if (value != null) - m_Description = value; - else - m_Description = ""; + m_Description = value ?? ""; if (Valid) Item.InvalidateProperties(); @@ -111,7 +102,7 @@ namespace Server.Mobiles { BaseHouse house = vendor.House; - if (house != null && house.IsAosRules && !house.CheckAosStorage(1 + item.TotalItems + plusItems)) + 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. @@ -142,13 +133,9 @@ namespace Server.Mobiles public override bool CheckTarget(Mobile from, Target targ, object targeted) { - if (!base.CheckTarget(from, targ, targeted)) - return false; - - if (from.AccessLevel >= AccessLevel.GameMaster) - return true; - - return targ.GetType().IsDefined(typeof(PlayerVendorTargetAttribute), false); + return base.CheckTarget(from, targ, targeted) && + (from.AccessLevel >= AccessLevel.GameMaster || + targ.GetType().IsDefined(typeof(PlayerVendorTargetAttribute), false)); } public override void GetChildContextMenuEntries(Mobile from, List list, Item item) @@ -317,10 +304,7 @@ namespace Server.Mobiles get => m_ShopName; set { - if (value == null) - m_ShopName = ""; - else - m_ShopName = value; + m_ShopName = value ?? ""; InvalidateProperties(); } @@ -515,7 +499,7 @@ namespace Server.Mobiles { FixDresswear(); - if (House != null && !House.IsOwner(Owner)) + if (House?.IsOwner(Owner) == false) Destroy(false); } @@ -604,7 +588,7 @@ namespace Server.Mobiles if (list.Count > 0 || HoldGold > 0) // No case 1 { - if ((!toBackpack || Map == Map.Internal) && House != null && House.IsAosRules) // Case 2 + if ((!toBackpack || Map == Map.Internal) && House?.IsAosRules == true) // Case 2 { if (House.IsOwner(Owner)) // Move to moving crate { @@ -844,7 +828,7 @@ namespace Server.Mobiles bool newItem = GetVendorItem(item) == null; - if (Backpack != null && Backpack.TryDropItem(from, item, false)) + if (Backpack?.TryDropItem(from, item, false) == true) { if (newItem) OnItemGiven(from, item); @@ -918,7 +902,7 @@ namespace Server.Mobiles if (ownerOnly) return IsOwner(from); - if (House != null && House.IsBanned(from) && !IsOwner(from)) + if (House?.IsBanned(from) == true && !IsOwner(from)) { from.SendLocalizedMessage( 1062674); // You can't shop from this home as you have been banned from this establishment. @@ -1051,7 +1035,7 @@ namespace Server.Mobiles { Container pack = Backpack; - if (pack != null && pack.Items.Count > 0) + if (pack?.Items.Count > 0) { SayTo(from, 1038325); // You cannot dismiss me while I am holding your goods. return; @@ -1156,7 +1140,7 @@ namespace Server.Mobiles } else if (e.HasKeyword(0x3D) || e.HasKeyword(0x172) && WasNamed(e.Speech)) // vendor browse, *browse { - if (House != null && House.IsBanned(from) && !IsOwner(from)) + if (House?.IsBanned(from) == true && !IsOwner(from)) { SayTo(from, 1062674); // You can't shop from this home as you have been banned from this establishment. } @@ -1553,7 +1537,7 @@ namespace Server.Mobiles public override void OnDelete() { - if (Vendor != null && !Vendor.Deleted) + if (Vendor?.Deleted == false) { Vendor.MoveToWorld(Location, Map); Vendor.Placeholder = null; diff --git a/Scripts/Mobiles/Vendors/RentedVendor.cs b/Scripts/Mobiles/Vendors/RentedVendor.cs index 8222f05b1..72a883dd0 100644 --- a/Scripts/Mobiles/Vendors/RentedVendor.cs +++ b/Scripts/Mobiles/Vendors/RentedVendor.cs @@ -97,7 +97,7 @@ namespace Server.Mobiles public bool IsLandlord(Mobile m) { - return House != null && House.IsOwner(m); + return House?.IsOwner(m) == true; } public void ComputeRentalExpireDelay(out int days, out int hours) @@ -134,7 +134,7 @@ namespace Server.Mobiles public override void Destroy(bool toBackpack) { - if (RentalGold > 0 && House != null && House.IsAosRules) + if (RentalGold > 0 && House?.IsAosRules == true) { if (House.MovingCrate == null) House.MovingCrate = new MovingCrate(House); @@ -374,4 +374,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/BaseHouse.cs b/Scripts/Multis/BaseHouse.cs index cb09944da..cba02cda2 100644 --- a/Scripts/Multis/BaseHouse.cs +++ b/Scripts/Multis/BaseHouse.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Server.Accounting; @@ -119,7 +118,7 @@ namespace Server.Multis { Mobile mob = acct[i]; - if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster) + if (mob?.AccessLevel >= AccessLevel.GameMaster) return DecayType.Ageless; } @@ -202,7 +201,7 @@ namespace Server.Multis { m_LastDecayLevel = result; - if (Sign != null && !Sign.GettingProperties) + if (Sign?.GettingProperties == false) Sign.InvalidateProperties(); } @@ -722,8 +721,8 @@ namespace Server.Multis if (!item.Deleted) { - if (item is StrongBox) - item = ((StrongBox)item).ConvertToStandardContainer(); + if (item is StrongBox box) + item = box.ConvertToStandardContainer(); item.IsLockedDown = false; item.IsSecure = false; @@ -1017,13 +1016,8 @@ namespace Server.Multis Point2D end = new Point2D(X + Components.Max.X + 1, Y + Components.Max.Y + 1); Rectangle2D rect = new Rectangle2D(start, end); - List list = new List(); - IPooledEnumerable eable = Map.GetItemsInBounds(rect); - - foreach (Item item in eable) - if (item.Movable && IsInside(item)) - list.Add(item); + List list = eable.Where(item => item.Movable && IsInside(item)).ToList(); eable.Free(); @@ -1080,22 +1074,17 @@ namespace Server.Multis public static bool CheckLockedDown(Item item) { - BaseHouse house = FindHouseAt(item); - - return house != null && house.HasLockedDownItem(item); + return FindHouseAt(item)?.HasLockedDownItem(item) == true; } public static bool CheckSecured(Item item) { - BaseHouse house = FindHouseAt(item); - - return house != null && house.HasSecureItem(item); + return FindHouseAt(item)?.HasSecureItem(item) == true; } public static bool CheckLockedDownOrSecured(Item item) { BaseHouse house = FindHouseAt(item); - return house != null && (house.HasSecureItem(item) || house.HasLockedDownItem(item)); } @@ -1110,7 +1099,7 @@ namespace Server.Multis { BaseHouse house = exists[i]; - if (house != null && !house.Deleted && house.Owner == m) + if (house?.Deleted == false && house.Owner == m) list.Add(house); } } @@ -1164,7 +1153,7 @@ namespace Server.Multis public static BaseHouse FindHouseAt(Mobile m) { - if (m == null || m.Deleted) + if (m?.Deleted != false) return null; return FindHouseAt(m.Location, m.Map, 16); @@ -1172,10 +1161,8 @@ namespace Server.Multis public static BaseHouse FindHouseAt(Item item) { - if (item == null || item.Deleted) - return null; - - return FindHouseAt(item.GetWorldLocation(), item.Map, item.ItemData.Height); + return item?.Deleted != false ? null : + FindHouseAt(item.GetWorldLocation(), item.Map, item.ItemData.Height); } public static BaseHouse FindHouseAt(Point3D loc, Map map, int height) @@ -1196,18 +1183,12 @@ namespace Server.Multis public bool IsInside(Mobile m) { - if (m == null || m.Deleted || m.Map != Map) - return false; - - return IsInside(m.Location, 16); + return m?.Deleted == false && m.Map == Map && IsInside(m.Location, 16); } public bool IsInside(Item item) { - if (item == null || item.Deleted || item.Map != Map) - return false; - - return IsInside(item.Location, item.ItemData.Height); + return item?.Deleted == false && item.Map == Map && IsInside(item.Location, item.ItemData.Height); } public bool CheckAccessibility(Item item, Mobile from) @@ -1321,11 +1302,11 @@ namespace Server.Multis UpdateRegion(); - if (Sign != null && !Sign.Deleted) + if (Sign?.Deleted == false) Sign.Map = Map; if (Doors != null) - foreach (Item item in Doors) + foreach (BaseDoor item in Doors) item.Map = Map; foreach (IEntity entity in GetHouseEntities()) @@ -1365,13 +1346,13 @@ namespace Server.Multis int y = base.Location.Y - oldLocation.Y; int z = base.Location.Z - oldLocation.Z; - if (Sign != null && !Sign.Deleted) + if (Sign?.Deleted == false) Sign.Location = new Point3D(Sign.X + x, Sign.Y + y, Sign.Z + z); UpdateRegion(); if (Doors != null) - foreach (Item item in Doors) + foreach (BaseDoor item in Doors) if (!item.Deleted) item.Location = new Point3D(item.X + x, item.Y + y, item.Z + z); @@ -1538,7 +1519,7 @@ namespace Server.Multis for (int i = 0; Doors != null && i < Doors.Count; ++i) { - BaseDoor door = Doors[i] as BaseDoor; + BaseDoor door = Doors[i]; Point3D p = door.Location; if (door.Open) @@ -1552,7 +1533,7 @@ namespace Server.Multis } } - if (m_Trash == null || m_Trash.Deleted) + if (m_Trash?.Deleted != false) { m_Trash = new TrashBarrel { Movable = false }; m_Trash.MoveToWorld(from.Location, from.Map); @@ -2028,7 +2009,7 @@ namespace Server.Multis for (int i = 0; Doors != null && i < Doors.Count; ++i) { - BaseDoor door = Doors[i] as BaseDoor; + BaseDoor door = Doors[i]; Point3D p = door.Location; if (door.Open) @@ -3012,36 +2993,27 @@ namespace Server.Multis if (m == null) return false; - if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access != null && Access.Contains(m)) + if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access?.Contains(m) == true) return true; - if (m is BaseCreature bc) - { - if (bc.NoHouseRestrictions) - return true; + if (!(m is BaseCreature bc)) + return false; - if (bc.Controlled || bc.Summoned) - { - m = bc.ControlMaster; + if (bc.NoHouseRestrictions) + return true; - if (m == null) - m = bc.SummonMaster; + if (!(bc.Controlled || bc.Summoned)) + return false; - if (m == null) - return false; + m = bc.ControlMaster ?? bc.SummonMaster; - if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access != null && Access.Contains(m)) - return true; - } - } - - return false; + return m != null && (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access?.Contains(m) == true); } public bool HasLockedDownItem(Item check) { - return check != null && LockDowns != null && - (LockDowns.Contains(check) || check is VendorRentalContract contract && VendorRentalContracts.Contains(contract)); + return LockDowns?.Contains(check) == true || + check is VendorRentalContract contract && VendorRentalContracts.Contains(contract); } public bool HasSecureItem(Item item) @@ -3049,15 +3021,11 @@ namespace Server.Multis if (item == null) return false; - if (Secures == null) - return false; + for (int i = 0; i < Secures?.Count; ++i) + if (Secures[i].Item == item) + return true; - bool contains = false; - - for (int i = 0; !contains && i < Secures.Count; ++i) - contains = Secures[i].Item == item; - - return contains; + return false; } public virtual Guildstone FindGuildstone() @@ -3071,15 +3039,9 @@ namespace Server.Multis IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height)); - foreach (Guildstone item in eable) - if (Contains(item)) - { - eable.Free(); - return item; - } - + Guildstone item = eable.FirstOrDefault(Contains); eable.Free(); - return null; + return item; } private class TransferItem : Item @@ -3144,7 +3106,7 @@ namespace Server.Multis if (!accepted) return true; - if (Deleted || m_House == null || m_House.Deleted || !m_House.IsOwner(from) || !from.CheckAlive() || + if (Deleted || m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive()) return false; @@ -3164,7 +3126,7 @@ namespace Server.Multis Delete(); - if (m_House == null || m_House.Deleted || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive()) + if (m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive()) return; diff --git a/Scripts/Multis/Boats/BaseBoat.cs b/Scripts/Multis/Boats/BaseBoat.cs index 3acbbab08..7e8189ce6 100644 --- a/Scripts/Multis/Boats/BaseBoat.cs +++ b/Scripts/Multis/Boats/BaseBoat.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using Server.Items; using Server.Network; @@ -466,13 +467,7 @@ namespace Server.Multis public bool CheckKey(uint keyValue) { - if (SPlank != null && SPlank.KeyValue == keyValue) - return true; - - if (PPlank != null && PPlank.KeyValue == keyValue) - return true; - - return false; + return SPlank?.KeyValue == keyValue || PPlank?.KeyValue == keyValue; } public void Refresh() @@ -751,7 +746,7 @@ namespace Server.Multis if (CheckDecay()) return; - if (newName != null && newName.Length > 40) + if (newName?.Length > 40) newName = newName.Substring(0, 40); if (m_ShipName == newName) @@ -899,7 +894,7 @@ namespace Server.Multis return false; } - if (MapItem == null || MapItem.Deleted) + if (MapItem?.Deleted != false) { if (message) TillerMan?.Say(502513); // I have seen no map, sir. @@ -1198,71 +1193,61 @@ namespace Server.Multis MultiComponentList newComponents = MultiData.GetComponents(itemID); for (int x = 0; x < newComponents.Width; ++x) - for (int y = 0; y < newComponents.Height; ++y) - { - int tx = p.X + newComponents.Min.X + x; - int ty = p.Y + newComponents.Min.Y + y; - - if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty)) - continue; - - LandTile landTile = map.Tiles.GetLandTile(tx, ty); - StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true); - - bool hasWater = false; - - if (landTile.Z == p.Z && - (landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311)) - hasWater = true; - - int z = p.Z; - - //int landZ = 0, landAvg = 0, landTop = 0; - - //map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop ); - - //if ( !landTile.Ignored && top > landZ && landTop > z ) - // return false; - - for (int i = 0; i < tiles.Length; ++i) + for (int y = 0; y < newComponents.Height; ++y) { - StaticTile tile = tiles[i]; - bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2; + int tx = p.X + newComponents.Min.X + x; + int ty = p.Y + newComponents.Min.Y + y; - if (tile.Z == p.Z && isWater) - hasWater = true; - else if (tile.Z >= p.Z && !isWater) + if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty)) + continue; + + LandTile landTile = map.Tiles.GetLandTile(tx, ty); + StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true); + + bool hasWater = landTile.Z == p.Z && + (landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311); + + // int z = p.Z; + + //int landZ = 0, landAvg = 0, landTop = 0; + + //map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop ); + + //if ( !landTile.Ignored && top > landZ && landTop > z ) + // return false; + + for (int i = 0; i < tiles.Length; ++i) + { + StaticTile tile = tiles[i]; + bool 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; } - if (!hasWater) - return false; - } - IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height)); - foreach (Item item in eable) + bool canFit = eable.All(item => { if (item is BaseMulti || item.ItemID > TileData.MaxItemValue || item.Z < p.Z || !item.Visible) - continue; + return true; int x = item.X - p.X + newComponents.Min.X; int y = item.Y - p.Y + newComponents.Min.Y; - if (x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && - newComponents.Tiles[x][y].Length == 0) - continue; - if (Contains(item)) - continue; - - eable.Free(); - return false; - } + return x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && + newComponents.Tiles[x][y].Length == 0 || Contains(item); + }); eable.Free(); - - return true; + return canFit; } public Point3D Rotate(Point3D p, int count) @@ -1282,22 +1267,11 @@ namespace Server.Multis public override bool Contains(int x, int y) { - if (base.Contains(x, y)) - return true; - - if (TillerMan != null && x == TillerMan.X && y == TillerMan.Y) - return true; - - if (Hold != null && x == Hold.X && y == Hold.Y) - return true; - - if (PPlank != null && x == PPlank.X && y == PPlank.Y) - return true; - - if (SPlank != null && x == SPlank.X && y == SPlank.Y) - return true; - - return false; + return base.Contains(x, y) || + TillerMan?.X == x && y == TillerMan.Y || + Hold?.X == x && Hold.Y == y || + PPlank?.X == x && PPlank.Y == y || + SPlank?.X == x && SPlank.Y == y; } public static bool IsValidLocation(Point3D p, Map map) @@ -1313,11 +1287,7 @@ namespace Server.Multis public static Rectangle2D[] GetWrapFor(Map m) { - if (m == Map.Ilshenar) - return m_IlshWrap; - if (m == Map.Tokuno) - return m_TokunoWrap; - return m_BritWrap; + return m == Map.Ilshenar ? m_IlshWrap : m == Map.Tokuno ? m_TokunoWrap : m_BritWrap; } public Direction GetMovementFor(int x, int y, out int maxSpeed) @@ -1351,7 +1321,7 @@ namespace Server.Multis speed = Speed; clientSpeed = m_ClientSpeed; } - else if (MapItem == null || MapItem.Deleted) + else if (MapItem?.Deleted != false) { if (message) TillerMan?.Say(502513); // I have seen no map, sir. @@ -1941,4 +1911,4 @@ namespace Server.Multis #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Multis/Boats/ConfirmDryDockGump.cs b/Scripts/Multis/Boats/ConfirmDryDockGump.cs index eb638a6aa..920eecaa5 100644 --- a/Scripts/Multis/Boats/ConfirmDryDockGump.cs +++ b/Scripts/Multis/Boats/ConfirmDryDockGump.cs @@ -20,13 +20,13 @@ namespace Server.Multis AddBackground(0, 0, 220, 170, 5054); AddBackground(10, 10, 200, 150, 3000); - AddHtmlLocalized(20, 20, 180, 80, 1018319, true, false); // Do you wish to dry dock this boat? + AddHtmlLocalized(20, 20, 180, 80, 1018319, true); // Do you wish to dry dock this boat? - AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false); // CONTINUE - AddButton(20, 100, 4005, 4007, 2, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 100, 140, 25, 1011011); // CONTINUE + AddButton(20, 100, 4005, 4007, 2); - AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false); // CANCEL - AddButton(20, 125, 4005, 4007, 1, GumpButtonType.Reply, 0); + AddHtmlLocalized(55, 125, 140, 25, 1011012); // CANCEL + AddButton(20, 125, 4005, 4007, 1); } public override void OnResponse(NetState state, RelayInfo info) @@ -35,4 +35,4 @@ namespace Server.Multis m_Boat.EndDryDock(m_From); } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/Boats/Plank.cs b/Scripts/Multis/Boats/Plank.cs index 786b3fbf1..afef35689 100644 --- a/Scripts/Multis/Boats/Plank.cs +++ b/Scripts/Multis/Boats/Plank.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Factions; using Server.Multis; using Server.Network; @@ -161,7 +162,7 @@ namespace Server.Items if (from is BaseFactionGuard) return false; - if ((from.Direction & Direction.Running) != 0 || Boat != null && !Boat.Contains(from)) + if ((from.Direction & Direction.Running) != 0 || Boat?.Contains(from) == false) return true; Map map = Map; @@ -222,16 +223,7 @@ namespace Server.Items public bool CanClose() { - Map map = Map; - - if (map == null || Deleted) - return false; - - foreach (object o in GetObjectsInRange(0)) - if (o != this) - return false; - - return true; + return Map != null && !Deleted && GetObjectsInRange(0).Cast().All(o => o == this); } public void Close() @@ -334,4 +326,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/ComponentVerification.cs b/Scripts/Multis/ComponentVerification.cs index 62a47d1ee..6a3c9934d 100644 --- a/Scripts/Multis/ComponentVerification.cs +++ b/Scripts/Multis/ComponentVerification.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; @@ -33,26 +34,17 @@ namespace Server.Multis public bool IsItemValid(int itemID) { - if (itemID <= 0 || itemID >= m_ItemTable.Length) - return false; - - return CheckValidity(m_ItemTable[itemID]); + return itemID > 0 && itemID < m_ItemTable.Length && CheckValidity(m_ItemTable[itemID]); } public bool IsMultiValid(int multiID) { - if (multiID <= 0 || multiID >= m_MultiTable.Length) - return false; - - return CheckValidity(m_MultiTable[multiID]); + return multiID > 0 && multiID < m_MultiTable.Length && CheckValidity(m_MultiTable[multiID]); } public bool CheckValidity(int val) { - if (val == -1) - return false; - - return val == 0 || ((int)ExpansionInfo.CoreExpansion.CustomHousingFlag & val) != 0; + return val != -1 && (val == 0 || ((int)ExpansionInfo.CoreExpansion.CustomHousingFlag & val) != 0); } private int[] CreateTable(int length) @@ -172,10 +164,8 @@ namespace Server.Multis while ((line = ip.ReadLine()) != null) { - if (line.Length == 0) - continue; - - return line.Split('\t'); + if (line.Length > 0) + return line.Split('\t'); } return null; @@ -212,16 +202,7 @@ namespace Server.Multis public object this[string name] => this[Spreadsheet.GetColumnID(name)]; - public object this[int id] - { - get - { - if (id < 0) - return null; - - return Data[id]; - } - } + public object this[int id] => id < 0 ? null : Data[id]; public int GetInt32(string name) { @@ -235,10 +216,7 @@ namespace Server.Multis public int GetInt32(object obj) { - if (obj is int i) - return i; - - return 0; + return Convert.ToInt32(obj); } public string GetString(string name) @@ -246,4 +224,4 @@ namespace Server.Multis return this[name] as string; } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/Deeds.cs b/Scripts/Multis/Deeds.cs index 2b22716c6..1b25f320a 100644 --- a/Scripts/Multis/Deeds.cs +++ b/Scripts/Multis/Deeds.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using Server.Regions; using Server.Targeting; diff --git a/Scripts/Multis/HouseFoundation.cs b/Scripts/Multis/HouseFoundation.cs index dd946dce9..1fc86d488 100644 --- a/Scripts/Multis/HouseFoundation.cs +++ b/Scripts/Multis/HouseFoundation.cs @@ -185,20 +185,11 @@ namespace Server.Multis } } - public static ComponentVerification Verification - { - get - { - if (m_Verification == null) - m_Verification = new ComponentVerification(); - - return m_Verification; - } - } + public static ComponentVerification Verification => m_Verification ?? (m_Verification = new ComponentVerification()); public bool IsFixture(Item item) { - return Fixtures != null && Fixtures.Contains(item); + return Fixtures.Contains(item); } public override int GetMaxUpdateRange() @@ -303,7 +294,7 @@ namespace Server.Multis { Item item = Fixtures[i]; item.Delete(); - + if (item is BaseDoor door) Doors.Remove(door); } @@ -858,14 +849,7 @@ namespace Server.Multis { base.SendInfoTo(state, sendOplPacket); - DesignContext context = DesignContext.Find(state.Mobile); - DesignState stateToSend; - - if (context != null && context.Foundation == this) - stateToSend = DesignState; - else - stateToSend = CurrentState; - + DesignState stateToSend = DesignContext.Find(state.Mobile)?.Foundation == this ? DesignState : CurrentState; stateToSend.SendGeneralInfoTo(state); } @@ -985,19 +969,13 @@ namespace Server.Multis public static void Designer_Sync(NetState state, IEntity e, EncodedReader pvSrc) { Mobile from = state.Mobile; - DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client requested state synchronization + /* Client requested state synchronization * - Resend full house state */ - DesignState design = context.Foundation.DesignState; - - // Resend full house state - design.SendDetailedInfoTo(state); - } + // Resend full house state + DesignContext.Find(from)?.Foundation.DesignState.SendDetailedInfoTo(state); } public static void Designer_Clear(NetState state, IEntity e, EncodedReader pvSrc) @@ -1005,9 +983,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to clear the design + if (context == null) + return; + + /* Client chose to clear the design * - Restore empty foundation * - Construct new design state from empty foundation * - Assign constructed state to foundation @@ -1015,19 +994,18 @@ namespace Server.Multis * - Update client with new state */ - // Restore empty foundation : Construct new design state from empty foundation - DesignState newDesign = new DesignState(context.Foundation, context.Foundation.GetEmptyFoundation()); + // Restore empty foundation : Construct new design state from empty foundation + DesignState newDesign = new DesignState(context.Foundation, context.Foundation.GetEmptyFoundation()); - // Restore empty foundation : Assign constructed state to foundation - context.Foundation.DesignState = newDesign; + // Restore empty foundation : Assign constructed state to foundation + context.Foundation.DesignState = newDesign; - // Update revision - newDesign.OnRevised(); + // Update revision + newDesign.OnRevised(); - // Update client with new state - context.Foundation.SendInfoTo(state); - newDesign.SendDetailedInfoTo(state); - } + // Update client with new state + context.Foundation.SendInfoTo(state); + newDesign.SendDetailedInfoTo(state); } public static void Designer_Restore(NetState state, IEntity e, EncodedReader pvSrc) @@ -1035,9 +1013,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to restore design to the last backup state + if (context == null) + return; + + /* Client chose to restore design to the last backup state * - Restore backup * - Construct new design state from backup state * - Assign constructed state to foundation @@ -1045,19 +1024,18 @@ namespace Server.Multis * - Update client with new state */ - // Restore backup : Construct new design state from backup state - DesignState backupDesign = new DesignState(context.Foundation.BackupState); + // Restore backup : Construct new design state from backup state + DesignState backupDesign = new DesignState(context.Foundation.BackupState); - // Restore backup : Assign constructed state to foundation - context.Foundation.DesignState = backupDesign; + // Restore backup : Assign constructed state to foundation + context.Foundation.DesignState = backupDesign; - // Update revision; - backupDesign.OnRevised(); + // Update revision; + backupDesign.OnRevised(); - // Update client with new state - context.Foundation.SendInfoTo(state); - backupDesign.SendDetailedInfoTo(state); - } + // Update client with new state + context.Foundation.SendInfoTo(state); + backupDesign.SendDetailedInfoTo(state); } public static void Designer_Backup(NetState state, IEntity e, EncodedReader pvSrc) @@ -1065,19 +1043,19 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to backup design state + if (context == null) + return; + + /* Client chose to backup design state * - Construct a copy of the current design state * - Assign constructed state to backup state field */ - // Construct a copy of the current design state - DesignState copyState = new DesignState(context.Foundation.DesignState); + // Construct a copy of the current design state + DesignState copyState = new DesignState(context.Foundation.DesignState); - // Assign constructed state to backup state field - context.Foundation.BackupState = copyState; - } + // Assign constructed state to backup state field + context.Foundation.BackupState = copyState; } public static void Designer_Revert(NetState state, IEntity e, EncodedReader pvSrc) @@ -1085,9 +1063,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to revert design state to currently visible state + if (context == null) + return; + + /* Client chose to revert design state to currently visible state * - Revert design state * - Construct a copy of the current visible state * - Freeze fixtures in constructed state @@ -1097,25 +1076,24 @@ namespace Server.Multis * - Update client with new state */ - // Revert design state : Construct a copy of the current visible state - DesignState copyState = new DesignState(context.Foundation.CurrentState); + // Revert design state : Construct a copy of the current visible state + DesignState copyState = new DesignState(context.Foundation.CurrentState); - // Revert design state : Freeze fixtures in constructed state - copyState.FreezeFixtures(); + // Revert design state : Freeze fixtures in constructed state + copyState.FreezeFixtures(); - // Revert design state : Assign constructed state to foundation - context.Foundation.DesignState = copyState; + // Revert design state : Assign constructed state to foundation + context.Foundation.DesignState = copyState; - // Revert design state : If a signpost is needed, add it - context.Foundation.CheckSignpost(); + // Revert design state : If a signpost is needed, add it + context.Foundation.CheckSignpost(); - // Update revision - copyState.OnRevised(); + // Update revision + copyState.OnRevised(); - // Update client with new state - context.Foundation.SendInfoTo(state); - copyState.SendDetailedInfoTo(state); - } + // Update client with new state + context.Foundation.SendInfoTo(state); + copyState.SendDetailedInfoTo(state); } public void EndConfirmCommit(Mobile from) @@ -1246,17 +1224,6 @@ namespace Server.Multis level = 1; return (level - 1) * 20 + 7; - - /* - switch( level ) - { - default: - case 1: return 07; - case 2: return 27; - case 3: return 47; - case 4: return 67; - } - * */ } public static int GetZLevel(int z, HouseFoundation house) @@ -1269,21 +1236,10 @@ namespace Server.Multis return level; } - public static bool ValidPiece(int itemID) - { - return ValidPiece(itemID, false); - } - - public static bool ValidPiece(int itemID, bool roof) + public static bool ValidPiece(int itemID, bool roof = false) { itemID &= TileData.MaxItemValue; - - if (!roof && (TileData.ItemTable[itemID].Flags & TileFlag.Roof) != 0) - return false; - if (roof && (TileData.ItemTable[itemID].Flags & TileFlag.Roof) == 0) - return false; - - return Verification.IsItemValid(itemID); + return roof != ((TileData.ItemTable[itemID].Flags & TileFlag.Roof) == 0) && Verification.IsItemValid(itemID); } public static bool IsStairBlock(int id) @@ -1432,9 +1388,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to delete a component + if (context == null) + return; + + /* Client chose to delete a component * - Read data detailing which component to delete * - Verify component is deletable * - Remove the component @@ -1442,66 +1399,65 @@ namespace Server.Multis * - Update revision */ - // Read data detailing which component to delete - int itemID = pvSrc.ReadInt32(); - int x = pvSrc.ReadInt32(); - int y = pvSrc.ReadInt32(); - int z = pvSrc.ReadInt32(); + // Read data detailing which component to delete + int itemID = pvSrc.ReadInt32(); + int x = pvSrc.ReadInt32(); + int y = pvSrc.ReadInt32(); + int z = pvSrc.ReadInt32(); - // Verify component is deletable - DesignState design = context.Foundation.DesignState; - MultiComponentList mcl = design.Components; + // Verify component is deletable + DesignState design = context.Foundation.DesignState; + MultiComponentList mcl = design.Components; - int ax = x + mcl.Center.X; - int ay = y + mcl.Center.Y; + int ax = x + mcl.Center.X; + int ay = y + mcl.Center.Y; - if (z == 0 && ax >= 0 && ax < mcl.Width && ay >= 0 && ay < mcl.Height - 1) - { - /* Component is not deletable + if (z == 0 && ax >= 0 && ax < mcl.Width && ay >= 0 && ay < mcl.Height - 1) + { + /* Component is not deletable * - Resend design state * - Return without further processing */ - design.SendDetailedInfoTo(state); - return; - } - - bool fixState = false; - - // Remove the component - if (AllowStairSectioning) - { - if (DeleteStairs(mcl, itemID, x, y, z)) - fixState = true; // The client removes the entire set of stairs locally, resend state - - mcl.Remove(itemID, x, y, z); - } - else - { - if (!DeleteStairs(mcl, itemID, x, y, z)) - mcl.Remove(itemID, x, y, z); - } - - // If needed, replace removed component with a dirt tile - if (ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1) - { - StaticTile[] tiles = mcl.Tiles[ax][ay]; - - bool hasBaseFloor = false; - - for (int i = 0; !hasBaseFloor && i < tiles.Length; ++i) - hasBaseFloor = tiles[i].Z == 7 && tiles[i].ID != 1; - - if (!hasBaseFloor) mcl.Add(0x31F4, x, y, 7); - } - - // Update revision - design.OnRevised(); - - // Resend design state - if (fixState) - design.SendDetailedInfoTo(state); + design.SendDetailedInfoTo(state); + return; } + + bool fixState = false; + + // Remove the component + if (AllowStairSectioning) + { + if (DeleteStairs(mcl, itemID, x, y, z)) + fixState = true; // The client removes the entire set of stairs locally, resend state + + mcl.Remove(itemID, x, y, z); + } + else + { + if (!DeleteStairs(mcl, itemID, x, y, z)) + mcl.Remove(itemID, x, y, z); + } + + // If needed, replace removed component with a dirt tile + if (ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1) + { + StaticTile[] tiles = mcl.Tiles[ax][ay]; + + bool hasBaseFloor = false; + + for (int i = 0; !hasBaseFloor && i < tiles.Length; ++i) + hasBaseFloor = tiles[i].Z == 7 && tiles[i].ID != 1; + + if (!hasBaseFloor) mcl.Add(0x31F4, x, y, 7); + } + + // Update revision + design.OnRevised(); + + // Resend design state + if (fixState) + design.SendDetailedInfoTo(state); } public static void Designer_Stairs(NetState state, IEntity e, EncodedReader pvSrc) @@ -1509,9 +1465,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to add stairs + if (context == null) + return; + + /* Client chose to add stairs * - Read data detailing stair type and location * - Validate stair multi ID * - Add the stairs @@ -1520,46 +1477,45 @@ namespace Server.Multis * - Update revision */ - // Read data detailing stair type and location - int itemID = pvSrc.ReadInt32(); - int x = pvSrc.ReadInt32(); - int y = pvSrc.ReadInt32(); + // Read data detailing stair type and location + int itemID = pvSrc.ReadInt32(); + int x = pvSrc.ReadInt32(); + int y = pvSrc.ReadInt32(); - // Validate stair multi ID - DesignState design = context.Foundation.DesignState; + // Validate stair multi ID + DesignState design = context.Foundation.DesignState; - if (!Verification.IsMultiValid(itemID)) - { - /* Specified multi ID is not a stair + if (!Verification.IsMultiValid(itemID)) + { + /* Specified multi ID is not a stair * - Resend design state * - Return without further processing */ - TraceValidity(state, itemID); - design.SendDetailedInfoTo(state); - return; - } - - // Add the stairs - MultiComponentList mcl = design.Components; - - // Add the stairs : Load data describing stair components - MultiComponentList stairs = MultiData.GetComponents(itemID); - - // Add the stairs : Insert described components - int z = GetLevelZ(context.Level, context.Foundation); - - for (int i = 0; i < stairs.List.Length; ++i) - { - MultiTileEntry entry = stairs.List[i]; - - if (entry.m_ItemID != 1) - mcl.Add(entry.m_ItemID, x + entry.m_OffsetX, y + entry.m_OffsetY, z + entry.m_OffsetZ); - } - - // Update revision - design.OnRevised(); + TraceValidity(state, itemID); + design.SendDetailedInfoTo(state); + return; } + + // Add the stairs + MultiComponentList mcl = design.Components; + + // Add the stairs : Load data describing stair components + MultiComponentList stairs = MultiData.GetComponents(itemID); + + // Add the stairs : Insert described components + int z = GetLevelZ(context.Level, context.Foundation); + + for (int i = 0; i < stairs.List.Length; ++i) + { + MultiTileEntry entry = stairs.List[i]; + + if (entry.m_ItemID != 1) + mcl.Add(entry.m_ItemID, x + entry.m_OffsetX, y + entry.m_OffsetY, z + entry.m_OffsetZ); + } + + // Update revision + design.OnRevised(); } private static void TraceValidity(NetState state, int itemID) @@ -1582,41 +1538,41 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client chose to add a component + if (context == null) + return; + + /* Client chose to add a component * - Read data detailing component graphic and location * - Add component * - Update revision */ - // Read data detailing component graphic and location - int itemID = pvSrc.ReadInt32(); - int x = pvSrc.ReadInt32(); - int y = pvSrc.ReadInt32(); + // Read data detailing component graphic and location + int itemID = pvSrc.ReadInt32(); + int x = pvSrc.ReadInt32(); + int y = pvSrc.ReadInt32(); - // Add component - DesignState design = context.Foundation.DesignState; + // Add component + DesignState design = context.Foundation.DesignState; - if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID)) - { - TraceValidity(state, itemID); - design.SendDetailedInfoTo(state); - return; - } - - MultiComponentList mcl = design.Components; - - int z = GetLevelZ(context.Level, context.Foundation); - - if (y + mcl.Center.Y == mcl.Height - 1) - z = 0; // Tiles placed on the far-south of the house are at 0 Z - - mcl.Add(itemID, x, y, z); - - // Update revision - design.OnRevised(); + if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID)) + { + TraceValidity(state, itemID); + design.SendDetailedInfoTo(state); + return; } + + MultiComponentList mcl = design.Components; + + int z = GetLevelZ(context.Level, context.Foundation); + + if (y + mcl.Center.Y == mcl.Height - 1) + z = 0; // Tiles placed on the far-south of the house are at 0 Z + + mcl.Add(itemID, x, y, z); + + // Update revision + design.OnRevised(); } public static void Designer_Close(NetState state, IEntity e, EncodedReader pvSrc) @@ -1624,9 +1580,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client closed his house design window + if (context == null) + return; + + /* Client closed his house design window * - Remove design context * - Notify the client that customization has ended * - Refresh client with current visible design state @@ -1635,31 +1592,30 @@ namespace Server.Multis * - Restore relocated entities */ - // Remove design context - DesignContext.Remove(from); + // Remove design context + DesignContext.Remove(from); - // Notify the client that customization has ended - from.Send(new EndHouseCustomization(context.Foundation)); + // Notify the client that customization has ended + from.Send(new EndHouseCustomization(context.Foundation)); - // Refresh client with current visible design state - context.Foundation.SendInfoTo(state); - context.Foundation.CurrentState.SendDetailedInfoTo(state); + // Refresh client with current visible design state + context.Foundation.SendInfoTo(state); + context.Foundation.CurrentState.SendDetailedInfoTo(state); - // If a signpost is needed, add it - context.Foundation.CheckSignpost(); + // If a signpost is needed, add it + context.Foundation.CheckSignpost(); - // Eject all from house - from.RevealingAction(); + // Eject all from house + from.RevealingAction(); - foreach (Item item in context.Foundation.GetItems()) - item.Location = context.Foundation.BanLocation; + foreach (Item item in context.Foundation.GetItems()) + item.Location = context.Foundation.BanLocation; - foreach (Mobile mobile in context.Foundation.GetMobiles()) - mobile.Location = context.Foundation.BanLocation; + foreach (Mobile mobile in context.Foundation.GetMobiles()) + mobile.Location = context.Foundation.BanLocation; - // Restore relocated entities - context.Foundation.RestoreRelocatedEntities(); - } + // Restore relocated entities + context.Foundation.RestoreRelocatedEntities(); } public static void Designer_Level(NetState state, IEntity e, EncodedReader pvSrc) @@ -1667,9 +1623,10 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null) - { - /* Client is moving to a new floor level + if (context == null) + return; + + /* Client is moving to a new floor level * - Read data detailing the target level * - Validate target level * - Update design context with new level @@ -1678,39 +1635,31 @@ namespace Server.Multis * */ - // Read data detailing the target level - int newLevel = pvSrc.ReadInt32(); + // Read data detailing the target level + int newLevel = pvSrc.ReadInt32(); - // Validate target level - if (newLevel < 1 || newLevel > context.MaxLevels) - newLevel = 1; + // Validate target level + if (newLevel < 1 || newLevel > context.MaxLevels) + newLevel = 1; - // Update design context with new level - context.Level = newLevel; + // Update design context with new level + context.Level = newLevel; - // Teleport mobile to new level - from.Location = new Point3D(from.X, from.Y, context.Foundation.Z + GetLevelZ(newLevel, context.Foundation)); + // Teleport mobile to new level + from.Location = new Point3D(from.X, from.Y, context.Foundation.Z + GetLevelZ(newLevel, context.Foundation)); - // Update client - context.Foundation.SendInfoTo(state); - } + // Update client + context.Foundation.SendInfoTo(state); } public static void QueryDesignDetails(NetState state, PacketReader pvSrc) { Mobile from = state.Mobile; - DesignContext context = DesignContext.Find(from); if (World.FindItem(pvSrc.ReadUInt32()) is HouseFoundation foundation && from.Map == foundation.Map && from.InRange(foundation.GetWorldLocation(), 24) && from.CanSee(foundation)) { - DesignState stateToSend; - - if (context != null && context.Foundation == foundation) - stateToSend = foundation.DesignState; - else - stateToSend = foundation.CurrentState; - + DesignState stateToSend = DesignContext.Find(from)?.Foundation == foundation ? foundation.DesignState : foundation.CurrentState; stateToSend.SendDetailedInfoTo(state); } } @@ -1720,46 +1669,46 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null && (Core.SE || from.AccessLevel >= AccessLevel.GameMaster)) + if (context == null || !Core.SE && from.AccessLevel < AccessLevel.GameMaster) + return; + + // Read data detailing component graphic and location + int itemID = pvSrc.ReadInt32(); + int x = pvSrc.ReadInt32(); + int y = pvSrc.ReadInt32(); + int z = pvSrc.ReadInt32(); + + // Add component + DesignState design = context.Foundation.DesignState; + + if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID, true)) { - // Read data detailing component graphic and location - int itemID = pvSrc.ReadInt32(); - int x = pvSrc.ReadInt32(); - int y = pvSrc.ReadInt32(); - int z = pvSrc.ReadInt32(); - - // Add component - DesignState design = context.Foundation.DesignState; - - if (from.AccessLevel < AccessLevel.GameMaster && !ValidPiece(itemID, true)) - { - TraceValidity(state, itemID); - design.SendDetailedInfoTo(state); - return; - } - - MultiComponentList mcl = design.Components; - - if (z < -3 || z > 12 || z % 3 != 0) - z = -3; - z += GetLevelZ(context.Level, context.Foundation); - - MultiTileEntry[] list = mcl.List; - for (int i = 0; i < list.Length; i++) - { - MultiTileEntry mte = list[i]; - - if (mte.m_OffsetX == x && mte.m_OffsetY == y && - GetZLevel(mte.m_OffsetZ, context.Foundation) == context.Level && - (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0) - mcl.Remove(mte.m_ItemID, x, y, mte.m_OffsetZ); - } - - mcl.Add(itemID, x, y, z); - - // Update revision - design.OnRevised(); + TraceValidity(state, itemID); + design.SendDetailedInfoTo(state); + return; } + + MultiComponentList mcl = design.Components; + + if (z < -3 || z > 12 || z % 3 != 0) + z = -3; + z += GetLevelZ(context.Level, context.Foundation); + + MultiTileEntry[] list = mcl.List; + for (int i = 0; i < list.Length; i++) + { + MultiTileEntry mte = list[i]; + + if (mte.m_OffsetX == x && mte.m_OffsetY == y && + GetZLevel(mte.m_OffsetZ, context.Foundation) == context.Level && + (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0) + mcl.Remove(mte.m_ItemID, x, y, mte.m_OffsetZ); + } + + mcl.Add(itemID, x, y, z); + + // Update revision + design.OnRevised(); } public static void Designer_RoofDelete(NetState state, IEntity e, EncodedReader pvSrc) @@ -1767,29 +1716,29 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context != null - ) // No need to check for Core.SE if trying to remove something that shouldn't be able to be placed anyways + // No need to check for Core.SE if trying to remove something that shouldn't be able to be placed anyways + if (context == null) + return; + + // Read data detailing which component to delete + int itemID = pvSrc.ReadInt32(); + int x = pvSrc.ReadInt32(); + int y = pvSrc.ReadInt32(); + int z = pvSrc.ReadInt32(); + + // Verify component is deletable + DesignState design = context.Foundation.DesignState; + MultiComponentList mcl = design.Components; + + if ((TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.Roof) == 0) { - // Read data detailing which component to delete - int itemID = pvSrc.ReadInt32(); - int x = pvSrc.ReadInt32(); - int y = pvSrc.ReadInt32(); - int z = pvSrc.ReadInt32(); - - // Verify component is deletable - DesignState design = context.Foundation.DesignState; - MultiComponentList mcl = design.Components; - - if ((TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.Roof) == 0) - { - design.SendDetailedInfoTo(state); - return; - } - - mcl.Remove(itemID, x, y, z); - - design.OnRevised(); + design.SendDetailedInfoTo(state); + return; } + + mcl.Remove(itemID, x, y, z); + + design.OnRevised(); } } @@ -2022,10 +1971,8 @@ namespace Server.Multis // TOL doors if (itemID >= 0x9AD7 && itemID < 0x9AE7) return true; - if (itemID >= 0x9B3C && itemID < 0x9B4C) - return true; - return false; + return itemID >= 0x9B3C && itemID < 0x9B4C; } } @@ -2048,35 +1995,35 @@ namespace Server.Multis AddAlphaRegion(10, 10, 300, 300); - AddHtmlLocalized(10, 10, 300, 20, 1062060, 32736, false, false); //
COMMIT DESIGN
+ AddHtmlLocalized(10, 10, 300, 20, 1062060, 32736); //
COMMIT DESIGN
AddHtmlLocalized(10, 40, 300, 140, newPrice - oldPrice <= bankBalance ? 1061898 : 1061903, 1023, false, true); - AddHtmlLocalized(10, 190, 150, 20, 1061902, 32736, false, false); // Bank Balance: + AddHtmlLocalized(10, 190, 150, 20, 1061902, 32736); // Bank Balance: AddLabel(170, 190, 55, bankBalance.ToString()); - AddHtmlLocalized(10, 215, 150, 20, 1061899, 1023, false, false); // Old Value: + AddHtmlLocalized(10, 215, 150, 20, 1061899, 1023); // Old Value: AddLabel(170, 215, 90, oldPrice.ToString()); - AddHtmlLocalized(10, 235, 150, 20, 1061900, 1023, false, false); // Cost To Commit: + AddHtmlLocalized(10, 235, 150, 20, 1061900, 1023); // Cost To Commit: AddLabel(170, 235, 90, newPrice.ToString()); if (newPrice - oldPrice < 0) { - AddHtmlLocalized(10, 260, 150, 20, 1062059, 992, false, false); // Your Refund: + AddHtmlLocalized(10, 260, 150, 20, 1062059, 992); // Your Refund: AddLabel(170, 260, 70, (oldPrice - newPrice).ToString()); } else { - AddHtmlLocalized(10, 260, 150, 20, 1061901, 31744, false, false); // Your Cost: + AddHtmlLocalized(10, 260, 150, 20, 1061901, 31744); // Your Cost: AddLabel(170, 260, 40, (newPrice - oldPrice).ToString()); } - AddButton(10, 290, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 290, 55, 20, 1011036, 32767, false, false); // OKAY + AddButton(10, 290, 4005, 4007, 1); + AddHtmlLocalized(45, 290, 55, 20, 1011036, 32767); // OKAY - AddButton(170, 290, 4005, 4007, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(195, 290, 55, 20, 1011012, 32767, false, false); // CANCEL + AddButton(170, 290, 4005, 4007, 0); + AddHtmlLocalized(195, 290, 55, 20, 1011012, 32767); // CANCEL } public override void OnResponse(NetState sender, RelayInfo info) @@ -2114,13 +2061,12 @@ namespace Server.Multis public static bool Check(Mobile m) { - if (Find(m) != null) - { - m.SendLocalizedMessage(1062206); // You cannot do that while customizing a house. - return false; - } + if (Find(m) == null) + return true; + + m.SendLocalizedMessage(1062206); // You cannot do that while customizing a house. + return false; - return true; } public static void Add(Mobile from, HouseFoundation foundation) @@ -2523,7 +2469,7 @@ namespace Server.Multis m_Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 4); } - + public void Write(uint value) { m_PrimBuffer[0] = (byte)(value >> 24); @@ -2617,6 +2563,7 @@ namespace Server.Multis } catch { + // ignored } } finally @@ -2669,4 +2616,4 @@ namespace Server.Multis } } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/HousePlacement.cs b/Scripts/Multis/HousePlacement.cs index 57ea43167..a41b615f4 100644 --- a/Scripts/Multis/HousePlacement.cs +++ b/Scripts/Multis/HousePlacement.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using Server.Regions; using Server.Spells; @@ -325,13 +324,12 @@ namespace Server.Multis { _sectors.Add(sector); - if (sector.Multis != null) - for (int j = 0; j < sector.Multis.Count; j++) - if (sector.Multis[j] is BaseHouse) - { - BaseHouse _house = (BaseHouse)sector.Multis[j]; - if (!_houses.Contains(_house)) _houses.Add(_house); - } + for (int j = 0; j < sector.Multis?.Count; j++) + if (sector.Multis[j] is BaseHouse) + { + BaseHouse _house = (BaseHouse)sector.Multis[j]; + if (!_houses.Contains(_house)) _houses.Add(_house); + } } } diff --git a/Scripts/Multis/HousePlacementTool.cs b/Scripts/Multis/HousePlacementTool.cs index 03546c7de..6c79e252b 100644 --- a/Scripts/Multis/HousePlacementTool.cs +++ b/Scripts/Multis/HousePlacementTool.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Server.Gumps; @@ -72,19 +71,19 @@ namespace Server.Items AddImageTiled(10, 10, 250, 125, 2624); AddAlphaRegion(10, 10, 250, 125); - AddHtmlLocalized(10, 10, 250, 20, 1060239, LabelColor, false, false); //
HOUSE PLACEMENT TOOL
+ AddHtmlLocalized(10, 10, 250, 20, 1060239, LabelColor); //
HOUSE PLACEMENT TOOL
- AddButton(10, 110, 4017, 4019, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 110, 150, 20, 3000363, LabelColor, false, false); // Close + AddButton(10, 110, 4017, 4019, 0); + AddHtmlLocalized(45, 110, 150, 20, 3000363, LabelColor); // Close - AddButton(10, 40, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 40, 200, 20, 1060390, LabelColor, false, false); // Classic Houses + AddButton(10, 40, 4005, 4007, 1); + AddHtmlLocalized(45, 40, 200, 20, 1060390, LabelColor); // Classic Houses - AddButton(10, 60, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 60, 200, 20, 1060391, LabelColor, false, false); // 2-Story Customizable Houses + AddButton(10, 60, 4005, 4007, 2); + AddHtmlLocalized(45, 60, 200, 20, 1060391, LabelColor); // 2-Story Customizable Houses - AddButton(10, 80, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 80, 200, 20, 1060392, LabelColor, false, false); // 3-Story Customizable Houses + AddButton(10, 80, 4005, 4007, 3); + AddHtmlLocalized(45, 80, 200, 20, 1060392, LabelColor); // 3-Story Customizable Houses } public override void OnResponse(NetState sender, RelayInfo info) @@ -135,15 +134,15 @@ namespace Server.Items AddImageTiled(10, 10, 500, 20, 2624); AddAlphaRegion(10, 10, 500, 20); - AddHtmlLocalized(10, 10, 500, 20, 1060239, LabelColor, false, false); //
HOUSE PLACEMENT TOOL
+ AddHtmlLocalized(10, 10, 500, 20, 1060239, LabelColor); //
HOUSE PLACEMENT TOOL
AddImageTiled(10, 40, 500, 20, 2624); AddAlphaRegion(10, 40, 500, 20); - AddHtmlLocalized(50, 40, 225, 20, 1060235, LabelColor, false, false); // House Description - AddHtmlLocalized(275, 40, 75, 20, 1060236, LabelColor, false, false); // Storage - AddHtmlLocalized(350, 40, 75, 20, 1060237, LabelColor, false, false); // Lockdowns - AddHtmlLocalized(425, 40, 75, 20, 1060034, LabelColor, false, false); // Cost + AddHtmlLocalized(50, 40, 225, 20, 1060235, LabelColor); // House Description + AddHtmlLocalized(275, 40, 75, 20, 1060236, LabelColor); // Storage + AddHtmlLocalized(350, 40, 75, 20, 1060237, LabelColor); // Lockdowns + AddHtmlLocalized(425, 40, 75, 20, 1060034, LabelColor); // Cost AddImageTiled(10, 70, 500, 280, 2624); AddAlphaRegion(10, 70, 500, 280); @@ -151,14 +150,14 @@ namespace Server.Items AddImageTiled(10, 360, 500, 20, 2624); AddAlphaRegion(10, 360, 500, 20); - AddHtmlLocalized(10, 360, 250, 20, 1060645, LabelColor, false, false); // Bank Balance: + AddHtmlLocalized(10, 360, 250, 20, 1060645, LabelColor); // Bank Balance: AddLabel(250, 360, LabelHue, Banker.GetBalance(from).ToString()); AddImageTiled(10, 390, 500, 20, 2624); AddAlphaRegion(10, 390, 500, 20); - AddButton(10, 390, 4017, 4019, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, 390, 100, 20, 3000363, LabelColor, false, false); // Close + AddButton(10, 390, 4017, 4019, 0); + AddHtmlLocalized(50, 390, 100, 20, 3000363, LabelColor); // Close for (int i = 0; i < entries.Length; ++i) { @@ -170,7 +169,7 @@ namespace Server.Items if (page > 1) { AddButton(450, 390, 4005, 4007, 0, GumpButtonType.Page, page); - AddHtmlLocalized(400, 390, 100, 20, 3000406, LabelColor, false, false); // Next + AddHtmlLocalized(400, 390, 100, 20, 3000406, LabelColor); // Next } AddPage(page); @@ -178,7 +177,7 @@ namespace Server.Items if (page > 1) { AddButton(200, 390, 4014, 4016, 0, GumpButtonType.Page, page - 1); - AddHtmlLocalized(250, 390, 100, 20, 3000405, LabelColor, false, false); // Previous + AddHtmlLocalized(250, 390, 100, 20, 3000405, LabelColor); // Previous } } @@ -186,8 +185,8 @@ namespace Server.Items int y = 70 + index * 20; - AddButton(10, y, 4005, 4007, 1 + i, GumpButtonType.Reply, 0); - AddHtmlLocalized(50, y, 225, 20, entry.Description, LabelColor, false, false); + AddButton(10, y, 4005, 4007, 1 + i); + AddHtmlLocalized(50, y, 225, 20, entry.Description, LabelColor); AddLabel(275, y, LabelHue, entry.Storage.ToString()); AddLabel(350, y, LabelHue, entry.Lockdowns.ToString()); AddLabel(425, y, LabelHue, entry.Cost.ToString()); @@ -809,9 +808,7 @@ namespace Server.Items return entry; if (obj is List list) - { return list.FirstOrDefault(e => e.MultiID == house.ItemID); - } if (obj is Dictionary table) return table[house.ItemID]; diff --git a/Scripts/Multis/HouseSign.cs b/Scripts/Multis/HouseSign.cs index 2e2530869..54d043419 100644 --- a/Scripts/Multis/HouseSign.cs +++ b/Scripts/Multis/HouseSign.cs @@ -23,10 +23,11 @@ namespace Server.Multis [CommandProperty(AccessLevel.GameMaster)] public bool RestrictDecay { - get => Owner != null && Owner.RestrictDecay; + get => Owner?.RestrictDecay == true; set { - if (Owner != null) Owner.RestrictDecay = value; + if (Owner != null) + Owner.RestrictDecay = value; } } @@ -39,17 +40,14 @@ namespace Server.Multis public string GetName() { - if (Name == null) - return "An Unnamed House"; - - return Name; + return Name ?? "An Unnamed House"; } public override void OnAfterDelete() { base.OnAfterDelete(); - if (Owner != null && !Owner.Deleted) + if (Owner?.Deleted == false) Owner.Delete(); } @@ -152,12 +150,7 @@ namespace Server.Multis { if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending) { - bool canClaim; - - if (Owner.CoOwners == null || Owner.CoOwners.Count == 0) - canClaim = Owner.IsFriend(from); - else - canClaim = Owner.IsCoOwner(from); + bool canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from); if (canClaim && !BaseHouse.HasAccountHouse(from)) { @@ -177,12 +170,7 @@ namespace Server.Multis if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending) { - bool canClaim = false; - - if (Owner.CoOwners == null || Owner.CoOwners.Count == 0) - canClaim = Owner.IsFriend(m); - else - canClaim = Owner.IsCoOwner(m); + bool 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))); @@ -195,14 +183,14 @@ namespace Server.Multis { base.GetContextMenuEntries(from, list); - if (BaseHouse.NewVendorSystem && from.Alive && Owner != null && Owner.IsAosRules) - { - if (Owner.AreThereAvailableVendorsFor(from)) - list.Add(new VendorsEntry(this)); + if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true) + return; - if (Owner.VendorInventories.Count > 0) - list.Add(new ReclaimVendorInventoryEntry(this)); - } + if (Owner.AreThereAvailableVendorsFor(from)) + list.Add(new VendorsEntry(this)); + + if (Owner.VendorInventories.Count > 0) + list.Add(new ReclaimVendorInventoryEntry(this)); } public override void Serialize(GenericWriter writer) @@ -291,4 +279,4 @@ namespace Server.Multis } } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/HouseTeleporter.cs b/Scripts/Multis/HouseTeleporter.cs index 480048833..7e451ed36 100644 --- a/Scripts/Multis/HouseTeleporter.cs +++ b/Scripts/Multis/HouseTeleporter.cs @@ -9,12 +9,7 @@ namespace Server.Items { public class HouseTeleporter : Item, ISecurable { - [Constructible] - public HouseTeleporter(int itemID) : this(itemID, null) - { - } - - public HouseTeleporter(int itemID, Item target) : base(itemID) + public HouseTeleporter(int itemID, Item target = null) : base(itemID) { Movable = false; @@ -37,15 +32,13 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(this); - if (house != null && (house.Public ? house.IsBanned(m) : !house.HasAccess(m))) - return false; - - return house != null && house.HasSecureAccess(m, Level); + return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) && + house?.HasSecureAccess(m, Level) == true; } public override bool OnMoveOver(Mobile m) { - if (Target != null && !Target.Deleted) + if (Target?.Deleted == false) { if (CheckAccess(m)) { @@ -145,35 +138,35 @@ namespace Server.Items { Item target = m_Teleporter.Target; - if (target != null && !target.Deleted) - { - Mobile m = m_Mobile; + if (target?.Deleted != false) + return; - if (m.Location == m_Teleporter.Location && m.Map == m_Teleporter.Map) - { - Point3D p = target.GetWorldTop(); - Map map = target.Map; + Mobile m = m_Mobile; - BaseCreature.TeleportPets(m, p, map); + if (m.Location != m_Teleporter.Location || m.Map != m_Teleporter.Map) + return; - m.MoveToWorld(p, map); + Point3D p = target.GetWorldTop(); + Map map = target.Map; - if (!m.Hidden || m.AccessLevel == AccessLevel.Player) - { - Effects.PlaySound(target.Location, target.Map, 0x1FE); + BaseCreature.TeleportPets(m, p, map); - Effects.SendLocationParticles( - EffectItem.Create(m_Teleporter.Location, m_Teleporter.Map, EffectItem.DefaultDuration), - 0x3728, 10, 10, 2023, 0); - Effects.SendLocationParticles( - EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, - 5023, 0); + m.MoveToWorld(p, map); - new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start(); - } - } - } + if (m.Hidden && m.AccessLevel != AccessLevel.Player) + return; + + Effects.PlaySound(target.Location, target.Map, 0x1FE); + + Effects.SendLocationParticles( + EffectItem.Create(m_Teleporter.Location, m_Teleporter.Map, EffectItem.DefaultDuration), + 0x3728, 10, 10, 2023, 0); + Effects.SendLocationParticles( + EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, + 5023, 0); + + new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start(); } } } -} \ No newline at end of file +} diff --git a/Scripts/Multis/MovingCrate.cs b/Scripts/Multis/MovingCrate.cs index 4888017bf..1dd344de8 100644 --- a/Scripts/Multis/MovingCrate.cs +++ b/Scripts/Multis/MovingCrate.cs @@ -141,12 +141,12 @@ namespace Server.Multis public override bool CheckLift(Mobile from, Item item, ref LRReason reject) { - return base.CheckLift(from, item, ref reject) && House != null && !House.Deleted && House.IsOwner(from); + return House?.Deleted == false && base.CheckLift(from, item, ref reject) && House.IsOwner(from); } public override bool CheckItemUse(Mobile from, Item item) { - return base.CheckItemUse(from, item) && House != null && !House.Deleted && House.IsOwner(from); + return House?.Deleted == false && base.CheckItemUse(from, item) && House.IsOwner(from); } public override void OnItemRemoved(Item item) @@ -197,7 +197,7 @@ namespace Server.Multis { base.OnAfterDelete(); - if (House != null && House.MovingCrate == this) + if (House?.MovingCrate == this) House.MovingCrate = null; m_InternalizeTimer?.Stop(); @@ -311,4 +311,4 @@ namespace Server.Multis MaxItems = -1; // reset to default } } -} \ No newline at end of file +} diff --git a/Scripts/Regions/GuardedRegion.cs b/Scripts/Regions/GuardedRegion.cs index 7334a55b3..7d7f830e8 100644 --- a/Scripts/Regions/GuardedRegion.cs +++ b/Scripts/Regions/GuardedRegion.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Xml; using Server.Commands; using Server.Mobiles; @@ -171,15 +172,8 @@ namespace Server.Regions public override void MakeGuard(Mobile focus) { - BaseGuard useGuard = null; - IPooledEnumerable eable = focus.GetMobilesInRange(8); - foreach (BaseGuard m in eable) - if (m.Focus == null) // idling - { - useGuard = m; - break; - } + BaseGuard useGuard = eable.FirstOrDefault(m => m.Focus == null); eable.Free(); @@ -193,6 +187,7 @@ namespace Server.Regions } catch { + // ignored } } else @@ -212,7 +207,7 @@ namespace Server.Regions public override void OnExit(Mobile m) { - if (IsDisabled()) +// if (IsDisabled()) return; } diff --git a/Scripts/Regions/HouseRegion.cs b/Scripts/Regions/HouseRegion.cs index 964c8ab5c..c2e61787d 100644 --- a/Scripts/Regions/HouseRegion.cs +++ b/Scripts/Regions/HouseRegion.cs @@ -34,7 +34,7 @@ namespace Server.Regions { BaseHouse house = BaseHouse.FindHouseAt(e.Mobile); - if (house != null && !house.Public && !house.IsFriend(e.Mobile)) + if (house?.Public == false && !house.IsFriend(e.Mobile)) e.Mobile.Location = house.BanLocation; } @@ -47,7 +47,7 @@ namespace Server.Regions { int x = house.X; int y = house.Y; - int z = house.Z; + // int z = house.Z; Rectangle2D[] houseArea = house.Area; Rectangle3D[] area = new Rectangle3D[houseArea.Length]; @@ -372,4 +372,4 @@ namespace Server.Regions return base.OnSingleClick(from, o); } } -} \ No newline at end of file +} diff --git a/Scripts/Regions/Spawning/SpawnDefinition.cs b/Scripts/Regions/Spawning/SpawnDefinition.cs index 972e1e3f2..f25556d41 100644 --- a/Scripts/Regions/Spawning/SpawnDefinition.cs +++ b/Scripts/Regions/Spawning/SpawnDefinition.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Xml; diff --git a/Scripts/Regions/Spawning/SpawnEntry.cs b/Scripts/Regions/Spawning/SpawnEntry.cs index ca82a9329..5c1d06729 100644 --- a/Scripts/Regions/Spawning/SpawnEntry.cs +++ b/Scripts/Regions/Spawning/SpawnEntry.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Commands; using Server.Mobiles; diff --git a/Scripts/Regions/Spawning/SpawnPersistence.cs b/Scripts/Regions/Spawning/SpawnPersistence.cs index a4a5f8647..ab85b19ba 100644 --- a/Scripts/Regions/Spawning/SpawnPersistence.cs +++ b/Scripts/Regions/Spawning/SpawnPersistence.cs @@ -51,7 +51,7 @@ namespace Server.Regions { int id = reader.ReadInt(); - SpawnEntry entry = (SpawnEntry)SpawnEntry.Table[id]; + SpawnEntry entry = SpawnEntry.Table[id]; if (entry != null) entry.Deserialize(reader, version); diff --git a/Scripts/Scripts.csproj b/Scripts/Scripts.csproj index 123a83fc2..b68d69801 100644 --- a/Scripts/Scripts.csproj +++ b/Scripts/Scripts.csproj @@ -134,6 +134,7 @@ + @@ -148,7 +149,6 @@ - @@ -156,7 +156,7 @@ - + @@ -3269,6 +3269,12 @@ + + + + + + diff --git a/Scripts/Skills/AnimalLore.cs b/Scripts/Skills/AnimalLore.cs index 3ff603655..08a45b97b 100644 --- a/Scripts/Skills/AnimalLore.cs +++ b/Scripts/Skills/AnimalLore.cs @@ -92,9 +92,9 @@ namespace Server.SkillHandlers AddImage(118, 277, 2081); AddImage(118, 347, 2083); - AddHtml(147, 108, 210, 18, $"
{c.Name}
", false, false); + AddHtml(147, 108, 210, 18, $"
{c.Name}
"); - AddButton(240, 77, 2093, 2093, 2, GumpButtonType.Reply, 0); + AddButton(240, 77, 2093, 2093, 2); AddImage(140, 138, 2091); AddImage(140, 335, 2091); @@ -108,25 +108,25 @@ namespace Server.SkillHandlers AddPage(++page); AddImage(128, 152, 2086); - AddHtmlLocalized(147, 150, 160, 18, 1049593, 200, false, false); // Attributes + AddHtmlLocalized(147, 150, 160, 18, 1049593, 200); // Attributes - AddHtmlLocalized(153, 168, 160, 18, 1049578, LabelColor, false, false); // Hits - AddHtml(280, 168, 75, 18, FormatAttributes(c.Hits, c.HitsMax), false, false); + AddHtmlLocalized(153, 168, 160, 18, 1049578, LabelColor); // Hits + AddHtml(280, 168, 75, 18, FormatAttributes(c.Hits, c.HitsMax)); - AddHtmlLocalized(153, 186, 160, 18, 1049579, LabelColor, false, false); // Stamina - AddHtml(280, 186, 75, 18, FormatAttributes(c.Stam, c.StamMax), false, false); + AddHtmlLocalized(153, 186, 160, 18, 1049579, LabelColor); // Stamina + AddHtml(280, 186, 75, 18, FormatAttributes(c.Stam, c.StamMax)); - AddHtmlLocalized(153, 204, 160, 18, 1049580, LabelColor, false, false); // Mana - AddHtml(280, 204, 75, 18, FormatAttributes(c.Mana, c.ManaMax), false, false); + AddHtmlLocalized(153, 204, 160, 18, 1049580, LabelColor); // Mana + AddHtml(280, 204, 75, 18, FormatAttributes(c.Mana, c.ManaMax)); - AddHtmlLocalized(153, 222, 160, 18, 1028335, LabelColor, false, false); // Strength - AddHtml(320, 222, 35, 18, FormatStat(c.Str), false, false); + AddHtmlLocalized(153, 222, 160, 18, 1028335, LabelColor); // Strength + AddHtml(320, 222, 35, 18, FormatStat(c.Str)); - AddHtmlLocalized(153, 240, 160, 18, 3000113, LabelColor, false, false); // Dexterity - AddHtml(320, 240, 35, 18, FormatStat(c.Dex), false, false); + AddHtmlLocalized(153, 240, 160, 18, 3000113, LabelColor); // Dexterity + AddHtml(320, 240, 35, 18, FormatStat(c.Dex)); - AddHtmlLocalized(153, 258, 160, 18, 3000112, LabelColor, false, false); // Intelligence - AddHtml(320, 258, 35, 18, FormatStat(c.Int), false, false); + AddHtmlLocalized(153, 258, 160, 18, 3000112, LabelColor); // Intelligence + AddHtml(320, 258, 35, 18, FormatStat(c.Int)); if (Core.AOS) { @@ -138,26 +138,26 @@ namespace Server.SkillHandlers if (c.Uncalmable) bd = 0; - AddHtmlLocalized(153, 276, 160, 18, 1070793, LabelColor, false, false); // Barding Difficulty - AddHtml(320, y, 35, 18, FormatDouble(bd), false, false); + AddHtmlLocalized(153, 276, 160, 18, 1070793, LabelColor); // Barding Difficulty + AddHtml(320, y, 35, 18, FormatDouble(bd)); y += 18; } AddImage(128, y + 2, 2086); - AddHtmlLocalized(147, y, 160, 18, 1049594, 200, false, false); // Loyalty Rating + AddHtmlLocalized(147, y, 160, 18, 1049594, 200); // Loyalty Rating y += 18; AddHtmlLocalized(153, y, 160, 18, !c.Controlled || c.Loyalty == 0 ? 1061643 : 1049595 + c.Loyalty / 10, - LabelColor, false, false); + LabelColor); } else { AddImage(128, 278, 2086); - AddHtmlLocalized(147, 276, 160, 18, 3001016, 200, false, false); // Miscellaneous + AddHtmlLocalized(147, 276, 160, 18, 3001016, 200); // Miscellaneous - AddHtmlLocalized(153, 294, 160, 18, 1049581, LabelColor, false, false); // Armor Rating - AddHtml(320, 294, 35, 18, FormatStat(c.VirtualArmor), false, false); + AddHtmlLocalized(153, 294, 160, 18, 1049581, LabelColor); // Armor Rating + AddHtml(320, 294, 35, 18, FormatStat(c.VirtualArmor)); } AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1); @@ -172,22 +172,22 @@ namespace Server.SkillHandlers AddPage(++page); AddImage(128, 152, 2086); - AddHtmlLocalized(147, 150, 160, 18, 1061645, 200, false, false); // Resistances + AddHtmlLocalized(147, 150, 160, 18, 1061645, 200); // Resistances - AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor, false, false); // Physical - AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalResistance), false, false); + AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor); // Physical + AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalResistance)); - AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor, false, false); // Fire - AddHtml(320, 186, 35, 18, FormatElement(c.FireResistance), false, false); + AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor); // Fire + AddHtml(320, 186, 35, 18, FormatElement(c.FireResistance)); - AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor, false, false); // Cold - AddHtml(320, 204, 35, 18, FormatElement(c.ColdResistance), false, false); + AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor); // Cold + AddHtml(320, 204, 35, 18, FormatElement(c.ColdResistance)); - AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor, false, false); // Poison - AddHtml(320, 222, 35, 18, FormatElement(c.PoisonResistance), false, false); + AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor); // Poison + AddHtml(320, 222, 35, 18, FormatElement(c.PoisonResistance)); - AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor, false, false); // Energy - AddHtml(320, 240, 35, 18, FormatElement(c.EnergyResistance), false, false); + AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor); // Energy + AddHtml(320, 240, 35, 18, FormatElement(c.EnergyResistance)); AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1); AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1); @@ -202,29 +202,29 @@ namespace Server.SkillHandlers AddPage(++page); AddImage(128, 152, 2086); - AddHtmlLocalized(147, 150, 160, 18, 1017319, 200, false, false); // Damage + AddHtmlLocalized(147, 150, 160, 18, 1017319, 200); // Damage - AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor, false, false); // Physical - AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalDamage), false, false); + AddHtmlLocalized(153, 168, 160, 18, 1061646, LabelColor); // Physical + AddHtml(320, 168, 35, 18, FormatElement(c.PhysicalDamage)); - AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor, false, false); // Fire - AddHtml(320, 186, 35, 18, FormatElement(c.FireDamage), false, false); + AddHtmlLocalized(153, 186, 160, 18, 1061647, LabelColor); // Fire + AddHtml(320, 186, 35, 18, FormatElement(c.FireDamage)); - AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor, false, false); // Cold - AddHtml(320, 204, 35, 18, FormatElement(c.ColdDamage), false, false); + AddHtmlLocalized(153, 204, 160, 18, 1061648, LabelColor); // Cold + AddHtml(320, 204, 35, 18, FormatElement(c.ColdDamage)); - AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor, false, false); // Poison - AddHtml(320, 222, 35, 18, FormatElement(c.PoisonDamage), false, false); + AddHtmlLocalized(153, 222, 160, 18, 1061649, LabelColor); // Poison + AddHtml(320, 222, 35, 18, FormatElement(c.PoisonDamage)); - AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor, false, false); // Energy - AddHtml(320, 240, 35, 18, FormatElement(c.EnergyDamage), false, false); + AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor); // Energy + AddHtml(320, 240, 35, 18, FormatElement(c.EnergyDamage)); #region Mondain's Legacy if (Core.ML) { - AddHtmlLocalized(153, 258, 160, 18, 1076750, LabelColor, false, false); // Base Damage - AddHtml(300, 258, 55, 18, FormatDamage(c.DamageMin, c.DamageMax), false, false); + AddHtmlLocalized(153, 258, 160, 18, 1076750, LabelColor); // Base Damage + AddHtml(300, 258, 55, 18, FormatDamage(c.DamageMin, c.DamageMax)); } #endregion @@ -240,46 +240,46 @@ namespace Server.SkillHandlers AddPage(++page); AddImage(128, 152, 2086); - AddHtmlLocalized(147, 150, 160, 18, 3001030, 200, false, false); // Combat Ratings + AddHtmlLocalized(147, 150, 160, 18, 3001030, 200); // Combat Ratings - AddHtmlLocalized(153, 168, 160, 18, 1044103, LabelColor, false, false); // Wrestling - AddHtml(320, 168, 35, 18, FormatSkill(c, SkillName.Wrestling), false, false); + AddHtmlLocalized(153, 168, 160, 18, 1044103, LabelColor); // Wrestling + AddHtml(320, 168, 35, 18, FormatSkill(c, SkillName.Wrestling)); - AddHtmlLocalized(153, 186, 160, 18, 1044087, LabelColor, false, false); // Tactics - AddHtml(320, 186, 35, 18, FormatSkill(c, SkillName.Tactics), false, false); + AddHtmlLocalized(153, 186, 160, 18, 1044087, LabelColor); // Tactics + AddHtml(320, 186, 35, 18, FormatSkill(c, SkillName.Tactics)); - AddHtmlLocalized(153, 204, 160, 18, 1044086, LabelColor, false, false); // Magic Resistance - AddHtml(320, 204, 35, 18, FormatSkill(c, SkillName.MagicResist), false, false); + AddHtmlLocalized(153, 204, 160, 18, 1044086, LabelColor); // Magic Resistance + AddHtml(320, 204, 35, 18, FormatSkill(c, SkillName.MagicResist)); - AddHtmlLocalized(153, 222, 160, 18, 1044061, LabelColor, false, false); // Anatomy - AddHtml(320, 222, 35, 18, FormatSkill(c, SkillName.Anatomy), false, false); + AddHtmlLocalized(153, 222, 160, 18, 1044061, LabelColor); // Anatomy + AddHtml(320, 222, 35, 18, FormatSkill(c, SkillName.Anatomy)); #region Mondain's Legacy if (c is CuSidhe) { - AddHtmlLocalized(153, 240, 160, 18, 1044077, LabelColor, false, false); // Healing - AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Healing), false, false); + AddHtmlLocalized(153, 240, 160, 18, 1044077, LabelColor); // Healing + AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Healing)); } else { - AddHtmlLocalized(153, 240, 160, 18, 1044090, LabelColor, false, false); // Poisoning - AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Poisoning), false, false); + AddHtmlLocalized(153, 240, 160, 18, 1044090, LabelColor); // Poisoning + AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Poisoning)); } #endregion AddImage(128, 260, 2086); - AddHtmlLocalized(147, 258, 160, 18, 3001032, 200, false, false); // Lore & Knowledge + AddHtmlLocalized(147, 258, 160, 18, 3001032, 200); // Lore & Knowledge - AddHtmlLocalized(153, 276, 160, 18, 1044085, LabelColor, false, false); // Magery - AddHtml(320, 276, 35, 18, FormatSkill(c, SkillName.Magery), false, false); + AddHtmlLocalized(153, 276, 160, 18, 1044085, LabelColor); // Magery + AddHtml(320, 276, 35, 18, FormatSkill(c, SkillName.Magery)); - AddHtmlLocalized(153, 294, 160, 18, 1044076, LabelColor, false, false); // Evaluating Intelligence - AddHtml(320, 294, 35, 18, FormatSkill(c, SkillName.EvalInt), false, false); + AddHtmlLocalized(153, 294, 160, 18, 1044076, LabelColor); // Evaluating Intelligence + AddHtml(320, 294, 35, 18, FormatSkill(c, SkillName.EvalInt)); - AddHtmlLocalized(153, 312, 160, 18, 1044106, LabelColor, false, false); // Meditation - AddHtml(320, 312, 35, 18, FormatSkill(c, SkillName.Meditation), false, false); + AddHtmlLocalized(153, 312, 160, 18, 1044106, LabelColor); // Meditation + AddHtml(320, 312, 35, 18, FormatSkill(c, SkillName.Meditation)); AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1); AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1); @@ -291,7 +291,7 @@ namespace Server.SkillHandlers AddPage(++page); AddImage(128, 152, 2086); - AddHtmlLocalized(147, 150, 160, 18, 1049563, 200, false, false); // Preferred Foods + AddHtmlLocalized(147, 150, 160, 18, 1049563, 200); // Preferred Foods int foodPref = 3000340; @@ -306,10 +306,10 @@ namespace Server.SkillHandlers else if ((c.FavoriteFood & FoodType.Eggs) != 0) foodPref = 1044477; // Eggs - AddHtmlLocalized(153, 168, 160, 18, foodPref, LabelColor, false, false); + AddHtmlLocalized(153, 168, 160, 18, foodPref, LabelColor); AddImage(128, 188, 2086); - AddHtmlLocalized(147, 186, 160, 18, 1049569, 200, false, false); // Pack Instincts + AddHtmlLocalized(147, 186, 160, 18, 1049569, 200); // Pack Instincts int packInstinct = 3000340; @@ -330,15 +330,15 @@ namespace Server.SkillHandlers else if ((c.PackInstinct & PackInstinct.Bull) != 0) packInstinct = 1049577; // Bull - AddHtmlLocalized(153, 204, 160, 18, packInstinct, LabelColor, false, false); + AddHtmlLocalized(153, 204, 160, 18, packInstinct, LabelColor); if (!Core.AOS) { AddImage(128, 224, 2086); - AddHtmlLocalized(147, 222, 160, 18, 1049594, 200, false, false); // Loyalty Rating + AddHtmlLocalized(147, 222, 160, 18, 1049594, 200); // Loyalty Rating AddHtmlLocalized(153, 240, 160, 18, !c.Controlled || c.Loyalty == 0 ? 1061643 : 1049595 + c.Loyalty / 10, - LabelColor, false, false); + LabelColor); } AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, 1); @@ -401,4 +401,4 @@ namespace Server.SkillHandlers #endregion } -} \ No newline at end of file +} diff --git a/Scripts/Skills/AnimalTaming.cs b/Scripts/Skills/AnimalTaming.cs index a6a9782f7..85b3e9799 100644 --- a/Scripts/Skills/AnimalTaming.cs +++ b/Scripts/Skills/AnimalTaming.cs @@ -44,8 +44,7 @@ namespace Server.SkillHandlers public static bool MustBeSubdued(BaseCreature bc) { - if (bc.Owners.Count > 0) return false; - return bc.SubdueBeforeTame && bc.Hits > bc.HitsMax / 10; + return bc.Owners.Count <= 0 && bc.SubdueBeforeTame && bc.Hits > bc.HitsMax / 10; } public static void ScaleStats(BaseCreature bc, double scalar) @@ -316,7 +315,7 @@ namespace Server.SkillHandlers m_Tamer.NetState); // You must subdue this creature before you can tame it! Stop(); } - else if (de != null && de.LastDamage > m_StartTime) + else if (de?.LastDamage > m_StartTime) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; @@ -418,14 +417,8 @@ namespace Server.SkillHandlers { IPoint3D p = m_Tamer; - if (p == null) - return false; - - if (m_Creature.InRange(new Point3D(p), 1)) - return true; - - MovementPath path = new MovementPath(m_Creature, new Point3D(p)); - return path.Success; + return p != null && (m_Creature.InRange(new Point3D(p), 1) || + new MovementPath(m_Creature, new Point3D(p)).Success); } } } diff --git a/Scripts/Skills/DetectHidden.cs b/Scripts/Skills/DetectHidden.cs index 51e840bd8..86b51183e 100644 --- a/Scripts/Skills/DetectHidden.cs +++ b/Scripts/Skills/DetectHidden.cs @@ -49,7 +49,7 @@ namespace Server.SkillHandlers BaseHouse house = BaseHouse.FindHouseAt(p, src.Map, 16); - bool inHouse = house != null && house.IsFriend(src); + bool inHouse = house?.IsFriend(src) == true; if (inHouse) range = 22; @@ -103,4 +103,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Scripts/Skills/Discordance.cs b/Scripts/Skills/Discordance.cs index b92eb30e9..3ace537e9 100644 --- a/Scripts/Skills/Discordance.cs +++ b/Scripts/Skills/Discordance.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; using Server.Mobiles; diff --git a/Scripts/Skills/Hiding.cs b/Scripts/Skills/Hiding.cs index 65f4ffdbb..ae64766c5 100644 --- a/Scripts/Skills/Hiding.cs +++ b/Scripts/Skills/Hiding.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Server.Multis; using Server.Network; using Server.Targeting; @@ -28,23 +29,17 @@ namespace Server.SkillHandlers BaseHouse house = BaseHouse.FindHouseAt(m); - if (house != null && house.IsFriend(m)) + if (house?.IsFriend(m) == true) { bonus = 100.0; } else if (!Core.AOS) { if (house == null) - house = BaseHouse.FindHouseAt(new Point3D(m.X - 1, m.Y, 127), m.Map, 16); - - if (house == null) - house = BaseHouse.FindHouseAt(new Point3D(m.X + 1, m.Y, 127), m.Map, 16); - - if (house == null) - house = BaseHouse.FindHouseAt(new Point3D(m.X, m.Y - 1, 127), m.Map, 16); - - if (house == null) - house = BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16); + house = BaseHouse.FindHouseAt(new Point3D(m.X - 1, m.Y, 127), m.Map, 16) ?? + BaseHouse.FindHouseAt(new Point3D(m.X + 1, m.Y, 127), m.Map, 16) ?? + BaseHouse.FindHouseAt(new Point3D(m.X, m.Y - 1, 127), m.Map, 16) ?? + BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16); if (house != null) bonus = 50.0; @@ -61,13 +56,10 @@ namespace Server.SkillHandlers if (ok) { if (!CombatOverride) - foreach (Mobile check in m.GetMobilesInRange(range)) - if (check.InLOS(m) && check.Combatant == m) - { - badCombat = true; - ok = false; - break; - } + if (m.GetMobilesInRange(range).Any(check => check.InLOS(m) && check.Combatant == m)) + { + badCombat = true; + } ok = !badCombat && m.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus); } @@ -97,4 +89,4 @@ namespace Server.SkillHandlers return TimeSpan.FromSeconds(10.0); } } -} \ No newline at end of file +} diff --git a/Scripts/Skills/Inscribe.cs b/Scripts/Skills/Inscribe.cs index 61d7aaf87..66d628b44 100644 --- a/Scripts/Skills/Inscribe.cs +++ b/Scripts/Skills/Inscribe.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Items; using Server.Targeting; @@ -42,11 +43,7 @@ namespace Server.SkillHandlers public static bool IsEmpty(BaseBook book) { - foreach (BookPageInfo page in book.Pages) - foreach (string line in page.Lines) - if (line.Trim().Length != 0) - return false; - return true; + return book.Pages.SelectMany(page => page.Lines).All(line => line.Trim().Length == 0); } public static void Copy(BaseBook bookSrc, BaseBook bookDst) diff --git a/Scripts/Skills/RemoveTrap.cs b/Scripts/Skills/RemoveTrap.cs index 32fe79a19..9b9bd3dbc 100644 --- a/Scripts/Skills/RemoveTrap.cs +++ b/Scripts/Skills/RemoveTrap.cs @@ -81,7 +81,7 @@ namespace Server.SkillHandlers from.SendLocalizedMessage( 1010538); // You may not disarm faction traps unless you are in an opposing faction } - else if (faction == trap.Faction && trap.Faction != null && !isOwner) + else if (trap.Faction != null && faction == trap.Faction && !isOwner) { from.SendLocalizedMessage(1010537); // You may not disarm traps set by your own faction! } @@ -126,4 +126,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Scripts/Skills/Snooping.cs b/Scripts/Skills/Snooping.cs index dbd0cb721..f245ecad5 100644 --- a/Scripts/Skills/Snooping.cs +++ b/Scripts/Skills/Snooping.cs @@ -20,18 +20,15 @@ namespace Server.SkillHandlers if (to.Player) return from.CanBeHarmful(to, false, true); // normal restrictions - if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0) + if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) return true; // felucca you can snoop anybody GuardedRegion reg = to.Region.GetRegion(); - if (reg == null || reg.IsDisabled()) + if (reg?.IsDisabled() != true) return true; // not in town? we can snoop any npc - if (to.Body.IsHuman && (!(to is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer)) - return false; // in town we cannot snoop blue human npcs - - return true; + return !to.Body.IsHuman || to is BaseCreature cret && (cret.AlwaysAttackable || cret.AlwaysMurderer); } public static void Container_Snoop(Container cont, Mobile from) @@ -40,22 +37,22 @@ namespace Server.SkillHandlers { Mobile root = cont.RootParent as Mobile; - if (root != null && !root.Alive) + if (root?.Alive == false) return; - if (root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player) + if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player) { from.SendLocalizedMessage(500209); // You can not peek into the container. return; } - if (root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root)) + if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root)) { from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target. return; } - if (root != null && from.AccessLevel == AccessLevel.Player && + if (root?.AccessLevel == AccessLevel.Player && from.Skills.Snooping.Value < Utility.Random(100)) { Map map = from.Map; @@ -98,4 +95,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Scripts/Skills/SpiritSpeak.cs b/Scripts/Skills/SpiritSpeak.cs index abf7ef2ac..972825d29 100644 --- a/Scripts/Skills/SpiritSpeak.cs +++ b/Scripts/Skills/SpiritSpeak.cs @@ -136,22 +136,21 @@ namespace Server.SkillHandlers public override void OnCast() { IPooledEnumerable eable = Caster.GetItemsInRange(3); - Corpse toChannel = eable.ToList().Find(item => item is Corpse corpse && !corpse.Channeled); + Corpse toChannel = eable.FirstOrDefault(item => item is Corpse corpse && !corpse.Channeled); eable.Free(); - int max, min, mana, number; + int min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25); + int max = min + 4; + + int mana, number; if (toChannel != null) { - min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25); - max = min + 4; mana = 0; number = 1061287; // You channel energy from a nearby corpse to heal your wounds. } else { - min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25); - max = min + 4; mana = 10; number = 1061286; // You channel your own spiritual energy to heal your wounds. } @@ -192,4 +191,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Scripts/Skills/Stealing.cs b/Scripts/Skills/Stealing.cs index 610e198ea..3d39f614c 100644 --- a/Scripts/Skills/Stealing.cs +++ b/Scripts/Skills/Stealing.cs @@ -79,7 +79,7 @@ namespace Server.SkillHandlers { Item stolen = null; - object root = toSteal.RootParent; + IEntity root = toSteal.RootParent; Mobile mobRoot = root as Mobile; StealableArtifactsSpawner.StealableInstance si = null; @@ -115,7 +115,7 @@ namespace Server.SkillHandlers { m_Thief.SendLocalizedMessage(500237); // Target can not be seen. } - else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true)) + else if (m_Thief.Backpack?.CheckHold(m_Thief, toSteal, false, true) != true) { m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else. } @@ -177,7 +177,7 @@ namespace Server.SkillHandlers m_Thief.SendLocalizedMessage( 1010258); // The sigil has gone back to its home location because you already have a sigil. } - else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true)) + else if (m_Thief?.Backpack.CheckHold(m_Thief, sig, false, true) != true) { m_Thief.SendLocalizedMessage( 1010259); // The sigil has gone home because your backpack is full @@ -215,7 +215,7 @@ namespace Server.SkillHandlers { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } - else if (toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root)) + else if (toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(mobRoot)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } @@ -244,7 +244,7 @@ namespace Server.SkillHandlers { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } - else if (mobRoot != null && !m_Thief.CanBeHarmful((Mobile)root)) + else if (mobRoot != null && !m_Thief.CanBeHarmful(mobRoot)) { } else if (root is Corpse) @@ -289,10 +289,7 @@ namespace Server.SkillHandlers if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5)) { - stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount); - - if (stolen == null) - stolen = toSteal; + stolen = Mobile.LiftItemDupe(toSteal, toSteal.Amount - amount) ?? toSteal; } } } @@ -332,7 +329,7 @@ namespace Server.SkillHandlers from.RevealingAction(); Item stolen = null; - object root = null; + IEntity root = null; bool caught = false; if (target is Item item) @@ -344,7 +341,7 @@ namespace Server.SkillHandlers { Container pack = mobile.Backpack; - if (pack != null && pack.Items.Count > 0) + if (pack?.Items.Count > 0) { int randomIndex = Utility.Random(pack.Items.Count); @@ -356,7 +353,7 @@ namespace Server.SkillHandlers { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } - + Mobile mobRoot = root as Mobile; if (stolen != null) @@ -395,7 +392,7 @@ namespace Server.SkillHandlers if (mobRoot?.Player == true && m_Thief is PlayerMobile pm && IsInnocentTo(pm, mobRoot) && !IsInGuild(mobRoot)) { - pm.PermaFlags.Add((Mobile)root); + pm.PermaFlags.Add(mobRoot); pm.Delta(MobileDelta.Noto); } } @@ -484,4 +481,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Scripts/Skills/Tracking.cs b/Scripts/Skills/Tracking.cs index 22e2d60ef..f09cb55e5 100644 --- a/Scripts/Skills/Tracking.cs +++ b/Scripts/Skills/Tracking.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Gumps; using Server.Network; using Server.Spells; @@ -91,20 +92,20 @@ namespace Server.SkillHandlers AddBackground(10, 85, 420, 25, 3000); AddItem(20, 20, 9682); - AddButton(20, 110, 4005, 4007, 1, GumpButtonType.Reply, 0); - AddHtmlLocalized(20, 90, 100, 20, 1018087, false, false); // Animals + AddButton(20, 110, 4005, 4007, 1); + AddHtmlLocalized(20, 90, 100, 20, 1018087); // Animals AddItem(120, 20, 9607); - AddButton(120, 110, 4005, 4007, 2, GumpButtonType.Reply, 0); - AddHtmlLocalized(120, 90, 100, 20, 1018088, false, false); // Monsters + AddButton(120, 110, 4005, 4007, 2); + AddHtmlLocalized(120, 90, 100, 20, 1018088); // Monsters AddItem(220, 20, 8454); - AddButton(220, 110, 4005, 4007, 3, GumpButtonType.Reply, 0); - AddHtmlLocalized(220, 90, 100, 20, 1018089, false, false); // Human NPCs + AddButton(220, 110, 4005, 4007, 3); + AddHtmlLocalized(220, 90, 100, 20, 1018089); // Human NPCs AddItem(320, 20, 8455); - AddButton(320, 110, 4005, 4007, 4, GumpButtonType.Reply, 0); - AddHtmlLocalized(320, 90, 100, 20, 1018090, false, false); // Players + AddButton(320, 110, 4005, 4007, 4); + AddHtmlLocalized(320, 90, 100, 20, 1018090); // Players } public override void OnResponse(NetState state, RelayInfo info) @@ -165,10 +166,10 @@ namespace Server.SkillHandlers Mobile m = list[i]; AddItem(20 + i % 4 * 100, 20 + i / 4 * 155, ShrinkTable.Lookup(m)); - AddButton(20 + i % 4 * 100, 130 + i / 4 * 155, 4005, 4007, i + 1, GumpButtonType.Reply, 0); + AddButton(20 + i % 4 * 100, 130 + i / 4 * 155, 4005, 4007, i + 1); if (m.Name != null) - AddHtml(20 + i % 4 * 100, 90 + i / 4 * 155, 90, 40, m.Name, false, false); + AddHtml(20 + i % 4 * 100, 90 + i / 4 * 155, 90, 40, m.Name); } } @@ -191,14 +192,9 @@ namespace Server.SkillHandlers int range = 10 + (int)(from.Skills.Tracking.Value / 10); - List list = new List(); - - foreach (Mobile m in from.GetMobilesInRange(range)) - // Ghosts can no longer be tracked - if (m != from && (!Core.AOS || m.Alive) && - (!m.Hidden || m.AccessLevel == AccessLevel.Player || from.AccessLevel > m.AccessLevel) && check(m) && - CheckDifficulty(from, m)) - list.Add(m); + List list = from.GetMobilesInRange(range) + .Where(m => m != from && (!Core.AOS || m.Alive) && (!m.Hidden || m.AccessLevel == AccessLevel.Player || from.AccessLevel > m.AccessLevel) && check(m) && CheckDifficulty(from, m)) + .ToList(); if (list.Count > 0) { diff --git a/Scripts/SpecialSystems/Engines/GiftGiving.cs b/Scripts/SpecialSystems/Engines/GiftGiving.cs index cdd529296..2d3819f47 100644 --- a/Scripts/SpecialSystems/Engines/GiftGiving.cs +++ b/Scripts/SpecialSystems/Engines/GiftGiving.cs @@ -36,7 +36,7 @@ namespace Server.Misc GiftGiver giver = m_Givers[i]; if (now < giver.Start || now >= giver.Finish) - continue; // not in the correct timefream + continue; // not in the correct time frame if (acct.Created > giver.Start - giver.MinimumAge) continue; // newly created account @@ -66,12 +66,11 @@ namespace Server.Misc public virtual GiftResult GiveGift(Mobile mob, Item item) { - if (mob.PlaceInBackpack(item)) - if (!WeightOverloading.IsOverloaded(mob)) - return GiftResult.Backpack; + if (mob.PlaceInBackpack(item) && !WeightOverloading.IsOverloaded(mob)) + return GiftResult.Backpack; mob.BankBox.DropItem(item); return GiftResult.BankBox; } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Engines/PreventInaccess.cs b/Scripts/SpecialSystems/Engines/PreventInaccess.cs index 377b05d32..4c0dc2bf1 100644 --- a/Scripts/SpecialSystems/Engines/PreventInaccess.cs +++ b/Scripts/SpecialSystems/Engines/PreventInaccess.cs @@ -41,7 +41,7 @@ namespace Server.Misc { Mobile from = e.Mobile; - if (from == null || from.AccessLevel < AccessLevel.Counselor) + if (from?.AccessLevel < AccessLevel.Counselor) return; if (HasDisconnected(from)) diff --git a/Scripts/SpecialSystems/Engines/TestCenter.cs b/Scripts/SpecialSystems/Engines/TestCenter.cs index be7018bed..5e8944f8a 100644 --- a/Scripts/SpecialSystems/Engines/TestCenter.cs +++ b/Scripts/SpecialSystems/Engines/TestCenter.cs @@ -20,39 +20,39 @@ namespace Server.Misc private static void EventSink_Speech(SpeechEventArgs args) { - if (!args.Handled) + if (args.Handled) + return; + + if (Insensitive.StartsWith(args.Speech, "set")) { - if (Insensitive.StartsWith(args.Speech, "set")) - { - Mobile from = args.Mobile; + Mobile from = args.Mobile; - string[] split = args.Speech.Split(' '); + string[] split = args.Speech.Split(' '); - if (split.Length == 3) - try - { - string name = split[1]; - double value = Convert.ToDouble(split[2]); + if (split.Length == 3) + try + { + string name = split[1]; + double value = Convert.ToDouble(split[2]); - if (Insensitive.Equals(name, "str")) - ChangeStrength(from, (int)value); - else if (Insensitive.Equals(name, "dex")) - ChangeDexterity(from, (int)value); - else if (Insensitive.Equals(name, "int")) - ChangeIntelligence(from, (int)value); - else - ChangeSkill(from, name, value); - } - catch - { - } - } - else if (Insensitive.Equals(args.Speech, "help")) - { - args.Mobile.SendGump(new TCHelpGump()); - - args.Handled = true; - } + if (Insensitive.Equals(name, "str")) + ChangeStrength(from, (int)value); + else if (Insensitive.Equals(name, "dex")) + ChangeDexterity(from, (int)value); + else if (Insensitive.Equals(name, "int")) + ChangeIntelligence(from, (int)value); + else + ChangeSkill(from, name, value); + } + catch + { + // ignored + } + } + else if (Insensitive.Equals(args.Speech, "help")) + { + args.Mobile.SendGump(new TCHelpGump()); + args.Handled = true; } } @@ -160,16 +160,16 @@ namespace Server.Misc AddPage(0); AddBackground(0, 0, 160, 120, 5054); - AddButton(10, 10, 0xFB7, 0xFB9, 1, GumpButtonType.Reply, 0); + AddButton(10, 10, 0xFB7, 0xFB9, 1); AddLabel(45, 10, 0x34, "RunUO"); - AddButton(10, 35, 0xFB7, 0xFB9, 2, GumpButtonType.Reply, 0); + AddButton(10, 35, 0xFB7, 0xFB9, 2); AddLabel(45, 35, 0x34, "List of skills"); - AddButton(10, 60, 0xFB7, 0xFB9, 3, GumpButtonType.Reply, 0); + AddButton(10, 60, 0xFB7, 0xFB9, 3); AddLabel(45, 60, 0x34, "Command list"); - AddButton(10, 85, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0); + AddButton(10, 85, 0xFB1, 0xFB3, 0); AddLabel(45, 85, 0x34, "Close"); } @@ -228,4 +228,4 @@ namespace Server.Misc } } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs b/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs index ca137d1bd..a35b6e4bb 100644 --- a/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs +++ b/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs @@ -47,7 +47,7 @@ namespace Server.Items { Container pack = from.Backpack; - if (pack != null && pack.ConsumeTotal(typeof(Gold), 250)) + if (pack?.ConsumeTotal(typeof(Gold), 250) == true) { m_GamblePot += 150; InvalidateProperties(); @@ -74,7 +74,7 @@ namespace Server.Items else if (roll <= 20) // Chance for a regbag { from.SendMessage(0x35, "You win a bag of reagents!"); - from.AddToBackpack(new BagOfReagents(50)); + from.AddToBackpack(new BagOfReagents()); } else if (roll <= 40) // Chance for gold { @@ -123,4 +123,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Items/Stones/IngotStone.cs b/Scripts/SpecialSystems/Items/Stones/IngotStone.cs index fbe699bae..8ccf6c949 100644 --- a/Scripts/SpecialSystems/Items/Stones/IngotStone.cs +++ b/Scripts/SpecialSystems/Items/Stones/IngotStone.cs @@ -17,7 +17,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - BagOfingots ingotBag = new BagOfingots(5000); + BagOfingots ingotBag = new BagOfingots(); if (!from.AddToBackpack(ingotBag)) ingotBag.Delete(); diff --git a/Scripts/SpecialSystems/Items/Stones/RegStone.cs b/Scripts/SpecialSystems/Items/Stones/RegStone.cs index 123d00da0..d9ff57879 100644 --- a/Scripts/SpecialSystems/Items/Stones/RegStone.cs +++ b/Scripts/SpecialSystems/Items/Stones/RegStone.cs @@ -17,7 +17,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - BagOfReagents regBag = new BagOfReagents(50); + BagOfReagents regBag = new BagOfReagents(); if (!from.AddToBackpack(regBag)) regBag.Delete(); diff --git a/Scripts/SpecialSystems/Items/Stones/SmithStone.cs b/Scripts/SpecialSystems/Items/Stones/SmithStone.cs index 80152fa68..1b4e772b1 100644 --- a/Scripts/SpecialSystems/Items/Stones/SmithStone.cs +++ b/Scripts/SpecialSystems/Items/Stones/SmithStone.cs @@ -17,7 +17,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - SmithBag SmithBag = new SmithBag(5000); + SmithBag SmithBag = new SmithBag(); if (!from.AddToBackpack(SmithBag)) SmithBag.Delete(); diff --git a/Scripts/SpecialSystems/Items/SupplyBags/AlchemyBag.cs b/Scripts/SpecialSystems/Items/SupplyBags/AlchemyBag.cs index 2c67ab50b..2c6ad41ec 100644 --- a/Scripts/SpecialSystems/Items/SupplyBags/AlchemyBag.cs +++ b/Scripts/SpecialSystems/Items/SupplyBags/AlchemyBag.cs @@ -1,18 +1,14 @@ +using System; + namespace Server.Items { public class AlchemyBag : Bag { [Constructible] - public AlchemyBag() : this(1) + public AlchemyBag(int amount = 5000) { - Movable = true; Hue = 0x250; - } - - [Constructible] - public AlchemyBag(int amount) - { - DropItem(new MortarPestle(5)); + DropItem(new MortarPestle(Math.Max(amount / 1000, 1))); DropItem(new BagOfReagents(5000)); DropItem(new Bottle(5000)); } @@ -37,4 +33,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Items/SupplyBags/BagOfIngots.cs b/Scripts/SpecialSystems/Items/SupplyBags/BagOfIngots.cs index 0122384c0..dfe5911dd 100644 --- a/Scripts/SpecialSystems/Items/SupplyBags/BagOfIngots.cs +++ b/Scripts/SpecialSystems/Items/SupplyBags/BagOfIngots.cs @@ -3,12 +3,7 @@ namespace Server.Items public class BagOfingots : Bag { [Constructible] - public BagOfingots() : this(5000) - { - } - - [Constructible] - public BagOfingots(int amount) + public BagOfingots(int amount = 5000) { DropItem(new DullCopperIngot(amount)); DropItem(new ShadowIronIngot(amount)); @@ -31,7 +26,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(GenericReader reader) @@ -41,4 +36,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Items/SupplyBags/ScribeBag.cs b/Scripts/SpecialSystems/Items/SupplyBags/ScribeBag.cs index 68bf9606b..c3bc6f00b 100644 --- a/Scripts/SpecialSystems/Items/SupplyBags/ScribeBag.cs +++ b/Scripts/SpecialSystems/Items/SupplyBags/ScribeBag.cs @@ -3,17 +3,11 @@ namespace Server.Items public class ScribeBag : Bag { [Constructible] - public ScribeBag() : this(1) + public ScribeBag(int amount = 5000) { - Movable = true; Hue = 0x105; - } - - [Constructible] - public ScribeBag(int amount) - { - DropItem(new BagOfReagents(5000)); - DropItem(new BlankScroll(500)); + DropItem(new BagOfReagents(amount)); + DropItem(new BlankScroll(amount)); } public ScribeBag(Serial serial) : base(serial) @@ -36,4 +30,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Items/SupplyBags/SmithBag.cs b/Scripts/SpecialSystems/Items/SupplyBags/SmithBag.cs index 77689763f..b551c49b5 100644 --- a/Scripts/SpecialSystems/Items/SupplyBags/SmithBag.cs +++ b/Scripts/SpecialSystems/Items/SupplyBags/SmithBag.cs @@ -3,12 +3,7 @@ namespace Server.Items public class SmithBag : Bag { [Constructible] - public SmithBag() : this(5000) - { - } - - [Constructible] - public SmithBag(int amount) + public SmithBag(int amount = 5000) { DropItem(new DullCopperIngot(amount)); DropItem(new ShadowIronIngot(amount)); @@ -31,7 +26,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(GenericReader reader) @@ -41,4 +36,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/SpecialSystems/Items/SupplyBags/TailorBag.cs b/Scripts/SpecialSystems/Items/SupplyBags/TailorBag.cs index 38d38612a..0e8977dce 100644 --- a/Scripts/SpecialSystems/Items/SupplyBags/TailorBag.cs +++ b/Scripts/SpecialSystems/Items/SupplyBags/TailorBag.cs @@ -1,21 +1,17 @@ +using System; + namespace Server.Items { public class TailorBag : Bag { [Constructible] - public TailorBag() : this(1) + public TailorBag(int amount = 500) { - Movable = true; Hue = 0x315; - } - - [Constructible] - public TailorBag(int amount) - { - DropItem(new SewingKit(5)); + DropItem(new SewingKit(Math.Max(amount / 100, 1))); DropItem(new Scissors()); - DropItem(new Hides(500)); - DropItem(new BoltOfCloth(20)); + DropItem(new Hides(amount)); + DropItem(new BoltOfCloth(Math.Max(amount / 25, 1))); DropItem(new DyeTub()); DropItem(new DyeTub()); DropItem(new BlackDyeTub()); @@ -42,4 +38,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Base/MagerySpell.cs b/Scripts/Spells/Base/MagerySpell.cs index af1bc26fc..5fa66c2c3 100644 --- a/Scripts/Spells/Base/MagerySpell.cs +++ b/Scripts/Spells/Base/MagerySpell.cs @@ -20,13 +20,7 @@ namespace Server.Spells public override bool ConsumeReagents() { - if (base.ConsumeReagents()) - return true; - - if (ArcaneGem.ConsumeCharges(Caster, Core.SE ? 1 : 1 + (int)Circle)) - return true; - - return false; + return base.ConsumeReagents() || ArcaneGem.ConsumeCharges(Caster, Core.SE ? 1 : 1 + (int)Circle); } public override void GetCastSkills(out double min, out double max) @@ -44,10 +38,7 @@ namespace Server.Spells public override int GetMana() { - if (Scroll is BaseWand) - return 0; - - return m_ManaTable[(int)Circle]; + return Scroll is BaseWand ? 0 : m_ManaTable[(int)Circle]; } public override double GetResistSkill(Mobile m) @@ -108,4 +99,4 @@ namespace Server.Spells return base.GetCastDelay(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Base/SpecialMove.cs b/Scripts/Spells/Base/SpecialMove.cs index 594b02ec3..6a8a5192d 100644 --- a/Scripts/Spells/Base/SpecialMove.cs +++ b/Scripts/Spells/Base/SpecialMove.cs @@ -236,7 +236,7 @@ namespace Server.Spells return false; } - if (move != null && !move.Validate(m)) + if (move?.Validate(m) == false) { ClearCurrentMove(m); return false; diff --git a/Scripts/Spells/Base/Spell.cs b/Scripts/Spells/Base/Spell.cs index eec45b17a..d6259fb06 100644 --- a/Scripts/Spells/Base/Spell.cs +++ b/Scripts/Spells/Base/Spell.cs @@ -118,7 +118,7 @@ namespace Server.Spells return true; } - public virtual bool OnCasterUsingObject(object o) + public virtual bool OnCasterUsingObject(IEntity entity) { if (State == SpellState.Sequencing) Disturb(DisturbType.UseRequest); @@ -313,13 +313,12 @@ namespace Server.Spells SlayerEntry atkSlayer = SlayerGroup.GetEntryByName(atkBook.Slayer); SlayerEntry atkSlayer2 = SlayerGroup.GetEntryByName(atkBook.Slayer2); - if (atkSlayer != null && atkSlayer.Slays(defender) || atkSlayer2 != null && atkSlayer2.Slays(defender)) + if (atkSlayer?.Slays(defender) == true || atkSlayer2?.Slays(defender) == true) { defender.FixedEffect(0x37B9, 10, 5); //TODO: Confirm this displays on OSIs scalar = 2.0; } - TransformContext context = TransformationSpellHelper.GetContext(defender); if ((atkBook.Slayer == SlayerName.Silver || atkBook.Slayer2 == SlayerName.Silver) && context != null && @@ -330,18 +329,15 @@ namespace Server.Spells return scalar; } - ISlayer defISlayer = Spellbook.FindEquippedSpellbook(defender); - - if (defISlayer == null) - defISlayer = defender.Weapon as ISlayer; + ISlayer defISlayer = Spellbook.FindEquippedSpellbook(defender) ?? defender.Weapon as ISlayer; if (defISlayer != null) { SlayerEntry defSlayer = SlayerGroup.GetEntryByName(defISlayer.Slayer); SlayerEntry defSlayer2 = SlayerGroup.GetEntryByName(defISlayer.Slayer2); - if (defSlayer != null && defSlayer.Group.OppositionSuperSlays(Caster) || - defSlayer2 != null && defSlayer2.Group.OppositionSuperSlays(Caster)) + if (defSlayer?.Group.OppositionSuperSlays(Caster) == true || + defSlayer2?.Group.OppositionSuperSlays(Caster) == true) scalar = 2.0; } diff --git a/Scripts/Spells/Base/SpellHelper.cs b/Scripts/Spells/Base/SpellHelper.cs index 3f3f7242a..87c0175d4 100644 --- a/Scripts/Spells/Base/SpellHelper.cs +++ b/Scripts/Spells/Base/SpellHelper.cs @@ -286,7 +286,7 @@ namespace Server.Spells StatMod mod = target.GetStatMod(name); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) { target.AddStatMod(new StatMod(type, name, mod.Offset + offset, duration)); return true; @@ -313,7 +313,7 @@ namespace Server.Spells StatMod mod = target.GetStatMod(name); - if (mod != null && mod.Offset > 0) + if (mod?.Offset > 0) { target.AddStatMod(new StatMod(type, name, mod.Offset + offset, duration)); return true; @@ -420,20 +420,19 @@ namespace Server.Spells PlayerMobile pmFrom; PlayerMobile pmTarg; - if (bcFrom != null && bcFrom.Summoned) + if (bcFrom?.Summoned == true) pmFrom = bcFrom.SummonMaster as PlayerMobile; else pmFrom = from as PlayerMobile; - if (bcTarg != null && bcTarg.Summoned) + if (bcTarg?.Summoned == true) pmTarg = bcTarg.SummonMaster as PlayerMobile; else pmTarg = to as PlayerMobile; - if (pmFrom != null && pmTarg != null) - if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started && - pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null) - return pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant; + if (pmFrom?.DuelContext != null && pmFrom.DuelContext == pmTarg?.DuelContext && pmFrom.DuelContext.Started && + pmFrom.DuelPlayer != null && pmTarg?.DuelPlayer != null) + return pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant; #endregion @@ -445,7 +444,7 @@ namespace Server.Spells Party p = Party.Get(from); - if (p != null && p.Contains(to)) + if (p?.Contains(to) == true) return false; if (bcTarg != null && (bcTarg.Controlled || bcTarg.Summoned)) @@ -468,12 +467,8 @@ namespace Server.Spells return false; } - if (bcTarg != null && !bcTarg.Controlled && bcTarg.InitialInnocent) - return true; - - int noto = Notoriety.Compute(from, to); - - return noto != Notoriety.Innocent || from.Kills >= 5; + return bcTarg?.Controlled == false && bcTarg.InitialInnocent || + Notoriety.Compute(from, to) != Notoriety.Innocent || from.Kills >= 5; } public static void Summon(BaseCreature creature, Mobile caster, int sound, TimeSpan duration, bool scaleDuration, @@ -617,7 +612,7 @@ namespace Server.Spells return false; } - if (caster != null && caster.AccessLevel == AccessLevel.Player && caster.Region.IsPartOf()) + if (caster?.AccessLevel == AccessLevel.Player && caster.Region.IsPartOf()) { caster.SendLocalizedMessage(1114345); // You'll need a better jailbreak plan than that! return false; @@ -722,18 +717,12 @@ namespace Server.Spells public static bool IsSafeZone(Map map, Point3D loc) { #region Duels - - if (Region.Find(loc, map).IsPartOf()) + if (Region.Find(loc, map).IsPartOf() && + (m_TravelType == TravelCheckType.TeleportTo || m_TravelType == TravelCheckType.TeleportFrom) + && (m_TravelCaster as PlayerMobile)?.DuelPlayer?.Eliminated == false) { - if (m_TravelType == TravelCheckType.TeleportTo || m_TravelType == TravelCheckType.TeleportFrom) - { - if (m_TravelCaster is PlayerMobile pm && pm.DuelPlayer != null && !pm.DuelPlayer.Eliminated) - return true; - } - return true; } - #endregion return false; @@ -855,22 +844,18 @@ namespace Server.Spells return false; #region Dueling - - SafeZone sz = Region.Find(loc, map).GetRegion(); - - if (sz != null) + if (Region.Find(loc, map).GetRegion() != null) { PlayerMobile pm = caster as PlayerMobile; - if (pm?.DuelContext == null || !pm.DuelContext.Started || pm.DuelPlayer == null || pm.DuelPlayer.Eliminated) + if (pm.DuelContext?.Started != true || pm.DuelPlayer?.Eliminated != false) return true; } - #endregion GuardedRegion reg = Region.Find(loc, map).GetRegion(); - return reg != null && !reg.IsDisabled(); + return reg?.IsDisabled() == false; } public static bool CheckTown(IPoint3D ip, Mobile caster) @@ -1047,6 +1032,7 @@ namespace Server.Spells int wraithLeech = 5 + (int)(15 * from.Skills.SpiritSpeak.Value / 100); // Wraith form gives 5-20% mana leech int manaLeech = AOS.Scale(damageGiven, wraithLeech); + if (manaLeech != 0) { from.Mana += manaLeech; @@ -1060,12 +1046,7 @@ namespace Server.Spells } } - public static void Heal(int amount, Mobile target, Mobile from) - { - Heal(amount, target, from, true); - } - - public static void Heal(int amount, Mobile target, Mobile from, bool message) + public static void Heal(int amount, Mobile target, Mobile from, bool message = true) { //TODO: All Healing *spells* go through ArcaneEmpowerment target.Heal(amount, from, message); @@ -1087,7 +1068,7 @@ namespace Server.Spells m_Damage = damage; m_Spell = s; - if (m_Spell != null && m_Spell.DelayedDamage && !m_Spell.DelayedDamageStacking) + if (m_Spell?.DelayedDamage == true && !m_Spell.DelayedDamageStacking) m_Spell.StartDelayedDamageContext(target, this); Priority = TimerPriority.TwentyFiveMS; @@ -1127,7 +1108,7 @@ namespace Server.Spells m_Chaos = chaos; m_DFA = dfa; m_Spell = s; - if (m_Spell != null && m_Spell.DelayedDamage && !m_Spell.DelayedDamageStacking) + if (m_Spell?.DelayedDamage == true && !m_Spell.DelayedDamageStacking) m_Spell.StartDelayedDamageContext(target, this); Priority = TimerPriority.TwentyFiveMS; @@ -1333,9 +1314,7 @@ namespace Server.Spells public static bool UnderTransformation(Mobile m, Type type) { - TransformContext context = GetContext(m); - - return context != null && context.Type == type; + return GetContext(m)?.Type == type; } #endregion diff --git a/Scripts/Spells/Base/SpellRegistry.cs b/Scripts/Spells/Base/SpellRegistry.cs index ab2ad4630..0f985c93c 100644 --- a/Scripts/Spells/Base/SpellRegistry.cs +++ b/Scripts/Spells/Base/SpellRegistry.cs @@ -125,7 +125,7 @@ namespace Server.Spells Type t = m_Types[spellID]; - if (t != null && !t.IsSubclassOf(typeof(SpecialMove))) + if (t?.IsSubclassOf(typeof(SpecialMove)) == false) { m_Params[0] = caster; m_Params[1] = scroll; @@ -136,6 +136,7 @@ namespace Server.Spells } catch { + // ignored } } @@ -148,7 +149,7 @@ namespace Server.Spells { Type t = ScriptCompiler.FindTypeByFullName($"Server.Spells.{m_CircleNames[i]}.{name}"); - if (t != null && !t.IsSubclassOf(typeof(SpecialMove))) + if (t?.IsSubclassOf(typeof(SpecialMove)) == false) { m_Params[0] = caster; m_Params[1] = scroll; @@ -159,6 +160,7 @@ namespace Server.Spells } catch { + // ignored } } } diff --git a/Scripts/Spells/Bushido/Confidence.cs b/Scripts/Spells/Bushido/Confidence.cs index 138285613..b0e71d13d 100644 --- a/Scripts/Spells/Bushido/Confidence.cs +++ b/Scripts/Spells/Bushido/Confidence.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Spells.Bushido diff --git a/Scripts/Spells/Bushido/CounterAttack.cs b/Scripts/Spells/Bushido/CounterAttack.cs index 9544647ad..2b15d2482 100644 --- a/Scripts/Spells/Bushido/CounterAttack.cs +++ b/Scripts/Spells/Bushido/CounterAttack.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; diff --git a/Scripts/Spells/Bushido/Evasion.cs b/Scripts/Spells/Bushido/Evasion.cs index 50c8338d2..5928c95ec 100644 --- a/Scripts/Spells/Bushido/Evasion.cs +++ b/Scripts/Spells/Bushido/Evasion.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; diff --git a/Scripts/Spells/Bushido/HonorableExecution.cs b/Scripts/Spells/Bushido/HonorableExecution.cs index cb2efa475..44ba99710 100644 --- a/Scripts/Spells/Bushido/HonorableExecution.cs +++ b/Scripts/Spells/Bushido/HonorableExecution.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Spells.Bushido @@ -103,7 +102,7 @@ namespace Server.Spells.Bushido public int m_SwingBonus; public Timer m_Timer; - public HonorableExecutionInfo(Mobile from, List mods) : this(from, 0, mods, true) + public HonorableExecutionInfo(Mobile from, List mods) : this(from, 0, mods, mods != null) { } diff --git a/Scripts/Spells/Bushido/MomentumStrike.cs b/Scripts/Spells/Bushido/MomentumStrike.cs index 1d96a48eb..45055ddf0 100644 --- a/Scripts/Spells/Bushido/MomentumStrike.cs +++ b/Scripts/Spells/Bushido/MomentumStrike.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Server.Items; namespace Server.Spells.Bushido @@ -20,46 +21,35 @@ namespace Server.Spells.Bushido BaseWeapon weapon = attacker.Weapon as BaseWeapon; - List targets = new List(); + List targets = attacker.GetMobilesInRange(weapon.MaxRange) + .Where(m => m != defender).Where(m => m.Combatant == attacker).ToList(); - foreach (Mobile m in attacker.GetMobilesInRange(weapon.MaxRange)) - { - if (m == defender) - continue; - - if (m.Combatant != attacker) - continue; - - targets.Add(m); - } - - if (targets.Count > 0) - { - if (!CheckMana(attacker, true)) - return; - - Mobile target = targets[Utility.Random(targets.Count)]; - - double 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! - - target.FixedParticles(0x37B9, 1, 4, 0x251D, 0, 0, EffectLayer.Waist); - - attacker.PlaySound(0x510); - - weapon.OnSwing(attacker, target, damageBonus); - - CheckGain(attacker); - } - else + if (targets.Count <= 0) { attacker.SendLocalizedMessage(1063123); // There are no valid targets to attack! + return; } + + if (!CheckMana(attacker, true)) + return; + + Mobile target = targets[Utility.Random(targets.Count)]; + + double 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! + + target.FixedParticles(0x37B9, 1, 4, 0x251D, 0, 0, EffectLayer.Waist); + + attacker.PlaySound(0x510); + + weapon.OnSwing(attacker, target, damageBonus); + + CheckGain(attacker); } public override void CheckGain(Mobile m) @@ -67,4 +57,4 @@ namespace Server.Spells.Bushido m.CheckSkill(MoveSkill, RequiredSkill, 120.0); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Bushido/SamuraiSpell.cs b/Scripts/Spells/Bushido/SamuraiSpell.cs index 7824bbe6f..b16a512fe 100644 --- a/Scripts/Spells/Bushido/SamuraiSpell.cs +++ b/Scripts/Spells/Bushido/SamuraiSpell.cs @@ -27,13 +27,7 @@ namespace Server.Spells.Bushido public static bool CheckExpansion(Mobile from) { - if (!(from is PlayerMobile)) - return true; - - if (from.NetState == null) - return false; - - return from.NetState.SupportsExpansion(Expansion.SE); + return (from as PlayerMobile)?.NetState?.SupportsExpansion(Expansion.SE) == true; } public override bool CheckCast() @@ -129,4 +123,4 @@ namespace Server.Spells.Bushido caster.Send(new ToggleSpecialAbility(spellID + 1, false)); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/CleanseByFire.cs b/Scripts/Spells/Chivalry/CleanseByFire.cs index 3c7550d5e..7c9404a31 100644 --- a/Scripts/Spells/Chivalry/CleanseByFire.cs +++ b/Scripts/Spells/Chivalry/CleanseByFire.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Chivalry { - public class CleanseByFireSpell : PaladinSpell + public class CleanseByFireSpell : PaladinSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Cleanse By Fire", "Expor Flamus", @@ -12,7 +12,7 @@ namespace Server.Spells.Chivalry 9002 ); - public CleanseByFireSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CleanseByFireSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -36,15 +36,16 @@ namespace Server.Spells.Chivalry public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!m.Poisoned) - { Caster.SendLocalizedMessage(1060176); // That creature is not poisoned! - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -101,26 +102,5 @@ namespace Server.Spells.Chivalry FinishSequence(); } - - private class InternalTarget : Target - { - private CleanseByFireSpell m_Owner; - - public InternalTarget(CleanseByFireSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/CloseWounds.cs b/Scripts/Spells/Chivalry/CloseWounds.cs index 70972eacb..2b66a3fa9 100644 --- a/Scripts/Spells/Chivalry/CloseWounds.cs +++ b/Scripts/Spells/Chivalry/CloseWounds.cs @@ -7,7 +7,7 @@ using Server.Targeting; namespace Server.Spells.Chivalry { - public class CloseWoundsSpell : PaladinSpell + public class CloseWoundsSpell : PaladinSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Close Wounds", "Obsu Vulni", @@ -15,7 +15,7 @@ namespace Server.Spells.Chivalry 9002 ); - public CloseWoundsSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CloseWoundsSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -39,31 +39,24 @@ namespace Server.Spells.Chivalry public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.InRange(m, 2)) - { Caster.SendLocalizedMessage(1060178); // You are too far away to perform that action! - } else if (m is BaseCreature creature && creature.IsAnimatedDead) - { Caster.SendLocalizedMessage(1061654); // You cannot heal that which is not alive. - } else if (m.IsDeadBondedPet) - { Caster.SendLocalizedMessage(1060177); // You cannot heal a creature that is already dead! - } else if (m.Hits >= m.HitsMax) - { Caster.SendLocalizedMessage(500955); // That being is not damaged! - } else if (m.Poisoned || MortalStrike.IsWounded(m)) - { Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, Caster == m ? 1005000 : 1010398); - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -90,26 +83,5 @@ namespace Server.Spells.Chivalry FinishSequence(); } - - private class InternalTarget : Target - { - private CloseWoundsSpell m_Owner; - - public InternalTarget(CloseWoundsSpell owner) : base(12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/ConsecrateWeapon.cs b/Scripts/Spells/Chivalry/ConsecrateWeapon.cs index fde82c008..860f380b4 100644 --- a/Scripts/Spells/Chivalry/ConsecrateWeapon.cs +++ b/Scripts/Spells/Chivalry/ConsecrateWeapon.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; @@ -15,7 +14,7 @@ namespace Server.Spells.Chivalry private static Dictionary m_Table = new Dictionary(); - public ConsecrateWeaponSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ConsecrateWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Chivalry/DispelEvil.cs b/Scripts/Spells/Chivalry/DispelEvil.cs index ef9b2aeb2..d76a6bebc 100644 --- a/Scripts/Spells/Chivalry/DispelEvil.cs +++ b/Scripts/Spells/Chivalry/DispelEvil.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Items; using Server.Mobiles; using Server.Spells.Necromancy; @@ -14,7 +15,7 @@ namespace Server.Spells.Chivalry 9002 ); - public DispelEvilSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public DispelEvilSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -37,12 +38,6 @@ namespace Server.Spells.Chivalry { if (CheckSequence()) { - List targets = new List(); - - foreach (Mobile m in Caster.GetMobilesInRange(8)) - if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false)) - targets.Add(m); - Caster.PlaySound(0xF5); Caster.PlaySound(0x299); Caster.FixedParticles(0x37C4, 1, 25, 9922, 14, 3, EffectLayer.Head); @@ -51,10 +46,11 @@ namespace Server.Spells.Chivalry double chiv = Caster.Skills.Chivalry.Value; - for (int i = 0; i < targets.Count; ++i) - { - Mobile m = targets[i]; + IEnumerable targets = Caster.GetMobilesInRange(8) + .Where(m => Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false)); + foreach (Mobile m in targets) + { if (m is BaseCreature bc) { if (bc.Summoned && !bc.IsAnimatedDead) @@ -106,4 +102,4 @@ namespace Server.Spells.Chivalry FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/DivineFury.cs b/Scripts/Spells/Chivalry/DivineFury.cs index d732c0b79..d3f7439bf 100644 --- a/Scripts/Spells/Chivalry/DivineFury.cs +++ b/Scripts/Spells/Chivalry/DivineFury.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Spells.Chivalry @@ -14,7 +13,7 @@ namespace Server.Spells.Chivalry private static Dictionary m_Table = new Dictionary(); - public DivineFurySpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public DivineFurySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Chivalry/EnemyOfOne.cs b/Scripts/Spells/Chivalry/EnemyOfOne.cs index e1954a822..191e76466 100644 --- a/Scripts/Spells/Chivalry/EnemyOfOne.cs +++ b/Scripts/Spells/Chivalry/EnemyOfOne.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Mobiles; @@ -15,7 +14,7 @@ namespace Server.Spells.Chivalry private static Dictionary m_Table = new Dictionary(); - public EnemyOfOneSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EnemyOfOneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Chivalry/HolyLight.cs b/Scripts/Spells/Chivalry/HolyLight.cs index 0e7edf21f..2a0d3274e 100644 --- a/Scripts/Spells/Chivalry/HolyLight.cs +++ b/Scripts/Spells/Chivalry/HolyLight.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Items; namespace Server.Spells.Chivalry @@ -12,7 +13,7 @@ namespace Server.Spells.Chivalry 9002 ); - public HolyLightSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public HolyLightSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -30,13 +31,6 @@ namespace Server.Spells.Chivalry { if (CheckSequence()) { - List targets = new List(); - - foreach (Mobile m in Caster.GetMobilesInRange(3)) - if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && - (!Core.AOS || Caster.InLOS(m))) - targets.Add(m); - Caster.PlaySound(0x212); Caster.PlaySound(0x206); @@ -46,10 +40,12 @@ namespace Server.Spells.Chivalry EffectItem.Create(new Point3D(Caster.X, Caster.Y, Caster.Z - 7), Caster.Map, EffectItem.DefaultDuration), 0x37C4, 1, 29, 0x47D, 2, 9502, 0); - for (int i = 0; i < targets.Count; ++i) - { - Mobile m = targets[i]; + IEnumerable targets = Caster.GetMobilesInRange(3) + .Where(m => Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && + (!Core.AOS || Caster.InLOS(m))); + foreach (Mobile m in targets) + { int damage = ComputePowerValue(10) + Utility.RandomMinMax(0, 2); // TODO: Should caps be applied? @@ -66,4 +62,4 @@ namespace Server.Spells.Chivalry FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/NobleSacrifice.cs b/Scripts/Spells/Chivalry/NobleSacrifice.cs index 97a8b806b..1bb57d30a 100644 --- a/Scripts/Spells/Chivalry/NobleSacrifice.cs +++ b/Scripts/Spells/Chivalry/NobleSacrifice.cs @@ -14,7 +14,7 @@ namespace Server.Spells.Chivalry 9002 ); - public NobleSacrificeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public NobleSacrificeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -109,21 +109,21 @@ namespace Server.Spells.Chivalry StatMod mod; mod = m.GetStatMod("[Magic] Str Offset"); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) { m.RemoveStatMod("[Magic] Str Offset"); sendEffect = true; } mod = m.GetStatMod("[Magic] Dex Offset"); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) { m.RemoveStatMod("[Magic] Dex Offset"); sendEffect = true; } mod = m.GetStatMod("[Magic] Int Offset"); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) { m.RemoveStatMod("[Magic] Int Offset"); sendEffect = true; @@ -166,4 +166,4 @@ namespace Server.Spells.Chivalry FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/RemoveCurse.cs b/Scripts/Spells/Chivalry/RemoveCurse.cs index 7447a942e..1e514e348 100644 --- a/Scripts/Spells/Chivalry/RemoveCurse.cs +++ b/Scripts/Spells/Chivalry/RemoveCurse.cs @@ -7,7 +7,7 @@ using Server.Targeting; namespace Server.Spells.Chivalry { - public class RemoveCurseSpell : PaladinSpell + public class RemoveCurseSpell : PaladinSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Remove Curse", "Extermo Vomica", @@ -15,7 +15,7 @@ namespace Server.Spells.Chivalry 9002 ); - public RemoveCurseSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public RemoveCurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -39,11 +39,14 @@ namespace Server.Spells.Chivalry public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -54,7 +57,7 @@ namespace Server.Spells.Chivalry * Chance of removing curse is affected by Caster's Karma. */ - int chance = 0; + int chance; if (Caster.Karma < -5000) chance = 0; @@ -77,15 +80,15 @@ namespace Server.Spells.Chivalry 0x100); StatMod mod = m.GetStatMod("[Magic] Str Offset"); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) m.RemoveStatMod("[Magic] Str Offset"); mod = m.GetStatMod("[Magic] Dex Offset"); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) m.RemoveStatMod("[Magic] Dex Offset"); mod = m.GetStatMod("[Magic] Int Offset"); - if (mod != null && mod.Offset < 0) + if (mod?.Offset < 0) m.RemoveStatMod("[Magic] Int Offset"); m.Paralyzed = false; @@ -116,26 +119,5 @@ namespace Server.Spells.Chivalry FinishSequence(); } - - private class InternalTarget : Target - { - private RemoveCurseSpell m_Owner; - - public InternalTarget(RemoveCurseSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Chivalry/SacredJourney.cs b/Scripts/Spells/Chivalry/SacredJourney.cs index d4a1beedd..5ca1a4152 100644 --- a/Scripts/Spells/Chivalry/SacredJourney.cs +++ b/Scripts/Spells/Chivalry/SacredJourney.cs @@ -3,13 +3,10 @@ using Server.Factions; using Server.Items; using Server.Misc; using Server.Mobiles; -using Server.Multis; -using Server.Network; -using Server.Targeting; namespace Server.Spells.Chivalry { - public class SacredJourneySpell : PaladinSpell + public class SacredJourneySpell : PaladinSpell, IRecallSpell { private static SpellInfo m_Info = new SpellInfo( "Sacred Journey", "Sanctum Viatas", @@ -21,8 +18,8 @@ namespace Server.Spells.Chivalry private RunebookEntry m_Entry; - public SacredJourneySpell(Mobile caster, Item scroll, RunebookEntry entry = null, Runebook book = null) : base(caster, scroll, - m_Info) + public SacredJourneySpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) : + base(caster, scroll, m_Info) { m_Entry = entry; m_Book = book; @@ -39,7 +36,7 @@ namespace Server.Spells.Chivalry public override void OnCast() { if (m_Entry == null) - Caster.Target = new InternalTarget(this); + Caster.Target = new RecallSpellTarget(this); else Effect(m_Entry.Location, m_Entry.Map, true); } @@ -141,61 +138,5 @@ namespace Server.Spells.Chivalry FinishSequence(); } - - private class InternalTarget : Target - { - private SacredJourneySpell m_Owner; - - public InternalTarget(SacredJourneySpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is RecallRune rune) - { - if (rune.Marked) - m_Owner.Effect(rune.Target, rune.TargetMap, true); - else - from.SendLocalizedMessage(501805); // That rune is not yet marked. - } - else if (o is Runebook runebook) - { - RunebookEntry e = runebook.Default; - - if (e != null) - m_Owner.Effect(e.Location, e.Map, true); - else - from.SendLocalizedMessage(502354); // Target is not marked. - } - else if (o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat) - { - if (!boat.Deleted && boat.CheckKey(key.KeyValue)) - m_Owner.Effect(boat.GetMarkedLocation(), boat.Map, false); - else - from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, - from.Name, "")); // I can not recall from that object. - } - else if (o is HouseRaffleDeed deed && deed.ValidLocation()) - { - m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true); - } - else - { - from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, - "")); // I can not recall from that object. - } - } - - protected override void OnNonlocalTarget(Mobile from, object o) - { - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/AirElemental.cs b/Scripts/Spells/Eighth/AirElemental.cs index ddef638fa..0aec5b631 100644 --- a/Scripts/Spells/Eighth/AirElemental.cs +++ b/Scripts/Spells/Eighth/AirElemental.cs @@ -15,7 +15,7 @@ namespace Server.Spells.Eighth Reagent.SpidersSilk ); - public AirElementalSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public AirElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -50,4 +50,4 @@ namespace Server.Spells.Eighth FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/EarthElemental.cs b/Scripts/Spells/Eighth/EarthElemental.cs index 629d6ab4a..18dfceb2a 100644 --- a/Scripts/Spells/Eighth/EarthElemental.cs +++ b/Scripts/Spells/Eighth/EarthElemental.cs @@ -15,7 +15,7 @@ namespace Server.Spells.Eighth Reagent.SpidersSilk ); - public EarthElementalSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EarthElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -50,4 +50,4 @@ namespace Server.Spells.Eighth FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/Earthquake.cs b/Scripts/Spells/Eighth/Earthquake.cs index 4be387c45..0d721e33a 100644 --- a/Scripts/Spells/Eighth/Earthquake.cs +++ b/Scripts/Spells/Eighth/Earthquake.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Server.Spells.Eighth { @@ -16,7 +17,7 @@ namespace Server.Spells.Eighth Reagent.SulfurousAsh ); - public EarthquakeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EarthquakeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -28,22 +29,19 @@ namespace Server.Spells.Eighth { if (SpellHelper.CheckTown(Caster, Caster) && CheckSequence()) { - List targets = new List(); - - Map map = Caster.Map; - - if (map != null) - foreach (Mobile m in Caster.GetMobilesInRange(1 + (int)(Caster.Skills.Magery.Value / 15.0))) - if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && - (!Core.AOS || Caster.InLOS(m))) - targets.Add(m); - Caster.PlaySound(0x220); - for (int i = 0; i < targets.Count; ++i) + if (Caster.Map == null) { - Mobile m = targets[i]; + FinishSequence(); + return; + } + IEnumerable targets = Caster.GetMobilesInRange(1 + (int)(Caster.Skills.Magery.Value / 15.0)) + .Where(m => Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && (!Core.AOS || Caster.InLOS(m))); + + foreach (Mobile m in targets) + { int damage; if (Core.AOS) @@ -72,4 +70,4 @@ namespace Server.Spells.Eighth FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/EnergyVortex.cs b/Scripts/Spells/Eighth/EnergyVortex.cs index 86dbed550..3c72fc941 100644 --- a/Scripts/Spells/Eighth/EnergyVortex.cs +++ b/Scripts/Spells/Eighth/EnergyVortex.cs @@ -1,10 +1,9 @@ using System; using Server.Mobiles; -using Server.Targeting; namespace Server.Spells.Eighth { - public class EnergyVortexSpell : MagerySpell + public class EnergyVortexSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Energy Vortex", "Vas Corp Por", @@ -17,7 +16,7 @@ namespace Server.Spells.Eighth Reagent.Nightshade ); - public EnergyVortexSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EnergyVortexSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -39,7 +38,7 @@ namespace Server.Spells.Eighth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this); } public void Target(IPoint3D p) @@ -66,34 +65,5 @@ namespace Server.Spells.Eighth FinishSequence(); } - - private class InternalTarget : Target - { - private EnergyVortexSpell m_Owner; - - public InternalTarget(EnergyVortexSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetOutOfLOS(Mobile from, object o) - { - from.SendLocalizedMessage(501943); // Target cannot be seen. Try again. - from.Target = new InternalTarget(m_Owner); - from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow); - m_Owner = null; - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner?.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/FireElemental.cs b/Scripts/Spells/Eighth/FireElemental.cs index 4aa50825b..62e37ff46 100644 --- a/Scripts/Spells/Eighth/FireElemental.cs +++ b/Scripts/Spells/Eighth/FireElemental.cs @@ -16,7 +16,7 @@ namespace Server.Spells.Eighth Reagent.SulfurousAsh ); - public FireElementalSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public FireElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -51,4 +51,4 @@ namespace Server.Spells.Eighth FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/Resurrection.cs b/Scripts/Spells/Eighth/Resurrection.cs index 7c41b1e49..c1a5f5673 100644 --- a/Scripts/Spells/Eighth/Resurrection.cs +++ b/Scripts/Spells/Eighth/Resurrection.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Eighth { - public class ResurrectionSpell : MagerySpell + public class ResurrectionSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Resurrection", "An Corp", @@ -15,7 +15,7 @@ namespace Server.Spells.Eighth Reagent.Ginseng ); - public ResurrectionSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ResurrectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -34,45 +34,34 @@ namespace Server.Spells.Eighth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 1); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (m == Caster) - { Caster.SendLocalizedMessage(501039); // Thou can not resurrect thyself. - } else if (!Caster.Alive) - { Caster.SendLocalizedMessage(501040); // The resurrecter must be alive. - } else if (m.Alive) - { Caster.SendLocalizedMessage(501041); // Target is not dead. - } else if (!Caster.InRange(m, 1)) - { Caster.SendLocalizedMessage(501042); // Target is not close enough. - } else if (!m.Player) - { Caster.SendLocalizedMessage(501043); // Target is not a being. - } else if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false)) { Caster.SendLocalizedMessage(501042); // Target can not be resurrected at that location. m.SendLocalizedMessage(502391); // Thou can not be resurrected there! } else if (m.Region?.IsPartOf("Khaldun") == true) - { Caster.SendLocalizedMessage( 1010395); // The veil of death in this area is too strong and resists thy efforts to restore life. - } else if (CheckBSequence(m, true)) { SpellHelper.Turn(Caster, m); @@ -86,26 +75,5 @@ namespace Server.Spells.Eighth FinishSequence(); } - - private class InternalTarget : Target - { - private ResurrectionSpell m_Owner; - - public InternalTarget(ResurrectionSpell owner) : base(1, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/SummonDaemon.cs b/Scripts/Spells/Eighth/SummonDaemon.cs index 0751efa04..b5853ac02 100644 --- a/Scripts/Spells/Eighth/SummonDaemon.cs +++ b/Scripts/Spells/Eighth/SummonDaemon.cs @@ -16,7 +16,7 @@ namespace Server.Spells.Eighth Reagent.SulfurousAsh ); - public SummonDaemonSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public SummonDaemonSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -57,4 +57,4 @@ namespace Server.Spells.Eighth FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Eighth/WaterElemental.cs b/Scripts/Spells/Eighth/WaterElemental.cs index 80250ba26..122871ba5 100644 --- a/Scripts/Spells/Eighth/WaterElemental.cs +++ b/Scripts/Spells/Eighth/WaterElemental.cs @@ -15,7 +15,7 @@ namespace Server.Spells.Eighth Reagent.SpidersSilk ); - public WaterElementalSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public WaterElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -50,4 +50,4 @@ namespace Server.Spells.Eighth FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fifth/BladeSpirits.cs b/Scripts/Spells/Fifth/BladeSpirits.cs index a402371ed..18935b99a 100644 --- a/Scripts/Spells/Fifth/BladeSpirits.cs +++ b/Scripts/Spells/Fifth/BladeSpirits.cs @@ -1,10 +1,9 @@ using System; using Server.Mobiles; -using Server.Targeting; namespace Server.Spells.Fifth { - public class BladeSpiritsSpell : MagerySpell + public class BladeSpiritsSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Blade Spirits", "In Jux Hur Ylem", @@ -16,7 +15,7 @@ namespace Server.Spells.Fifth Reagent.Nightshade ); - public BladeSpiritsSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public BladeSpiritsSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -46,7 +45,7 @@ namespace Server.Spells.Fifth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this); } public void Target(IPoint3D p) @@ -73,34 +72,5 @@ namespace Server.Spells.Fifth FinishSequence(); } - - private class InternalTarget : Target - { - private BladeSpiritsSpell m_Owner; - - public InternalTarget(BladeSpiritsSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetOutOfLOS(Mobile from, object o) - { - from.SendLocalizedMessage(501943); // Target cannot be seen. Try again. - from.Target = new InternalTarget(m_Owner); - from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow); - m_Owner = null; - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner?.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fifth/DispelField.cs b/Scripts/Spells/Fifth/DispelField.cs index 3e8536a0b..c9662a02b 100644 --- a/Scripts/Spells/Fifth/DispelField.cs +++ b/Scripts/Spells/Fifth/DispelField.cs @@ -1,11 +1,10 @@ -using System; using Server.Items; using Server.Misc; using Server.Targeting; namespace Server.Spells.Fifth { - public class DispelFieldSpell : MagerySpell + public class DispelFieldSpell : MagerySpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Dispel Field", "An Grav", @@ -17,7 +16,7 @@ namespace Server.Spells.Fifth Reagent.Garlic ); - public DispelFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public DispelFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -25,25 +24,19 @@ namespace Server.Spells.Fifth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(Item item) { - Type t = item.GetType(); - - if (!Caster.CanSee(item)) - { - Caster.SendLocalizedMessage(500237); // Target can not be seen. - } - else if (!t.IsDefined(typeof(DispellableFieldAttribute), false)) - { + if (item == null) + Caster.SendLocalizedMessage(1005049); // That cannot be dispelled. + else if (!Caster.CanSee(item)) + Caster.SendLocalizedMessage(500237); // Target can not be seen. + else if (!item.GetType().IsDefined(typeof(DispellableFieldAttribute), false)) Caster.SendLocalizedMessage(1005049); // That cannot be dispelled. - } else if (item is Moongate moongate && !moongate.Dispellable) - { Caster.SendLocalizedMessage(1005047); // That magic is too chaotic - } else if (CheckSequence()) { SpellHelper.Turn(Caster, item); @@ -57,28 +50,5 @@ namespace Server.Spells.Fifth FinishSequence(); } - - private class InternalTarget : Target - { - private DispelFieldSpell m_Owner; - - public InternalTarget(DispelFieldSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Item item) - m_Owner.Target(item); - else - m_Owner.Caster.SendLocalizedMessage(1005049); // That cannot be dispelled. - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fifth/Incognito.cs b/Scripts/Spells/Fifth/Incognito.cs index e03b8dd38..e28e75943 100644 --- a/Scripts/Spells/Fifth/Incognito.cs +++ b/Scripts/Spells/Fifth/Incognito.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Factions; using Server.Items; @@ -21,7 +20,7 @@ namespace Server.Spells.Fifth private static Dictionary m_Timers = new Dictionary(); - public IncognitoSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public IncognitoSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Fifth/MagicReflect.cs b/Scripts/Spells/Fifth/MagicReflect.cs index 3897b4ac5..609061727 100644 --- a/Scripts/Spells/Fifth/MagicReflect.cs +++ b/Scripts/Spells/Fifth/MagicReflect.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; namespace Server.Spells.Fifth @@ -16,7 +15,7 @@ namespace Server.Spells.Fifth private static Dictionary m_Table = new Dictionary(); - public MagicReflectSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MagicReflectSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -79,7 +78,7 @@ namespace Server.Spells.Fifth for (int i = 0; i < mods.Length; ++i) targ.AddResistanceMod(mods[i]); - string buffFormat = string.Format("{0}\t+{1}\t+{1}\t+{1}\t+{1}", physiMod, otherMod); + string buffFormat = $"{physiMod}\t+{otherMod}\t+{otherMod}\t+{otherMod}\t+{otherMod}"; BuffInfo.AddBuff(targ, new BuffInfo(BuffIcon.MagicReflection, 1075817, buffFormat, true)); } @@ -133,16 +132,14 @@ namespace Server.Spells.Fifth public static void EndReflect(Mobile m) { - ResistanceMod[] mods = m_Table[m]; + if (!m_Table.TryGetValue(m, out ResistanceMod[] mods)) + return; - if (mods != null) - { - for (int i = 0; i < mods.Length; ++i) - m.RemoveResistanceMod(mods[i]); + for (int i = 0; i < mods?.Length; ++i) + m.RemoveResistanceMod(mods[i]); - m_Table.Remove(m); - BuffInfo.RemoveBuff(m, BuffIcon.MagicReflection); - } + m_Table.Remove(m); + BuffInfo.RemoveBuff(m, BuffIcon.MagicReflection); } } } diff --git a/Scripts/Spells/Fifth/MindBlast.cs b/Scripts/Spells/Fifth/MindBlast.cs index a0cd18622..f94f990bb 100644 --- a/Scripts/Spells/Fifth/MindBlast.cs +++ b/Scripts/Spells/Fifth/MindBlast.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Fifth { - public class MindBlastSpell : MagerySpell + public class MindBlastSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Mind Blast", "Por Corp Wis", @@ -15,7 +15,7 @@ namespace Server.Spells.Fifth Reagent.SulfurousAsh ); - public MindBlastSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MindBlastSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { if (Core.AOS) m_Info.LeftHandEffect = m_Info.RightHandEffect = 9002; @@ -27,7 +27,7 @@ namespace Server.Spells.Fifth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } private void AosDelay_Callback(Mobile caster, Mobile target, Mobile defender, int damage) @@ -43,10 +43,11 @@ namespace Server.Spells.Fifth public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (Core.AOS) { if (Caster.CanBeHarmful(m) && CheckSequence()) @@ -122,26 +123,5 @@ namespace Server.Spells.Fifth { return 1.0; //This spell isn't affected by slayer spellbooks } - - private class InternalTarget : Target - { - private MindBlastSpell m_Owner; - - public InternalTarget(MindBlastSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fifth/Paralyze.cs b/Scripts/Spells/Fifth/Paralyze.cs index b5f0892e1..2f2555931 100644 --- a/Scripts/Spells/Fifth/Paralyze.cs +++ b/Scripts/Spells/Fifth/Paralyze.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.Spells.Fifth { - public class ParalyzeSpell : MagerySpell + public class ParalyzeSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Paralyze", "An Ex Por", @@ -16,7 +16,7 @@ namespace Server.Spells.Fifth Reagent.SpidersSilk ); - public ParalyzeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ParalyzeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -24,15 +24,16 @@ namespace Server.Spells.Fifth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (Core.AOS && (m.Frozen || m.Paralyzed || m.Spell != null && m.Spell.IsCasting && !(m.Spell is PaladinSpell))) { @@ -87,26 +88,5 @@ namespace Server.Spells.Fifth FinishSequence(); } - - public class InternalTarget : Target - { - private ParalyzeSpell m_Owner; - - public InternalTarget(ParalyzeSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fifth/PoisonField.cs b/Scripts/Spells/Fifth/PoisonField.cs index 941c92326..4eb0f9aae 100644 --- a/Scripts/Spells/Fifth/PoisonField.cs +++ b/Scripts/Spells/Fifth/PoisonField.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using Server.Items; using Server.Misc; using Server.Mobiles; @@ -7,7 +7,7 @@ using Server.Targeting; namespace Server.Spells.Fifth { - public class PoisonFieldSpell : MagerySpell + public class PoisonFieldSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Poison Field", "In Nox Grav", @@ -19,7 +19,7 @@ namespace Server.Spells.Fifth Reagent.SpidersSilk ); - public PoisonFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public PoisonFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -27,7 +27,7 @@ namespace Server.Spells.Fifth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12, false); } public void Target(IPoint3D p) @@ -197,7 +197,7 @@ namespace Server.Spells.Fifth private class InternalTimer : Timer { - private static Queue m_Queue = new Queue(); + private static Queue m_Queue = new Queue(); private bool m_InLOS, m_CanFit; private InternalItem m_Item; @@ -257,7 +257,7 @@ namespace Server.Spells.Fifth while (m_Queue.Count > 0) { - Mobile m = (Mobile)m_Queue.Dequeue(); + Mobile m = m_Queue.Dequeue(); caster.DoHarmful(m); @@ -269,26 +269,5 @@ namespace Server.Spells.Fifth } } } - - private class InternalTarget : Target - { - private PoisonFieldSpell m_Owner; - - public InternalTarget(PoisonFieldSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fifth/SummonCreature.cs b/Scripts/Spells/Fifth/SummonCreature.cs index 4e848f32c..4786ce796 100644 --- a/Scripts/Spells/Fifth/SummonCreature.cs +++ b/Scripts/Spells/Fifth/SummonCreature.cs @@ -38,7 +38,7 @@ namespace Server.Spells.Fifth typeof(Rabbit) }; - public SummonCreatureSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public SummonCreatureSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -78,6 +78,7 @@ namespace Server.Spells.Fifth } catch { + // ignored } FinishSequence(); @@ -91,4 +92,4 @@ namespace Server.Spells.Fifth return base.GetCastDelay() + TimeSpan.FromSeconds(6.0); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/Clumsy.cs b/Scripts/Spells/First/Clumsy.cs index 7310a5a67..e0d0e1e49 100644 --- a/Scripts/Spells/First/Clumsy.cs +++ b/Scripts/Spells/First/Clumsy.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.First { - public class ClumsySpell : MagerySpell + public class ClumsySpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Clumsy", "Uus Jux", @@ -13,7 +13,7 @@ namespace Server.Spells.First Reagent.Nightshade ); - public ClumsySpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ClumsySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -21,11 +21,14 @@ namespace Server.Spells.First public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. @@ -55,26 +58,5 @@ namespace Server.Spells.First FinishSequence(); } - - private class InternalTarget : Target - { - private ClumsySpell m_Owner; - - public InternalTarget(ClumsySpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/CreateFood.cs b/Scripts/Spells/First/CreateFood.cs index a9aee7ff5..cf3dd2f10 100644 --- a/Scripts/Spells/First/CreateFood.cs +++ b/Scripts/Spells/First/CreateFood.cs @@ -28,7 +28,7 @@ namespace Server.Spells.First new FoodInfo(typeof(Peach), "a peach") }; - public CreateFoodSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CreateFoodSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -85,4 +85,4 @@ namespace Server.Spells.First return item; } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/Feeblemind.cs b/Scripts/Spells/First/Feeblemind.cs index b8498ad78..37344a029 100644 --- a/Scripts/Spells/First/Feeblemind.cs +++ b/Scripts/Spells/First/Feeblemind.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.First { - public class FeeblemindSpell : MagerySpell + public class FeeblemindSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Feeblemind", "Rel Wis", @@ -13,7 +13,7 @@ namespace Server.Spells.First Reagent.Nightshade ); - public FeeblemindSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public FeeblemindSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -21,15 +21,16 @@ namespace Server.Spells.First public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -55,26 +56,5 @@ namespace Server.Spells.First FinishSequence(); } - - private class InternalTarget : Target - { - private FeeblemindSpell m_Owner; - - public InternalTarget(FeeblemindSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/Heal.cs b/Scripts/Spells/First/Heal.cs index 77118315d..2e2c80b36 100644 --- a/Scripts/Spells/First/Heal.cs +++ b/Scripts/Spells/First/Heal.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.Spells.First { - public class HealSpell : MagerySpell + public class HealSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Heal", "In Mani", @@ -17,7 +17,7 @@ namespace Server.Spells.First Reagent.SpidersSilk ); - public HealSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public HealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -36,11 +36,14 @@ namespace Server.Spells.First public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. @@ -90,26 +93,5 @@ namespace Server.Spells.First FinishSequence(); } - - public class InternalTarget : Target - { - private HealSpell m_Owner; - - public InternalTarget(HealSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/MagicArrow.cs b/Scripts/Spells/First/MagicArrow.cs index e19dc80d7..9addce105 100644 --- a/Scripts/Spells/First/MagicArrow.cs +++ b/Scripts/Spells/First/MagicArrow.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.First { - public class MagicArrowSpell : MagerySpell + public class MagicArrowSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Magic Arrow", "In Por Ylem", @@ -11,7 +11,7 @@ namespace Server.Spells.First Reagent.SulfurousAsh ); - public MagicArrowSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MagicArrowSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -23,15 +23,16 @@ namespace Server.Spells.First public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { Mobile source = Caster; @@ -68,26 +69,5 @@ namespace Server.Spells.First FinishSequence(); } - - private class InternalTarget : Target - { - private MagicArrowSpell m_Owner; - - public InternalTarget(MagicArrowSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/NightSight.cs b/Scripts/Spells/First/NightSight.cs index c43ab9a44..c345af69d 100644 --- a/Scripts/Spells/First/NightSight.cs +++ b/Scripts/Spells/First/NightSight.cs @@ -12,7 +12,7 @@ namespace Server.Spells.First Reagent.SpidersSilk ); - public NightSightSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public NightSightSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -72,4 +72,4 @@ namespace Server.Spells.First } } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/First/ReactiveArmor.cs b/Scripts/Spells/First/ReactiveArmor.cs index eac621c05..521b6397a 100644 --- a/Scripts/Spells/First/ReactiveArmor.cs +++ b/Scripts/Spells/First/ReactiveArmor.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; namespace Server.Spells.First @@ -16,7 +15,7 @@ namespace Server.Spells.First private static Dictionary m_Table = new Dictionary(); - public ReactiveArmorSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ReactiveArmorSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -139,16 +138,14 @@ namespace Server.Spells.First public static void EndArmor(Mobile m) { - ResistanceMod[] mods = m_Table[m]; + if (!m_Table.TryGetValue(m, out ResistanceMod[] mods)) + return; - if (mods != null) - { - for (int i = 0; i < mods.Length; ++i) - m.RemoveResistanceMod(mods[i]); + for (int i = 0; i < mods?.Length; ++i) + m.RemoveResistanceMod(mods[i]); - m_Table.Remove(m); - BuffInfo.RemoveBuff(m, BuffIcon.ReactiveArmor); - } + m_Table.Remove(m); + BuffInfo.RemoveBuff(m, BuffIcon.ReactiveArmor); } } } diff --git a/Scripts/Spells/First/Weaken.cs b/Scripts/Spells/First/Weaken.cs index d553639c4..8584877e0 100644 --- a/Scripts/Spells/First/Weaken.cs +++ b/Scripts/Spells/First/Weaken.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.First { - public class WeakenSpell : MagerySpell + public class WeakenSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Weaken", "Des Mani", @@ -13,7 +13,7 @@ namespace Server.Spells.First Reagent.Nightshade ); - public WeakenSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public WeakenSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -21,15 +21,16 @@ namespace Server.Spells.First public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -55,26 +56,5 @@ namespace Server.Spells.First FinishSequence(); } - - public class InternalTarget : Target - { - private WeakenSpell m_Owner; - - public InternalTarget(WeakenSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fourth/ArchCure.cs b/Scripts/Spells/Fourth/ArchCure.cs index 6b8cfbf4f..827a356b8 100644 --- a/Scripts/Spells/Fourth/ArchCure.cs +++ b/Scripts/Spells/Fourth/ArchCure.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Mobiles; using Server.Targeting; namespace Server.Spells.Fourth { - public class ArchCureSpell : MagerySpell + public class ArchCureSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Arch Cure", "Vas An Nox", @@ -16,7 +17,7 @@ namespace Server.Spells.Fourth Reagent.MandrakeRoot ); - public ArchCureSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ArchCureSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -27,7 +28,7 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -56,15 +57,7 @@ namespace Server.Spells.Fourth targets.Add(directTarget); IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2); - - foreach (Mobile m in eable) - { - if (m == directTarget) - continue; - - if (AreaCanTarget(m, feluccaRules)) - targets.Add(m); - } + targets.AddRange(eable.Where(m => m != directTarget).Where(m => AreaCanTarget(m, feluccaRules))); eable.Free(); } @@ -158,26 +151,5 @@ namespace Server.Spells.Fourth { return Notoriety.Compute(from, to) == Notoriety.Ally; } - - private class InternalTarget : Target - { - private ArchCureSpell m_Owner; - - public InternalTarget(ArchCureSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fourth/ArchProtection.cs b/Scripts/Spells/Fourth/ArchProtection.cs index d8f9e6547..b83d8d496 100644 --- a/Scripts/Spells/Fourth/ArchProtection.cs +++ b/Scripts/Spells/Fourth/ArchProtection.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Engines.PartySystem; using Server.Spells.Second; using Server.Targeting; namespace Server.Spells.Fourth { - public class ArchProtectionSpell : MagerySpell + public class ArchProtectionSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Arch Protection", "Vas Uus Sanct", @@ -20,7 +21,7 @@ namespace Server.Spells.Fourth private static Dictionary _Table = new Dictionary(); - public ArchProtectionSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ArchProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -28,7 +29,7 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -43,30 +44,25 @@ namespace Server.Spells.Fourth SpellHelper.GetSurfaceTop(ref p); - List targets = new List(); + if (!Core.AOS) + Effects.PlaySound(p, Caster.Map, 0x299); - Map map = Caster.Map; - - if (map != null) + if (Caster.Map == null) { - IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), Core.AOS ? 2 : 3); - - foreach (Mobile m in eable) - if (Caster.CanBeBeneficial(m, false)) - targets.Add(m); - - eable.Free(); + FinishSequence(); + return; } + IEnumerable targets = Caster.Map.GetMobilesInRange(new Point3D(p), Core.AOS ? 2 : 3) + .Where(m => Caster.CanBeBeneficial(m, false)); + if (Core.AOS) { Party party = Party.Get(Caster); - for (int i = 0; i < targets.Count; ++i) + foreach (Mobile m in targets) { - Mobile m = targets[i]; - - if (m == Caster || party != null && party.Contains(m)) + if (m == Caster || party?.Contains(m) == true) { Caster.DoBeneficial(m); ProtectionSpell.Toggle(Caster, m); @@ -75,27 +71,22 @@ namespace Server.Spells.Fourth } else { - Effects.PlaySound(p, Caster.Map, 0x299); - int val = (int)(Caster.Skills.Magery.Value / 10.0 + 1); - if (targets.Count > 0) - for (int i = 0; i < targets.Count; ++i) + foreach (Mobile m in targets) + { + if (m.BeginAction()) { - Mobile m = targets[i]; + Caster.DoBeneficial(m); + m.VirtualArmorMod += val; - if (m.BeginAction()) - { - Caster.DoBeneficial(m); - m.VirtualArmorMod += val; + AddEntry(m, val); + new InternalTimer(m, Caster).Start(); - AddEntry(m, val); - new InternalTimer(m, Caster).Start(); - - m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist); - m.PlaySound(0x1F7); - } + m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist); + m.PlaySound(0x1F7); } + } } } @@ -139,26 +130,5 @@ namespace Server.Spells.Fourth RemoveEntry(m_Owner); } } - - private class InternalTarget : Target - { - private ArchProtectionSpell m_Owner; - - public InternalTarget(ArchProtectionSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Fourth/Curse.cs b/Scripts/Spells/Fourth/Curse.cs index 0aec525e6..4b82c39c4 100644 --- a/Scripts/Spells/Fourth/Curse.cs +++ b/Scripts/Spells/Fourth/Curse.cs @@ -1,11 +1,10 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Targeting; namespace Server.Spells.Fourth { - public class CurseSpell : MagerySpell + public class CurseSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Curse", "Des Sanct", @@ -18,7 +17,7 @@ namespace Server.Spells.Fourth private static HashSet m_UnderEffect = new HashSet(); - public CurseSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -26,7 +25,7 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public static void RemoveEffect(Mobile m) @@ -43,10 +42,11 @@ namespace Server.Spells.Fourth public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -87,26 +87,5 @@ namespace Server.Spells.Fourth FinishSequence(); } - - private class InternalTarget : Target - { - private CurseSpell m_Owner; - - public InternalTarget(CurseSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Fourth/FireField.cs b/Scripts/Spells/Fourth/FireField.cs index a5388cbb2..376732848 100644 --- a/Scripts/Spells/Fourth/FireField.cs +++ b/Scripts/Spells/Fourth/FireField.cs @@ -7,7 +7,7 @@ using Server.Targeting; namespace Server.Spells.Fourth { - public class FireFieldSpell : MagerySpell + public class FireFieldSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Fire Field", "In Flam Grav", @@ -19,7 +19,7 @@ namespace Server.Spells.Fourth Reagent.SulfurousAsh ); - public FireFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public FireFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -27,7 +27,7 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -88,13 +88,8 @@ namespace Server.Spells.Fourth private DateTime m_End; private Timer m_Timer; - public FireFieldItem(int itemID, Point3D loc, Mobile caster, Map map, TimeSpan duration, int val) - : this(itemID, loc, caster, map, duration, val, 2) - { - } - public FireFieldItem(int itemID, Point3D loc, Mobile caster, Map map, TimeSpan duration, int val, - int damage) : base(itemID) + int damage = 2) : base(itemID) { bool canFit = SpellHelper.AdjustField(ref loc, map, 12, false); @@ -248,7 +243,7 @@ namespace Server.Spells.Fourth if (map == null || caster == null) return; - + foreach (Mobile 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)) @@ -281,26 +276,5 @@ namespace Server.Spells.Fourth } } } - - private class InternalTarget : Target - { - private FireFieldSpell m_Owner; - - public InternalTarget(FireFieldSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fourth/GreaterHeal.cs b/Scripts/Spells/Fourth/GreaterHeal.cs index 39aee8a86..67ee99f2e 100644 --- a/Scripts/Spells/Fourth/GreaterHeal.cs +++ b/Scripts/Spells/Fourth/GreaterHeal.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.Spells.Fourth { - public class GreaterHealSpell : MagerySpell + public class GreaterHealSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Greater Heal", "In Vas Mani", @@ -18,7 +18,7 @@ namespace Server.Spells.Fourth Reagent.SpidersSilk ); - public GreaterHealSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public GreaterHealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -37,15 +37,16 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (m is BaseCreature creature && creature.IsAnimatedDead) { Caster.SendLocalizedMessage(1061654); // You cannot heal that which is not alive. @@ -80,26 +81,5 @@ namespace Server.Spells.Fourth FinishSequence(); } - - public class InternalTarget : Target - { - private GreaterHealSpell m_Owner; - - public InternalTarget(GreaterHealSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fourth/Lightning.cs b/Scripts/Spells/Fourth/Lightning.cs index 163fcae79..151054b36 100644 --- a/Scripts/Spells/Fourth/Lightning.cs +++ b/Scripts/Spells/Fourth/Lightning.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.Fourth { - public class LightningSpell : MagerySpell + public class LightningSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Lightning", "Por Ort Grav", @@ -12,7 +12,7 @@ namespace Server.Spells.Fourth Reagent.SulfurousAsh ); - public LightningSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public LightningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,15 +22,16 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -64,26 +65,5 @@ namespace Server.Spells.Fourth FinishSequence(); } - - private class InternalTarget : Target - { - private LightningSpell m_Owner; - - public InternalTarget(LightningSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Fourth/ManaDrain.cs b/Scripts/Spells/Fourth/ManaDrain.cs index f8a1a7572..93d953758 100644 --- a/Scripts/Spells/Fourth/ManaDrain.cs +++ b/Scripts/Spells/Fourth/ManaDrain.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Fourth { - public class ManaDrainSpell : MagerySpell + public class ManaDrainSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Mana Drain", "Ort Rel", @@ -17,7 +17,7 @@ namespace Server.Spells.Fourth private static HashSet m_Table = new HashSet(); - public ManaDrainSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ManaDrainSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -25,7 +25,7 @@ namespace Server.Spells.Fourth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } private void AosDelay_Callback(Mobile m, int mana) @@ -43,10 +43,11 @@ namespace Server.Spells.Fourth public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -103,26 +104,5 @@ namespace Server.Spells.Fourth { return 99.0; } - - private class InternalTarget : Target - { - private ManaDrainSpell m_Owner; - - public InternalTarget(ManaDrainSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Fourth/Recall.cs b/Scripts/Spells/Fourth/Recall.cs index e3c86baa7..3dd83bcfb 100644 --- a/Scripts/Spells/Fourth/Recall.cs +++ b/Scripts/Spells/Fourth/Recall.cs @@ -2,14 +2,11 @@ using Server.Factions; using Server.Items; using Server.Misc; using Server.Mobiles; -using Server.Multis; -using Server.Network; using Server.Spells.Necromancy; -using Server.Targeting; namespace Server.Spells.Fourth { - public class RecallSpell : MagerySpell + public class RecallSpell : MagerySpell, IRecallSpell { private static SpellInfo m_Info = new SpellInfo( "Recall", "Kal Ort Por", @@ -24,7 +21,8 @@ namespace Server.Spells.Fourth private RunebookEntry m_Entry; - public RecallSpell(Mobile caster, Item scroll, RunebookEntry entry = null, Runebook book = null) : base(caster, scroll, m_Info) + public RecallSpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) : + base(caster, scroll, m_Info) { m_Entry = entry; m_Book = book; @@ -45,7 +43,7 @@ namespace Server.Spells.Fourth public override void OnCast() { if (m_Entry == null) - Caster.Target = new InternalTarget(this); + Caster.Target = new RecallSpellTarget(this); else Effect(m_Entry.Location, m_Entry.Map, true); } @@ -141,63 +139,5 @@ namespace Server.Spells.Fourth FinishSequence(); } - - private class InternalTarget : Target - { - private RecallSpell m_Owner; - - public InternalTarget(RecallSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - - owner.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item. - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is RecallRune rune) - { - if (rune.Marked) - m_Owner.Effect(rune.Target, rune.TargetMap, true); - else - from.SendLocalizedMessage(501805); // That rune is not yet marked. - } - else if (o is Runebook runebook) - { - RunebookEntry e = runebook.Default; - - if (e != null) - m_Owner.Effect(e.Location, e.Map, true); - else - from.SendLocalizedMessage(502354); // Target is not marked. - } - else if (o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat) - { - if (!boat.Deleted && boat.CheckKey(key.KeyValue)) - m_Owner.Effect(boat.GetMarkedLocation(), boat.Map, false); - else - from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, - from.Name, "")); // I can not recall from that object. - } - else if (o is HouseRaffleDeed deed && deed.ValidLocation()) - { - m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true); - } - else - { - from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, - "")); // I can not recall from that object. - } - } - - protected override void OnNonlocalTarget(Mobile from, object o) - { - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs b/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs index 563cf0168..e60847098 100644 --- a/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs +++ b/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs @@ -1,89 +1,66 @@ -using System; -using Server.Mobiles; -using Server.Targeting; - -namespace Server.Spells.Mysticism -{ - public class AnimatedWeaponSpell : MysticSpell - { - private static SpellInfo m_Info = new SpellInfo( - "Animated Weapon", "In Jux Por Ylem", - -1, - 9002, - Reagent.Bone, - Reagent.BlackPearl, - Reagent.MandrakeRoot, - Reagent.Nightshade - ); - - public AnimatedWeaponSpell(Mobile caster, Item scroll) - : base(caster, scroll, m_Info) - { - } - - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5); - - public override double RequiredSkill => 33.0; - public override int RequiredMana => 11; - - public override void OnCast() - { - Caster.Target = new InternalTarget(this); - } - - public void Target(IPoint3D p) - { - if (Caster.Followers + 4 > Caster.FollowersMax) - { - Caster.SendLocalizedMessage(1049645); // You have too many followers to summon that creature. - return; - } - - Map map = Caster.Map; - - SpellHelper.GetSurfaceTop(ref p); - - if (map == null || Caster.Player && !map.CanSpawnMobile(p.X, p.Y, p.Z)) - { - Caster.SendLocalizedMessage(501942); // That location is blocked. - } - else if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) - { - int level = (int)((GetBaseSkill(Caster) + GetBoostSkill(Caster)) / 2.0); - - TimeSpan duration = TimeSpan.FromSeconds(10 + level); - - AnimatedWeapon summon = new AnimatedWeapon(Caster, level); - BaseCreature.Summon(summon, false, Caster, new Point3D(p), 0x212, duration); - - summon.PlaySound(0x64A); - - Effects.SendTargetParticles(summon, 0x3728, 10, 10, 0x13AA, (EffectLayer)255); - } - - FinishSequence(); - } - - public class InternalTarget : Target - { - private AnimatedWeaponSpell m_Owner; - - public InternalTarget(AnimatedWeaponSpell owner) - : base(12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } - } -} \ No newline at end of file +using System; +using Server.Mobiles; + +namespace Server.Spells.Mysticism +{ + public class AnimatedWeaponSpell : MysticSpell, ISpellTargetingPoint3D + { + private static SpellInfo m_Info = new SpellInfo( + "Animated Weapon", "In Jux Por Ylem", + -1, + 9002, + Reagent.Bone, + Reagent.BlackPearl, + Reagent.MandrakeRoot, + Reagent.Nightshade + ); + + public AnimatedWeaponSpell(Mobile caster, Item scroll = null) + : base(caster, scroll, m_Info) + { + } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5); + + public override double RequiredSkill => 33.0; + public override int RequiredMana => 11; + + public override void OnCast() + { + Caster.Target = new SpellTargetPoint3D(this); + } + + public void Target(IPoint3D p) + { + if (Caster.Followers + 4 > Caster.FollowersMax) + { + Caster.SendLocalizedMessage(1049645); // You have too many followers to summon that creature. + return; + } + + Map map = Caster.Map; + + SpellHelper.GetSurfaceTop(ref p); + + if (map == null || Caster.Player && !map.CanSpawnMobile(p.X, p.Y, p.Z)) + { + Caster.SendLocalizedMessage(501942); // That location is blocked. + } + else if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) + { + int level = (int)((GetBaseSkill(Caster) + GetBoostSkill(Caster)) / 2.0); + + TimeSpan duration = TimeSpan.FromSeconds(10 + level); + + AnimatedWeapon summon = new AnimatedWeapon(Caster, level); + BaseCreature.Summon(summon, false, Caster, new Point3D(p), 0x212, duration); + + summon.PlaySound(0x64A); + + Effects.SendTargetParticles(summon, 0x3728, 10, 10, 0x13AA, (EffectLayer)255); + } + + FinishSequence(); + } + } +} diff --git a/Scripts/Spells/Mysticism/EagleStrikeSpell.cs b/Scripts/Spells/Mysticism/EagleStrikeSpell.cs index 5872252c0..0fd88b9e0 100644 --- a/Scripts/Spells/Mysticism/EagleStrikeSpell.cs +++ b/Scripts/Spells/Mysticism/EagleStrikeSpell.cs @@ -1,88 +1,69 @@ -using System; -using Server.Targeting; - -namespace Server.Spells.Mysticism -{ - public class EagleStrikeSpell : MysticSpell - { - private static SpellInfo m_Info = new SpellInfo( - "Eagle Strike", "Kal Por Xen", - -1, - 9002, - Reagent.Bloodmoss, - Reagent.Bone, - Reagent.SpidersSilk, - Reagent.MandrakeRoot - ); - - public EagleStrikeSpell(Mobile caster, Item scroll) - : base(caster, scroll, m_Info) - { - } - - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.25); - - public override double RequiredSkill => 20.0; - public override int RequiredMana => 9; - - public override void OnCast() - { - Caster.Target = new InternalTarget(this); - } - - public void Target(Mobile m) - { - if (CheckHSequence(m)) - { - /* Conjures a magical eagle that assaults the Target with - * its talons, dealing energy damage. - */ - - SpellHelper.Turn(Caster, m); - - SpellHelper.CheckReflect(2, Caster, ref m); - - Caster.MovingParticles(m, 0x407A, 7, 0, false, true, 0, 0, 0xBBE, 0xFA6, 0xFFFF, 0); - Caster.PlaySound(0x2EE); - - Timer.DelayCall(TimeSpan.FromSeconds(1.0), Damage, m); - } - - FinishSequence(); - } - - private void Damage(Mobile to) - { - if (to == null) - return; - - double damage = GetNewAosDamage(19, 1, 5, to); - - SpellHelper.Damage(this, to, damage, 0, 0, 0, 0, 100); - - to.PlaySound(0x64D); - } - - private class InternalTarget : Target - { - private EagleStrikeSpell m_Owner; - - public InternalTarget(EagleStrikeSpell owner) - : base(12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } - } -} \ No newline at end of file +using System; +using Server.Targeting; + +namespace Server.Spells.Mysticism +{ + public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile + { + private static SpellInfo m_Info = new SpellInfo( + "Eagle Strike", "Kal Por Xen", + -1, + 9002, + Reagent.Bloodmoss, + Reagent.Bone, + Reagent.SpidersSilk, + Reagent.MandrakeRoot + ); + + public EagleStrikeSpell(Mobile caster, Item scroll = null) + : base(caster, scroll, m_Info) + { + } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.25); + + public override double RequiredSkill => 20.0; + public override int RequiredMana => 9; + + public override void OnCast() + { + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful); + } + + public void Target(Mobile m) + { + if (m == null) + return; + + if (CheckHSequence(m)) + { + /* Conjures a magical eagle that assaults the Target with + * its talons, dealing energy damage. + */ + + SpellHelper.Turn(Caster, m); + + SpellHelper.CheckReflect(2, Caster, ref m); + + Caster.MovingParticles(m, 0x407A, 7, 0, false, true, 0, 0, 0xBBE, 0xFA6, 0xFFFF, 0); + Caster.PlaySound(0x2EE); + + Timer.DelayCall(TimeSpan.FromSeconds(1.0), Damage, m); + } + + FinishSequence(); + } + + private void Damage(Mobile to) + { + if (to == null) + return; + + double damage = GetNewAosDamage(19, 1, 5, to); + + SpellHelper.Damage(this, to, damage, 0, 0, 0, 0, 100); + + to.PlaySound(0x64D); + } + } +} diff --git a/Scripts/Spells/Mysticism/HailStormSpell.cs b/Scripts/Spells/Mysticism/HailStormSpell.cs index ef5040d8c..53c2b8fa4 100644 --- a/Scripts/Spells/Mysticism/HailStormSpell.cs +++ b/Scripts/Spells/Mysticism/HailStormSpell.cs @@ -1,144 +1,121 @@ -using System; -using System.Collections.Generic; -using Server.Network; -using Server.Targeting; - -namespace Server.Spells.Mysticism -{ - public class HailStormSpell : MysticSpell - { - private static SpellInfo m_Info = new SpellInfo( - "Hail Storm", "Kal Des Ylem", - -1, - 9002, - Reagent.DragonsBlood, - Reagent.Bloodmoss, - Reagent.BlackPearl, - Reagent.MandrakeRoot - ); - - public HailStormSpell(Mobile caster, Item scroll) - : base(caster, scroll, m_Info) - { - } - - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.25); - - public override double RequiredSkill => 70.0; - public override int RequiredMana => 40; - - public override void OnCast() - { - Caster.Target = new InternalTarget(this); - } - - public void Target(IPoint3D p) - { - if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) - { - /* Summons a storm of hailstones that strikes all Targets - * within a radius around the Target's Location, dealing - * cold damage. - */ - - SpellHelper.Turn(Caster, p); - - if (p is Item item) - p = item.GetWorldLocation(); - - List targets = new List(); - - Map map = Caster.Map; - - bool pvp = false; - - if (map != null) - { - PlayEffect(p, Caster.Map); - - foreach (Mobile 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; - } - } - } - - double damage = GetNewAosDamage(51, 1, 5, pvp); - - foreach (Mobile m in targets) - { - Caster.DoHarmful(m); - SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0); - } - } - - FinishSequence(); - } - - private static void PlayEffect(IPoint3D p, Map map) - { - Effects.PlaySound(p, map, 0x64F); - - PlaySingleEffect(p, map, -1, 1, -1, 1); - PlaySingleEffect(p, map, -2, 0, -3, -1); - PlaySingleEffect(p, map, -3, -1, -1, 1); - PlaySingleEffect(p, map, 1, 3, -1, 1); - PlaySingleEffect(p, map, -1, 1, 1, 3); - } - - private static void PlaySingleEffect(IPoint3D p, Map map, int a, int b, int c, int d) - { - int x = p.X, y = p.Y, z = p.Z + 18; - - SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z)); - SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z)); - - SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z)); - SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z)); - } - - private static void SendEffectPacket(IPoint3D p, Map map, Point3D orig, Point3D dest) - { - Effects.SendPacket(p, map, - new HuedEffect(EffectType.Moving, Serial.Zero, Serial.Zero, 0x36D4, orig, dest, 0, 0, false, false, 0x63, - 0x4)); - } - - private class InternalTarget : Target - { - private HailStormSpell m_Owner; - - public InternalTarget(HailStormSpell owner) - : base(12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using Server.Network; + +namespace Server.Spells.Mysticism +{ + public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D + { + private static SpellInfo m_Info = new SpellInfo( + "Hail Storm", "Kal Des Ylem", + -1, + 9002, + Reagent.DragonsBlood, + Reagent.Bloodmoss, + Reagent.BlackPearl, + Reagent.MandrakeRoot + ); + + public HailStormSpell(Mobile caster, Item scroll = null) + : base(caster, scroll, m_Info) + { + } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.25); + + public override double RequiredSkill => 70.0; + public override int RequiredMana => 40; + + public override void OnCast() + { + Caster.Target = new SpellTargetPoint3D(this); + } + + public void Target(IPoint3D p) + { + if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) + { + /* Summons a storm of hailstones that strikes all Targets + * within a radius around the Target's Location, dealing + * cold damage. + */ + + SpellHelper.Turn(Caster, p); + + if (p is Item item) + p = item.GetWorldLocation(); + + List targets = new List(); + + Map map = Caster.Map; + + bool pvp = false; + + if (map != null) + { + PlayEffect(p, Caster.Map); + + foreach (Mobile 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; + } + } + } + + double damage = GetNewAosDamage(51, 1, 5, pvp); + + foreach (Mobile m in targets) + { + Caster.DoHarmful(m); + SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0); + } + } + + FinishSequence(); + } + + private static void PlayEffect(IPoint3D p, Map map) + { + Effects.PlaySound(p, map, 0x64F); + + PlaySingleEffect(p, map, -1, 1, -1, 1); + PlaySingleEffect(p, map, -2, 0, -3, -1); + PlaySingleEffect(p, map, -3, -1, -1, 1); + PlaySingleEffect(p, map, 1, 3, -1, 1); + PlaySingleEffect(p, map, -1, 1, 1, 3); + } + + private static void PlaySingleEffect(IPoint3D p, Map map, int a, int b, int c, int d) + { + int x = p.X, y = p.Y, z = p.Z + 18; + + SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z)); + SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z)); + + SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z)); + SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z)); + } + + private static void SendEffectPacket(IPoint3D p, Map map, Point3D orig, Point3D dest) + { + Effects.SendPacket(p, map, + new HuedEffect(EffectType.Moving, Serial.Zero, Serial.Zero, 0x36D4, orig, dest, 0, 0, false, false, 0x63, + 0x4)); + } + } +} diff --git a/Scripts/Spells/Mysticism/NetherCycloneSpell.cs b/Scripts/Spells/Mysticism/NetherCycloneSpell.cs index 15982d9dd..36ec20616 100644 --- a/Scripts/Spells/Mysticism/NetherCycloneSpell.cs +++ b/Scripts/Spells/Mysticism/NetherCycloneSpell.cs @@ -1,153 +1,130 @@ -using System; -using System.Collections.Generic; -using Server.Network; -using Server.Targeting; - -namespace Server.Spells.Mysticism -{ - public class NetherCycloneSpell : MysticSpell - { - private static SpellInfo m_Info = new SpellInfo( - "Nether Cyclone", "Grav Hur", - -1, - 9002, - Reagent.MandrakeRoot, - Reagent.Nightshade, - Reagent.SulfurousAsh, - Reagent.Bloodmoss - ); - - public NetherCycloneSpell(Mobile caster, Item scroll) - : base(caster, scroll, m_Info) - { - } - - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.5); - - public override double RequiredSkill => 83.0; - public override int RequiredMana => 50; - - public override void OnCast() - { - Caster.Target = new InternalTarget(this); - } - - public void Target(IPoint3D p) - { - if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) - { - /* Summons a gale of lethal winds that strikes all Targets within a radius around - * the Target's Location, dealing chaos damage. In addition to inflicting damage, - * each Target of the Nether Cyclone temporarily loses a percentage of mana and - * stamina. The effectiveness of the Nether Cyclone is determined by a comparison - * between the Caster's Mysticism and either Focus or Imbuing (whichever is greater) - * skills and the Resisting Spells skill of the Target. - */ - - SpellHelper.Turn(Caster, p); - - if (p is Item item) - p = item.GetWorldLocation(); - - List targets = new List(); - - Map map = Caster.Map; - - bool pvp = false; - - if (map != null) - { - PlayEffect(p, Caster.Map); - - foreach (Mobile 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; - } - } - } - - int damage = GetNewAosDamage(51, 1, 5, pvp); - double reduction = (GetBaseSkill(Caster) + GetBoostSkill(Caster)) / 1200.0; - - foreach (Mobile m in targets) - { - Caster.DoHarmful(m); - SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0, 100); - - double resistedReduction = reduction - m.Skills.MagicResist.Value / 800.0; - - m.Stam -= (int)(m.StamMax * resistedReduction); - m.Mana -= (int)(m.ManaMax * resistedReduction); - } - } - - FinishSequence(); - } - - private static void PlayEffect(IPoint3D p, Map map) - { - Effects.PlaySound(p, map, 0x64F); - - PlaySingleEffect(p, map, -1, 1, -1, 1); - PlaySingleEffect(p, map, -2, 0, -3, -1); - PlaySingleEffect(p, map, -3, -1, -1, 1); - PlaySingleEffect(p, map, 1, 3, -1, 1); - PlaySingleEffect(p, map, -1, 1, 1, 3); - } - - private static void PlaySingleEffect(IPoint3D p, Map map, int a, int b, int c, int d) - { - int x = p.X, y = p.Y, z = p.Z + 18; - - SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z)); - SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z)); - - SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z)); - SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z)); - SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z)); - } - - private static void SendEffectPacket(IPoint3D p, Map map, Point3D orig, Point3D dest) - { - Effects.SendPacket(p, map, - new HuedEffect(EffectType.Moving, Serial.Zero, Serial.Zero, 0x375A, orig, dest, 0, 0, false, false, 0x49A, - 0x4)); - } - - private class InternalTarget : Target - { - private NetherCycloneSpell m_Owner; - - public InternalTarget(NetherCycloneSpell owner) - : base(12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using Server.Network; + +namespace Server.Spells.Mysticism +{ + public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D + { + private static SpellInfo m_Info = new SpellInfo( + "Nether Cyclone", "Grav Hur", + -1, + 9002, + Reagent.MandrakeRoot, + Reagent.Nightshade, + Reagent.SulfurousAsh, + Reagent.Bloodmoss + ); + + public NetherCycloneSpell(Mobile caster, Item scroll = null) + : base(caster, scroll, m_Info) + { + } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.5); + + public override double RequiredSkill => 83.0; + public override int RequiredMana => 50; + + public override void OnCast() + { + Caster.Target = new SpellTargetPoint3D(this); + } + + public void Target(IPoint3D p) + { + if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) + { + /* Summons a gale of lethal winds that strikes all Targets within a radius around + * the Target's Location, dealing chaos damage. In addition to inflicting damage, + * each Target of the Nether Cyclone temporarily loses a percentage of mana and + * stamina. The effectiveness of the Nether Cyclone is determined by a comparison + * between the Caster's Mysticism and either Focus or Imbuing (whichever is greater) + * skills and the Resisting Spells skill of the Target. + */ + + SpellHelper.Turn(Caster, p); + + if (p is Item item) + p = item.GetWorldLocation(); + + List targets = new List(); + + Map map = Caster.Map; + + bool pvp = false; + + if (map != null) + { + PlayEffect(p, Caster.Map); + + foreach (Mobile 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; + } + } + } + + int damage = GetNewAosDamage(51, 1, 5, pvp); + double reduction = (GetBaseSkill(Caster) + GetBoostSkill(Caster)) / 1200.0; + + foreach (Mobile m in targets) + { + Caster.DoHarmful(m); + SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0, 100); + + double resistedReduction = reduction - m.Skills.MagicResist.Value / 800.0; + + m.Stam -= (int)(m.StamMax * resistedReduction); + m.Mana -= (int)(m.ManaMax * resistedReduction); + } + } + + FinishSequence(); + } + + private static void PlayEffect(IPoint3D p, Map map) + { + Effects.PlaySound(p, map, 0x64F); + + PlaySingleEffect(p, map, -1, 1, -1, 1); + PlaySingleEffect(p, map, -2, 0, -3, -1); + PlaySingleEffect(p, map, -3, -1, -1, 1); + PlaySingleEffect(p, map, 1, 3, -1, 1); + PlaySingleEffect(p, map, -1, 1, 1, 3); + } + + private static void PlaySingleEffect(IPoint3D p, Map map, int a, int b, int c, int d) + { + int x = p.X, y = p.Y, z = p.Z + 18; + + SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z)); + SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z)); + + SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z)); + SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z)); + SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z)); + } + + private static void SendEffectPacket(IPoint3D p, Map map, Point3D orig, Point3D dest) + { + Effects.SendPacket(p, map, + new HuedEffect(EffectType.Moving, Serial.Zero, Serial.Zero, 0x375A, orig, dest, 0, 0, false, false, 0x49A, + 0x4)); + } + } +} diff --git a/Scripts/Spells/Mysticism/SpellPlagueSpell.cs b/Scripts/Spells/Mysticism/SpellPlagueSpell.cs index 04e259b96..5246733e3 100644 --- a/Scripts/Spells/Mysticism/SpellPlagueSpell.cs +++ b/Scripts/Spells/Mysticism/SpellPlagueSpell.cs @@ -1,217 +1,217 @@ -using System; -using System.Collections.Generic; -using Server.Targeting; - -namespace Server.Spells.Mysticism -{ - public class SpellPlagueSpell : MysticSpell - { - private static SpellInfo m_Info = new SpellInfo( - "Spell Plague", "Vas Rel Jux Ort", - -1, - 9002, - Reagent.DaemonBone, - Reagent.DragonsBlood, - Reagent.Nightshade, - Reagent.SulfurousAsh - ); - - private static Dictionary m_Table = new Dictionary(); - - public SpellPlagueSpell(Mobile caster, Item scroll) - : base(caster, scroll, m_Info) - { - } - - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.25); - - public override double RequiredSkill => 70.0; - public override int RequiredMana => 40; - - public static void Initialize() - { - EventSink.PlayerDeath += OnPlayerDeath; - } - - public override void OnCast() - { - Caster.Target = new InternalTarget(this); - } - - public void Target(Mobile targeted) - { - if (!Caster.CanSee(targeted)) - { - Caster.SendLocalizedMessage(500237); // Target can not be seen. - } - else if (CheckHSequence(targeted)) - { - SpellHelper.Turn(Caster, targeted); - - SpellHelper.CheckReflect(6, Caster, ref targeted); - - /* The target is hit with an explosion of chaos damage and then inflicted - * with the spell plague curse. Each time the target is damaged while under - * the effect of the spell plague, they may suffer an explosion of chaos - * damage. The initial chance to trigger the explosion starts at 90% and - * reduces by 30% every time an explosion occurs. Once the target is - * afflicted by 3 explosions or 8 seconds have passed, that spell plague - * is removed from the target. Spell Plague will stack with other spell - * plagues so that they are applied one after the other. - */ - - VisualEffect(targeted); - - int damage = GetNewAosDamage(33, 1, 5, targeted); - SpellHelper.Damage(this, targeted, damage, 0, 0, 0, 0, 0); - - SpellPlagueContext context = new SpellPlagueContext(this, targeted); - - if (m_Table.TryGetValue(targeted, out SpellPlagueContext oldContext)) - oldContext.SetNext(context); - else - { - m_Table[targeted] = context; - context.Start(); - } - } - - FinishSequence(); - } - - public static bool UnderEffect(Mobile m) - { - return m_Table.ContainsKey(m); - } - - public static void RemoveEffect(Mobile m) - { - if (m_Table.TryGetValue(m, out SpellPlagueContext context)) - context.EndPlague(false); - } - - public static void CheckPlague(Mobile m) - { - if (m_Table.TryGetValue(m, out SpellPlagueContext context)) - context.OnDamage(); - } - - private static void OnPlayerDeath(PlayerDeathEventArgs e) - { - RemoveEffect(e.Mobile); - } - - protected void VisualEffect(Mobile to) - { - to.PlaySound(0x658); - - to.FixedParticles(0x3728, 1, 13, 0x26B8, 0x47E, 7, EffectLayer.Head, 0); - to.FixedParticles(0x3779, 1, 15, 0x251E, 0x43, 7, EffectLayer.Head, 0); - } - - private class SpellPlagueContext - { - private int m_Explosions; - private DateTime m_LastExploded; - private SpellPlagueContext m_Next; - private SpellPlagueSpell m_Owner; - private Mobile m_Target; - private Timer m_Timer; - - public SpellPlagueContext(SpellPlagueSpell owner, Mobile target) - { - m_Owner = owner; - m_Target = target; - } - - public void SetNext(SpellPlagueContext context) - { - if (m_Next == null) - m_Next = context; - else - m_Next.SetNext(context); - } - - public void Start() - { - m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(8.0), EndPlague); - m_Timer.Start(); - - BuffInfo.AddBuff(m_Target, - new BuffInfo(BuffIcon.SpellPlague, 1031690, 1080167, TimeSpan.FromSeconds(8.5), m_Target)); - } - - public void OnDamage() - { - if (DateTime.Now > m_LastExploded + TimeSpan.FromSeconds(2.0)) - { - int exploChance = 90 - m_Explosions * 30; - - double resist = m_Target.Skills.MagicResist.Value; - - if (resist >= 70) - exploChance -= (int)((resist - 70.0) * 3.0 / 10.0); - - if (exploChance > Utility.Random(100)) - { - m_Owner.VisualEffect(m_Target); - - int damage = m_Owner.GetNewAosDamage(15 + m_Explosions * 3, 1, 5, m_Target); - - m_Explosions++; - m_LastExploded = DateTime.Now; - - SpellHelper.Damage(m_Owner, m_Target, damage, 0, 0, 0, 0, 0, 100); - - if (m_Explosions >= 3) - EndPlague(); - } - } - } - - private void EndPlague() - { - EndPlague(true); - } - - public void EndPlague(bool restart) - { - m_Timer?.Stop(); - - if (restart && m_Next != null) - { - m_Table[m_Target] = m_Next; - m_Next.Start(); - } - else - { - m_Table.Remove(m_Target); - - BuffInfo.RemoveBuff(m_Target, BuffIcon.SpellPlague); - } - } - } - - private class InternalTarget : Target - { - private SpellPlagueSpell m_Owner; - - public InternalTarget(SpellPlagueSpell owner) - : base(12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } - } -} +using System; +using System.Collections.Generic; +using Server.Targeting; + +namespace Server.Spells.Mysticism +{ + public class SpellPlagueSpell : MysticSpell + { + private static SpellInfo m_Info = new SpellInfo( + "Spell Plague", "Vas Rel Jux Ort", + -1, + 9002, + Reagent.DaemonBone, + Reagent.DragonsBlood, + Reagent.Nightshade, + Reagent.SulfurousAsh + ); + + private static Dictionary m_Table = new Dictionary(); + + public SpellPlagueSpell(Mobile caster, Item scroll = null) + : base(caster, scroll, m_Info) + { + } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(2.25); + + public override double RequiredSkill => 70.0; + public override int RequiredMana => 40; + + public static void Initialize() + { + EventSink.PlayerDeath += OnPlayerDeath; + } + + public override void OnCast() + { + Caster.Target = new InternalTarget(this); + } + + public void Target(Mobile targeted) + { + if (!Caster.CanSee(targeted)) + { + Caster.SendLocalizedMessage(500237); // Target can not be seen. + } + else if (CheckHSequence(targeted)) + { + SpellHelper.Turn(Caster, targeted); + + SpellHelper.CheckReflect(6, Caster, ref targeted); + + /* The target is hit with an explosion of chaos damage and then inflicted + * with the spell plague curse. Each time the target is damaged while under + * the effect of the spell plague, they may suffer an explosion of chaos + * damage. The initial chance to trigger the explosion starts at 90% and + * reduces by 30% every time an explosion occurs. Once the target is + * afflicted by 3 explosions or 8 seconds have passed, that spell plague + * is removed from the target. Spell Plague will stack with other spell + * plagues so that they are applied one after the other. + */ + + VisualEffect(targeted); + + int damage = GetNewAosDamage(33, 1, 5, targeted); + SpellHelper.Damage(this, targeted, damage, 0, 0, 0, 0, 0); + + SpellPlagueContext context = new SpellPlagueContext(this, targeted); + + if (m_Table.TryGetValue(targeted, out SpellPlagueContext oldContext)) + oldContext.SetNext(context); + else + { + m_Table[targeted] = context; + context.Start(); + } + } + + FinishSequence(); + } + + public static bool UnderEffect(Mobile m) + { + return m_Table.ContainsKey(m); + } + + public static void RemoveEffect(Mobile m) + { + if (m_Table.TryGetValue(m, out SpellPlagueContext context)) + context.EndPlague(false); + } + + public static void CheckPlague(Mobile m) + { + if (m_Table.TryGetValue(m, out SpellPlagueContext context)) + context.OnDamage(); + } + + private static void OnPlayerDeath(PlayerDeathEventArgs e) + { + RemoveEffect(e.Mobile); + } + + protected void VisualEffect(Mobile to) + { + to.PlaySound(0x658); + + to.FixedParticles(0x3728, 1, 13, 0x26B8, 0x47E, 7, EffectLayer.Head, 0); + to.FixedParticles(0x3779, 1, 15, 0x251E, 0x43, 7, EffectLayer.Head, 0); + } + + private class SpellPlagueContext + { + private int m_Explosions; + private DateTime m_LastExploded; + private SpellPlagueContext m_Next; + private SpellPlagueSpell m_Owner; + private Mobile m_Target; + private Timer m_Timer; + + public SpellPlagueContext(SpellPlagueSpell owner, Mobile target) + { + m_Owner = owner; + m_Target = target; + } + + public void SetNext(SpellPlagueContext context) + { + if (m_Next == null) + m_Next = context; + else + m_Next.SetNext(context); + } + + public void Start() + { + m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(8.0), EndPlague); + m_Timer.Start(); + + BuffInfo.AddBuff(m_Target, + new BuffInfo(BuffIcon.SpellPlague, 1031690, 1080167, TimeSpan.FromSeconds(8.5), m_Target)); + } + + public void OnDamage() + { + if (DateTime.Now > m_LastExploded + TimeSpan.FromSeconds(2.0)) + { + int exploChance = 90 - m_Explosions * 30; + + double resist = m_Target.Skills.MagicResist.Value; + + if (resist >= 70) + exploChance -= (int)((resist - 70.0) * 3.0 / 10.0); + + if (exploChance > Utility.Random(100)) + { + m_Owner.VisualEffect(m_Target); + + int damage = m_Owner.GetNewAosDamage(15 + m_Explosions * 3, 1, 5, m_Target); + + m_Explosions++; + m_LastExploded = DateTime.Now; + + SpellHelper.Damage(m_Owner, m_Target, damage, 0, 0, 0, 0, 0, 100); + + if (m_Explosions >= 3) + EndPlague(); + } + } + } + + private void EndPlague() + { + EndPlague(true); + } + + public void EndPlague(bool restart) + { + m_Timer?.Stop(); + + if (restart && m_Next != null) + { + m_Table[m_Target] = m_Next; + m_Next.Start(); + } + else + { + m_Table.Remove(m_Target); + + BuffInfo.RemoveBuff(m_Target, BuffIcon.SpellPlague); + } + } + } + + private class InternalTarget : Target + { + private SpellPlagueSpell m_Owner; + + public InternalTarget(SpellPlagueSpell owner) + : base(12, false, TargetFlags.Harmful) + { + m_Owner = owner; + } + + protected override void OnTarget(Mobile from, object o) + { + if (o is Mobile mobile) + m_Owner.Target(mobile); + } + + protected override void OnTargetFinish(Mobile from) + { + m_Owner.FinishSequence(); + } + } + } +} diff --git a/Scripts/Spells/Mysticism/StoneFormSpell.cs b/Scripts/Spells/Mysticism/StoneFormSpell.cs index 618ce8748..4e6052adc 100644 --- a/Scripts/Spells/Mysticism/StoneFormSpell.cs +++ b/Scripts/Spells/Mysticism/StoneFormSpell.cs @@ -1,164 +1,163 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Server.Factions; -using Server.Mobiles; -using Server.Spells.Fifth; -using Server.Spells.Ninjitsu; -using Server.Spells.Seventh; - -namespace Server.Spells.Mysticism -{ - public class StoneFormSpell : MysticSpell - { - private static SpellInfo m_Info = new SpellInfo( - "Stone Form", "In Rel Ylem", - -1, - 9002, - Reagent.Bloodmoss, - Reagent.FertileDirt, - Reagent.Garlic - ); - - private static Dictionary m_Table = new Dictionary(); - - public StoneFormSpell(Mobile caster, Item scroll) - : base(caster, scroll, m_Info) - { - } - - public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5); - - public override double RequiredSkill => 33.0; - public override int RequiredMana => 11; - - public static void Initialize() - { - EventSink.PlayerDeath += OnPlayerDeath; - } - - public static bool UnderEffect(Mobile m) - { - return m_Table.ContainsKey(m); - } - - public override bool CheckCast() - { - if (Sigil.ExistsOn(Caster)) - { - Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. - return false; - } - - if (!Caster.CanBeginAction()) - { - Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed. - return false; - } - - if (AnimalForm.UnderTransformation(Caster)) - { - Caster.SendLocalizedMessage(1063218); // You cannot use that ability in this form. - return false; - } - - if (Caster.Flying) - { - Caster.SendLocalizedMessage(1113415); // You cannot use this ability while flying. - return false; - } - - return base.CheckCast(); - } - - public override void OnCast() - { - if (Sigil.ExistsOn(Caster)) - { - Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. - } - else if (!Caster.CanBeginAction()) - { - Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed. - } - else if (!Caster.CanBeginAction() || Caster.IsBodyMod && !UnderEffect(Caster)) - { - Caster.SendLocalizedMessage(1063218); // You cannot use that ability in this form. - } - else if (CheckSequence()) - { - if (UnderEffect(Caster)) - { - RemoveEffects(Caster); - - Caster.PlaySound(0xFA); - Caster.Delta(MobileDelta.Resistances); - } - else - { - IMount mount = Caster.Mount; - - if (mount != null) - mount.Rider = null; - - Caster.BodyMod = 0x2C1; - Caster.HueMod = 0; - - int offset = (int)((GetBaseSkill(Caster) + GetBoostSkill(Caster)) / 24.0); - - ResistanceMod[] mods = { - new ResistanceMod(ResistanceType.Physical, offset), - new ResistanceMod(ResistanceType.Fire, offset), - new ResistanceMod(ResistanceType.Cold, offset), - new ResistanceMod(ResistanceType.Poison, offset), - new ResistanceMod(ResistanceType.Energy, offset) - }; - - for (int i = 0; i < mods.Length; ++i) - Caster.AddResistanceMod(mods[i]); - - m_Table[Caster] = mods; - - Caster.PlaySound(0x65A); - Caster.Delta(MobileDelta.Resistances); - - BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.StoneForm, 1080145, 1080146, - $"-10\t-2\t{offset}\t{GetResistCapBonus(Caster)}\t{GetDIBonus(Caster)}", false)); - } - } - - FinishSequence(); - } - - public static int GetDIBonus(Mobile m) - { - return (int)((GetBaseSkill(m) + GetBoostSkill(m)) / 12.0); - } - - public static int GetResistCapBonus(Mobile m) - { - return (int)((GetBaseSkill(m) + GetBoostSkill(m)) / 48.0); - } - - public static void RemoveEffects(Mobile m) - { - if (!m_Table.TryGetValue(m, out ResistanceMod[] mods)) - return; - - for (int i = 0; i < mods.Length; ++i) - m.RemoveResistanceMod(mods[i]); - - m.BodyMod = 0; - m.HueMod = -1; - - m_Table.Remove(m); - - BuffInfo.RemoveBuff(m, BuffIcon.StoneForm); - } - - private static void OnPlayerDeath(PlayerDeathEventArgs e) - { - RemoveEffects(e.Mobile); - } - } -} +using System; +using System.Collections.Generic; +using Server.Factions; +using Server.Mobiles; +using Server.Spells.Fifth; +using Server.Spells.Ninjitsu; +using Server.Spells.Seventh; + +namespace Server.Spells.Mysticism +{ + public class StoneFormSpell : MysticSpell + { + private static SpellInfo m_Info = new SpellInfo( + "Stone Form", "In Rel Ylem", + -1, + 9002, + Reagent.Bloodmoss, + Reagent.FertileDirt, + Reagent.Garlic + ); + + private static Dictionary m_Table = new Dictionary(); + + public StoneFormSpell(Mobile caster, Item scroll = null) + : base(caster, scroll, m_Info) + { + } + + public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(1.5); + + public override double RequiredSkill => 33.0; + public override int RequiredMana => 11; + + public static void Initialize() + { + EventSink.PlayerDeath += OnPlayerDeath; + } + + public static bool UnderEffect(Mobile m) + { + return m_Table.ContainsKey(m); + } + + public override bool CheckCast() + { + if (Sigil.ExistsOn(Caster)) + { + Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. + return false; + } + + if (!Caster.CanBeginAction()) + { + Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed. + return false; + } + + if (AnimalForm.UnderTransformation(Caster)) + { + Caster.SendLocalizedMessage(1063218); // You cannot use that ability in this form. + return false; + } + + if (Caster.Flying) + { + Caster.SendLocalizedMessage(1113415); // You cannot use this ability while flying. + return false; + } + + return base.CheckCast(); + } + + public override void OnCast() + { + if (Sigil.ExistsOn(Caster)) + { + Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. + } + else if (!Caster.CanBeginAction()) + { + Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed. + } + else if (!Caster.CanBeginAction() || Caster.IsBodyMod && !UnderEffect(Caster)) + { + Caster.SendLocalizedMessage(1063218); // You cannot use that ability in this form. + } + else if (CheckSequence()) + { + if (UnderEffect(Caster)) + { + RemoveEffects(Caster); + + Caster.PlaySound(0xFA); + Caster.Delta(MobileDelta.Resistances); + } + else + { + IMount mount = Caster.Mount; + + if (mount != null) + mount.Rider = null; + + Caster.BodyMod = 0x2C1; + Caster.HueMod = 0; + + int offset = (int)((GetBaseSkill(Caster) + GetBoostSkill(Caster)) / 24.0); + + ResistanceMod[] mods = { + new ResistanceMod(ResistanceType.Physical, offset), + new ResistanceMod(ResistanceType.Fire, offset), + new ResistanceMod(ResistanceType.Cold, offset), + new ResistanceMod(ResistanceType.Poison, offset), + new ResistanceMod(ResistanceType.Energy, offset) + }; + + for (int i = 0; i < mods.Length; ++i) + Caster.AddResistanceMod(mods[i]); + + m_Table[Caster] = mods; + + Caster.PlaySound(0x65A); + Caster.Delta(MobileDelta.Resistances); + + BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.StoneForm, 1080145, 1080146, + $"-10\t-2\t{offset}\t{GetResistCapBonus(Caster)}\t{GetDIBonus(Caster)}", false)); + } + } + + FinishSequence(); + } + + public static int GetDIBonus(Mobile m) + { + return (int)((GetBaseSkill(m) + GetBoostSkill(m)) / 12.0); + } + + public static int GetResistCapBonus(Mobile m) + { + return (int)((GetBaseSkill(m) + GetBoostSkill(m)) / 48.0); + } + + public static void RemoveEffects(Mobile m) + { + if (!m_Table.TryGetValue(m, out ResistanceMod[] mods)) + return; + + for (int i = 0; i < mods.Length; ++i) + m.RemoveResistanceMod(mods[i]); + + m.BodyMod = 0; + m.HueMod = -1; + + m_Table.Remove(m); + + BuffInfo.RemoveBuff(m, BuffIcon.StoneForm); + } + + private static void OnPlayerDeath(PlayerDeathEventArgs e) + { + RemoveEffects(e.Mobile); + } + } +} diff --git a/Scripts/Spells/Necromancy/AnimateDeadSpell.cs b/Scripts/Spells/Necromancy/AnimateDeadSpell.cs index 702162bb0..f586d7ab5 100644 --- a/Scripts/Spells/Necromancy/AnimateDeadSpell.cs +++ b/Scripts/Spells/Necromancy/AnimateDeadSpell.cs @@ -8,7 +8,7 @@ using Server.Targeting; namespace Server.Spells.Necromancy { - public class AnimateDeadSpell : NecromancerSpell + public class AnimateDeadSpell : NecromancerSpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Animate Dead", "Uus Corp", @@ -94,7 +94,7 @@ namespace Server.Spells.Necromancy private static Dictionary> m_Table = new Dictionary>(); - public AnimateDeadSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public AnimateDeadSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -105,7 +105,7 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); Caster.SendLocalizedMessage(1061083); // Animate what corpse? } @@ -128,9 +128,9 @@ namespace Server.Spells.Necromancy return null; } - public void Target(object obj) + public void Target(Item item) { - MaabusCoffinComponent comp = obj as MaabusCoffinComponent; + MaabusCoffinComponent comp = item as MaabusCoffinComponent; if (comp?.Addon is MaabusCoffin addon) { @@ -142,7 +142,7 @@ namespace Server.Spells.Necromancy { QuestObjective objective = qs.FindObjective(); - if (objective != null && !objective.Completed) + if (objective?.Completed == false) { addon.Awake(Caster); objective.Complete(); @@ -152,7 +152,7 @@ namespace Server.Spells.Necromancy return; } - if (!(obj is Corpse c)) + if (!(item is Corpse c)) { Caster.SendLocalizedMessage(1061084); // You cannot animate that. } @@ -370,25 +370,5 @@ namespace Server.Spells.Necromancy m_Requirement = requirement; } } - - private class InternalTarget : Target - { - private AnimateDeadSpell m_Owner; - - public InternalTarget(AnimateDeadSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - m_Owner.Target(o); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Necromancy/BloodOathSpell.cs b/Scripts/Spells/Necromancy/BloodOathSpell.cs index 49ae4b292..080327e0d 100644 --- a/Scripts/Spells/Necromancy/BloodOathSpell.cs +++ b/Scripts/Spells/Necromancy/BloodOathSpell.cs @@ -1,12 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Mobiles; using Server.Targeting; namespace Server.Spells.Necromancy { - public class BloodOathSpell : NecromancerSpell + public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Blood Oath", "In Jux Mani Xen", @@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_OathTable = new Dictionary(); private static Dictionary m_Table = new Dictionary(); - public BloodOathSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public BloodOathSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -29,20 +28,18 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { - if (Caster == m || !(m is PlayerMobile || m is BaseCreature) - ) // only PlayerMobile and BaseCreature implement blood oath checking - { + if (m == null) + Caster.SendLocalizedMessage(1060508); // You can't curse that. + // only PlayerMobile and BaseCreature implement blood oath checking + else if (Caster == m || !(m is PlayerMobile || m is BaseCreature)) Caster.SendLocalizedMessage(1060508); // You can't curse that. - } else if (m_OathTable.ContainsKey(Caster)) - { Caster.SendLocalizedMessage(1061607); // You are already bonded in a Blood Oath. - } else if (m_OathTable.ContainsKey(m)) { if (m.Player) @@ -149,28 +146,5 @@ namespace Server.Spells.Necromancy m_Table.Remove(m_Caster); } } - - private class InternalTarget : Target - { - private BloodOathSpell m_Owner; - - public InternalTarget(BloodOathSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - else - from.SendLocalizedMessage(1060508); // You can't curse that. - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Necromancy/CorpseSkin.cs b/Scripts/Spells/Necromancy/CorpseSkin.cs index b1f5defa0..824f5f97b 100644 --- a/Scripts/Spells/Necromancy/CorpseSkin.cs +++ b/Scripts/Spells/Necromancy/CorpseSkin.cs @@ -1,11 +1,10 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Targeting; namespace Server.Spells.Necromancy { - public class CorpseSkinSpell : NecromancerSpell + public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Corpse Skin", "In Agle Corp Ylem", @@ -17,7 +16,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_Table = new Dictionary(); - public CorpseSkinSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CorpseSkinSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -28,11 +27,14 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -90,13 +92,11 @@ namespace Server.Spells.Necromancy public static bool RemoveCurse(Mobile m) { - ExpireTimer t = m_Table[m]; - - if (t == null) + if (!m_Table.TryGetValue(m, out ExpireTimer t)) return false; m.SendLocalizedMessage(1061688); // Your skin returns to normal. - t.DoExpire(); + t?.DoExpire(); return true; } @@ -127,26 +127,5 @@ namespace Server.Spells.Necromancy DoExpire(); } } - - private class InternalTarget : Target - { - private CorpseSkinSpell m_Owner; - - public InternalTarget(CorpseSkinSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Necromancy/CurseWeapon.cs b/Scripts/Spells/Necromancy/CurseWeapon.cs index 50a0c647b..fdce75d67 100644 --- a/Scripts/Spells/Necromancy/CurseWeapon.cs +++ b/Scripts/Spells/Necromancy/CurseWeapon.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; @@ -16,7 +15,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_Table = new Dictionary(); - public CurseWeaponSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CurseWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Necromancy/EvilOmen.cs b/Scripts/Spells/Necromancy/EvilOmen.cs index 171fd7432..d03192c0c 100644 --- a/Scripts/Spells/Necromancy/EvilOmen.cs +++ b/Scripts/Spells/Necromancy/EvilOmen.cs @@ -1,12 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Mobiles; using Server.Targeting; namespace Server.Spells.Necromancy { - public class EvilOmenSpell : NecromancerSpell + public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Evil Omen", "Pas Tym An Sanct", @@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_Table = new Dictionary(); - public EvilOmenSpell(Mobile caster, Item scroll) + public EvilOmenSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -30,15 +29,13 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { if (!(m is BaseCreature || m is PlayerMobile)) - { Caster.SendLocalizedMessage(1060508); // You can't curse that. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -69,7 +66,7 @@ namespace Server.Spells.Necromancy TimeSpan duration = TimeSpan.FromSeconds(Caster.Skills.SpiritSpeak.Value / 12 + 1.0); - Timer.DelayCall(duration, TryEndEffect_Callback, m); + Timer.DelayCall(duration, mob => TryEndEffect(mob), m); HarmfulSpell(m); @@ -79,53 +76,15 @@ namespace Server.Spells.Necromancy FinishSequence(); } - /* - * The naming here was confusing. Its a 1-off effect spell. - * So, we don't actually "checkeffect"; we endeffect with bool - * return to determine external behaviors. - * - * -refactored. - */ - private static void TryEndEffect_Callback(Mobile m) - { - TryEndEffect(m); - } - public static bool TryEndEffect(Mobile m) { - DefaultSkillMod mod = m_Table[m]; - - if (mod == null) + if (!m_Table.TryGetValue(m, out DefaultSkillMod mod)) return false; m_Table.Remove(m); - mod.Remove(); + mod?.Remove(); return true; } - - private class InternalTarget : Target - { - private EvilOmenSpell m_Owner; - - public InternalTarget(EvilOmenSpell owner) - : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - else - from.SendLocalizedMessage(1060508); // You can't curse that. - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Necromancy/Exorcism.cs b/Scripts/Spells/Necromancy/Exorcism.cs index 755ceb8eb..49add1dd7 100644 --- a/Scripts/Spells/Necromancy/Exorcism.cs +++ b/Scripts/Spells/Necromancy/Exorcism.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Engines.CannedEvil; using Server.Engines.PartySystem; using Server.Factions; @@ -57,7 +58,7 @@ namespace Server.Spells.Necromancy new Point3D(295, 712, 55) }; - public ExorcismSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ExorcismSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -98,17 +99,11 @@ namespace Server.Spells.Necromancy if (map != null) { - List targets = new List(); + IEnumerable targets = r.ChampionSpawn.GetMobilesInRange(Range).Where(IsValidTarget); - foreach (Mobile m in r.ChampionSpawn.GetMobilesInRange(Range)) - if (IsValidTarget(m)) - targets.Add(m); - - for (int i = 0; i < targets.Count; ++i) + foreach (Mobile m in targets) { - Mobile m = targets[i]; - - //Suprisingly, no sparkle type effects + //Surprisingly, no sparkle type effects m.Location = GetNearestShrine(m); } @@ -126,7 +121,7 @@ namespace Server.Spells.Necromancy Corpse c = m.Corpse as Corpse; Map map = m.Map; - if (c != null && !c.Deleted && map != null && c.Map == map) + 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'. @@ -134,12 +129,10 @@ namespace Server.Spells.Necromancy 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 doens't divide up the world the same way OSI does ;p + //Just an approximation cause RunUO doesn't divide up the world the same way OSI does ;p } - Party p = Party.Get(m); - - if (p != null && p.Contains(Caster)) + if (Party.Get(m)?.Contains(Caster) == true) return false; if (m.Guild != null && Caster.Guild != null) @@ -156,10 +149,7 @@ namespace Server.Spells.Necromancy Faction f = Faction.Find(m); - if (Faction.Facet == m.Map && f != null && f == Faction.Find(Caster)) - return false; - - return true; + return Faction.Facet != m.Map || f == null || f != Faction.Find(Caster); } private static Point3D GetNearestShrine(Mobile m) @@ -198,4 +188,4 @@ namespace Server.Spells.Necromancy return closest; } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/HorrificBeast.cs b/Scripts/Spells/Necromancy/HorrificBeast.cs index d2f876c75..dde8bb17b 100644 --- a/Scripts/Spells/Necromancy/HorrificBeast.cs +++ b/Scripts/Spells/Necromancy/HorrificBeast.cs @@ -12,7 +12,7 @@ namespace Server.Spells.Necromancy Reagent.DaemonBlood ); - public HorrificBeastSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public HorrificBeastSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -37,4 +37,4 @@ namespace Server.Spells.Necromancy m.Delta(MobileDelta.WeaponDamage); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/LichForm.cs b/Scripts/Spells/Necromancy/LichForm.cs index 2d5ada771..6c36f8acb 100644 --- a/Scripts/Spells/Necromancy/LichForm.cs +++ b/Scripts/Spells/Necromancy/LichForm.cs @@ -13,7 +13,7 @@ namespace Server.Spells.Necromancy Reagent.NoxCrystal ); - public LichFormSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public LichFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -41,4 +41,4 @@ namespace Server.Spells.Necromancy --m.Hits; } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/MindRot.cs b/Scripts/Spells/Necromancy/MindRot.cs index 634424e2f..2e35f5691 100644 --- a/Scripts/Spells/Necromancy/MindRot.cs +++ b/Scripts/Spells/Necromancy/MindRot.cs @@ -1,11 +1,10 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Targeting; namespace Server.Spells.Necromancy { - public class MindRotSpell : NecromancerSpell + public class MindRotSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Mind Rot", "Wis An Ben", @@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_Table = new Dictionary(); - public MindRotSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MindRotSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -29,15 +28,15 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { - if (HasMindRotScalar(m)) - { + if (m == null) + Caster.SendLocalizedMessage(1060508); // You can't curse that. + else if (HasMindRotScalar(m)) Caster.SendLocalizedMessage(1005559); // This spell is already in effect. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -104,29 +103,6 @@ namespace Server.Spells.Necromancy target.SendLocalizedMessage(1074384); } } - - private class InternalTarget : Target - { - private MindRotSpell m_Owner; - - public InternalTarget(MindRotSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - else - from.SendLocalizedMessage(1060508); // You can't curse that. - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } public class MRExpireTimer : Timer diff --git a/Scripts/Spells/Necromancy/PainSpike.cs b/Scripts/Spells/Necromancy/PainSpike.cs index 1e5c213b5..79b03d0f0 100644 --- a/Scripts/Spells/Necromancy/PainSpike.cs +++ b/Scripts/Spells/Necromancy/PainSpike.cs @@ -1,12 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Misc; using Server.Targeting; namespace Server.Spells.Necromancy { - public class PainSpikeSpell : NecromancerSpell + public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Pain Spike", "In Sar", @@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_Table = new Dictionary(); - public PainSpikeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public PainSpikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -31,11 +30,14 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -109,26 +111,5 @@ namespace Server.Spells.Necromancy BuffInfo.RemoveBuff(m_Mobile, BuffIcon.PainSpike); } } - - private class InternalTarget : Target - { - private PainSpikeSpell m_Owner; - - public InternalTarget(PainSpikeSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Necromancy/PoisonStrike.cs b/Scripts/Spells/Necromancy/PoisonStrike.cs index 47f085182..98b82aa40 100644 --- a/Scripts/Spells/Necromancy/PoisonStrike.cs +++ b/Scripts/Spells/Necromancy/PoisonStrike.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Items; using Server.Mobiles; using Server.Targeting; namespace Server.Spells.Necromancy { - public class PoisonStrikeSpell : NecromancerSpell + public class PoisonStrikeSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Poison Strike", "In Vas Nox", @@ -15,7 +16,7 @@ namespace Server.Spells.Necromancy Reagent.NoxCrystal ); - public PoisonStrikeSpell(Mobile caster, Item scroll) + public PoisonStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -29,11 +30,14 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -67,11 +71,8 @@ namespace Server.Spells.Necromancy if (Caster.CanBeHarmful(m, false)) targets.Add(m); - foreach (Mobile targ in m.GetMobilesInRange(2)) - if (!(Caster is BaseCreature && targ is BaseCreature)) - if (targ != Caster && m != targ && SpellHelper.ValidIndirectTarget(Caster, targ) && - Caster.CanBeHarmful(targ, false)) - targets.Add(targ); + targets.AddRange(m.GetMobilesInRange(2) + .Where(targ => !(Caster is BaseCreature && targ is BaseCreature && targ != Caster && m != targ && SpellHelper.ValidIndirectTarget(Caster, targ) && Caster.CanBeHarmful(targ, false)))); for (int i = 0; i < targets.Count; ++i) { @@ -94,27 +95,5 @@ namespace Server.Spells.Necromancy FinishSequence(); } - - private class InternalTarget : Target - { - private PoisonStrikeSpell m_Owner; - - public InternalTarget(PoisonStrikeSpell owner) - : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/Strangle.cs b/Scripts/Spells/Necromancy/Strangle.cs index 4af1c477f..5d02a6627 100644 --- a/Scripts/Spells/Necromancy/Strangle.cs +++ b/Scripts/Spells/Necromancy/Strangle.cs @@ -1,11 +1,10 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Targeting; namespace Server.Spells.Necromancy { - public class StrangleSpell : NecromancerSpell + public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Strangle", "In Bal Nox", @@ -17,7 +16,7 @@ namespace Server.Spells.Necromancy private static Dictionary m_Table = new Dictionary(); - public StrangleSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public StrangleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -28,11 +27,14 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -209,26 +211,5 @@ namespace Server.Spells.Necromancy } } } - - private class InternalTarget : Target - { - private StrangleSpell m_Owner; - - public InternalTarget(StrangleSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Necromancy/SummonFamiliar.cs b/Scripts/Spells/Necromancy/SummonFamiliar.cs index 5e023b7e2..6d4ea7722 100644 --- a/Scripts/Spells/Necromancy/SummonFamiliar.cs +++ b/Scripts/Spells/Necromancy/SummonFamiliar.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Gumps; using Server.Mobiles; @@ -18,7 +17,7 @@ namespace Server.Spells.Necromancy Reagent.DaemonBlood ); - public SummonFamiliarSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public SummonFamiliarSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -111,7 +110,7 @@ namespace Server.Spells.Necromancy AddItem(8, 15, 6882); AddItem(2, 168, 6880); - AddHtmlLocalized(30, 26, 200, 20, 1060147, EnabledColor16, false, false); // Chose thy familiar... + AddHtmlLocalized(30, 26, 200, 20, 1060147, EnabledColor16); // Chose thy familiar... double necro = from.Skills.Necromancy.Value; double spirit = from.Skills.SpiritSpeak.Value; @@ -122,15 +121,13 @@ namespace Server.Spells.Necromancy bool enabled = necro >= entries[i].ReqNecromancy && spirit >= entries[i].ReqSpiritSpeak; - AddButton(27, 53 + i * 21, 9702, 9703, i + 1, GumpButtonType.Reply, 0); + 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, false, - false); + AddHtmlLocalized(50, 51 + i * 21, 150, 20, intName, enabled ? EnabledColor16 : DisabledColor16); else if (name is string strName) AddHtml(50, 51 + i * 21, 150, 20, - $"{strName}", false, - false); + $"{strName}"); } } diff --git a/Scripts/Spells/Necromancy/VampiricEmbrace.cs b/Scripts/Spells/Necromancy/VampiricEmbrace.cs index c9f3cc843..0ae64c73b 100644 --- a/Scripts/Spells/Necromancy/VampiricEmbrace.cs +++ b/Scripts/Spells/Necromancy/VampiricEmbrace.cs @@ -14,7 +14,7 @@ namespace Server.Spells.Necromancy Reagent.PigIron ); - public VampiricEmbraceSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public VampiricEmbraceSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -50,4 +50,4 @@ namespace Server.Spells.Necromancy Effects.PlaySound(m.Location, m.Map, 0x4B1); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/VengefulSpirit.cs b/Scripts/Spells/Necromancy/VengefulSpirit.cs index 5e64c948f..ff8d8c7eb 100644 --- a/Scripts/Spells/Necromancy/VengefulSpirit.cs +++ b/Scripts/Spells/Necromancy/VengefulSpirit.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Necromancy { - public class VengefulSpiritSpell : NecromancerSpell + public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Vengeful Spirit", "Kal Xen Bal Beh", @@ -15,7 +15,7 @@ namespace Server.Spells.Necromancy Reagent.PigIron ); - public VengefulSpiritSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public VengefulSpiritSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -26,7 +26,7 @@ namespace Server.Spells.Necromancy public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public override bool CheckCast() @@ -45,10 +45,11 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { + if (m == null) + return; + if (Caster == m) - { Caster.SendLocalizedMessage(1061832); // You cannot exact vengeance on yourself. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -70,26 +71,5 @@ namespace Server.Spells.Necromancy FinishSequence(); } - - private class InternalTarget : Target - { - private VengefulSpiritSpell m_Owner; - - public InternalTarget(VengefulSpiritSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/Wither.cs b/Scripts/Spells/Necromancy/Wither.cs index a76633e03..6b9ba0408 100644 --- a/Scripts/Spells/Necromancy/Wither.cs +++ b/Scripts/Spells/Necromancy/Wither.cs @@ -16,7 +16,7 @@ namespace Server.Spells.Necromancy Reagent.PigIron ); - public WitherSpell(Mobile caster, Item scroll) + public WitherSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -44,7 +44,7 @@ namespace Server.Spells.Necromancy List targets = new List(); BaseCreature cbc = Caster as BaseCreature; - bool isMonster = cbc != null && !cbc.Controlled && !cbc.Summoned; + bool isMonster = cbc?.Controlled == false && !cbc.Summoned; foreach (Mobile m in Caster.GetMobilesInRange(Core.ML ? 4 : 5)) if (Caster != m && Caster.InLOS(m) && (isMonster || SpellHelper.ValidIndirectTarget(Caster, m)) && @@ -104,4 +104,4 @@ namespace Server.Spells.Necromancy FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Necromancy/WraithForm.cs b/Scripts/Spells/Necromancy/WraithForm.cs index 3ac9a7da6..81833224d 100644 --- a/Scripts/Spells/Necromancy/WraithForm.cs +++ b/Scripts/Spells/Necromancy/WraithForm.cs @@ -13,7 +13,7 @@ namespace Server.Spells.Necromancy Reagent.PigIron ); - public WraithFormSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public WraithFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -46,4 +46,4 @@ namespace Server.Spells.Necromancy mobile.IgnoreMobiles = false; } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Ninjitsu/AnimalForm.cs b/Scripts/Spells/Ninjitsu/AnimalForm.cs index 766b4f570..d10a9e8cd 100644 --- a/Scripts/Spells/Ninjitsu/AnimalForm.cs +++ b/Scripts/Spells/Ninjitsu/AnimalForm.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Gumps; using Server.Items; @@ -45,26 +44,22 @@ namespace Server.Spells.Ninjitsu public static AnimalFormEntry[] Entries{ get; } = { - new AnimalFormEntry(typeof(Kirin), 1029632, 9632, 0, 1070811, 100.0, 0x84, 0, 0, false, true, false), - new AnimalFormEntry(typeof(Unicorn), 1018214, 9678, 0, 1070812, 100.0, 0x7A, 0, 0, false, true, false), - new AnimalFormEntry(typeof(BakeKitsune), 1030083, 10083, 0, 1070810, 82.5, 0xF6, 0, 0, false, true, false), - new AnimalFormEntry(typeof(GreyWolf), 1028482, 9681, 2309, 1070810, 82.5, 0x19, 0x8FD, 0x90E, false, true, - false), - new AnimalFormEntry(typeof(Llama), 1028438, 8438, 0, 1070809, 70.0, 0xDC, 0, 0, false, true, false), - new AnimalFormEntry(typeof(ForestOstard), 1018273, 8503, 2212, 1070809, 70.0, 0xDB, 0x899, 0x8B0, false, true, - false), - new AnimalFormEntry(typeof(BullFrog), 1028496, 8496, 2003, 1070807, 50.0, 0x51, 0x7D1, 0x7D6, false, false, - false), - new AnimalFormEntry(typeof(GiantSerpent), 1018114, 9663, 2009, 1070808, 50.0, 0x15, 0x7D1, 0x7E2, false, false, - false), - new AnimalFormEntry(typeof(Dog), 1018280, 8476, 2309, 1070806, 40.0, 0xD9, 0x8FD, 0x90E, false, false, false), - new AnimalFormEntry(typeof(Cat), 1018264, 8475, 2309, 1070806, 40.0, 0xC9, 0x8FD, 0x90E, false, false, false), - new AnimalFormEntry(typeof(Rat), 1018294, 8483, 2309, 1070805, 20.0, 0xEE, 0x8FD, 0x90E, true, false, false), - new AnimalFormEntry(typeof(Rabbit), 1028485, 8485, 2309, 1070805, 20.0, 0xCD, 0x8FD, 0x90E, true, false, false), - new AnimalFormEntry(typeof(Squirrel), 1031671, 11671, 0, 0, 20.0, 0x116, 0, 0, false, false, false), + new AnimalFormEntry(typeof(Kirin), 1029632, 9632, 0, 1070811, 100.0, 0x84, 0, 0), + new AnimalFormEntry(typeof(Unicorn), 1018214, 9678, 0, 1070812, 100.0, 0x7A, 0, 0), + new AnimalFormEntry(typeof(BakeKitsune), 1030083, 10083, 0, 1070810, 82.5, 0xF6, 0, 0), + new AnimalFormEntry(typeof(GreyWolf), 1028482, 9681, 2309, 1070810, 82.5, 0x19, 0x8FD, 0x90E), + new AnimalFormEntry(typeof(Llama), 1028438, 8438, 0, 1070809, 70.0, 0xDC, 0, 0), + new AnimalFormEntry(typeof(ForestOstard), 1018273, 8503, 2212, 1070809, 70.0, 0xDB, 0x899, 0x8B0), + new AnimalFormEntry(typeof(BullFrog), 1028496, 8496, 2003, 1070807, 50.0, 0x51, 0x7D1, 0x7D6, false, false), + new AnimalFormEntry(typeof(GiantSerpent), 1018114, 9663, 2009, 1070808, 50.0, 0x15, 0x7D1, 0x7E2, false, false), + new AnimalFormEntry(typeof(Dog), 1018280, 8476, 2309, 1070806, 40.0, 0xD9, 0x8FD, 0x90E, false, false), + new AnimalFormEntry(typeof(Cat), 1018264, 8475, 2309, 1070806, 40.0, 0xC9, 0x8FD, 0x90E, false, false), + new AnimalFormEntry(typeof(Rat), 1018294, 8483, 2309, 1070805, 20.0, 0xEE, 0x8FD, 0x90E, true, false), + new AnimalFormEntry(typeof(Rabbit), 1028485, 8485, 2309, 1070805, 20.0, 0xCD, 0x8FD, 0x90E, true, false), + new AnimalFormEntry(typeof(Squirrel), 1031671, 11671, 0, 0, 20.0, 0x116, 0, 0, false, false), new AnimalFormEntry(typeof(Ferret), 1031672, 11672, 0, 1075220, 40.0, 0x117, 0, 0, false, false, true), - new AnimalFormEntry(typeof(CuSidhe), 1031670, 11670, 0, 1075221, 60.0, 0x115, 0, 0, false, false, false), - new AnimalFormEntry(typeof(Reptalon), 1075202, 11669, 0, 1075222, 90.0, 0x114, 0, 0, false, false, false) + new AnimalFormEntry(typeof(CuSidhe), 1031670, 11670, 0, 1075221, 60.0, 0x115, 0, 0, false, false), + new AnimalFormEntry(typeof(Reptalon), 1075202, 11669, 0, 1075222, 90.0, 0x114, 0, 0, false, false) }; public static void Initialize() @@ -74,9 +69,7 @@ namespace Server.Spells.Ninjitsu public static void OnLogin(LoginEventArgs e) { - AnimalFormContext context = GetContext(e.Mobile); - - if (context != null && context.SpeedBoost) + if (GetContext(e.Mobile)?.SpeedBoost == true) e.Mobile.Send(SpeedControl.MountSpeed); } @@ -350,7 +343,7 @@ namespace Server.Spells.Ninjitsu */ public AnimalFormEntry(Type type, TextDefinition name, int itemID, int hue, int tooltip, double reqSkill, - int bodyMod, int hueModMin, int hueModMax, bool stealthBonus, bool speedBoost, bool stealingBonus) + int bodyMod, int hueModMin, int hueModMax, bool stealthBonus = false, bool speedBoost = true, bool stealingBonus = false) { Type = type; Name = name; @@ -390,7 +383,7 @@ namespace Server.Spells.Ninjitsu public class AnimalFormGump : Gump { - //TODO: Convert this for ML to the BaseImageTileButtonsgump + //TODO: Convert this for ML to the BaseImageTileButtonsGump private Mobile m_Caster; private AnimalForm m_Spell; @@ -408,11 +401,10 @@ namespace Server.Spells.Ninjitsu AddImageTiled(10, 374, 500, 20, 0xA40); AddAlphaRegion(10, 10, 500, 384); - AddHtmlLocalized(14, 12, 500, 20, 1063394, 0x7FFF, false, - false); //
Polymorph Selection Menu
+ AddHtmlLocalized(14, 12, 500, 20, 1063394, 0x7FFF); //
Polymorph Selection Menu
- AddButton(10, 374, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0); - AddHtmlLocalized(45, 376, 450, 20, 1011012, 0x7FFF, false, false); // CANCEL + AddButton(10, 374, 0xFB1, 0xFB2, 0); + AddHtmlLocalized(45, 376, 450, 20, 1011012, 0x7FFF); // CANCEL double ninjitsu = caster.Skills.Ninjitsu.Value; @@ -430,7 +422,7 @@ namespace Server.Spells.Ninjitsu if (page > 1) { AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page); - AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF, false, false); // Next + AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next } AddPage(page); @@ -438,7 +430,7 @@ namespace Server.Spells.Ninjitsu if (page > 1) { AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1); - AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF, false, false); // Back + AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back } } @@ -452,7 +444,7 @@ namespace Server.Spells.Ninjitsu AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entries[i].ItemID, entries[i].Hue, 40 - b.Width / 2 - b.X, 30 - b.Height / 2 - b.Y, entries[i].Tooltip); - AddHtmlLocalized(x + 84, y, 250, 60, entries[i].Name, 0x7FFF, false, false); + AddHtmlLocalized(x + 84, y, 250, 60, entries[i].Name, 0x7FFF); current++; } @@ -579,7 +571,7 @@ namespace Server.Spells.Ninjitsu m_LastTarget = m_Mobile.Combatant; } - if (m_Mobile.Warmode && m_LastTarget != null && m_LastTarget.Alive && !m_LastTarget.Deleted && + if (m_Mobile.Warmode && m_LastTarget?.Alive == true && m_LastTarget?.Deleted != true && m_Counter-- <= 0) { if (m_Mobile.CanBeHarmful(m_LastTarget) && m_LastTarget.Map == m_Mobile.Map && diff --git a/Scripts/Spells/Ninjitsu/DeathStrike.cs b/Scripts/Spells/Ninjitsu/DeathStrike.cs index 203bdd0e7..84fb31fa2 100644 --- a/Scripts/Spells/Ninjitsu/DeathStrike.cs +++ b/Scripts/Spells/Ninjitsu/DeathStrike.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; using Server.SkillHandlers; @@ -31,11 +30,9 @@ namespace Server.Spells.Ninjitsu double ninjitsu = attacker.Skills.Ninjitsu.Value; double chance; - bool - isRanged = false; // should be defined onHit method, what if the player hit and remove the weapon before process? ;) - if (attacker.Weapon is BaseRanged) - isRanged = true; + // TODO: should be defined onHit method, what if the player hit and remove the weapon before process? ;) + bool isRanged = attacker.Weapon is BaseRanged; if (ninjitsu < 100) //This formula is an approximation from OSI data. TODO: find correct formula chance = 30 + (ninjitsu - 85) * 2.2; diff --git a/Scripts/Spells/Ninjitsu/KiAttack.cs b/Scripts/Spells/Ninjitsu/KiAttack.cs index e74ea7fbd..e785a4827 100644 --- a/Scripts/Spells/Ninjitsu/KiAttack.cs +++ b/Scripts/Spells/Ninjitsu/KiAttack.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Items; diff --git a/Scripts/Spells/Ninjitsu/MirrorImage.cs b/Scripts/Spells/Ninjitsu/MirrorImage.cs index 06dd52bf9..437117399 100644 --- a/Scripts/Spells/Ninjitsu/MirrorImage.cs +++ b/Scripts/Spells/Ninjitsu/MirrorImage.cs @@ -251,7 +251,7 @@ namespace Server.Mobiles // Clones only follow their owners Mobile master = m_Mobile.SummonMaster; - if (master != null && master.Map == m_Mobile.Map && master.InRange(m_Mobile, m_Mobile.RangePerception)) + if (master?.Map == m_Mobile.Map && master?.InRange(m_Mobile, m_Mobile.RangePerception) == true) { int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(master); bool bRun = iCurrDist > 5; diff --git a/Scripts/Spells/Ninjitsu/NinjaSpell.cs b/Scripts/Spells/Ninjitsu/NinjaSpell.cs index 63d9627de..52fbe9006 100644 --- a/Scripts/Spells/Ninjitsu/NinjaSpell.cs +++ b/Scripts/Spells/Ninjitsu/NinjaSpell.cs @@ -26,13 +26,7 @@ namespace Server.Spells.Ninjitsu public static bool CheckExpansion(Mobile from) { - if (!(from is PlayerMobile)) - return true; - - if (from.NetState == null) - return false; - - return from.NetState.SupportsExpansion(Expansion.SE); + return (from as PlayerMobile)?.NetState?.SupportsExpansion(Expansion.SE) == true; } public override bool CheckCast() @@ -103,4 +97,4 @@ namespace Server.Spells.Ninjitsu return 0; } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Ninjitsu/ShadowJump.cs b/Scripts/Spells/Ninjitsu/ShadowJump.cs index 6b00f0ff6..22f025093 100644 --- a/Scripts/Spells/Ninjitsu/ShadowJump.cs +++ b/Scripts/Spells/Ninjitsu/ShadowJump.cs @@ -9,7 +9,7 @@ using Server.Targeting; namespace Server.Spells.Ninjitsu { - public class Shadowjump : NinjaSpell + public class Shadowjump : NinjaSpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Shadowjump", null, @@ -48,7 +48,7 @@ namespace Server.Spells.Ninjitsu public override void OnCast() { Caster.SendLocalizedMessage(1063088); // You prepare to perform a Shadowjump. - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, 11); } public void Target(IPoint3D p) @@ -110,26 +110,5 @@ namespace Server.Spells.Ninjitsu FinishSequence(); } - - public class InternalTarget : Target - { - private Shadowjump m_Owner; - - public InternalTarget(Shadowjump owner) : base(11, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Ninjitsu/SurpriseAttack.cs b/Scripts/Spells/Ninjitsu/SurpriseAttack.cs index 626278a3a..57669d273 100644 --- a/Scripts/Spells/Ninjitsu/SurpriseAttack.cs +++ b/Scripts/Spells/Ninjitsu/SurpriseAttack.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.SkillHandlers; diff --git a/Scripts/Spells/Second/Agility.cs b/Scripts/Spells/Second/Agility.cs index 8966241df..ce8b7e4c0 100644 --- a/Scripts/Spells/Second/Agility.cs +++ b/Scripts/Spells/Second/Agility.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class AgilitySpell : MagerySpell + public class AgilitySpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Agility", "Ex Uus", @@ -14,7 +14,7 @@ namespace Server.Spells.Second Reagent.MandrakeRoot ); - public AgilitySpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public AgilitySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -33,15 +33,16 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -59,26 +60,5 @@ namespace Server.Spells.Second FinishSequence(); } - - private class InternalTarget : Target - { - private AgilitySpell m_Owner; - - public InternalTarget(AgilitySpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Second/Cunning.cs b/Scripts/Spells/Second/Cunning.cs index 465c8ae55..fac065ce5 100644 --- a/Scripts/Spells/Second/Cunning.cs +++ b/Scripts/Spells/Second/Cunning.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class CunningSpell : MagerySpell + public class CunningSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Cunning", "Uus Wis", @@ -14,7 +14,7 @@ namespace Server.Spells.Second Reagent.Nightshade ); - public CunningSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CunningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -33,15 +33,16 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -59,26 +60,5 @@ namespace Server.Spells.Second FinishSequence(); } - - private class InternalTarget : Target - { - private CunningSpell m_Owner; - - public InternalTarget(CunningSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Second/Cure.cs b/Scripts/Spells/Second/Cure.cs index 3d78f4048..a880d5984 100644 --- a/Scripts/Spells/Second/Cure.cs +++ b/Scripts/Spells/Second/Cure.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class CureSpell : MagerySpell + public class CureSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Cure", "An Nox", @@ -13,7 +13,7 @@ namespace Server.Spells.Second Reagent.Ginseng ); - public CureSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public CureSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -32,15 +32,16 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -75,26 +76,5 @@ namespace Server.Spells.Second FinishSequence(); } - - public class InternalTarget : Target - { - private CureSpell m_Owner; - - public InternalTarget(CureSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Second/Harm.cs b/Scripts/Spells/Second/Harm.cs index b228e84a0..703fde5f0 100644 --- a/Scripts/Spells/Second/Harm.cs +++ b/Scripts/Spells/Second/Harm.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class HarmSpell : MagerySpell + public class HarmSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Harm", "An Mani", @@ -12,7 +12,7 @@ namespace Server.Spells.Second Reagent.SpidersSilk ); - public HarmSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public HarmSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,7 +22,7 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public override double GetSlayerDamageScalar(Mobile target) @@ -32,10 +32,11 @@ namespace Server.Spells.Second public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -83,26 +84,5 @@ namespace Server.Spells.Second FinishSequence(); } - - private class InternalTarget : Target - { - private HarmSpell m_Owner; - - public InternalTarget(HarmSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Second/MagicTrap.cs b/Scripts/Spells/Second/MagicTrap.cs index 543288c9a..232310a28 100644 --- a/Scripts/Spells/Second/MagicTrap.cs +++ b/Scripts/Spells/Second/MagicTrap.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class MagicTrapSpell : MagerySpell + public class MagicTrapSpell : MagerySpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Magic Trap", "In Jux", @@ -14,7 +14,7 @@ namespace Server.Spells.Second Reagent.SulfurousAsh ); - public MagicTrapSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MagicTrapSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,16 +22,18 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); } - public void Target(TrappableContainer item) + public void Target(Item item) { - if (!Caster.CanSee(item)) + if (!(item is TrappableContainer cont)) + Caster.SendMessage("You can't trap that"); // TODO: Localization for this? + else if (!Caster.CanSee(item)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } - else if (item.TrapType != TrapType.None && item.TrapType != TrapType.MagicTrap) + else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap) { base.DoFizzle(); } @@ -39,9 +41,9 @@ namespace Server.Spells.Second { SpellHelper.Turn(Caster, item); - item.TrapType = TrapType.MagicTrap; - item.TrapPower = Core.AOS ? Utility.RandomMinMax(10, 50) : 1; - item.TrapLevel = 0; + cont.TrapType = TrapType.MagicTrap; + cont.TrapPower = Core.AOS ? Utility.RandomMinMax(10, 50) : 1; + cont.TrapLevel = 0; Point3D loc = item.GetWorldLocation(); @@ -66,28 +68,5 @@ namespace Server.Spells.Second FinishSequence(); } - - private class InternalTarget : Target - { - private MagicTrapSpell m_Owner; - - public InternalTarget(MagicTrapSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is TrappableContainer container) - m_Owner.Target(container); - else - from.SendMessage("You can't trap that"); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Second/Protection.cs b/Scripts/Spells/Second/Protection.cs index c3f4b1f88..f4587ed26 100644 --- a/Scripts/Spells/Second/Protection.cs +++ b/Scripts/Spells/Second/Protection.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Server.Spells.Second @@ -17,7 +16,7 @@ namespace Server.Spells.Second private static Dictionary> m_Table = new Dictionary>(); - public ProtectionSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Second/RemoveTrap.cs b/Scripts/Spells/Second/RemoveTrap.cs index 20651770f..340b6e8f1 100644 --- a/Scripts/Spells/Second/RemoveTrap.cs +++ b/Scripts/Spells/Second/RemoveTrap.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class RemoveTrapSpell : MagerySpell + public class RemoveTrapSpell : MagerySpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Remove Trap", "An Jux", @@ -13,7 +13,7 @@ namespace Server.Spells.Second Reagent.SulfurousAsh ); - public RemoveTrapSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public RemoveTrapSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -21,17 +21,19 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); - Caster.SendMessage("What do you wish to untrap?"); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); + Caster.SendMessage("What do you wish to untrap?"); // TODO: Localization? } - public void Target(TrappableContainer item) + public void Target(Item item) { - if (!Caster.CanSee(item)) + if (!(item is TrappableContainer cont)) + Caster.SendMessage("You can't disarm that"); // TODO: Localization? + else if (!Caster.CanSee(item)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } - else if (item.TrapType != TrapType.None && item.TrapType != TrapType.MagicTrap) + else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap) { base.DoFizzle(); } @@ -45,35 +47,12 @@ namespace Server.Spells.Second 5015); Effects.PlaySound(loc, item.Map, 0x1F0); - item.TrapType = TrapType.None; - item.TrapPower = 0; - item.TrapLevel = 0; + cont.TrapType = TrapType.None; + cont.TrapPower = 0; + cont.TrapLevel = 0; } FinishSequence(); } - - private class InternalTarget : Target - { - private RemoveTrapSpell m_Owner; - - public InternalTarget(RemoveTrapSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is TrappableContainer container) - m_Owner.Target(container); - else - from.SendMessage("You can't disarm that"); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Second/Strength.cs b/Scripts/Spells/Second/Strength.cs index 0e36eef11..bc05a93ff 100644 --- a/Scripts/Spells/Second/Strength.cs +++ b/Scripts/Spells/Second/Strength.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Second { - public class StrengthSpell : MagerySpell + public class StrengthSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Strength", "Uus Mani", @@ -14,7 +14,7 @@ namespace Server.Spells.Second Reagent.Nightshade ); - public StrengthSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public StrengthSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -33,15 +33,16 @@ namespace Server.Spells.Second public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -59,26 +60,5 @@ namespace Server.Spells.Second FinishSequence(); } - - private class InternalTarget : Target - { - private StrengthSpell m_Owner; - - public InternalTarget(StrengthSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/ChainLightning.cs b/Scripts/Spells/Seventh/ChainLightning.cs index 860431ffe..9609f56f3 100644 --- a/Scripts/Spells/Seventh/ChainLightning.cs +++ b/Scripts/Spells/Seventh/ChainLightning.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; +using System.Linq; using Server.Targeting; namespace Server.Spells.Seventh { - public class ChainLightningSpell : MagerySpell + public class ChainLightningSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Chain Lightning", "Vas Ort Grav", @@ -16,7 +17,7 @@ namespace Server.Spells.Seventh Reagent.SulfurousAsh ); - public ChainLightningSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ChainLightningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -26,7 +27,7 @@ namespace Server.Spells.Seventh public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -52,32 +53,25 @@ namespace Server.Spells.Seventh { IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2); - foreach (Mobile m in eable) + targets.AddRange(eable.Where(m => { - if (Core.AOS && m == Caster) - continue; + if (Core.AOS && (m == Caster || !Caster.InLOS(m)) || !SpellHelper.ValidIndirectTarget(Caster, m) || + !Caster.CanBeHarmful(m, false)) + return false; - if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false)) - { - if (Core.AOS && !Caster.InLOS(m)) - continue; + if (m.Player) + playerVsPlayer = true; - targets.Add(m); - - if (m.Player) - playerVsPlayer = true; - } - } + return true; + }).ToList()); eable.Free(); } double damage; - if (Core.AOS) - damage = GetNewAosDamage(51, 1, 5, playerVsPlayer); - else - damage = Utility.Random(27, 22); + damage = Core.AOS ? GetNewAosDamage(51, 1, 5, playerVsPlayer) + : Utility.Random(27, 22); if (targets.Count > 0) { @@ -113,26 +107,5 @@ namespace Server.Spells.Seventh FinishSequence(); } - - private class InternalTarget : Target - { - private ChainLightningSpell m_Owner; - - public InternalTarget(ChainLightningSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/EnergyField.cs b/Scripts/Spells/Seventh/EnergyField.cs index e43f81905..f14dbe3c6 100644 --- a/Scripts/Spells/Seventh/EnergyField.cs +++ b/Scripts/Spells/Seventh/EnergyField.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.Spells.Seventh { - public class EnergyFieldSpell : MagerySpell + public class EnergyFieldSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Energy Field", "In Sanct Grav", @@ -19,7 +19,7 @@ namespace Server.Spells.Seventh Reagent.SulfurousAsh ); - public EnergyFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EnergyFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -27,7 +27,7 @@ namespace Server.Spells.Seventh public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -63,7 +63,7 @@ namespace Server.Spells.Seventh TimeSpan duration; if (Core.AOS) - duration = TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5) / 7); + 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 @@ -141,16 +141,11 @@ namespace Server.Spells.Seventh public override bool OnMoveOver(Mobile m) { - int noto; - - if (m is PlayerMobile) - { - noto = Notoriety.Compute(m_Caster, m); - if (noto == Notoriety.Enemy || noto == Notoriety.Ally) - return false; - } - - return base.OnMoveOver(m); + if (!(m is PlayerMobile)) + return base.OnMoveOver(m); + + int noto = Notoriety.Compute(m_Caster, m); + return noto != Notoriety.Enemy && noto != Notoriety.Ally && base.OnMoveOver(m); } public override void OnAfterDelete() @@ -176,26 +171,5 @@ namespace Server.Spells.Seventh } } } - - private class InternalTarget : Target - { - private EnergyFieldSpell m_Owner; - - public InternalTarget(EnergyFieldSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/FlameStrike.cs b/Scripts/Spells/Seventh/FlameStrike.cs index da64575f5..e6bf7561b 100644 --- a/Scripts/Spells/Seventh/FlameStrike.cs +++ b/Scripts/Spells/Seventh/FlameStrike.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.Seventh { - public class FlameStrikeSpell : MagerySpell + public class FlameStrikeSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Flame Strike", "Kal Vas Flam", @@ -12,7 +12,7 @@ namespace Server.Spells.Seventh Reagent.SulfurousAsh ); - public FlameStrikeSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public FlameStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,15 +22,16 @@ namespace Server.Spells.Seventh public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -65,26 +66,5 @@ namespace Server.Spells.Seventh FinishSequence(); } - - private class InternalTarget : Target - { - private FlameStrikeSpell m_Owner; - - public InternalTarget(FlameStrikeSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/GateTravel.cs b/Scripts/Spells/Seventh/GateTravel.cs index 5f455055a..ba9728b79 100644 --- a/Scripts/Spells/Seventh/GateTravel.cs +++ b/Scripts/Spells/Seventh/GateTravel.cs @@ -4,12 +4,10 @@ using Server.Factions; using Server.Items; using Server.Misc; using Server.Mobiles; -using Server.Network; -using Server.Targeting; namespace Server.Spells.Seventh { - public class GateTravelSpell : MagerySpell + public class GateTravelSpell : MagerySpell, IRecallSpell { private static SpellInfo m_Info = new SpellInfo( "Gate Travel", "Vas Rel Por", @@ -22,11 +20,7 @@ namespace Server.Spells.Seventh private RunebookEntry m_Entry; - public GateTravelSpell(Mobile caster, Item scroll) : this(caster, scroll, null) - { - } - - public GateTravelSpell(Mobile caster, Item scroll, RunebookEntry entry) : base(caster, scroll, m_Info) + public GateTravelSpell(Mobile caster, RunebookEntry entry = null, Item scroll = null) : base(caster, scroll, m_Info) { m_Entry = entry; } @@ -36,7 +30,7 @@ namespace Server.Spells.Seventh public override void OnCast() { if (m_Entry == null) - Caster.Target = new InternalTarget(this); + Caster.Target = new RecallSpellTarget(this, false); else Effect(m_Entry.Location, m_Entry.Map, true); } @@ -186,64 +180,5 @@ namespace Server.Spells.Seventh } } } - - private class InternalTarget : Target - { - private GateTravelSpell m_Owner; - - public InternalTarget(GateTravelSpell owner) : base(12, false, TargetFlags.None) - { - m_Owner = owner; - - owner.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item. - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is RecallRune rune) - { - if (rune.Marked) - m_Owner.Effect(rune.Target, rune.TargetMap, true); - else - from.SendLocalizedMessage(501803); // That rune is not yet marked. - } - else if (o is Runebook runebook) - { - RunebookEntry e = runebook.Default; - - if (e != null) - m_Owner.Effect(e.Location, e.Map, true); - else - from.SendLocalizedMessage(502354); // Target is not marked. - } - /*else if ( o is Key && ((Key)o).KeyValue != 0 && ((Key)o).Link is BaseBoat ) - { - BaseBoat boat = ((Key)o).Link as BaseBoat; - - if ( !boat.Deleted && boat.CheckKey( ((Key)o).KeyValue ) ) - m_Owner.Effect( boat.GetMarkedLocation(), boat.Map, false ); - else - from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object. - }*/ - else if (o is HouseRaffleDeed deed && deed.ValidLocation()) - { - m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true); - } - else - { - from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, - "")); // I can not gate travel from that object. - } - } - - protected override void OnNonlocalTarget(Mobile from, object o) - { - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/ManaVampire.cs b/Scripts/Spells/Seventh/ManaVampire.cs index 932111842..32bde4d4f 100644 --- a/Scripts/Spells/Seventh/ManaVampire.cs +++ b/Scripts/Spells/Seventh/ManaVampire.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.Seventh { - public class ManaVampireSpell : MagerySpell + public class ManaVampireSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Mana Vampire", "Ort Sanct", @@ -14,7 +14,7 @@ namespace Server.Spells.Seventh Reagent.SpidersSilk ); - public ManaVampireSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ManaVampireSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,15 +22,16 @@ namespace Server.Spells.Seventh public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -92,25 +93,5 @@ namespace Server.Spells.Seventh { return 98.0; } - - private class InternalTarget : Target - { - private ManaVampireSpell m_Owner; - - public InternalTarget(ManaVampireSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile)m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/MassDispel.cs b/Scripts/Spells/Seventh/MassDispel.cs index 513b7fd17..8b6f32123 100644 --- a/Scripts/Spells/Seventh/MassDispel.cs +++ b/Scripts/Spells/Seventh/MassDispel.cs @@ -1,11 +1,10 @@ -using System.Collections.Generic; using Server.Items; using Server.Mobiles; using Server.Targeting; namespace Server.Spells.Seventh { - public class MassDispelSpell : MagerySpell + public class MassDispelSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Mass Dispel", "Vas An Ort", @@ -17,7 +16,7 @@ namespace Server.Spells.Seventh Reagent.SulfurousAsh ); - public MassDispelSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MassDispelSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -25,7 +24,7 @@ namespace Server.Spells.Seventh public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -40,70 +39,41 @@ namespace Server.Spells.Seventh SpellHelper.GetSurfaceTop(ref p); - List targets = new List(); - Map map = Caster.Map; if (map != null) { IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 8); - foreach (BaseCreature m in eable) - if (m.IsDispellable && Caster.CanBeHarmful(m, false)) - targets.Add(m); + foreach (BaseCreature bc in eable) + { + if (!(bc.IsDispellable && Caster.CanBeHarmful(bc, false))) + continue; + + double dispelChance = + (50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100; + + if (dispelChance > Utility.RandomDouble()) + { + Effects.SendLocationParticles(EffectItem.Create(bc.Location, bc.Map, EffectItem.DefaultDuration), + 0x3728, 8, 20, 5042); + Effects.PlaySound(bc, bc.Map, 0x201); + + bc.Delete(); + } + else + { + Caster.DoHarmful(bc); + + bc.FixedEffect(0x3779, 10, 20); + } + } eable.Free(); } - - for (int i = 0; i < targets.Count; ++i) - { - Mobile m = targets[i]; - - if (!(m is BaseCreature bc)) - continue; - - double dispelChance = - (50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100; - - if (dispelChance > Utility.RandomDouble()) - { - Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), - 0x3728, 8, 20, 5042); - Effects.PlaySound(m, m.Map, 0x201); - - m.Delete(); - } - else - { - Caster.DoHarmful(m); - - m.FixedEffect(0x3779, 10, 20); - } - } } FinishSequence(); } - - private class InternalTarget : Target - { - private MassDispelSpell m_Owner; - - public InternalTarget(MassDispelSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/MeteorSwarm.cs b/Scripts/Spells/Seventh/MeteorSwarm.cs index e75b9cc9a..3acc34147 100644 --- a/Scripts/Spells/Seventh/MeteorSwarm.cs +++ b/Scripts/Spells/Seventh/MeteorSwarm.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; +using System.Linq; using Server.Targeting; namespace Server.Spells.Seventh { - public class MeteorSwarmSpell : MagerySpell + public class MeteorSwarmSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Meteor Swarm", "Flam Kal Des Ylem", @@ -16,7 +17,7 @@ namespace Server.Spells.Seventh Reagent.SpidersSilk ); - public MeteorSwarmSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MeteorSwarmSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -26,7 +27,7 @@ namespace Server.Spells.Seventh public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -42,7 +43,7 @@ namespace Server.Spells.Seventh if (p is Item item) p = item.GetWorldLocation(); - List targets = new List(); + List targets; Map map = Caster.Map; @@ -52,27 +53,29 @@ namespace Server.Spells.Seventh { IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2); - foreach (Mobile m in eable) - if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false)) - { - if (Core.AOS && !Caster.InLOS(m)) - continue; + targets = eable.Where(m => + { + if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) || + Core.AOS && !Caster.InLOS(m)) + return false; - targets.Add(m); + if (m.Player) + playerVsPlayer = true; - if (m.Player) - playerVsPlayer = true; - } + return true; + }).ToList(); eable.Free(); } + else + { + targets = new List(); + } double damage; - if (Core.AOS) - damage = GetNewAosDamage(51, 1, 5, playerVsPlayer); - else - damage = Utility.Random(27, 22); + damage = Core.AOS ? GetNewAosDamage(51, 1, 5, playerVsPlayer) + : Utility.Random(27, 22); if (targets.Count > 0) { @@ -83,12 +86,11 @@ namespace Server.Spells.Seventh else if (!Core.AOS) damage /= targets.Count; - double toDeal; for (int i = 0; i < targets.Count; ++i) { Mobile m = targets[i]; - toDeal = damage; + double toDeal = damage; if (!Core.AOS && CheckResisted(m)) { @@ -108,26 +110,5 @@ namespace Server.Spells.Seventh FinishSequence(); } - - private class InternalTarget : Target - { - private MeteorSwarmSpell m_Owner; - - public InternalTarget(MeteorSwarmSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Seventh/Polymorph.cs b/Scripts/Spells/Seventh/Polymorph.cs index c8958d5ce..87ea5e111 100644 --- a/Scripts/Spells/Seventh/Polymorph.cs +++ b/Scripts/Spells/Seventh/Polymorph.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Server.Factions; using Server.Gumps; @@ -167,7 +166,7 @@ namespace Server.Spells.Seventh if (!m_Timers.TryGetValue(m, out InternalTimer timer)) return; - timer.Stop(); + timer?.Stop(); m_Timers.Remove(m); } diff --git a/Scripts/Spells/Sixth/Dispel.cs b/Scripts/Spells/Sixth/Dispel.cs index 511a62614..7ef8bbf72 100644 --- a/Scripts/Spells/Sixth/Dispel.cs +++ b/Scripts/Spells/Sixth/Dispel.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Sixth { - public class DispelSpell : MagerySpell + public class DispelSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Dispel", "An Ort", @@ -15,7 +15,7 @@ namespace Server.Spells.Sixth Reagent.SulfurousAsh ); - public DispelSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public DispelSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -23,60 +23,41 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } - public class InternalTarget : Target + public void Target(Mobile m) { - private DispelSpell m_Owner; + if (m == null) + return; - public InternalTarget(DispelSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) + if (!Caster.CanSee(m)) + Caster.SendLocalizedMessage(500237); // Target can not be seen. + else if (!(m is BaseCreature bc && bc.IsDispellable)) + Caster.SendLocalizedMessage(1005049); // That cannot be dispelled. + else if (CheckHSequence(m)) { - m_Owner = owner; - } + SpellHelper.Turn(Caster, m); - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile m) + double dispelChance = + (50.0 + 100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100; + + if (dispelChance > Utility.RandomDouble()) { - BaseCreature bc = m as BaseCreature; + Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), + 0x3728, 8, 20, 5042); + Effects.PlaySound(m, m.Map, 0x201); - if (!from.CanSee(m)) - { - from.SendLocalizedMessage(500237); // Target can not be seen. - } - else if (bc == null || !bc.IsDispellable) - { - from.SendLocalizedMessage(1005049); // That cannot be dispelled. - } - else if (m_Owner.CheckHSequence(m)) - { - SpellHelper.Turn(from, m); - - double dispelChance = - (50.0 + 100 * (from.Skills.Magery.Value - bc.DispelDifficulty) / (bc.DispelFocus * 2)) / 100; - - if (dispelChance > Utility.RandomDouble()) - { - Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), - 0x3728, 8, 20, 5042); - Effects.PlaySound(m, m.Map, 0x201); - - m.Delete(); - } - else - { - m.FixedEffect(0x3779, 10, 20); - from.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it! - } - } + m.Delete(); + } + else + { + m.FixedEffect(0x3779, 10, 20); + Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it! } } - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } + FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Sixth/EnergyBolt.cs b/Scripts/Spells/Sixth/EnergyBolt.cs index bfbd02fa9..5e31e04ac 100644 --- a/Scripts/Spells/Sixth/EnergyBolt.cs +++ b/Scripts/Spells/Sixth/EnergyBolt.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.Sixth { - public class EnergyBoltSpell : MagerySpell + public class EnergyBoltSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Energy Bolt", "Corp Por", @@ -12,7 +12,7 @@ namespace Server.Spells.Sixth Reagent.Nightshade ); - public EnergyBoltSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EnergyBoltSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,15 +22,16 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { Mobile source = Caster; @@ -70,26 +71,5 @@ namespace Server.Spells.Sixth FinishSequence(); } - - private class InternalTarget : Target - { - private EnergyBoltSpell m_Owner; - - public InternalTarget(EnergyBoltSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Sixth/Explosion.cs b/Scripts/Spells/Sixth/Explosion.cs index 4d27b9a14..da4281d02 100644 --- a/Scripts/Spells/Sixth/Explosion.cs +++ b/Scripts/Spells/Sixth/Explosion.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Sixth { - public class ExplosionSpell : MagerySpell + public class ExplosionSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Explosion", "Vas Ort Flam", @@ -13,7 +13,7 @@ namespace Server.Spells.Sixth Reagent.MandrakeRoot ); - public ExplosionSpell(Mobile caster, Item scroll) + public ExplosionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -26,11 +26,14 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. @@ -102,27 +105,5 @@ namespace Server.Spells.Sixth } } } - - private class InternalTarget : Target - { - private ExplosionSpell m_Owner; - - public InternalTarget(ExplosionSpell owner) - : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Sixth/Invisibility.cs b/Scripts/Spells/Sixth/Invisibility.cs index c1e1d4742..2bd6accb3 100644 --- a/Scripts/Spells/Sixth/Invisibility.cs +++ b/Scripts/Spells/Sixth/Invisibility.cs @@ -7,7 +7,7 @@ using Server.Targeting; namespace Server.Spells.Sixth { - public class InvisibilitySpell : MagerySpell + public class InvisibilitySpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Invisibility", "An Lor Xen", @@ -19,7 +19,7 @@ namespace Server.Spells.Sixth private static Dictionary m_Table = new Dictionary(); - public InvisibilitySpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public InvisibilitySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -38,11 +38,14 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. @@ -111,26 +114,5 @@ namespace Server.Spells.Sixth RemoveTimer(m_Mobile); } } - - public class InternalTarget : Target - { - private InvisibilitySpell m_Owner; - - public InternalTarget(InvisibilitySpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Sixth/Mark.cs b/Scripts/Spells/Sixth/Mark.cs index 0db750102..2f708855c 100644 --- a/Scripts/Spells/Sixth/Mark.cs +++ b/Scripts/Spells/Sixth/Mark.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Sixth { - public class MarkSpell : MagerySpell + public class MarkSpell : MagerySpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Mark", "Kal Por Ylem", @@ -15,7 +15,7 @@ namespace Server.Spells.Sixth Reagent.MandrakeRoot ); - public MarkSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MarkSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -23,35 +23,29 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); } public override bool CheckCast() { - if (!base.CheckCast()) - return false; - - return SpellHelper.CheckTravel(Caster, TravelCheckType.Mark); + return base.CheckCast() && SpellHelper.CheckTravel(Caster, TravelCheckType.Mark); } - public void Target(RecallRune rune) + public void Target(Item item) { - if (!Caster.CanSee(rune)) - { + if (!(item is RecallRune rune)) + Caster.Send(new MessageLocalized(Caster.Serial, Caster.Body, MessageType.Regular, 0x3B2, 3, 501797, Caster.Name, + "")); // I cannot mark that object. + else if (!Caster.CanSee(rune)) Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (!SpellHelper.CheckTravel(Caster, TravelCheckType.Mark)) { } else if (SpellHelper.CheckMulti(Caster.Location, Caster.Map, !Core.AOS)) - { Caster.SendLocalizedMessage(501942); // That location is blocked. - } else if (!rune.IsChildOf(Caster.Backpack)) - { Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1062422); // You must have this rune in your backpack in order to mark it. - } else if (CheckSequence()) { rune.Mark(Caster); @@ -62,29 +56,5 @@ namespace Server.Spells.Sixth FinishSequence(); } - - private class InternalTarget : Target - { - private MarkSpell m_Owner; - - public InternalTarget(MarkSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is RecallRune rune) - m_Owner.Target(rune); - else - from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501797, from.Name, - "")); // I cannot mark that object. - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Sixth/MassCurse.cs b/Scripts/Spells/Sixth/MassCurse.cs index 20024e593..ba9121c9d 100644 --- a/Scripts/Spells/Sixth/MassCurse.cs +++ b/Scripts/Spells/Sixth/MassCurse.cs @@ -1,9 +1,8 @@ -using System.Collections.Generic; using Server.Targeting; namespace Server.Spells.Sixth { - public class MassCurseSpell : MagerySpell + public class MassCurseSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Mass Curse", "Vas Des Sanct", @@ -16,7 +15,7 @@ namespace Server.Spells.Sixth Reagent.SulfurousAsh ); - public MassCurseSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MassCurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -24,7 +23,7 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -39,8 +38,6 @@ namespace Server.Spells.Sixth SpellHelper.GetSurfaceTop(ref p); - List targets = new List(); - Map map = Caster.Map; if (map != null) @@ -49,57 +46,29 @@ namespace Server.Spells.Sixth foreach (Mobile m in eable) { - if (Core.AOS && m == Caster) + if (Core.AOS && (m == Caster || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanSee(m) || + !Caster.CanBeHarmful(m, false))) continue; - if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanSee(m) && Caster.CanBeHarmful(m, false)) - targets.Add(m); + Caster.DoHarmful(m); + + SpellHelper.AddStatCurse(Caster, m, StatType.Str); + SpellHelper.DisableSkillCheck = true; + SpellHelper.AddStatCurse(Caster, m, StatType.Dex); + SpellHelper.AddStatCurse(Caster, m, StatType.Int); + SpellHelper.DisableSkillCheck = false; + + m.FixedParticles(0x374A, 10, 15, 5028, EffectLayer.Waist); + m.PlaySound(0x1FB); + + HarmfulSpell(m); } eable.Free(); } - - for (int i = 0; i < targets.Count; ++i) - { - Mobile m = targets[i]; - - Caster.DoHarmful(m); - - SpellHelper.AddStatCurse(Caster, m, StatType.Str); - SpellHelper.DisableSkillCheck = true; - SpellHelper.AddStatCurse(Caster, m, StatType.Dex); - SpellHelper.AddStatCurse(Caster, m, StatType.Int); - SpellHelper.DisableSkillCheck = false; - - m.FixedParticles(0x374A, 10, 15, 5028, EffectLayer.Waist); - m.PlaySound(0x1FB); - - HarmfulSpell(m); - } } FinishSequence(); } - - private class InternalTarget : Target - { - private MassCurseSpell m_Owner; - - public InternalTarget(MassCurseSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Sixth/ParalyzeField.cs b/Scripts/Spells/Sixth/ParalyzeField.cs index 8466520d7..4f16ac735 100644 --- a/Scripts/Spells/Sixth/ParalyzeField.cs +++ b/Scripts/Spells/Sixth/ParalyzeField.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.Spells.Sixth { - public class ParalyzeFieldSpell : MagerySpell + public class ParalyzeFieldSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Paralyze Field", "In Ex Grav", @@ -18,7 +18,7 @@ namespace Server.Spells.Sixth Reagent.SpidersSilk ); - public ParalyzeFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ParalyzeFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -26,7 +26,7 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -66,9 +66,8 @@ namespace Server.Spells.Sixth for (int i = -2; i <= 2; ++i) { Point3D loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z); - bool canFit = SpellHelper.AdjustField(ref loc, Caster.Map, 12, false); - if (!canFit) + if (!SpellHelper.AdjustField(ref loc, Caster.Map, 12, false)) continue; Item item = new InternalItem(Caster, itemID, loc, Caster.Map, duration); @@ -212,26 +211,5 @@ namespace Server.Spells.Sixth } } } - - private class InternalTarget : Target - { - private ParalyzeFieldSpell m_Owner; - - public InternalTarget(ParalyzeFieldSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Sixth/Reveal.cs b/Scripts/Spells/Sixth/Reveal.cs index 3b7473e24..7a0b21d3c 100644 --- a/Scripts/Spells/Sixth/Reveal.cs +++ b/Scripts/Spells/Sixth/Reveal.cs @@ -1,10 +1,9 @@ -using System.Collections.Generic; using Server.Mobiles; using Server.Targeting; namespace Server.Spells.Sixth { - public class RevealSpell : MagerySpell + public class RevealSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Reveal", "Wis Quas", @@ -14,7 +13,7 @@ namespace Server.Spells.Sixth Reagent.SulfurousAsh ); - public RevealSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public RevealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -22,7 +21,7 @@ namespace Server.Spells.Sixth public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -34,11 +33,7 @@ namespace Server.Spells.Sixth else if (CheckSequence()) { SpellHelper.Turn(Caster, p); - SpellHelper.GetSurfaceTop(ref p); - - List targets = new List(); - Map map = Caster.Map; if (map != null) @@ -48,26 +43,20 @@ namespace Server.Spells.Sixth foreach (Mobile m in eable) { - if (m is ShadowKnight && (m.X != p.X || m.Y != p.Y)) + if (m is ShadowKnight && + (m.X != p.X || m.Y != p.Y || !m.Hidden || m.AccessLevel != AccessLevel.Player && + Caster.AccessLevel <= m.AccessLevel || + !CheckDifficulty(Caster, m))) continue; - if (m.Hidden && (m.AccessLevel == AccessLevel.Player || Caster.AccessLevel > m.AccessLevel) && - CheckDifficulty(Caster, m)) - targets.Add(m); + m.RevealingAction(); + + m.FixedParticles(0x375A, 9, 20, 5049, EffectLayer.Head); + m.PlaySound(0x1FD); } eable.Free(); } - - for (int i = 0; i < targets.Count; ++i) - { - Mobile m = targets[i]; - - m.RevealingAction(); - - m.FixedParticles(0x375A, 9, 20, 5049, EffectLayer.Head); - m.PlaySound(0x1FD); - } } FinishSequence(); @@ -95,26 +84,5 @@ namespace Server.Spells.Sixth return chance > Utility.Random(100); } - - public class InternalTarget : Target - { - private RevealSpell m_Owner; - - public InternalTarget(RevealSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/ArcaneCircle.cs b/Scripts/Spells/Spellweaving/ArcaneCircle.cs index b6c9cfb11..2ff71c495 100644 --- a/Scripts/Spells/Spellweaving/ArcaneCircle.cs +++ b/Scripts/Spells/Spellweaving/ArcaneCircle.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Server.Items; using Server.Mobiles; @@ -12,7 +13,7 @@ namespace Server.Spells.Spellweaving -1 ); - public ArcaneCircleSpell(Mobile caster, Item scroll) + public ArcaneCircleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -91,23 +92,14 @@ namespace Server.Spells.Spellweaving return true; } - IPooledEnumerable eable = map.GetItemsInRange(location, 0); // Added Tiles + IPooledEnumerable eable = map.GetItemsInRange(location, 0); - foreach (Item item in eable) - { - ItemData id = item.ItemData; - - if (item.Z + id.CalcHeight != location.Z) - continue; - if (IsValidTile(item.ItemID)) - { - eable.Free(); - return true; - } - } + bool found = eable.Any(item => + item.Z + item.ItemData.CalcHeight == location.Z && IsValidTile(item.ItemID)); eable.Free(); - return false; + + return found; } public static bool IsValidTile(int itemID) @@ -123,11 +115,10 @@ namespace Server.Spells.Spellweaving List weavers = new List { Caster }; //OSI Verified: Even enemies/combatants count - foreach (Mobile m in Caster.GetMobilesInRange(1)) //Range verified as 1 - if (m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) && - Math.Abs(Caster.Skills.Spellweaving.Value - m.Skills.Spellweaving.Value) <= 20) - weavers.Add(m); // Everyone gets the Arcane Focus, power capped elsewhere + weavers.AddRange(Caster.GetMobilesInRange(1) + .Where(m => m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) && + Math.Abs(Caster.Skills.Spellweaving.Value - m.Skills.Spellweaving.Value) <= 20)); return weavers; } @@ -163,4 +154,4 @@ namespace Server.Spells.Spellweaving } } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/ArcanistSpell.cs b/Scripts/Spells/Spellweaving/ArcanistSpell.cs index 46e133144..9caa61ea0 100644 --- a/Scripts/Spells/Spellweaving/ArcanistSpell.cs +++ b/Scripts/Spells/Spellweaving/ArcanistSpell.cs @@ -27,32 +27,17 @@ namespace Server.Spells.Spellweaving { ArcaneFocus focus = FindArcaneFocus(from); - if (focus == null || focus.Deleted) - return 0; - - return focus.StrengthBonus; + return focus?.Deleted != false ? 0 : focus.StrengthBonus; } public static ArcaneFocus FindArcaneFocus(Mobile from) { - if (from?.Backpack == null) - return null; - - if (from.Holding is ArcaneFocus focus) - return focus; - - return from.Backpack.FindItemByType(); + return from.Holding as ArcaneFocus ?? from.Backpack?.FindItemByType(); } public static bool CheckExpansion(Mobile from) { - if (!(from is PlayerMobile)) - return true; - - if (from.NetState == null) - return false; - - return from.NetState.SupportsExpansion(Expansion.ML); + return !(from is PlayerMobile) || from.NetState?.SupportsExpansion(Expansion.ML) == true; } public override bool CheckCast() @@ -158,4 +143,4 @@ namespace Server.Spells.Spellweaving return percent >= Utility.RandomDouble(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/AttuneWeapon.cs b/Scripts/Spells/Spellweaving/AttuneWeapon.cs index 1e1b7ae66..9cbb17fdf 100644 --- a/Scripts/Spells/Spellweaving/AttuneWeapon.cs +++ b/Scripts/Spells/Spellweaving/AttuneWeapon.cs @@ -12,7 +12,7 @@ namespace Server.Spells.Spellweaving private static Dictionary m_Table = new Dictionary(); - public AttuneWeaponSpell(Mobile caster, Item scroll) + public AttuneWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Spellweaving/EssenceOfWind.cs b/Scripts/Spells/Spellweaving/EssenceOfWind.cs index ad4a3a632..de358013f 100644 --- a/Scripts/Spells/Spellweaving/EssenceOfWind.cs +++ b/Scripts/Spells/Spellweaving/EssenceOfWind.cs @@ -9,7 +9,7 @@ namespace Server.Spells.Spellweaving private static Dictionary m_Table = new Dictionary(); - public EssenceOfWindSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public EssenceOfWindSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -34,29 +34,28 @@ namespace Server.Spells.Spellweaving int fcMalus = FocusLevel + 1; int ssiMalus = 2 * (FocusLevel + 1); - List targets = new List(); + IPooledEnumerable eable = Caster.GetMobilesInRange(range); - foreach (Mobile m in Caster.GetMobilesInRange(range)) - if (Caster != m && Caster.InLOS(m) && SpellHelper.ValidIndirectTarget(Caster, m) && - Caster.CanBeHarmful(m, false)) - targets.Add(m); - - for (int i = 0; i < targets.Count; i++) + foreach (Mobile m in eable) { - Mobile m = targets[i]; + 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)) //No message on resist - { - m_Table[m] = new EssenceOfWindInfo(m, fcMalus, ssiMalus, duration); + if (CheckResisted(m)) + continue; - BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.EssenceOfWind, 1075802, duration, m, - $"{fcMalus.ToString()}\t{ssiMalus.ToString()}")); - } + m_Table[m] = new EssenceOfWindInfo(m, fcMalus, ssiMalus, duration); + + BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.EssenceOfWind, 1075802, duration, m, + $"{fcMalus.ToString()}\t{ssiMalus.ToString()}")); } + + eable.Free(); } FinishSequence(); diff --git a/Scripts/Spells/Spellweaving/EtherealVoyage.cs b/Scripts/Spells/Spellweaving/EtherealVoyage.cs index 61512015c..8e86426f6 100644 --- a/Scripts/Spells/Spellweaving/EtherealVoyage.cs +++ b/Scripts/Spells/Spellweaving/EtherealVoyage.cs @@ -9,7 +9,7 @@ namespace Server.Spells.Spellweaving -1 ); - public EtherealVoyageSpell(Mobile caster, Item scroll) + public EtherealVoyageSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -73,4 +73,4 @@ namespace Server.Spells.Spellweaving BuffInfo.RemoveBuff(m, BuffIcon.EtherealVoyage); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/GiftOfLife.cs b/Scripts/Spells/Spellweaving/GiftOfLife.cs index 2af71865d..d0aa91feb 100644 --- a/Scripts/Spells/Spellweaving/GiftOfLife.cs +++ b/Scripts/Spells/Spellweaving/GiftOfLife.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.Spells.Spellweaving { - public class GiftOfLifeSpell : ArcanistSpell + public class GiftOfLifeSpell : ArcanistSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Gift of Life", "Illorae", @@ -15,7 +15,7 @@ namespace Server.Spells.Spellweaving private static Dictionary m_Table = new Dictionary(); - public GiftOfLifeSpell(Mobile caster, Item scroll) + public GiftOfLifeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -34,27 +34,23 @@ namespace Server.Spells.Spellweaving public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 10); } public void Target(Mobile m) { - if (!Caster.CanSee(m)) - { + if (m == null) + Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet. + else if (!Caster.CanSee(m)) Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (m.IsDeadBondedPet || !m.Alive) { // As per Osi: Nothing happens. } else if (m != Caster && !(m is BaseCreature bc && bc.IsBonded && bc.ControlMaster == Caster)) - { Caster.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet. - } else if (m_Table.ContainsKey(m)) - { Caster.SendLocalizedMessage(501775); // This spell is already in effect. - } else if (CheckBSequence(m)) { if (Caster == m) @@ -132,7 +128,7 @@ namespace Server.Spells.Spellweaving m.SendGump(new ResurrectGump(m, hitsScalar)); } - //Per OSI, buff is removed when gump sent, irregardless of online status or acceptence + //Per OSI, buff is removed when gump sent, irregardless of online status or acceptance timer.DoExpire(); } @@ -174,29 +170,5 @@ namespace Server.Spells.Spellweaving BuffInfo.RemoveBuff(m_Mobile, BuffIcon.GiftOfLife); } } - - public class InternalTarget : Target - { - private GiftOfLifeSpell m_Owner; - - public InternalTarget(GiftOfLifeSpell owner) - : base(10, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile m, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - else - m.SendLocalizedMessage(1072077); // You may only cast this spell on yourself or a bonded pet. - } - - protected override void OnTargetFinish(Mobile m) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Spellweaving/GiftOfRenewal.cs b/Scripts/Spells/Spellweaving/GiftOfRenewal.cs index cdfd41510..1ded88fcb 100644 --- a/Scripts/Spells/Spellweaving/GiftOfRenewal.cs +++ b/Scripts/Spells/Spellweaving/GiftOfRenewal.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Spellweaving { - public class GiftOfRenewalSpell : ArcanistSpell + public class GiftOfRenewalSpell : ArcanistSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Gift of Renewal", "Olorisstra", @@ -13,7 +13,7 @@ namespace Server.Spells.Spellweaving private static Dictionary m_Table = new Dictionary(); - public GiftOfRenewalSpell(Mobile caster, Item scroll) + public GiftOfRenewalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -25,20 +25,20 @@ namespace Server.Spells.Spellweaving public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, 10); } public void Target(Mobile m) { - if (!Caster.CanSee(m)) Caster.SendLocalizedMessage(500237); // Target can not be seen. - if (m_Table.ContainsKey(m)) - { + if (m == null) + return; + + if (!Caster.CanSee(m)) + Caster.SendLocalizedMessage(500237); // Target can not be seen. + else if (m_Table.ContainsKey(m)) Caster.SendLocalizedMessage(501775); // This spell is already in effect. - } else if (!Caster.CanBeginAction()) - { Caster.SendLocalizedMessage(501789); // You must wait before trying again. - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -151,27 +151,5 @@ namespace Server.Spells.Spellweaving m.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist); } } - - private class InternalTarget : Target - { - private GiftOfRenewalSpell m_Owner; - - public InternalTarget(GiftOfRenewalSpell owner) - : base(10, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile m, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile m) - { - m_Owner.FinishSequence(); - } - } } } diff --git a/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs b/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs index ac8a7d2e2..b917f3ff3 100644 --- a/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs +++ b/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs @@ -14,7 +14,7 @@ namespace Server.Spells.Spellweaving private static Dictionary m_WeaponDamageTable = new Dictionary(); - public ImmolatingWeaponSpell(Mobile caster, Item scroll) + public ImmolatingWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } diff --git a/Scripts/Spells/Spellweaving/NatureFury.cs b/Scripts/Spells/Spellweaving/NatureFury.cs index d6d503f38..539bbd1ee 100644 --- a/Scripts/Spells/Spellweaving/NatureFury.cs +++ b/Scripts/Spells/Spellweaving/NatureFury.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.Spells.Spellweaving { - public class NatureFurySpell : ArcanistSpell + public class NatureFurySpell : ArcanistSpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Nature's Fury", "Rauvvrae", @@ -13,7 +13,7 @@ namespace Server.Spells.Spellweaving false ); - public NatureFurySpell(Mobile caster, Item scroll) + public NatureFurySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -39,7 +39,7 @@ namespace Server.Spells.Spellweaving public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, 10); } public void Target(IPoint3D point) @@ -50,9 +50,7 @@ namespace Server.Spells.Spellweaving if (map == null) return; - HouseRegion r = Region.Find(p, map).GetRegion(); - - if (r?.House != null && !r.House.IsFriend(Caster)) + if (Region.Find(p, map).GetRegion()?.House?.IsFriend(Caster) == false) return; if (!map.CanSpawnMobile(p.X, p.Y, p.Z)) @@ -72,28 +70,6 @@ namespace Server.Spells.Spellweaving FinishSequence(); } - private class InternalTarget : Target - { - private NatureFurySpell m_Owner; - - public InternalTarget(NatureFurySpell owner) - : base(10, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner?.FinishSequence(); - } - } - private class InternalTimer : Timer { private NatureFury m_NatureFury; @@ -118,4 +94,4 @@ namespace Server.Spells.Spellweaving } } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/ReaperForm.cs b/Scripts/Spells/Spellweaving/ReaperForm.cs index 27b47e91c..ff693ec24 100644 --- a/Scripts/Spells/Spellweaving/ReaperForm.cs +++ b/Scripts/Spells/Spellweaving/ReaperForm.cs @@ -7,7 +7,7 @@ namespace Server.Spells.Spellweaving { private static SpellInfo m_Info = new SpellInfo("Reaper Form", "Tarisstree", -1); - public ReaperFormSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public ReaperFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -36,7 +36,7 @@ namespace Server.Spells.Spellweaving { TransformContext context = TransformationSpellHelper.GetContext(e.Mobile); - if (context != null && context.Type == typeof(ReaperFormSpell)) + if (context?.Type == typeof(ReaperFormSpell)) e.Mobile.Send(SpeedControl.WalkSpeed); } @@ -52,4 +52,4 @@ namespace Server.Spells.Spellweaving m.Send(SpeedControl.Disable); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/SummonFey.cs b/Scripts/Spells/Spellweaving/SummonFey.cs index d8eb77be8..9f2599681 100644 --- a/Scripts/Spells/Spellweaving/SummonFey.cs +++ b/Scripts/Spells/Spellweaving/SummonFey.cs @@ -11,7 +11,7 @@ namespace Server.Spells.Spellweaving -1 ); - public SummonFeySpell(Mobile caster, Item scroll) + public SummonFeySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -43,4 +43,4 @@ namespace Server.Spells.Spellweaving return base.CheckSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/SummonFiend.cs b/Scripts/Spells/Spellweaving/SummonFiend.cs index 5b8c0df37..e5c1ca81b 100644 --- a/Scripts/Spells/Spellweaving/SummonFiend.cs +++ b/Scripts/Spells/Spellweaving/SummonFiend.cs @@ -11,7 +11,7 @@ namespace Server.Spells.Spellweaving -1 ); - public SummonFiendSpell(Mobile caster, Item scroll) + public SummonFiendSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -42,4 +42,4 @@ namespace Server.Spells.Spellweaving return base.CheckSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Spellweaving/Thunderstorm.cs b/Scripts/Spells/Spellweaving/Thunderstorm.cs index c6cbf24dd..b41a9ef8a 100644 --- a/Scripts/Spells/Spellweaving/Thunderstorm.cs +++ b/Scripts/Spells/Spellweaving/Thunderstorm.cs @@ -12,7 +12,7 @@ namespace Server.Spells.Spellweaving private static Dictionary m_Table = new Dictionary(); - public ThunderstormSpell(Mobile caster, Item scroll) + public ThunderstormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -46,16 +46,13 @@ namespace Server.Spells.Spellweaving int range = 2 + FocusLevel; TimeSpan duration = TimeSpan.FromSeconds(5 + FocusLevel); - List targets = new List(); + IPooledEnumerable eable = Caster.GetMobilesInRange(range); - foreach (Mobile m in Caster.GetMobilesInRange(range)) - if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && - Caster.InLOS(m)) - targets.Add(m); - - for (int i = 0; i < targets.Count; i++) + foreach (Mobile m in eable) { - Mobile m = targets[i]; + if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) || + !Caster.InLOS(m)) + continue; Caster.DoHarmful(m); @@ -63,14 +60,16 @@ namespace Server.Spells.Spellweaving SpellHelper.Damage(this, m, m.Player && Caster.Player ? pvpDamage : pvmDamage, 0, 0, 0, 0, 100); - if (oldSpell != null && oldSpell != m.Spell && !CheckResisted(m)) - { - m_Table[m] = Timer.DelayCall(duration, DoExpire, m); + if (oldSpell == null || oldSpell == m.Spell || CheckResisted(m)) + continue; - BuffInfo.AddBuff(m, - new BuffInfo(BuffIcon.Thunderstorm, 1075800, duration, m, GetCastRecoveryMalus(m))); - } + m_Table[m] = Timer.DelayCall(duration, DoExpire, m); + + BuffInfo.AddBuff(m, + new BuffInfo(BuffIcon.Thunderstorm, 1075800, duration, m, GetCastRecoveryMalus(m))); } + + eable.Free(); } FinishSequence(); diff --git a/Scripts/Spells/Spellweaving/WordOfDeath.cs b/Scripts/Spells/Spellweaving/WordOfDeath.cs index 4b696255e..8c2419230 100644 --- a/Scripts/Spells/Spellweaving/WordOfDeath.cs +++ b/Scripts/Spells/Spellweaving/WordOfDeath.cs @@ -3,11 +3,11 @@ using Server.Targeting; namespace Server.Spells.Spellweaving { - public class WordOfDeathSpell : ArcanistSpell + public class WordOfDeathSpell : ArcanistSpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo("Word of Death", "Nyraxle", -1); - public WordOfDeathSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public WordOfDeathSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -18,15 +18,16 @@ namespace Server.Spells.Spellweaving public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, 10); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { Point3D loc = m.Location; @@ -63,26 +64,5 @@ namespace Server.Spells.Spellweaving FinishSequence(); } - - public class InternalTarget : Target - { - private WordOfDeathSpell m_Owner; - - public InternalTarget(WordOfDeathSpell owner) : base(10, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile m, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile m) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Targeting/IRecallSpell.cs b/Scripts/Spells/Targeting/IRecallSpell.cs new file mode 100644 index 000000000..e986d8c8c --- /dev/null +++ b/Scripts/Spells/Targeting/IRecallSpell.cs @@ -0,0 +1,9 @@ +namespace Server.Spells +{ + public interface IRecallSpell + { + Mobile Caster{ get; } + void Effect(Point3D loc, Map map, bool checkMulti); + void FinishSequence(); + } +} diff --git a/Scripts/Spells/Targeting/ISpellTarget.cs b/Scripts/Spells/Targeting/ISpellTarget.cs new file mode 100644 index 000000000..69b5a24ca --- /dev/null +++ b/Scripts/Spells/Targeting/ISpellTarget.cs @@ -0,0 +1,7 @@ +namespace Server.Spells +{ + public interface ISpellTarget + { + ISpell Spell{ get; } + } +} diff --git a/Scripts/Spells/Targeting/RecallSpellTarget.cs b/Scripts/Spells/Targeting/RecallSpellTarget.cs new file mode 100644 index 000000000..b74530dfb --- /dev/null +++ b/Scripts/Spells/Targeting/RecallSpellTarget.cs @@ -0,0 +1,66 @@ +using Server.Items; +using Server.Multis; +using Server.Network; +using Server.Targeting; + +namespace Server.Spells +{ + public class RecallSpellTarget : Target + { + private IRecallSpell m_Spell; + private bool m_ToBoat; + + public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None) + { + m_Spell = spell; + m_ToBoat = toBoat; + m_Spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item. + } + + protected override void OnTarget(Mobile from, object o) + { + 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. + } + else if (o is Runebook runebook) + { + RunebookEntry e = runebook.Default; + + if (e != null) + m_Spell.Effect(e.Location, e.Map, true); + else + 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(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, + from.Name, "")); // I can not recall from that object. + } + else if (o is HouseRaffleDeed deed && deed.ValidLocation()) + { + m_Spell.Effect(deed.PlotLocation, deed.PlotFacet, true); + } + else + { + from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, + "")); // I can not recall from that object. + } + } + + protected override void OnNonlocalTarget(Mobile from, object o) + { + } + + protected override void OnTargetFinish(Mobile from) + { + m_Spell?.FinishSequence(); + } + } +} diff --git a/Scripts/Spells/Targeting/SpellTargetItem.cs b/Scripts/Spells/Targeting/SpellTargetItem.cs new file mode 100644 index 000000000..880222450 --- /dev/null +++ b/Scripts/Spells/Targeting/SpellTargetItem.cs @@ -0,0 +1,31 @@ +using Server.Targeting; + +namespace Server.Spells +{ + public interface ISpellTargetingItem : ISpell + { + void Target(Item item); + } + + public class SpellTargetItem : Target, ISpellTarget + { + private ISpellTargetingItem m_Spell; + public ISpell Spell => m_Spell; + + public SpellTargetItem(ISpellTargetingItem spell, TargetFlags flags, int range = 12) : base(range, false, flags) + { + m_Spell = spell; + } + + protected override void OnTarget(Mobile from, object o) + { + if (o is Item item) + m_Spell.Target(item); + } + + protected override void OnTargetFinish(Mobile from) + { + m_Spell?.FinishSequence(); + } + } +} diff --git a/Scripts/Spells/Targeting/SpellTargetMobile.cs b/Scripts/Spells/Targeting/SpellTargetMobile.cs new file mode 100644 index 000000000..ce07c85bd --- /dev/null +++ b/Scripts/Spells/Targeting/SpellTargetMobile.cs @@ -0,0 +1,30 @@ +using Server.Targeting; + +namespace Server.Spells +{ + public interface ISpellTargetingMobile : ISpell + { + void Target(Mobile from); + } + + public class SpellTargetMobile : Target, ISpellTarget + { + private ISpellTargetingMobile m_Spell; + public ISpell Spell => m_Spell; + + public SpellTargetMobile(ISpellTargetingMobile spell, TargetFlags flags, int range = 12) : base(range, false, flags) + { + m_Spell = spell; + } + + protected override void OnTarget(Mobile from, object o) + { + m_Spell.Target(o as Mobile); + } + + protected override void OnTargetFinish(Mobile from) + { + m_Spell?.FinishSequence(); + } + } +} diff --git a/Scripts/Spells/Targeting/SpellTargetPoint3D.cs b/Scripts/Spells/Targeting/SpellTargetPoint3D.cs new file mode 100644 index 000000000..1f17046fa --- /dev/null +++ b/Scripts/Spells/Targeting/SpellTargetPoint3D.cs @@ -0,0 +1,46 @@ +using System; +using Server.Targeting; + +namespace Server.Spells +{ + public interface ISpellTargetingPoint3D : ISpell + { + void Target(IPoint3D p); + } + + public class SpellTargetPoint3D : Target + { + private ISpellTargetingPoint3D m_Spell; + public ISpell Spell => m_Spell; + + private bool m_CheckLOS; + + public SpellTargetPoint3D(ISpellTargetingPoint3D spell, TargetFlags flags = TargetFlags.None, int range = 12, bool checkLOS = true) : base(range, true, flags) + { + m_Spell = spell; + m_CheckLOS = checkLOS; + } + + 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); + from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow); + m_Spell = null; // Needed? + } + + protected override void OnTargetFinish(Mobile from) + { + m_Spell?.FinishSequence(); + } + } +} diff --git a/Scripts/Spells/Third/Bless.cs b/Scripts/Spells/Third/Bless.cs index 3e3f2cb82..47e26354a 100644 --- a/Scripts/Spells/Third/Bless.cs +++ b/Scripts/Spells/Third/Bless.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class BlessSpell : MagerySpell + public class BlessSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Bless", "Rel Sanct", @@ -14,7 +14,7 @@ namespace Server.Spells.Third Reagent.MandrakeRoot ); - public BlessSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public BlessSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -33,15 +33,16 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckBSequence(m)) { SpellHelper.Turn(Caster, m); @@ -65,26 +66,5 @@ namespace Server.Spells.Third FinishSequence(); } - - private class InternalTarget : Target - { - private BlessSpell m_Owner; - - public InternalTarget(BlessSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/Fireball.cs b/Scripts/Spells/Third/Fireball.cs index cf1f76707..661486548 100644 --- a/Scripts/Spells/Third/Fireball.cs +++ b/Scripts/Spells/Third/Fireball.cs @@ -2,7 +2,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class FireballSpell : MagerySpell + public class FireballSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Fireball", "Vas Flam", @@ -11,7 +11,7 @@ namespace Server.Spells.Third Reagent.BlackPearl ); - public FireballSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public FireballSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -21,15 +21,16 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { Mobile source = Caster; @@ -66,26 +67,5 @@ namespace Server.Spells.Third FinishSequence(); } - - private class InternalTarget : Target - { - private FireballSpell m_Owner; - - public InternalTarget(FireballSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) - m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/MagicLock.cs b/Scripts/Spells/Third/MagicLock.cs index 9e60fc007..edf3ce3f4 100644 --- a/Scripts/Spells/Third/MagicLock.cs +++ b/Scripts/Spells/Third/MagicLock.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class MagicLockSpell : MagerySpell + public class MagicLockSpell : MagerySpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Magic Lock", "An Por", @@ -16,7 +16,7 @@ namespace Server.Spells.Third Reagent.SulfurousAsh ); - public MagicLockSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public MagicLockSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -24,64 +24,37 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); } - public void Target(LockableContainer targ) + public void Target(Item item) { - if (BaseHouse.CheckLockedDownOrSecured(targ)) - { - // You cannot cast this on a locked down item. - Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 501761); - } - else if (targ.Locked || targ.LockLevel == 0 || targ is ParagonChest) - { - // Target must be an unlocked chest. - Caster.SendLocalizedMessage(501762); - } + if (!(item is LockableContainer cont)) + Caster.SendLocalizedMessage(501762); // Target must be an unlocked chest. + else if (BaseHouse.CheckLockedDownOrSecured(cont)) + Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 501761); // You cannot cast this on a locked down item. + else if (cont.Locked || cont.LockLevel == 0 || cont is ParagonChest) + Caster.SendLocalizedMessage(501762); // Target must be an unlocked chest. else if (CheckSequence()) { - SpellHelper.Turn(Caster, targ); + SpellHelper.Turn(Caster, cont); - Point3D loc = targ.GetWorldLocation(); + Point3D loc = cont.GetWorldLocation(); Effects.SendLocationParticles( - EffectItem.Create(loc, targ.Map, EffectItem.DefaultDuration), + EffectItem.Create(loc, cont.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5020); - Effects.PlaySound(loc, targ.Map, 0x1FA); + Effects.PlaySound(loc, cont.Map, 0x1FA); // The chest is now locked! Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501763); - targ.LockLevel = -255; // signal magic lock - targ.Locked = true; + cont.LockLevel = -255; // signal magic lock + cont.Locked = true; } FinishSequence(); } - - private class InternalTarget : Target - { - private MagicLockSpell m_Owner; - - public InternalTarget(MagicLockSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is LockableContainer container) - m_Owner.Target(container); - else - from.SendLocalizedMessage(501762); // Target must be an unlocked chest. - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/Poison.cs b/Scripts/Spells/Third/Poison.cs index 1c88c109f..26693d3f1 100644 --- a/Scripts/Spells/Third/Poison.cs +++ b/Scripts/Spells/Third/Poison.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class PoisonSpell : MagerySpell + public class PoisonSpell : MagerySpell, ISpellTargetingMobile { private static SpellInfo m_Info = new SpellInfo( "Poison", "In Nox", @@ -12,7 +12,7 @@ namespace Server.Spells.Third Reagent.Nightshade ); - public PoisonSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public PoisonSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -20,15 +20,16 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } public void Target(Mobile m) { + if (m == null) + return; + if (!Caster.CanSee(m)) - { Caster.SendLocalizedMessage(500237); // Target can not be seen. - } else if (CheckHSequence(m)) { SpellHelper.Turn(Caster, m); @@ -77,11 +78,8 @@ namespace Server.Spells.Third if (Caster is PlayerMobile pm) { - if (pm.DuelContext != null && pm.DuelContext.Started && !pm.DuelContext.Finished && - !pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning")) - { - } - else + if (pm.DuelContext == null || !pm.DuelContext.Started || pm.DuelContext.Finished || + pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning")) { total += pm.Skills.Poisoning.Value; } @@ -119,25 +117,5 @@ namespace Server.Spells.Third FinishSequence(); } - - private class InternalTarget : Target - { - private PoisonSpell m_Owner; - - public InternalTarget(PoisonSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is Mobile mobile) m_Owner.Target(mobile); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/Telekinesis.cs b/Scripts/Spells/Third/Telekinesis.cs index 086682034..42de74425 100644 --- a/Scripts/Spells/Third/Telekinesis.cs +++ b/Scripts/Spells/Third/Telekinesis.cs @@ -3,7 +3,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class TelekinesisSpell : MagerySpell + public class TelekinesisSpell : MagerySpell, ISpellTargetingItem { private static SpellInfo m_Info = new SpellInfo( "Telekinesis", "Ort Por Ylem", @@ -13,7 +13,7 @@ namespace Server.Spells.Third Reagent.MandrakeRoot ); - public TelekinesisSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public TelekinesisSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -21,79 +21,55 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetItem(this, TargetFlags.None, Core.ML ? 10 : 12); } - public void Target(ITelekinesisable obj) + public void Target(Item item) { + ITelekinesisable t = item as ITelekinesisable; + if (!(t != null || item is Container)) + { + Caster.SendLocalizedMessage(501857); // This spell won't work on that! + return; + } + if (CheckSequence()) { - SpellHelper.Turn(Caster, obj); - - obj.OnTelekinesis(Caster); - } - - FinishSequence(); - } - - public void Target(Container item) - { - if (CheckSequence()) - { - SpellHelper.Turn(Caster, item); - - object root = item.RootParent; - - if (!item.IsAccessibleTo(Caster)) + if (t != null) { - item.OnDoubleClickNotAccessible(Caster); + SpellHelper.Turn(Caster, t); + t.OnTelekinesis(Caster); } - else if (!item.CheckItemUse(Caster, item)) - { - } - else if (root is Mobile && root != Caster) - { - item.OnSnoop(Caster); - } - else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null)) - { - } - else if (Caster.Region.OnDoubleClick(Caster, item)) - { - Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), - 0x376A, 9, 32, 5022); - Effects.PlaySound(item.Location, item.Map, 0x1F5); - - item.OnItemUsed(Caster, item); - } - } - - FinishSequence(); - } - - public class InternalTarget : Target - { - private TelekinesisSpell m_Owner; - - public InternalTarget(TelekinesisSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is ITelekinesisable telekinesisable) - m_Owner.Target(telekinesisable); - else if (o is Container container) - m_Owner.Target(container); else - from.SendLocalizedMessage(501857); // This spell won't work on that! + { + SpellHelper.Turn(Caster, item); + + if (!item.IsAccessibleTo(Caster)) + { + item.OnDoubleClickNotAccessible(Caster); + } + else if (!item.CheckItemUse(Caster, item)) + { + } + else if (item.RootParent is Mobile && item.RootParent != Caster) + { + item.OnSnoop(Caster); + } + else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null)) + { + } + else if (Caster.Region.OnDoubleClick(Caster, item)) + { + Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), + 0x376A, 9, 32, 5022); + Effects.PlaySound(item.Location, item.Map, 0x1F5); + + item.OnItemUsed(Caster, item); + } + } } - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } + FinishSequence(); } } } @@ -104,4 +80,4 @@ namespace Server { void OnTelekinesis(Mobile from); } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/Teleport.cs b/Scripts/Spells/Third/Teleport.cs index dfa7f300a..6b2b8e212 100644 --- a/Scripts/Spells/Third/Teleport.cs +++ b/Scripts/Spells/Third/Teleport.cs @@ -9,7 +9,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class TeleportSpell : MagerySpell + public class TeleportSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Teleport", "Rel Por", @@ -19,7 +19,7 @@ namespace Server.Spells.Third Reagent.MandrakeRoot ); - public TeleportSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public TeleportSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -44,7 +44,7 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -118,26 +118,5 @@ namespace Server.Spells.Third FinishSequence(); } - - public class InternalTarget : Target - { - private TeleportSpell m_Owner; - - public InternalTarget(TeleportSpell owner) : base(Core.ML ? 11 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D p) - m_Owner.Target(p); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/Unlock.cs b/Scripts/Spells/Third/Unlock.cs index 51f8c8609..86350a80d 100644 --- a/Scripts/Spells/Third/Unlock.cs +++ b/Scripts/Spells/Third/Unlock.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class UnlockSpell : MagerySpell + public class UnlockSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Unlock Spell", "Ex Por", @@ -15,7 +15,7 @@ namespace Server.Spells.Third Reagent.SulfurousAsh ); - public UnlockSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public UnlockSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -23,85 +23,53 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } - private class InternalTarget : Target + public void Target(IPoint3D p) { - private UnlockSpell m_Owner; - - public InternalTarget(UnlockSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.None) + if (CheckSequence()) { - m_Owner = owner; - } + SpellHelper.Turn(Caster, p); - protected override void OnTarget(Mobile from, object o) - { - if (!(o is IPoint3D loc)) - return; + Effects.SendLocationParticles(EffectItem.Create(new Point3D(p), Caster.Map, EffectItem.DefaultDuration), + 0x376A, 9, 32, 5024); - if (m_Owner.CheckSequence()) + Effects.PlaySound(p, Caster.Map, 0x1FF); + + if (p is Mobile) + Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503101); // That did not need to be unlocked. + else if (!(p is LockableContainer cont)) + Caster.SendLocalizedMessage(501666); // You can't unlock that! + else { - SpellHelper.Turn(from, o); - - Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc), from.Map, EffectItem.DefaultDuration), - 0x376A, 9, 32, 5024); - - Effects.PlaySound(loc, from.Map, 0x1FF); - - if (o is Mobile) - { - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503101); // That did not need to be unlocked. - } - else if (!(o is LockableContainer)) - { - from.SendLocalizedMessage(501666); // You can't unlock that! - } + if (BaseHouse.CheckSecured(cont)) + Caster.SendLocalizedMessage(503098); // You cannot cast this on a secure item. + else if (!cont.Locked) + Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, + 503101); // That did not need to be unlocked. + else if (cont.LockLevel == 0) + Caster.SendLocalizedMessage(501666); // You can't unlock that! else { - LockableContainer cont = (LockableContainer)o; + int level = (int)(Caster.Skills.Magery.Value * 0.8) - 4; - if (BaseHouse.CheckSecured(cont)) + if (level >= cont.RequiredSkill && + !(cont is TreasureMapChest chest && chest.Level > 2)) { - from.SendLocalizedMessage(503098); // You cannot cast this on a secure item. - } - else if (!cont.Locked) - { - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, - 503101); // That did not need to be unlocked. - } - else if (cont.LockLevel == 0) - { - from.SendLocalizedMessage(501666); // You can't unlock that! + cont.Locked = false; + + if (cont.LockLevel == -255) + cont.LockLevel = cont.RequiredSkill - 10; } else - { - int level = (int)(from.Skills.Magery.Value * 0.8) - 4; - - if (level >= cont.RequiredSkill && - !(cont is TreasureMapChest chest && chest.Level > 2)) - { - cont.Locked = false; - - if (cont.LockLevel == -255) - cont.LockLevel = cont.RequiredSkill - 10; - } - else - { - from.LocalOverheadMessage(MessageType.Regular, 0x3B2, - 503099); // My spell does not seem to have an effect on that lock. - } - } + Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, + 503099); // My spell does not seem to have an effect on that lock. } } - - m_Owner.FinishSequence(); } - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } + FinishSequence(); } } -} \ No newline at end of file +} diff --git a/Scripts/Spells/Third/WallOfStone.cs b/Scripts/Spells/Third/WallOfStone.cs index d512f42aa..430a37b69 100644 --- a/Scripts/Spells/Third/WallOfStone.cs +++ b/Scripts/Spells/Third/WallOfStone.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.Spells.Third { - public class WallOfStoneSpell : MagerySpell + public class WallOfStoneSpell : MagerySpell, ISpellTargetingPoint3D { private static SpellInfo m_Info = new SpellInfo( "Wall of Stone", "In Sanct Ylem", @@ -16,7 +16,7 @@ namespace Server.Spells.Third Reagent.Garlic ); - public WallOfStoneSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info) + public WallOfStoneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } @@ -24,7 +24,7 @@ namespace Server.Spells.Third public override void OnCast() { - Caster.Target = new InternalTarget(this); + Caster.Target = new SpellTargetPoint3D(this, TargetFlags.None, Core.ML ? 10 : 12); } public void Target(IPoint3D p) @@ -189,26 +189,5 @@ namespace Server.Spells.Third } } } - - private class InternalTarget : Target - { - private WallOfStoneSpell m_Owner; - - public InternalTarget(WallOfStoneSpell owner) : base(Core.ML ? 10 : 12, true, TargetFlags.None) - { - m_Owner = owner; - } - - protected override void OnTarget(Mobile from, object o) - { - if (o is IPoint3D d) - m_Owner.Target(d); - } - - protected override void OnTargetFinish(Mobile from) - { - m_Owner.FinishSequence(); - } - } } -} \ No newline at end of file +} diff --git a/Server/Body.cs b/Server/Body.cs index a41e0c6b0..314ccc228 100644 --- a/Server/Body.cs +++ b/Server/Body.cs @@ -80,15 +80,7 @@ namespace Server BodyID = bodyID; } - public BodyType Type - { - get - { - if (BodyID >= 0 && BodyID < m_Types.Length) - return m_Types[BodyID]; - return BodyType.Empty; - } - } + public BodyType Type => BodyID >= 0 && BodyID < m_Types.Length ? m_Types[BodyID] : BodyType.Empty; public bool IsHuman => BodyID >= 0 && BodyID < m_Types.Length @@ -173,14 +165,12 @@ namespace Server public override int GetHashCode() { - return BodyID; + return BodyID.GetHashCode(); } public override bool Equals(object o) { - if (!(o is Body)) return false; - - return ((Body)o).BodyID == BodyID; + return o is Body b && b.BodyID == BodyID; } public static bool operator ==(Body l, Body r) @@ -213,4 +203,4 @@ namespace Server return l.BodyID <= r.BodyID; } } -} \ No newline at end of file +} diff --git a/Server/ClientVersion.cs b/Server/ClientVersion.cs index 0d4ee6ae2..738a4b502 100644 --- a/Server/ClientVersion.cs +++ b/Server/ClientVersion.cs @@ -19,7 +19,7 @@ ***************************************************************************/ using System; -using System.Collections; +using System.Collections.Generic; using System.Text; namespace Server @@ -32,13 +32,9 @@ namespace Server SA } - public class ClientVersion : IComparable, IComparer + public class ClientVersion : IComparable, IComparer { - public ClientVersion(int maj, int min, int rev, int pat) : this(maj, min, rev, pat, ClientType.Regular) - { - } - - public ClientVersion(int maj, int min, int rev, int pat, ClientType type) + public ClientVersion(int maj, int min, int rev, int pat, ClientType type = ClientType.Regular) { Major = maj; Minor = min; @@ -111,15 +107,10 @@ namespace Server public string SourceString{ get; } - public int CompareTo(object obj) + public int CompareTo(ClientVersion o) { - if (obj == null) - return 1; - - ClientVersion o = obj as ClientVersion; - if (o == null) - throw new ArgumentException(); + return 1; if (Major > o.Major) return 1; @@ -140,24 +131,6 @@ namespace Server return 0; } - public int Compare(object x, object y) - { - if (IsNull(x) && IsNull(y)) - return 0; - if (IsNull(x)) - return -1; - if (IsNull(y)) - return 1; - - ClientVersion a = x as ClientVersion; - ClientVersion b = y as ClientVersion; - - if (IsNull(a) || IsNull(b)) - throw new ArgumentException(); - - return a.CompareTo(b); - } - public static bool operator ==(ClientVersion l, ClientVersion r) { return Compare(l, r) == 0; @@ -193,17 +166,16 @@ namespace Server return Major ^ Minor ^ Revision ^ Patch ^ (int)Type; } + int IComparer.Compare(ClientVersion x, ClientVersion y) + { + return Compare(x, y); + } + public override bool Equals(object obj) { - if (obj == null) - return false; - ClientVersion v = obj as ClientVersion; - if (v == null) - return false; - - return Major == v.Major + return Major == v?.Major && Minor == v.Minor && Revision == v.Revision && Patch == v.Patch @@ -262,4 +234,4 @@ namespace Server return a.CompareTo(b); } } -} \ No newline at end of file +} diff --git a/Server/Commands.cs b/Server/Commands.cs index e20cee97c..933cf7d86 100644 --- a/Server/Commands.cs +++ b/Server/Commands.cs @@ -95,7 +95,7 @@ namespace Server.Commands } } - public class CommandEntry : IComparable + public class CommandEntry : IComparable { public CommandEntry(string command, CommandEventHandler handler, AccessLevel accessLevel) { @@ -110,17 +110,9 @@ namespace Server.Commands public AccessLevel AccessLevel{ get; } - public int CompareTo(object obj) + public int CompareTo(CommandEntry e) { - if (obj == this) - return 0; - if (obj == null) - return 1; - - if (!(obj is CommandEntry e)) - throw new ArgumentException(); - - return Command.CompareTo(e.Command); + return e == null ? 1 : Command.CompareTo(e.Command); } } @@ -219,29 +211,29 @@ namespace Server.Commands if (entry != null) { - if (@from.AccessLevel >= entry.AccessLevel) + if (from.AccessLevel >= entry.AccessLevel) { if (entry.Handler != null) { - CommandEventArgs e = new CommandEventArgs(@from, command, argString, args); + CommandEventArgs e = new CommandEventArgs(from, command, argString, args); entry.Handler(e); EventSink.InvokeCommand(e); } } else { - if (@from.AccessLevel <= BadCommandIgnoreLevel) + if (from.AccessLevel <= BadCommandIgnoreLevel) return false; - @from.SendMessage("You do not have access to that command."); + from.SendMessage("You do not have access to that command."); } } else { - if (@from.AccessLevel <= BadCommandIgnoreLevel) + if (from.AccessLevel <= BadCommandIgnoreLevel) return false; - @from.SendMessage("That is not a valid command."); + from.SendMessage("That is not a valid command."); } return true; diff --git a/Server/ContextMenus/ContextMenu.cs b/Server/ContextMenus/ContextMenu.cs index 5f3ac4fd2..2918ae94f 100644 --- a/Server/ContextMenus/ContextMenu.cs +++ b/Server/ContextMenus/ContextMenu.cs @@ -49,13 +49,15 @@ namespace Server.ContextMenus if (target is Mobile mobile) mobile.GetContextMenuEntries(from, list); - else if (target is Item item) item.GetContextMenuEntries(from, list); + else if (target is Item item) + item.GetContextMenuEntries(from, list); //m_Entries = (ContextMenuEntry[])list.ToArray( typeof( ContextMenuEntry ) ); Entries = list.ToArray(); - for (int i = 0; i < Entries.Length; ++i) Entries[i].Owner = this; + for (int i = 0; i < Entries.Length; ++i) + Entries[i].Owner = this; } /// @@ -88,4 +90,4 @@ namespace Server.ContextMenus } } } -} \ No newline at end of file +} diff --git a/Server/ContextMenus/ContextMenuEntry.cs b/Server/ContextMenus/ContextMenuEntry.cs index 675576fa6..e482f98f9 100644 --- a/Server/ContextMenus/ContextMenuEntry.cs +++ b/Server/ContextMenus/ContextMenuEntry.cs @@ -28,18 +28,6 @@ namespace Server.ContextMenus /// public class ContextMenuEntry { - /// - /// Instantiates a new ContextMenuEntry with a given localization number ( - /// ). No maximum range is used. - /// - /// - /// The localization number containing the name of this entry. - /// - /// - public ContextMenuEntry(int number) : this(number, -1) - { - } - /// /// Instantiates a new ContextMenuEntry with a given localization number () /// and maximum range (). @@ -52,7 +40,7 @@ namespace Server.ContextMenus /// The maximum range at which this entry can be used. /// /// - public ContextMenuEntry(int number, int range) + public ContextMenuEntry(int number, int range = -1) { if (number <= 0x7FFF) // Legacy code support Number = 3000000 + number; diff --git a/Server/Geometry.cs b/Server/Geometry.cs index 3af3ef7d5..286ad4b74 100644 --- a/Server/Geometry.cs +++ b/Server/Geometry.cs @@ -23,7 +23,7 @@ using System; namespace Server { [Parsable] - public struct Point2D : IPoint2D, IComparable, IComparable + public struct Point2D : IPoint2D, IComparable { internal int m_X; internal int m_Y; @@ -84,23 +84,9 @@ namespace Server return v; } - public int CompareTo(object other) - { - if (other is Point2D d) - return CompareTo(d); - if (other == null) - return -1; - - throw new ArgumentException(); - } - public override bool Equals(object o) { - if (!(o is IPoint2D)) return false; - - IPoint2D p = (IPoint2D)o; - - return m_X == p.X && m_Y == p.Y; + return o is IPoint2D p && m_X == p.X && m_Y == p.Y; } public override int GetHashCode() @@ -120,18 +106,12 @@ namespace Server public static bool operator ==(Point2D l, IPoint2D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X == r.X && l.m_Y == r.Y; + return !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y; } public static bool operator !=(Point2D l, IPoint2D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X != r.X || l.m_Y != r.Y; + return !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y); } public static bool operator >(Point2D l, Point2D r) @@ -146,10 +126,7 @@ namespace Server public static bool operator >(Point2D l, IPoint2D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X > r.X && l.m_Y > r.Y; + return !ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y; } public static bool operator <(Point2D l, Point2D r) @@ -164,10 +141,7 @@ namespace Server public static bool operator <(Point2D l, IPoint2D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X < r.X && l.m_Y < r.Y; + return !ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y; } public static bool operator >=(Point2D l, Point2D r) @@ -182,10 +156,7 @@ namespace Server public static bool operator >=(Point2D l, IPoint2D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X >= r.X && l.m_Y >= r.Y; + return !ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y; } public static bool operator <=(Point2D l, Point2D r) @@ -200,15 +171,12 @@ namespace Server public static bool operator <=(Point2D l, IPoint2D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X <= r.X && l.m_Y <= r.Y; + return !ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y; } } [Parsable] - public struct Point3D : IPoint3D, IComparable, IComparable + public struct Point3D : IPoint3D, IComparable { internal int m_X; internal int m_Y; @@ -261,12 +229,7 @@ namespace Server public override bool Equals(object o) { - if (!(o is IPoint3D)) - return false; - - IPoint3D p = (IPoint3D)o; - - return m_X == p.X && m_Y == p.Y && m_Z == p.Z; + return o is IPoint3D p && m_X == p.X && m_Y == p.Y && m_Z == p.Z; } public override int GetHashCode() @@ -306,18 +269,12 @@ namespace Server public static bool operator ==(Point3D l, IPoint3D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z; + return !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z; } public static bool operator !=(Point3D l, IPoint3D r) { - if (ReferenceEquals(r, null)) - return false; - - return l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z; + return !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z); } public int CompareTo(Point3D other) @@ -334,16 +291,6 @@ namespace Server return v; } - - public int CompareTo(object other) - { - if (other is Point3D d) - return CompareTo(d); - if (other == null) - return -1; - - throw new ArgumentException(); - } } [NoSort] @@ -529,4 +476,4 @@ namespace Server && p.Z < End.m_Z; } } -} \ No newline at end of file +} diff --git a/Server/Gumps/Gump.cs b/Server/Gumps/Gump.cs index 57d044282..5b04c891c 100644 --- a/Server/Gumps/Gump.cs +++ b/Server/Gumps/Gump.cs @@ -185,7 +185,8 @@ namespace Server.Gumps Add(new GumpBackground(x, y, width, height, gumpID)); } - public void AddButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param) + public void AddButton(int x, int y, int normalID, int pressedID, int buttonID, + GumpButtonType type = GumpButtonType.Reply, int param = 0) { Add(new GumpButton(x, y, normalID, pressedID, buttonID, type, param)); } @@ -205,34 +206,29 @@ namespace Server.Gumps Add(new GumpTooltip(number)); } - public void AddHtml(int x, int y, int width, int height, string text, bool background, bool scrollbar) + public void AddHtml(int x, int y, int width, int height, string text, bool background = false, bool scrollbar = false) { Add(new GumpHtml(x, y, width, height, text, background, scrollbar)); } - public void AddHtmlLocalized(int x, int y, int width, int height, int number, bool background, bool scrollbar) + public void AddHtmlLocalized(int x, int y, int width, int height, int number, bool background = false, bool scrollbar = false) { Add(new GumpHtmlLocalized(x, y, width, height, number, background, scrollbar)); } - public void AddHtmlLocalized(int x, int y, int width, int height, int number, int color, bool background, - bool scrollbar) + public void AddHtmlLocalized(int x, int y, int width, int height, int number, int color, bool background = false, + bool scrollbar = false) { Add(new GumpHtmlLocalized(x, y, width, height, number, color, background, scrollbar)); } public void AddHtmlLocalized(int x, int y, int width, int height, int number, string args, int color, - bool background, bool scrollbar) + bool background = false, bool scrollbar = false) { Add(new GumpHtmlLocalized(x, y, width, height, number, args, color, background, scrollbar)); } - public void AddImage(int x, int y, int gumpID) - { - Add(new GumpImage(x, y, gumpID)); - } - - public void AddImage(int x, int y, int gumpID, int hue) + public void AddImage(int x, int y, int gumpID, int hue = 0) { Add(new GumpImage(x, y, gumpID, hue)); } @@ -243,24 +239,13 @@ namespace Server.Gumps } public void AddImageTiledButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, - int param, int itemID, int hue, int width, int height) - { - Add(new GumpImageTileButton(x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height)); - } - - public void AddImageTiledButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, - int param, int itemID, int hue, int width, int height, int localizedTooltip) + int param, int itemID, int hue, int width, int height, int localizedTooltip = -1) { Add(new GumpImageTileButton(x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height, localizedTooltip)); } - public void AddItem(int x, int y, int itemID) - { - Add(new GumpItem(x, y, itemID)); - } - - public void AddItem(int x, int y, int itemID, int hue) + public void AddItem(int x, int y, int itemID, int hue = 0) { Add(new GumpItem(x, y, itemID, hue)); } @@ -280,12 +265,7 @@ namespace Server.Gumps Add(new GumpRadio(x, y, inactiveID, activeID, initialState, switchID)); } - public void AddTextEntry(int x, int y, int width, int height, int hue, int entryID, string initialText) - { - Add(new GumpTextEntry(x, y, width, height, hue, entryID, initialText)); - } - - public void AddTextEntry(int x, int y, int width, int height, int hue, int entryID, string initialText, int size) + public void AddTextEntry(int x, int y, int width, int height, int hue, int entryID, string initialText, int size = 0) { Add(new GumpTextEntryLimited(x, y, width, height, hue, entryID, initialText, size)); } @@ -390,4 +370,4 @@ namespace Server.Gumps { } } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpButton.cs b/Server/Gumps/GumpButton.cs index a3a884d24..5ae85d512 100644 --- a/Server/Gumps/GumpButton.cs +++ b/Server/Gumps/GumpButton.cs @@ -37,7 +37,8 @@ namespace Server.Gumps private GumpButtonType m_Type; private int m_X, m_Y; - public GumpButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param) + public GumpButton(int x, int y, int normalID, int pressedID, int buttonID, + GumpButtonType type = GumpButtonType.Reply, int param = 0) { m_X = x; m_Y = y; @@ -117,4 +118,4 @@ namespace Server.Gumps disp.AppendLayout(m_ButtonID); } } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpEntry.cs b/Server/Gumps/GumpEntry.cs index 6ae7604c3..732125b15 100644 --- a/Server/Gumps/GumpEntry.cs +++ b/Server/Gumps/GumpEntry.cs @@ -41,33 +41,38 @@ namespace Server.Gumps } } } - + protected void Delta(ref uint var, uint val) { - if (var != val) var = val; + if (var != val) + var = val; } protected void Delta(ref int var, int val) { - if (var != val) var = val; + if (var != val) + var = val; } protected void Delta(ref bool var, bool val) { - if (var != val) var = val; + if (var != val) + var = val; } protected void Delta(ref string var, string val) { - if (var != val) var = val; + if (var != val) + var = val; } protected void Delta(ref object[] var, object[] val) { - if (var != val) var = val; + if (var != val) + var = val; } public abstract string Compile(NetState ns); public abstract void AppendTo(NetState ns, IGumpWriter disp); } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpHtmlLocalized.cs b/Server/Gumps/GumpHtmlLocalized.cs index 928878bae..a28668e4b 100644 --- a/Server/Gumps/GumpHtmlLocalized.cs +++ b/Server/Gumps/GumpHtmlLocalized.cs @@ -43,7 +43,8 @@ namespace Server.Gumps private int m_Width, m_Height; private int m_X, m_Y; - public GumpHtmlLocalized(int x, int y, int width, int height, int number, bool background, bool scrollbar) + public GumpHtmlLocalized(int x, int y, int width, int height, int number, + bool background = false, bool scrollbar = false) { m_X = x; m_Y = y; @@ -56,7 +57,8 @@ namespace Server.Gumps m_Type = GumpHtmlLocalizedType.Plain; } - public GumpHtmlLocalized(int x, int y, int width, int height, int number, int color, bool background, bool scrollbar) + public GumpHtmlLocalized(int x, int y, int width, int height, int number, int color, + bool background = false, bool scrollbar = false) { m_X = x; m_Y = y; @@ -70,8 +72,8 @@ namespace Server.Gumps m_Type = GumpHtmlLocalizedType.Color; } - public GumpHtmlLocalized(int x, int y, int width, int height, int number, string args, int color, bool background, - bool scrollbar) + public GumpHtmlLocalized(int x, int y, int width, int height, int number, string args, int color, + bool background = false, bool scrollbar = false) { // Are multiple arguments unsupported? And what about non ASCII arguments? @@ -228,4 +230,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpImage.cs b/Server/Gumps/GumpImage.cs index 3b64e634b..26c70cfb9 100644 --- a/Server/Gumps/GumpImage.cs +++ b/Server/Gumps/GumpImage.cs @@ -30,11 +30,7 @@ namespace Server.Gumps private int m_Hue; private int m_X, m_Y; - public GumpImage(int x, int y, int gumpID) : this(x, y, gumpID, 0) - { - } - - public GumpImage(int x, int y, int gumpID, int hue) + public GumpImage(int x, int y, int gumpID, int hue = 0) { m_X = x; m_Y = y; @@ -68,9 +64,8 @@ namespace Server.Gumps public override string Compile(NetState ns) { - if (m_Hue == 0) - return $"{{ gumppic {m_X} {m_Y} {m_GumpID} }}"; - return $"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}"; + return m_Hue == 0 ? $"{{ gumppic {m_X} {m_Y} {m_GumpID} }}" : + $"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}"; } public override void AppendTo(NetState ns, IGumpWriter disp) @@ -87,4 +82,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpImageTileButton.cs b/Server/Gumps/GumpImageTileButton.cs index 481731b04..a7fcfc4c0 100644 --- a/Server/Gumps/GumpImageTileButton.cs +++ b/Server/Gumps/GumpImageTileButton.cs @@ -41,13 +41,7 @@ namespace Server.Gumps private int m_X, m_Y; public GumpImageTileButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param, - int itemID, int hue, int width, int height) : this(x, y, normalID, pressedID, buttonID, type, param, itemID, hue, - width, height, -1) - { - } - - public GumpImageTileButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param, - int itemID, int hue, int width, int height, int localizedTooltip) + int itemID, int hue, int width, int height, int localizedTooltip = -1) { m_X = x; m_Y = y; @@ -175,4 +169,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpItem.cs b/Server/Gumps/GumpItem.cs index f365df2be..05c4f32d4 100644 --- a/Server/Gumps/GumpItem.cs +++ b/Server/Gumps/GumpItem.cs @@ -30,11 +30,7 @@ namespace Server.Gumps private int m_ItemID; private int m_X, m_Y; - public GumpItem(int x, int y, int itemID) : this(x, y, itemID, 0) - { - } - - public GumpItem(int x, int y, int itemID, int hue) + public GumpItem(int x, int y, int itemID, int hue = 0) { m_X = x; m_Y = y; @@ -68,9 +64,8 @@ namespace Server.Gumps public override string Compile(NetState ns) { - if (m_Hue == 0) - return $"{{ tilepic {m_X} {m_Y} {m_ItemID} }}"; - return $"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}"; + return m_Hue == 0 ? $"{{ tilepic {m_X} {m_Y} {m_ItemID} }}" : + $"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}"; } public override void AppendTo(NetState ns, IGumpWriter disp) @@ -84,4 +79,4 @@ namespace Server.Gumps disp.AppendLayout(m_Hue); } } -} \ No newline at end of file +} diff --git a/Server/Gumps/GumpTextEntryLimited.cs b/Server/Gumps/GumpTextEntryLimited.cs index 502dcf616..5fc346b41 100644 --- a/Server/Gumps/GumpTextEntryLimited.cs +++ b/Server/Gumps/GumpTextEntryLimited.cs @@ -32,7 +32,7 @@ namespace Server.Gumps private int m_Width, m_Height; private int m_X, m_Y; - public GumpTextEntryLimited(int x, int y, int width, int height, int hue, int entryID, string initialText, int size) + public GumpTextEntryLimited(int x, int y, int width, int height, int hue, int entryID, string initialText, int size = 0) { m_X = x; m_Y = y; @@ -113,4 +113,4 @@ namespace Server.Gumps disp.TextEntries++; } } -} \ No newline at end of file +} diff --git a/Server/IEntity.cs b/Server/IEntity.cs index 1661ee785..09f807249 100644 --- a/Server/IEntity.cs +++ b/Server/IEntity.cs @@ -22,7 +22,7 @@ using System; namespace Server { - public interface IEntity : IPoint3D, IComparable, IComparable + public interface IEntity : IPoint3D, IComparable { Serial Serial{ get; } Point3D Location{ get; } @@ -51,18 +51,7 @@ namespace Server public int CompareTo(IEntity other) { - if (other == null) - return -1; - - return Serial.CompareTo(other.Serial); - } - - public int CompareTo(object other) - { - if (other == null || other is IEntity) - return CompareTo((IEntity)other); - - throw new ArgumentException(); + return other == null ? -1 : Serial.CompareTo(other.Serial); } public Serial Serial{ get; } @@ -93,4 +82,4 @@ namespace Server { } } -} \ No newline at end of file +} diff --git a/Server/Insensitive.cs b/Server/Insensitive.cs index 164c758a5..affe68f78 100644 --- a/Server/Insensitive.cs +++ b/Server/Insensitive.cs @@ -18,13 +18,14 @@ * ***************************************************************************/ -using System.Collections; +using System; +using System.Collections.Generic; namespace Server { public static class Insensitive { - public static IComparer Comparer{ get; } = CaseInsensitiveComparer.Default; + public static IComparer Comparer{ get; } = StringComparer.OrdinalIgnoreCase; public static int Compare(string a, string b) { @@ -68,4 +69,4 @@ namespace Server return a.IndexOf(b) >= 0; } } -} \ No newline at end of file +} diff --git a/Server/Interfaces.cs b/Server/Interfaces.cs index 24a855285..7a7f370a0 100644 --- a/Server/Interfaces.cs +++ b/Server/Interfaces.cs @@ -84,8 +84,9 @@ namespace Server void OnConnectionChanged(); bool OnCasterMoving(Direction d); bool OnCasterEquipping(Item item); - bool OnCasterUsingObject(object o); + bool OnCasterUsingObject(IEntity entity); bool OnCastInTown(Region r); + void FinishSequence(); } public interface IParty @@ -111,4 +112,4 @@ namespace Server void OnBeforeSpawn(Point3D location, Map map); void OnAfterSpawn(); } -} \ No newline at end of file +} diff --git a/Server/Item.cs b/Server/Item.cs index 6e4b02a86..48a0b7412 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Threading.Tasks; using Server.ContextMenus; using Server.Items; @@ -30,177 +31,6 @@ using Server.Targeting; namespace Server { - /// - /// Enumeration of item layer values. - /// - public enum Layer : byte - { - /// - /// Invalid layer. - /// - Invalid = 0x00, - - /// - /// First valid layer. Equivalent to Layer.OneHanded. - /// - FirstValid = 0x01, - - /// - /// One handed weapon. - /// - OneHanded = 0x01, - - /// - /// Two handed weapon or shield. - /// - TwoHanded = 0x02, - - /// - /// Shoes. - /// - Shoes = 0x03, - - /// - /// Pants. - /// - Pants = 0x04, - - /// - /// Shirts. - /// - Shirt = 0x05, - - /// - /// Helmets, hats, and masks. - /// - Helm = 0x06, - - /// - /// Gloves. - /// - Gloves = 0x07, - - /// - /// Rings. - /// - Ring = 0x08, - - /// - /// Talismans. - /// - Talisman = 0x09, - - /// - /// Gorgets and necklaces. - /// - Neck = 0x0A, - - /// - /// Hair. - /// - Hair = 0x0B, - - /// - /// Half aprons. - /// - Waist = 0x0C, - - /// - /// Torso, inner layer. - /// - InnerTorso = 0x0D, - - /// - /// Bracelets. - /// - Bracelet = 0x0E, - - /// - /// Unused. - /// - Unused_xF = 0x0F, - - /// - /// Beards and mustaches. - /// - FacialHair = 0x10, - - /// - /// Torso, outer layer. - /// - MiddleTorso = 0x11, - - /// - /// Earings. - /// - Earrings = 0x12, - - /// - /// Arms and sleeves. - /// - Arms = 0x13, - - /// - /// Cloaks. - /// - Cloak = 0x14, - - /// - /// Backpacks. - /// - Backpack = 0x15, - - /// - /// Torso, outer layer. - /// - OuterTorso = 0x16, - - /// - /// Leggings, outer layer. - /// - OuterLegs = 0x17, - - /// - /// Leggings, inner layer. - /// - InnerLegs = 0x18, - - /// - /// Last valid non-internal layer. Equivalent to Layer.InnerLegs. - /// - LastUserValid = 0x18, - - /// - /// Mount item layer. - /// - Mount = 0x19, - - /// - /// Vendor 'buy pack' layer. - /// - ShopBuy = 0x1A, - - /// - /// Vendor 'resale pack' layer. - /// - ShopResale = 0x1B, - - /// - /// Vendor 'sell pack' layer. - /// - ShopSell = 0x1C, - - /// - /// Bank box layer. - /// - Bank = 0x1D, - - /// - /// Last valid layer. Equivalent to Layer.Bank. - /// - LastValid = 0x1D - } - /// /// Internal flags used to signal how the item should be updated and resent to nearby clients. /// @@ -249,295 +79,6 @@ namespace Server MoveToBackpack } - /// - /// Enumeration containing all possible light types. These are only applicable to light source items, like lanterns, candles, - /// braziers, etc. - /// - public enum LightType - { - /// - /// Window shape, arched, ray shining east. - /// - ArchedWindowEast, - - /// - /// Medium circular shape. - /// - Circle225, - - /// - /// Small circular shape. - /// - Circle150, - - /// - /// Door shape, shining south. - /// - DoorSouth, - - /// - /// Door shape, shining east. - /// - DoorEast, - - /// - /// Large semicircular shape (180 degrees), north wall. - /// - NorthBig, - - /// - /// Large pie shape (90 degrees), north-east corner. - /// - NorthEastBig, - - /// - /// Large semicircular shape (180 degrees), east wall. - /// - EastBig, - - /// - /// Large semicircular shape (180 degrees), west wall. - /// - WestBig, - - /// - /// Large pie shape (90 degrees), south-west corner. - /// - SouthWestBig, - - /// - /// Large semicircular shape (180 degrees), south wall. - /// - SouthBig, - - /// - /// Medium semicircular shape (180 degrees), north wall. - /// - NorthSmall, - - /// - /// Medium pie shape (90 degrees), north-east corner. - /// - NorthEastSmall, - - /// - /// Medium semicircular shape (180 degrees), east wall. - /// - EastSmall, - - /// - /// Medium semicircular shape (180 degrees), west wall. - /// - WestSmall, - - /// - /// Medium semicircular shape (180 degrees), south wall. - /// - SouthSmall, - - /// - /// Shaped like a wall decoration, north wall. - /// - DecorationNorth, - - /// - /// Shaped like a wall decoration, north-east corner. - /// - DecorationNorthEast, - - /// - /// Small semicircular shape (180 degrees), east wall. - /// - EastTiny, - - /// - /// Shaped like a wall decoration, west wall. - /// - DecorationWest, - - /// - /// Shaped like a wall decoration, south-west corner. - /// - DecorationSouthWest, - - /// - /// Small semicircular shape (180 degrees), south wall. - /// - SouthTiny, - - /// - /// Window shape, rectangular, no ray, shining south. - /// - RectWindowSouthNoRay, - - /// - /// Window shape, rectangular, no ray, shining east. - /// - RectWindowEastNoRay, - - /// - /// Window shape, rectangular, ray shining south. - /// - RectWindowSouth, - - /// - /// Window shape, rectangular, ray shining east. - /// - RectWindowEast, - - /// - /// Window shape, arched, no ray, shining south. - /// - ArchedWindowSouthNoRay, - - /// - /// Window shape, arched, no ray, shining east. - /// - ArchedWindowEastNoRay, - - /// - /// Window shape, arched, ray shining south. - /// - ArchedWindowSouth, - - /// - /// Large circular shape. - /// - Circle300, - - /// - /// Large pie shape (90 degrees), north-west corner. - /// - NorthWestBig, - - /// - /// Negative light. Medium pie shape (90 degrees), south-east corner. - /// - DarkSouthEast, - - /// - /// Negative light. Medium semicircular shape (180 degrees), south wall. - /// - DarkSouth, - - /// - /// Negative light. Medium pie shape (90 degrees), north-west corner. - /// - DarkNorthWest, - - /// - /// Negative light. Medium pie shape (90 degrees), south-east corner. Equivalent to LightType.SouthEast. - /// - DarkSouthEast2, - - /// - /// Negative light. Medium circular shape (180 degrees), east wall. - /// - DarkEast, - - /// - /// Negative light. Large circular shape. - /// - DarkCircle300, - - /// - /// Opened door shape, shining south. - /// - DoorOpenSouth, - - /// - /// Opened door shape, shining east. - /// - DoorOpenEast, - - /// - /// Window shape, square, ray shining east. - /// - SquareWindowEast, - - /// - /// Window shape, square, no ray, shining east. - /// - SquareWindowEastNoRay, - - /// - /// Window shape, square, ray shining south. - /// - SquareWindowSouth, - - /// - /// Window shape, square, no ray, shining south. - /// - SquareWindowSouthNoRay, - - /// - /// Empty. - /// - Empty, - - /// - /// Window shape, skinny, no ray, shining south. - /// - SkinnyWindowSouthNoRay, - - /// - /// Window shape, skinny, ray shining east. - /// - SkinnyWindowEast, - - /// - /// Window shape, skinny, no ray, shining east. - /// - SkinnyWindowEastNoRay, - - /// - /// Shaped like a hole, shining south. - /// - HoleSouth, - - /// - /// Shaped like a hole, shining south. - /// - HoleEast, - - /// - /// Large circular shape with a moongate graphic embeded. - /// - Moongate, - - /// - /// Unknown usage. Many rows of slightly angled lines. - /// - Strips, - - /// - /// Shaped like a small hole, shining south. - /// - SmallHoleSouth, - - /// - /// Shaped like a small hole, shining east. - /// - SmallHoleEast, - - /// - /// Large semicircular shape (180 degrees), north wall. Identical graphic as LightType.NorthBig, but slightly different - /// positioning. - /// - NorthBig2, - - /// - /// Large semicircular shape (180 degrees), west wall. Identical graphic as LightType.WestBig, but slightly different - /// positioning. - /// - WestBig2, - - /// - /// Large pie shape (90 degrees), north-west corner. Equivalent to LightType.NorthWestBig. - /// - NorthWestBig2 - } - /// /// Enumeration of an item's loot and steal state. /// @@ -658,7 +199,7 @@ namespace Server Spawner = 0x100 } - public class Item : IHued, IComparable, ISerializable, ISpawnable + public class Item : IHued, IComparable, ISerializable, ISpawnable, IPropertyListObject { public const int QuestItemHue = 0x4EA; // Hmmmm... "for EA"? public static readonly List EmptyItems = new List(); @@ -669,14 +210,6 @@ namespace Server private static int m_OpenSlots; - private object _opll = new object(); - - private object _rpl = new object(); - - private object _wpl = new object(); - private object _wplhs = new object(); - private object _wplsa = new object(); - private CompactInfo m_CompactInfo; private ItemDelta m_DeltaFlags; @@ -684,8 +217,10 @@ namespace Server internal int m_TypeRef; - public Item() + [Constructible] + public Item(int itemID = 0) { + m_ItemID = itemID; Serial = Serial.NewItem; //m_Items = new ArrayList( 1 ); @@ -708,12 +243,6 @@ namespace Server } } - [Constructible] - public Item(int itemID) : this() - { - m_ItemID = itemID; - } - public Item(Serial serial) { Serial = serial; @@ -811,138 +340,20 @@ namespace Server set => SetFlag(ImplFlag.Stackable, value); } - public Packet RemovePacket - { - get - { - if (m_RemovePacket == null) - lock (_rpl) - { - if (m_RemovePacket == null) - { - m_RemovePacket = new RemoveItem(this); - m_RemovePacket.SetStatic(); - } - } + public Packet RemovePacket => StaticPacketHandlers.GetRemoveEntityPacket(this); + public OPLInfo OPLPacket => StaticPacketHandlers.GetOPLInfoPacket(this); + public ObjectPropertyList PropertyList => StaticPacketHandlers.GetOPLPacket(this); - return m_RemovePacket; - } - } - - public Packet OPLPacket - { - get - { - if (m_OPLPacket == null) - lock (_opll) - { - if (m_OPLPacket == null) - { - m_OPLPacket = new OPLInfo(PropertyList); - m_OPLPacket.SetStatic(); - } - } - - return m_OPLPacket; - } - } - - public ObjectPropertyList PropertyList - { - get - { - if (m_PropertyList == null) - { - m_PropertyList = new ObjectPropertyList(this); - - GetProperties(m_PropertyList); - AppendChildProperties(m_PropertyList); - - m_PropertyList.Terminate(); - m_PropertyList.SetStatic(); - } - - return m_PropertyList; - } - } - - public Packet WorldPacket - { - get - { - // This needs to be invalidated when any of the following changes: - // - ItemID - // - Amount - // - Location - // - Hue - // - Packet Flags - // - Direction - - if (m_WorldPacket == null) - lock (_wpl) - { - if (m_WorldPacket == null) - { - m_WorldPacket = new WorldItem(this); - m_WorldPacket.SetStatic(); - } - } - - return m_WorldPacket; - } - } - - public Packet WorldPacketSA - { - get - { - // This needs to be invalidated when any of the following changes: - // - ItemID - // - Amount - // - Location - // - Hue - // - Packet Flags - // - Direction - - if (m_WorldPacketSA == null) - lock (_wplsa) - { - if (m_WorldPacketSA == null) - { - m_WorldPacketSA = new WorldItemSA(this); - m_WorldPacketSA.SetStatic(); - } - } - - return m_WorldPacketSA; - } - } - - public Packet WorldPacketHS - { - get - { - // This needs to be invalidated when any of the following changes: - // - ItemID - // - Amount - // - Location - // - Hue - // - Packet Flags - // - Direction - - if (m_WorldPacketHS == null) - lock (_wplhs) - { - if (m_WorldPacketHS == null) - { - m_WorldPacketHS = new WorldItemHS(this); - m_WorldPacketHS.SetStatic(); - } - } - - return m_WorldPacketHS; - } - } + // World packets need to be invalidated when any of the following changes: + // - ItemID + // - Amount + // - Location + // - Hue + // - Packet Flags + // - Direction + public Packet WorldPacket => StaticPacketHandlers.GetWorldItemPacket(this); + public Packet WorldPacketSA => StaticPacketHandlers.GetWorldItemSAPacket(this); + public Packet WorldPacketHS => StaticPacketHandlers.GetWorldItemHSPacket(this); [CommandProperty(AccessLevel.GameMaster)] public bool Visible @@ -965,7 +376,8 @@ namespace Server { Mobile m = state.Mobile; - if (!m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) state.Send(RemovePacket); + if (!m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) + state.Send(RemovePacket); } eable.Free(); @@ -1134,10 +546,8 @@ namespace Server { IEntity p = m_Parent; - while (p is Item) + while (p is Item item) { - Item item = (Item)p; - if (item.m_Parent == null) break; p = item.m_Parent; @@ -1349,25 +759,14 @@ namespace Server } } + int IComparable.CompareTo(IEntity other) + { + return other == null ? -1 : Serial.CompareTo(other.Serial); + } + public int CompareTo(Item other) { - return CompareTo((IEntity)other); - } - - public int CompareTo(IEntity other) - { - if (other == null) - return -1; - - return Serial.CompareTo(other.Serial); - } - - public int CompareTo(object other) - { - if (other == null || other is IEntity) - return CompareTo((IEntity)other); - - throw new ArgumentException(); + return other == null ? -1 : Serial.CompareTo(other.Serial); } /// @@ -1538,7 +937,7 @@ namespace Server } } - public void ProcessDelta() + public virtual void ProcessDelta() { ItemDelta flags = m_DeltaFlags; @@ -1547,220 +946,159 @@ namespace Server Map map = m_Map; - if (map != null && !Deleted) + if (map == null || Deleted) + return; + + Point3D worldLoc = GetWorldLocation(); + bool update = (flags & ItemDelta.Update) != 0; + + if (update && m_Parent is Container contParent && !contParent.IsPublicContainer) { - bool sendOPLUpdate = ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0; + Mobile rootParent = contParent.RootParent as Mobile; + Mobile tradeRecip = null; - if (m_Parent is Container contParent && !contParent.IsPublicContainer) - if ((flags & ItemDelta.Update) != 0) - { - Point3D worldLoc = GetWorldLocation(); - - Mobile rootParent = contParent.RootParent as Mobile; - Mobile tradeRecip = null; - - if (rootParent != null) - { - NetState ns = rootParent.NetState; - - if (ns != null) - if (rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent))) - { - if (ns.ContainerGridLines) - ns.Send(new ContainerContentUpdate6017(this)); - else - ns.Send(new ContainerContentUpdate(this)); - - if (ObjectPropertyList.Enabled) - ns.Send(OPLPacket); - } - } - - SecureTradeContainer stc = GetSecureTradeCont(); - - SecureTrade st = stc?.Trade; - - if (st != null) - { - Mobile test = st.From.Mobile; - - if (test != null && test != rootParent) - tradeRecip = test; - - test = st.To.Mobile; - - if (test != null && test != rootParent) - tradeRecip = test; - - NetState ns = tradeRecip?.NetState; - - if (ns != null) - if (tradeRecip.CanSee(this) && tradeRecip.InRange(worldLoc, GetUpdateRange(tradeRecip))) - { - if (ns.ContainerGridLines) - ns.Send(new ContainerContentUpdate6017(this)); - else - ns.Send(new ContainerContentUpdate(this)); - - if (ObjectPropertyList.Enabled) - ns.Send(OPLPacket); - } - } - - List openers = contParent.Openers; - - if (openers != null) - lock (openers) - { - for (int i = 0; i < openers.Count; ++i) - { - Mobile mob = openers[i]; - - int range = GetUpdateRange(mob); - - if (mob.Map != map || !mob.InRange(worldLoc, range)) - { - openers.RemoveAt(i--); - } - else - { - if (mob == rootParent || mob == tradeRecip) - continue; - - NetState ns = mob.NetState; - - if (ns != null) - if (mob.CanSee(this)) - { - if (ns.ContainerGridLines) - ns.Send(new ContainerContentUpdate6017(this)); - else - ns.Send(new ContainerContentUpdate(this)); - - if (ObjectPropertyList.Enabled) - ns.Send(OPLPacket); - } - } - } - - if (openers.Count == 0) - contParent.Openers = null; - } - - return; - } - - if ((flags & ItemDelta.Update) != 0) + if (rootParent != null) { - Packet p = null; - Point3D worldLoc = GetWorldLocation(); + NetState ns = rootParent.NetState; - IPooledEnumerable eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - - foreach (NetState state in eable) - { - Mobile m = state.Mobile; - - if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) + if (ns != null) + if (rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent))) { - if (m_Parent == null) + if (ns.ContainerGridLines) + ns.Send(new ContainerContentUpdate6017(this)); + else + ns.Send(new ContainerContentUpdate(this)); + + if (ObjectPropertyList.Enabled) + ns.Send(OPLPacket); + } + } + + SecureTrade st = GetSecureTradeCont()?.Trade; + + if (st != null) + { + Mobile test = st.From.Mobile; + + if (test != null && test != rootParent) + tradeRecip = test; + + test = st.To.Mobile; + + if (test != null && test != rootParent) + tradeRecip = test; + + NetState ns = tradeRecip?.NetState; + + if (ns != null && tradeRecip.CanSee(this) && tradeRecip.InRange(worldLoc, GetUpdateRange(tradeRecip))) + { + if (ns.ContainerGridLines) + ns.Send(new ContainerContentUpdate6017(this)); + else + ns.Send(new ContainerContentUpdate(this)); + + if (ObjectPropertyList.Enabled) + ns.Send(OPLPacket); + } + } + + List openers = contParent.Openers; + + if (openers != null) + lock (openers) + { + for (int i = 0; i < openers.Count; ++i) + { + Mobile mob = openers[i]; + + int range = GetUpdateRange(mob); + + if (mob.Map != map || !mob.InRange(worldLoc, range)) { - SendInfoTo(state, ObjectPropertyList.Enabled); + openers.RemoveAt(i--); } else { - if (p == null) - { - if (m_Parent is Item) - { - if (state.ContainerGridLines) - state.Send(new ContainerContentUpdate6017(this)); - else - state.Send(new ContainerContentUpdate(this)); - } - else if (m_Parent is Mobile) - { - p = new EquipUpdate(this); - p.Acquire(); + if (mob == rootParent || mob == tradeRecip) + continue; - state.Send(p); - } - } - else - { - state.Send(p); - } + NetState ns = mob.NetState; - if (ObjectPropertyList.Enabled) state.Send(OPLPacket); + if (ns != null && mob.CanSee(this)) + { + if (ns.ContainerGridLines) + ns.Send(new ContainerContentUpdate6017(this)); + else + ns.Send(new ContainerContentUpdate(this)); + + if (ObjectPropertyList.Enabled) + ns.Send(OPLPacket); + } } } + + if (openers.Count == 0) + contParent.Openers = null; } - if (p != null) - Packet.Release(p); + return; + } - eable.Free(); - sendOPLUpdate = false; - } - else if ((flags & ItemDelta.EquipOnly) != 0) + Packet p = null; + + IPooledEnumerable eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); + + foreach (NetState state in eable) + { + Mobile m = state.Mobile; + + if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) { - if (m_Parent is Mobile) + if (update) { - Packet p = null; - Point3D worldLoc = GetWorldLocation(); - - IPooledEnumerable eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - - foreach (NetState state in eable) + if (m_Parent == null) + SendInfoTo(state, ObjectPropertyList.Enabled); + else { - Mobile m = state.Mobile; - - if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) + if (p != null) + state.Send(p); + else if (m_Parent is Item) { - //if ( sendOPLUpdate ) - // state.Send( RemovePacket ); - - if (p == null) - p = Packet.Acquire(new EquipUpdate(this)); + if (state.ContainerGridLines) + state.Send(new ContainerContentUpdate6017(this)); + else + state.Send(new ContainerContentUpdate(this)); + } + else if (m_Parent is Mobile) + { + p = new EquipUpdate(this); + p.Acquire(); state.Send(p); - - if (ObjectPropertyList.Enabled) - state.Send(OPLPacket); } + + if (ObjectPropertyList.Enabled) + state.Send(OPLPacket); } - - Packet.Release(p); - - eable.Free(); - sendOPLUpdate = false; } - } - - if (sendOPLUpdate) - { - Point3D worldLoc = GetWorldLocation(); - IPooledEnumerable eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - - foreach (NetState state in eable) + else if ((flags & ItemDelta.EquipOnly) != 0 && m_Parent is Mobile) { - Mobile m = state.Mobile; + state.Send(p ?? (p = Packet.Acquire(new EquipUpdate(this)))); - if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) + if (ObjectPropertyList.Enabled) state.Send(OPLPacket); - } - - eable.Free(); + } else if (ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0) + state.Send(OPLPacket); } } + + Packet.Release(p); + eable.Free(); } public virtual void Delete() { - if (Deleted) - return; - - if (!World.OnDelete(this)) + if (Deleted || !World.OnDelete(this)) return; OnDelete(); @@ -1866,15 +1204,15 @@ namespace Server if (info != null) { - if (info.m_BlessedFor != null && !info.m_BlessedFor.Deleted) + if (info.m_BlessedFor?.Deleted == false) flags |= SaveFlag.BlessedFor; - if (info.m_HeldBy != null && !info.m_HeldBy.Deleted) + if (info.m_HeldBy?.Deleted == false) flags |= SaveFlag.HeldBy; if (info.m_SavedFlags != 0) flags |= SaveFlag.SavedFlags; } - if (info == null || info.m_Weight == -1) + if (info == null || info.m_Weight == -1.0) { flags |= SaveFlag.NullWeight; } @@ -1976,7 +1314,7 @@ namespace Server if (GetSaveFlag(flags, SaveFlag.Parent)) { - if (m_Parent != null && !m_Parent.Deleted) + if (m_Parent?.Deleted == false) writer.Write(m_Parent.Serial); else writer.Write(Serial.MinusOne); @@ -2325,7 +1663,7 @@ namespace Server Mobile blessedFor = BlessedFor; - if (blessedFor != null && !blessedFor.Deleted) + if (blessedFor?.Deleted == false) AddBlessedForProperty(list, blessedFor); if (DisplayLootType) @@ -2430,7 +1768,7 @@ namespace Server { IEntity parent = bounce.m_Parent; - if (parent == null || parent.Deleted) + if (parent?.Deleted != false) { MoveToWorld(bounce.m_WorldLoc, bounce.m_Map); } @@ -2715,8 +2053,8 @@ namespace Server public void ClearProperties() { - Packet.Release(ref m_PropertyList); - Packet.Release(ref m_OPLPacket); + StaticPacketHandlers.FreeOPLPacket(this); + StaticPacketHandlers.FreeOPLInfoPacket(this); } public void InvalidateProperties() @@ -2726,13 +2064,11 @@ namespace Server if (m_Map != null && m_Map != Map.Internal && !World.Loading) { - ObjectPropertyList oldList = m_PropertyList; - m_PropertyList = null; - ObjectPropertyList newList = PropertyList; + ObjectPropertyList oldList = StaticPacketHandlers.FreeOPLPacket(this); - if (oldList == null || oldList.Hash != newList.Hash) + if (oldList?.Hash != PropertyList.Hash) { - Packet.Release(ref m_OPLPacket); + StaticPacketHandlers.FreeOPLInfoPacket(this); Delta(ItemDelta.Properties); } } @@ -2744,9 +2080,7 @@ namespace Server public void ReleaseWorldPackets() { - Packet.Release(ref m_WorldPacket); - Packet.Release(ref m_WorldPacketSA); - Packet.Release(ref m_WorldPacketHS); + StaticPacketHandlers.FreeWorldItemPackets(this); } public virtual int GetPacketFlags() @@ -3349,13 +2683,11 @@ namespace Server { IEntity p = m_Parent; - while (p is Item) + while (p is Item item) { - if (p is T) + if (item is T) return true; - Item item = (Item)p; - if (item.m_Parent == null) break; p = item.m_Parent; @@ -3366,7 +2698,7 @@ namespace Server public virtual void AddItem(Item item) { - if (item == null || item.Deleted || item.m_Parent == this) return; + if (item?.Deleted != false || item.m_Parent == this) return; if (item == this) { @@ -3434,6 +2766,7 @@ namespace Server } catch { + // ignored } else m_DeltaQueue.Add(this); @@ -3501,9 +2834,9 @@ namespace Server public virtual void FreeCache() { ReleaseWorldPackets(); - Packet.Release(ref m_RemovePacket); - Packet.Release(ref m_OPLPacket); - Packet.Release(ref m_PropertyList); + StaticPacketHandlers.FreeRemoveItemPacket(this); + StaticPacketHandlers.FreeOPLInfoPacket(this); + StaticPacketHandlers.FreeOPLPacket(this); } public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text) @@ -3685,15 +3018,13 @@ namespace Server target.Map == null) return false; - object root = target.RootParent; - if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(target.GetWorldLocation(), 2)) return false; if (!from.CanSee(target) || !from.InLOS(target)) return false; if (!target.IsAccessibleTo(from)) return false; - if (root is Mobile mobile && !mobile.CheckNonlocalDrop(from, this, target)) + if (target.RootParent is Mobile mobile && !mobile.CheckNonlocalDrop(from, this, target)) return false; if (!from.OnDroppedItemToItem(this, target, p)) return false; @@ -3765,29 +3096,24 @@ namespace Server z = top; } - List items = new List(); - IPooledEnumerable eable = map.GetItemsInRange(p, 0); - foreach (Item item in eable) + List items = eable.Where(item => { if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) - continue; - - items.Add(item); + return false; ItemData id = item.ItemData; - if (!id.Surface) - continue; + if (id.Surface) + { + int top = item.Z + id.CalcHeight; + if (top <= maxZ && top >= z) + z = top; + } - int top = item.Z + id.CalcHeight; - - if (top > maxZ || top < z) - continue; - - z = top; - } + return true; + }).ToList(); eable.Free(); @@ -4024,12 +3350,12 @@ namespace Server { object p = this; - while (p is Item) + while (p is Item item) { - if (p is SecureTradeContainer container) + if (item is SecureTradeContainer container) return container; - p = ((Item)p).m_Parent; + p = item.m_Parent; } return null; @@ -4125,10 +3451,8 @@ namespace Server if (p == o) return true; - while (p is Item) + while (p is Item item) { - Item item = (Item)p; - if (item.m_Parent == null) break; @@ -4214,22 +3538,22 @@ namespace Server NetState ns = from.NetState; - if (ns != null) + if (ns == null) + return; + + if (Name == null) { - if (Name == null) - { - if (m_Amount <= 1) - ns.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", "")); - else - ns.Send(new MessageLocalizedAffix(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", - AffixType.Append, - $" : {m_Amount}", "")); - } + if (m_Amount <= 1) + ns.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", "")); else - { - ns.Send(new UnicodeMessage(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", - Name + (m_Amount > 1 ? " : " + m_Amount : ""))); - } + ns.Send(new MessageLocalizedAffix(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", + AffixType.Append, + $" : {m_Amount}", "")); + } + else + { + ns.Send(new UnicodeMessage(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", + Name + (m_Amount > 1 ? " : " + m_Amount : ""))); } } @@ -4296,11 +3620,6 @@ namespace Server Delete(); } - public virtual bool CheckBlessed(object obj) - { - return CheckBlessed(obj as Mobile); - } - public virtual bool CheckBlessed(Mobile m) { if (m_LootType == LootType.Blessed || Mobile.InsuranceEnabled && Insured) @@ -4417,18 +3736,6 @@ namespace Server #endregion - #region Packet caches - - private Packet m_WorldPacket; - private Packet m_WorldPacketSA; - private Packet m_WorldPacketHS; - private Packet m_RemovePacket; - - private Packet m_OPLPacket; - private ObjectPropertyList m_PropertyList; - - #endregion - #region Location Location Location! public virtual void OnLocationChange(Point3D oldLocation) diff --git a/Server/Items/BaseMulti.cs b/Server/Items/BaseMulti.cs index 8501e7039..98bc6bd24 100644 --- a/Server/Items/BaseMulti.cs +++ b/Server/Items/BaseMulti.cs @@ -22,9 +22,8 @@ using System; namespace Server.Items { - public class BaseMulti : Item + public abstract class BaseMulti : Item { - [Constructible] public BaseMulti(int itemID) : base(itemID) { Movable = false; @@ -162,4 +161,4 @@ namespace Server.Items ItemID -= 0x4000; } } -} \ No newline at end of file +} diff --git a/Server/Items/Container.cs b/Server/Items/Container.cs index cb6a6c8e3..b61228f05 100644 --- a/Server/Items/Container.cs +++ b/Server/Items/Container.cs @@ -19,7 +19,6 @@ ***************************************************************************/ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using Server.Network; @@ -203,7 +202,7 @@ namespace Server.Items public virtual bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { - if (m != null && m.AccessLevel < AccessLevel.GameMaster) + if (m?.AccessLevel < AccessLevel.GameMaster) { if (IsDecoContainer) { @@ -233,7 +232,7 @@ namespace Server.Items } } - object parent = Parent; + IEntity parent = Parent; while (parent != null) { @@ -607,15 +606,13 @@ namespace Server.Items { DisplayTo(from); - SecureTradeContainer cont = GetSecureTradeCont(); + SecureTrade trade = GetSecureTradeCont()?.Trade; - if (cont != null) + if (trade != null) { - SecureTrade trade = cont.Trade; - - if (trade != null && trade.From.Mobile == from) + if (trade.From.Mobile == from) DisplayTo(trade.To.Mobile); - else if (trade != null && trade.To.Mobile == from) + else if (trade.To.Mobile == from) DisplayTo(trade.From.Mobile); } } @@ -627,15 +624,9 @@ namespace Server.Items public virtual bool CheckContentDisplay(Mobile from) { - if (DisplaysContent) - { - object root = RootParent; - - if (root == null || root is Item || root == from || from.AccessLevel > AccessLevel.Player) - return true; - } - - return false; + return DisplaysContent && RootParent == null || + RootParent is Item || RootParent == from || + from.AccessLevel > AccessLevel.Player; } public override void OnSingleClick(Mobile from) @@ -681,50 +672,50 @@ namespace Server.Items public void ProcessOpeners(Mobile opener) { - if (!IsPublicContainer) + if (IsPublicContainer) + return; + + bool contains = false; + + if (Openers != null) { - bool contains = false; + Point3D worldLoc = GetWorldLocation(); + Map map = Map; - if (Openers != null) + for (int i = 0; i < Openers.Count; ++i) { - Point3D worldLoc = GetWorldLocation(); - Map map = Map; + Mobile mob = Openers[i]; - for (int i = 0; i < Openers.Count; ++i) + if (mob == opener) { - Mobile mob = Openers[i]; + contains = true; + } + else + { + int range = GetUpdateRange(mob); - if (mob == opener) - { - contains = true; - } - else - { - int range = GetUpdateRange(mob); - - if (mob.Map != map || !mob.InRange(worldLoc, range)) - Openers.RemoveAt(i--); - } + if (mob.Map != map || !mob.InRange(worldLoc, range)) + Openers.RemoveAt(i--); } } + } - if (!contains) - { - if (Openers == null) - Openers = new List(); + if (!contains) + { + if (Openers == null) + Openers = new List(); - Openers.Add(opener); - } - else if (Openers != null && Openers.Count == 0) - { - Openers = null; - } + Openers.Add(opener); + } + else if (Openers?.Count == 0) + { + Openers = null; } } public virtual void SendContentTo(NetState state) { - if (state != null && state.ContainerGridLines) + if (state?.ContainerGridLines == true) state.Send(new ContainerContent6017(state.Mobile, this)); else state.Send(new ContainerContent(state.Mobile, this)); @@ -762,7 +753,7 @@ namespace Server.Items from.SendLocalizedMessage(500446); // That is too far away. } - private class GroupComparer : IComparer + private class GroupComparer : IComparer { private CheckItemGroup m_Grouper; @@ -771,11 +762,8 @@ namespace Server.Items m_Grouper = grouper; } - public int Compare(object x, object y) + public int Compare(Item a, Item b) { - Item a = (Item)x; - Item b = (Item)y; - return m_Grouper(a, b); } } @@ -1128,17 +1116,7 @@ namespace Server.Items return -1; } - public int ConsumeTotal(Type[] types, int[] amounts) - { - return ConsumeTotal(types, amounts, true, null); - } - - public int ConsumeTotal(Type[] types, int[] amounts, bool recurse) - { - return ConsumeTotal(types, amounts, recurse, null); - } - - public int ConsumeTotal(Type[] types, int[] amounts, bool recurse, OnItemConsumed callback) + public int ConsumeTotal(Type[] types, int[] amounts, bool recurse = true, OnItemConsumed callback = null) { if (types.Length != amounts.Length) throw new ArgumentException(); @@ -1187,17 +1165,7 @@ namespace Server.Items return -1; } - public bool ConsumeTotal(Type type, int amount) - { - return ConsumeTotal(type, amount, true, null); - } - - public bool ConsumeTotal(Type type, int amount, bool recurse) - { - return ConsumeTotal(type, amount, recurse, null); - } - - public bool ConsumeTotal(Type type, int amount, bool recurse, OnItemConsumed callback) + public bool ConsumeTotal(Type type, int amount = 1, bool recurse = true, OnItemConsumed callback = null) { Item[] items = FindItemsByType(type, recurse); @@ -1240,12 +1208,7 @@ namespace Server.Items return false; } - public int ConsumeUpTo(Type type, int amount) - { - return ConsumeUpTo(type, amount, true); - } - - public int ConsumeUpTo(Type type, int amount, bool recurse) + public int ConsumeUpTo(Type type, int amount, bool recurse = true) { int consumed = 0; @@ -1262,37 +1225,37 @@ namespace Server.Items private static void RecurseConsumeUpTo(Item current, Type type, int amount, bool recurse, ref int consumed, Queue toDelete) { - if (current != null && current.Items.Count > 0) + if (current == null || current.Items.Count == 0) + return; + + List list = current.Items; + + for (int i = 0; i < list.Count; ++i) { - List list = current.Items; + Item item = list[i]; - for (int i = 0; i < list.Count; ++i) + if (type.IsInstanceOfType(item)) { - Item item = list[i]; + int need = amount - consumed; + int theirAmount = item.Amount; - if (type.IsInstanceOfType(item)) + if (theirAmount <= need) { - int need = amount - consumed; - int theirAmount = item.Amount; - - if (theirAmount <= need) - { - toDelete.Enqueue(item); - consumed += theirAmount; - } - else - { - item.Amount -= need; - consumed += need; - - return; - } + toDelete.Enqueue(item); + consumed += theirAmount; } - else if (recurse && item is Container) + else { - RecurseConsumeUpTo(item, type, amount, true, ref consumed, toDelete); + item.Amount -= need; + consumed += need; + + return; } } + else if (recurse && item is Container) + { + RecurseConsumeUpTo(item, type, amount, true, ref consumed, toDelete); + } } } @@ -1578,7 +1541,7 @@ namespace Server.Items private static Item RecurseFindItemByType(Item current, Type[] types, bool recurse) { - if (current == null || current.Items.Count <= 0) + if (current == null || current.Items.Count == 0) return null; List list = current.Items; @@ -1641,12 +1604,12 @@ namespace Server.Items } } - public T FindItemByType(bool recurse = true, Predicate predicate = null) where T : Item + public T FindItemByType(bool recurse = true) where T : Item { - return RecurseFindItemByType(this, recurse, predicate); + return RecurseFindItemByType(this, recurse); } - private static T RecurseFindItemByType(Item current, bool recurse, Predicate predicate) where T : Item + private static T RecurseFindItemByType(Item current, bool recurse = true, Predicate predicate = null) where T : Item { if (current == null || current.Items.Count == 0) return null; diff --git a/Server/Items/Containers.cs b/Server/Items/Containers.cs index 6842c67d0..5929bc03e 100644 --- a/Server/Items/Containers.cs +++ b/Server/Items/Containers.cs @@ -97,8 +97,8 @@ namespace Server.Items { Opened = false; - if (Owner != null && SendDeleteOnClose) - Owner.Send(RemovePacket); + if (SendDeleteOnClose) + Owner?.Send(RemovePacket); } public override void OnSingleClick(Mobile from) @@ -116,30 +116,26 @@ namespace Server.Items public override bool IsAccessibleTo(Mobile check) { - if (check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) - return base.IsAccessibleTo(check); - return false; + return (check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check); } public override bool OnDragDrop(Mobile from, Item dropped) { - if (from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) - return base.OnDragDrop(from, dropped); - return false; + return (from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped); } public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { - if (from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) - return base.OnDragDropInto(from, item, p); - return false; + return (from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && + base.OnDragDropInto(from, item, p); } public override int GetTotal(TotalType type) { - if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold) return Owner.Account.TotalGold; + if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold) + return Owner.Account.TotalGold; return base.GetTotal(type); } } -} \ No newline at end of file +} diff --git a/Server/Items/SecureTradeContainer.cs b/Server/Items/SecureTradeContainer.cs index 4381f001f..aa492ae6b 100644 --- a/Server/Items/SecureTradeContainer.cs +++ b/Server/Items/SecureTradeContainer.cs @@ -42,12 +42,7 @@ namespace Server.Items { if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck) return true; - Mobile to; - - if (Trade.From.Container != this) - to = Trade.From.Mobile; - else - to = Trade.To.Mobile; + Mobile to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile; return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight); } @@ -60,49 +55,52 @@ namespace Server.Items public override bool IsAccessibleTo(Mobile check) { - if (!IsChildOf(check) || Trade == null || !Trade.Valid) - return false; - - return base.IsAccessibleTo(check); + return IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check); } public override void OnItemAdded(Item item) { - if (!(item is VirtualCheck)) ClearChecks(); + if (!(item is VirtualCheck)) + ClearChecks(); } public override void OnItemRemoved(Item item) { - if (!(item is VirtualCheck)) ClearChecks(); + if (!(item is VirtualCheck)) + ClearChecks(); } public override void OnSubItemAdded(Item item) { - if (!(item is VirtualCheck)) ClearChecks(); + if (!(item is VirtualCheck)) + ClearChecks(); } public override void OnSubItemRemoved(Item item) { - if (!(item is VirtualCheck)) ClearChecks(); + if (!(item is VirtualCheck)) + ClearChecks(); } public void ClearChecks() { - if (Trade != null) - { - if (Trade.From != null && !Trade.From.IsDisposed) Trade.From.Accepted = false; + if (Trade == null) + return; - if (Trade.To != null && !Trade.To.IsDisposed) Trade.To.Accepted = false; + if (Trade.From?.IsDisposed == false) + Trade.From.Accepted = false; - Trade.Update(); - } + if (Trade.To?.IsDisposed == false) + Trade.To.Accepted = false; + + Trade.Update(); } public override bool IsChildVisibleTo(Mobile m, Item child) { - if (child is VirtualCheck) return AccountGold.Enabled && (m.NetState == null || !m.NetState.NewSecureTrading); - - return base.IsChildVisibleTo(m, child); + return child is VirtualCheck + ? AccountGold.Enabled && m.NetState?.NewSecureTrading != true + : base.IsChildVisibleTo(m, child); } public override void Serialize(GenericWriter writer) @@ -119,4 +117,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Server/Items/VirtualCheck.cs b/Server/Items/VirtualCheck.cs index 51db01159..514e60739 100644 --- a/Server/Items/VirtualCheck.cs +++ b/Server/Items/VirtualCheck.cs @@ -1,20 +1,7 @@ -#region Header - -// ********** -// ServUO - VirtualCheck.cs -// ********** - -#endregion - -#region References - -using System.Drawing; using Server.Gumps; using Server.Items; using Server.Network; -#endregion - namespace Server { public sealed class VirtualCheck : Item @@ -25,12 +12,7 @@ namespace Server private int _Plat; - public VirtualCheck() - : this(0, 0) - { - } - - public VirtualCheck(int plat, int gold) + public VirtualCheck(int plat = 0, int gold = 0) : base(0x14F0) { Plat = plat; @@ -90,7 +72,7 @@ namespace Server { if (UseEditGump && IsAccessibleTo(from)) { - if (Editor?.Check == null || Editor.Check.Deleted) + if (Editor?.Check?.Deleted != false) { Editor = new EditGump(from, this); Editor.Send(); @@ -196,14 +178,15 @@ namespace Server { base.OnServerClose(owner); - if (Check != null && !Check.Deleted) Check.UpdateTrade(User); + if (Check?.Deleted == false) + Check.UpdateTrade(User); } public void Close() { User.CloseGump(); - if (Check != null && !Check.Deleted) + if (Check?.Deleted == false) Check.UpdateTrade(User); else Check = null; @@ -211,7 +194,7 @@ namespace Server public void Send() { - if (Check != null && !Check.Deleted) + if (Check?.Deleted == false) User.SendGump(this); else Close(); @@ -219,13 +202,14 @@ namespace Server public void Refresh(bool recompile) { - if (Check == null || Check.Deleted) + if (Check?.Deleted != false) { Close(); return; } - if (recompile) CompileLayout(); + if (recompile) + CompileLayout(); Close(); Send(); @@ -233,7 +217,8 @@ namespace Server private void CompileLayout() { - if (Check == null || Check.Deleted) return; + if (Check?.Deleted != false) + return; Entries.ForEach(e => e.Parent = null); Entries.Clear(); @@ -248,9 +233,9 @@ namespace Server AddImage(360, 8, 113); string title = - $"
BANK OF {User.RawName.ToUpper()}
"; + $"
BANK OF {User.RawName.ToUpper()}
"; - AddHtml(40, 15, 320, 20, title, false, false); + AddHtml(40, 15, 320, 20, title); // Platinum Row AddBackground(15, 60, 175, 20, 9300); @@ -258,7 +243,7 @@ namespace Server AddItem(20, 45, 3826); // Plat AddLabel(60, 50, 0, User.Account.TotalPlat.ToString("#,0")); - AddButton(195, 50, 95, 95, (int)Buttons.AllPlat, GumpButtonType.Reply, 0); // -> + AddButton(195, 50, 95, 95, (int)Buttons.AllPlat); // -> AddBackground(210, 60, 175, 20, 9300); AddBackground(215, 45, 165, 30, 9350); @@ -270,21 +255,21 @@ namespace Server AddItem(20, 85, 3823); // Gold AddLabel(60, 90, 0, User.Account.TotalGold.ToString("#,0")); - AddButton(195, 90, 95, 95, (int)Buttons.AllGold, GumpButtonType.Reply, 0); // -> + AddButton(195, 90, 95, 95, (int)Buttons.AllGold); // -> AddBackground(210, 100, 175, 20, 9300); AddBackground(215, 85, 165, 30, 9350); AddTextEntry(225, 90, 145, 20, 0, 1, _Gold.ToString(), User.Account.TotalGold.ToString().Length); // Buttons - AddButton(20, 128, 12006, 12007, (int)Buttons.Close, GumpButtonType.Reply, 0); - AddButton(215, 128, 12003, 12004, (int)Buttons.Clear, GumpButtonType.Reply, 0); - AddButton(305, 128, 12000, 12002, (int)Buttons.Accept, GumpButtonType.Reply, 0); + AddButton(20, 128, 12006, 12007, (int)Buttons.Close); + AddButton(215, 128, 12003, 12004, (int)Buttons.Clear); + AddButton(305, 128, 12000, 12002, (int)Buttons.Accept); } public override void OnResponse(NetState sender, RelayInfo info) { - if (Check == null || Check.Deleted || sender.Mobile != User) + if (Check?.Deleted != false || sender.Mobile != User) { Close(); return; @@ -352,9 +337,10 @@ namespace Server break; } - if (updated) User.SendMessage("Your offer has been updated."); + if (updated) + User.SendMessage("Your offer has been updated."); - if (refresh && Check != null && !Check.Deleted) + if (refresh && Check?.Deleted == false) { Refresh(true); return; @@ -364,4 +350,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Server/Layer.cs b/Server/Layer.cs new file mode 100644 index 000000000..936917bf6 --- /dev/null +++ b/Server/Layer.cs @@ -0,0 +1,173 @@ +namespace Server +{ + /// + /// Enumeration of item layer values. + /// + public enum Layer : byte + { + /// + /// Invalid layer. + /// + Invalid = 0x00, + + /// + /// First valid layer. Equivalent to Layer.OneHanded. + /// + FirstValid = 0x01, + + /// + /// One handed weapon. + /// + OneHanded = 0x01, + + /// + /// Two handed weapon or shield. + /// + TwoHanded = 0x02, + + /// + /// Shoes. + /// + Shoes = 0x03, + + /// + /// Pants. + /// + Pants = 0x04, + + /// + /// Shirts. + /// + Shirt = 0x05, + + /// + /// Helmets, hats, and masks. + /// + Helm = 0x06, + + /// + /// Gloves. + /// + Gloves = 0x07, + + /// + /// Rings. + /// + Ring = 0x08, + + /// + /// Talismans. + /// + Talisman = 0x09, + + /// + /// Gorgets and necklaces. + /// + Neck = 0x0A, + + /// + /// Hair. + /// + Hair = 0x0B, + + /// + /// Half aprons. + /// + Waist = 0x0C, + + /// + /// Torso, inner layer. + /// + InnerTorso = 0x0D, + + /// + /// Bracelets. + /// + Bracelet = 0x0E, + + /// + /// Unused. + /// + Unused_xF = 0x0F, + + /// + /// Beards and mustaches. + /// + FacialHair = 0x10, + + /// + /// Torso, outer layer. + /// + MiddleTorso = 0x11, + + /// + /// Earings. + /// + Earrings = 0x12, + + /// + /// Arms and sleeves. + /// + Arms = 0x13, + + /// + /// Cloaks. + /// + Cloak = 0x14, + + /// + /// Backpacks. + /// + Backpack = 0x15, + + /// + /// Torso, outer layer. + /// + OuterTorso = 0x16, + + /// + /// Leggings, outer layer. + /// + OuterLegs = 0x17, + + /// + /// Leggings, inner layer. + /// + InnerLegs = 0x18, + + /// + /// Last valid non-internal layer. Equivalent to Layer.InnerLegs. + /// + LastUserValid = 0x18, + + /// + /// Mount item layer. + /// + Mount = 0x19, + + /// + /// Vendor 'buy pack' layer. + /// + ShopBuy = 0x1A, + + /// + /// Vendor 'resale pack' layer. + /// + ShopResale = 0x1B, + + /// + /// Vendor 'sell pack' layer. + /// + ShopSell = 0x1C, + + /// + /// Bank box layer. + /// + Bank = 0x1D, + + /// + /// Last valid layer. Equivalent to Layer.Bank. + /// + LastValid = 0x1D + } +} diff --git a/Server/LightType.cs b/Server/LightType.cs new file mode 100644 index 000000000..cdab2e58b --- /dev/null +++ b/Server/LightType.cs @@ -0,0 +1,287 @@ +namespace Server +{ + public enum LightType + { + /// + /// Window shape, arched, ray shining east. + /// + ArchedWindowEast, + + /// + /// Medium circular shape. + /// + Circle225, + + /// + /// Small circular shape. + /// + Circle150, + + /// + /// Door shape, shining south. + /// + DoorSouth, + + /// + /// Door shape, shining east. + /// + DoorEast, + + /// + /// Large semicircular shape (180 degrees), north wall. + /// + NorthBig, + + /// + /// Large pie shape (90 degrees), north-east corner. + /// + NorthEastBig, + + /// + /// Large semicircular shape (180 degrees), east wall. + /// + EastBig, + + /// + /// Large semicircular shape (180 degrees), west wall. + /// + WestBig, + + /// + /// Large pie shape (90 degrees), south-west corner. + /// + SouthWestBig, + + /// + /// Large semicircular shape (180 degrees), south wall. + /// + SouthBig, + + /// + /// Medium semicircular shape (180 degrees), north wall. + /// + NorthSmall, + + /// + /// Medium pie shape (90 degrees), north-east corner. + /// + NorthEastSmall, + + /// + /// Medium semicircular shape (180 degrees), east wall. + /// + EastSmall, + + /// + /// Medium semicircular shape (180 degrees), west wall. + /// + WestSmall, + + /// + /// Medium semicircular shape (180 degrees), south wall. + /// + SouthSmall, + + /// + /// Shaped like a wall decoration, north wall. + /// + DecorationNorth, + + /// + /// Shaped like a wall decoration, north-east corner. + /// + DecorationNorthEast, + + /// + /// Small semicircular shape (180 degrees), east wall. + /// + EastTiny, + + /// + /// Shaped like a wall decoration, west wall. + /// + DecorationWest, + + /// + /// Shaped like a wall decoration, south-west corner. + /// + DecorationSouthWest, + + /// + /// Small semicircular shape (180 degrees), south wall. + /// + SouthTiny, + + /// + /// Window shape, rectangular, no ray, shining south. + /// + RectWindowSouthNoRay, + + /// + /// Window shape, rectangular, no ray, shining east. + /// + RectWindowEastNoRay, + + /// + /// Window shape, rectangular, ray shining south. + /// + RectWindowSouth, + + /// + /// Window shape, rectangular, ray shining east. + /// + RectWindowEast, + + /// + /// Window shape, arched, no ray, shining south. + /// + ArchedWindowSouthNoRay, + + /// + /// Window shape, arched, no ray, shining east. + /// + ArchedWindowEastNoRay, + + /// + /// Window shape, arched, ray shining south. + /// + ArchedWindowSouth, + + /// + /// Large circular shape. + /// + Circle300, + + /// + /// Large pie shape (90 degrees), north-west corner. + /// + NorthWestBig, + + /// + /// Negative light. Medium pie shape (90 degrees), south-east corner. + /// + DarkSouthEast, + + /// + /// Negative light. Medium semicircular shape (180 degrees), south wall. + /// + DarkSouth, + + /// + /// Negative light. Medium pie shape (90 degrees), north-west corner. + /// + DarkNorthWest, + + /// + /// Negative light. Medium pie shape (90 degrees), south-east corner. Equivalent to LightType.SouthEast. + /// + DarkSouthEast2, + + /// + /// Negative light. Medium circular shape (180 degrees), east wall. + /// + DarkEast, + + /// + /// Negative light. Large circular shape. + /// + DarkCircle300, + + /// + /// Opened door shape, shining south. + /// + DoorOpenSouth, + + /// + /// Opened door shape, shining east. + /// + DoorOpenEast, + + /// + /// Window shape, square, ray shining east. + /// + SquareWindowEast, + + /// + /// Window shape, square, no ray, shining east. + /// + SquareWindowEastNoRay, + + /// + /// Window shape, square, ray shining south. + /// + SquareWindowSouth, + + /// + /// Window shape, square, no ray, shining south. + /// + SquareWindowSouthNoRay, + + /// + /// Empty. + /// + Empty, + + /// + /// Window shape, skinny, no ray, shining south. + /// + SkinnyWindowSouthNoRay, + + /// + /// Window shape, skinny, ray shining east. + /// + SkinnyWindowEast, + + /// + /// Window shape, skinny, no ray, shining east. + /// + SkinnyWindowEastNoRay, + + /// + /// Shaped like a hole, shining south. + /// + HoleSouth, + + /// + /// Shaped like a hole, shining south. + /// + HoleEast, + + /// + /// Large circular shape with a moongate graphic embedded. + /// + Moongate, + + /// + /// Unknown usage. Many rows of slightly angled lines. + /// + Strips, + + /// + /// Shaped like a small hole, shining south. + /// + SmallHoleSouth, + + /// + /// Shaped like a small hole, shining east. + /// + SmallHoleEast, + + /// + /// Large semicircular shape (180 degrees), north wall. Identical graphic as LightType.NorthBig, but slightly different + /// positioning. + /// + NorthBig2, + + /// + /// Large semicircular shape (180 degrees), west wall. Identical graphic as LightType.WestBig, but slightly different + /// positioning. + /// + WestBig2, + + /// + /// Large pie shape (90 degrees), north-west corner. Equivalent to LightType.NorthWestBig. + /// + NorthWestBig2 + } +} diff --git a/Server/Main.cs b/Server/Main.cs index 8974ebebb..e5bf0daaa 100644 --- a/Server/Main.cs +++ b/Server/Main.cs @@ -263,6 +263,7 @@ namespace Server } catch { + // ignored } if (!close && !Service) @@ -273,6 +274,7 @@ namespace Server } catch { + // ignored } Console.WriteLine("This exception is fatal, press return to exit"); @@ -374,6 +376,7 @@ namespace Server } catch { + // ignored } Thread = Thread.CurrentThread; @@ -563,7 +566,7 @@ namespace Server warningSb.AppendLine(" - No Deserialize() method"); } - if (warningSb != null && warningSb.Length > 0) Console.WriteLine("Warning: {0}\n{1}", t, warningSb); + if (warningSb?.Length > 0) Console.WriteLine("Warning: {0}\n{1}", t, warningSb); } catch { @@ -626,12 +629,7 @@ namespace Server private bool _NewLine; - public FileLogger(string file) - : this(file, false) - { - } - - public FileLogger(string file, bool append) + public FileLogger(string file, bool append = false) { FileName = file; @@ -733,4 +731,4 @@ namespace Server WriteLine(string.Format(line, args)); } } -} \ No newline at end of file +} diff --git a/Server/Map.cs b/Server/Map.cs index beab84716..612253fb5 100644 --- a/Server/Map.cs +++ b/Server/Map.cs @@ -72,7 +72,7 @@ namespace Server public static IEnumerable SelectClients(Sector s, Rectangle2D bounds) { - return s.Clients.Where(o => o?.Mobile != null && !o.Mobile.Deleted && bounds.Contains(o.Mobile)); + return s.Clients.Where(o => o?.Mobile?.Deleted == false && bounds.Contains(o.Mobile)); } public static IEnumerable SelectEntities(Sector s, Rectangle2D bounds) @@ -84,9 +84,9 @@ namespace Server { IEnumerable eable = Enumerable.Empty(); if (mobiles) - eable = eable.Union(s.Mobiles.Where(o => o != null && !o.Deleted)); + eable = eable.Union(s.Mobiles.Where(o => o?.Deleted == false)); if (items) - eable = eable.Union(s.Items.Where(o => o != null && !o.Deleted && o.Parent == null)); + eable = eable.Union(s.Items.Where(o => o?.Deleted == false && o.Parent == null)); return eable.Where(bounds.Contains); } @@ -99,17 +99,17 @@ namespace Server public static IEnumerable SelectItems(Sector s, Rectangle2D bounds) where T : Item { return s.Items.OfType() - .Where(o => !o.Deleted && o.Parent == null && bounds.Contains(o)); + .Where(o => o.Deleted == false && o.Parent == null && bounds.Contains(o)); } public static IEnumerable SelectMultis(Sector s, Rectangle2D bounds) { - return s.Multis.Where(o => o != null && !o.Deleted && bounds.Contains(o.Location)); + return s.Multis.Where(o => o?.Deleted == false && bounds.Contains(o.Location)); } public static IEnumerable SelectMultiTiles(Sector s, Rectangle2D bounds) { - foreach (BaseMulti o in s.Multis.Where(o => o != null && !o.Deleted)) + foreach (BaseMulti o in s.Multis.Where(o => o?.Deleted == false)) { MultiComponentList c = o.Components; @@ -275,7 +275,7 @@ namespace Server [Parsable] //[CustomEnum( new string[]{ "Felucca", "Trammel", "Ilshenar", "Malas", "Internal" } )] - public sealed class Map : IComparable, IComparable + public sealed class Map : IComparable { public const int SectorSize = 16; public const int SectorShift = 4; @@ -354,13 +354,8 @@ namespace Server public Region DefaultRegion { - get - { - if (m_DefaultRegion == null) - m_DefaultRegion = new Region(null, this, 0, new Rectangle3D[0]); - - return m_DefaultRegion; - } + get => m_DefaultRegion ?? + (m_DefaultRegion = new Region(null, this, 0, new Rectangle3D[0])); set => m_DefaultRegion = value; } @@ -396,20 +391,9 @@ namespace Server public static int[] InvalidLandTiles{ get; set; } = { 0x244 }; - public int CompareTo(object other) - { - if (other == null || other is Map) - return CompareTo(other); - - throw new ArgumentException(); - } - public int CompareTo(Map other) { - if (other == null) - return -1; - - return MapID.CompareTo(other.MapID); + return other == null ? -1 : MapID.CompareTo(other.MapID); } public static string[] GetMapNames() @@ -424,16 +408,16 @@ namespace Server public static Map Parse(string value) { - if (string.IsNullOrWhiteSpace(value)) return null; + if (string.IsNullOrWhiteSpace(value)) + return null; - if (Insensitive.Equals(value, "Internal")) return Internal; + if (Insensitive.Equals(value, "Internal")) + return Internal; if (!int.TryParse(value, out int index)) return Maps.FirstOrDefault(m => m != null && Insensitive.Equals(m.Name, value)); - if (index == 127) return Internal; - - return Maps.FirstOrDefault(m => m != null && m.MapIndex == index); + return index == 127 ? Internal : Maps.FirstOrDefault(m => m?.MapIndex == index); } public override string ToString() @@ -473,10 +457,8 @@ namespace Server if (zBottom > top) top = zBottom; - if (Math.Abs(zTop - zBottom) > Math.Abs(zLeft - zRight)) - avg = FloorAverage(zLeft, zRight); - else - avg = FloorAverage(zTop, zBottom); + avg = Math.Abs(zTop - zBottom) > Math.Abs(zLeft - zRight) ? + FloorAverage(zLeft, zRight) : FloorAverage(zTop, zBottom); } private static int FloorAverage(int a, int b) @@ -496,16 +478,19 @@ namespace Server private static List AcquireFixItems(Map map, int x, int y) { - if (map == null || map == Internal || x < 0 || x > map.Width || y < 0 || y > map.Height) return _EmptyFixItems; + if (map == null || map == Internal || x < 0 || x > map.Width || y < 0 || y > map.Height) + return _EmptyFixItems; List pool = null; lock (_FixPool) { - if (_FixPool.Count > 0) pool = _FixPool.Dequeue(); + if (_FixPool.Count > 0) + pool = _FixPool.Dequeue(); } - if (pool == null) pool = new List(128); // Arbitrary limit + if (pool == null) + pool = new List(128); // Arbitrary limit IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, 0), 0); @@ -528,7 +513,8 @@ namespace Server lock (_FixPool) { - if (_FixPool.Count < 128) _FixPool.Enqueue(pool); + if (_FixPool.Count < 128) + _FixPool.Enqueue(pool); } } @@ -970,16 +956,6 @@ namespace Server return p; } - private class ZComparer : IComparer - { - public static readonly ZComparer Default = new ZComparer(); - - public int Compare(Item x, Item y) - { - return x.Z.CompareTo(y.Z); - } - } - public class NullEnumerable : IPooledEnumerable { public static readonly NullEnumerable Instance = new NullEnumerable(); @@ -1064,13 +1040,12 @@ namespace Server IEnumerable pool = PooledEnumeration.EnumerateSectors(map, bounds).SelectMany(s => selector(s, bounds)); - if (e != null) - { - e._Pool.AddRange(pool); - return e; - } + if (e == null) + return new PooledEnumerable(pool); + + e._Pool.AddRange(pool); + return e; - return new PooledEnumerable(pool); } } @@ -1436,14 +1411,7 @@ namespace Server { IPooledEnumerable eable = GetItemsInRange(point, 0); - foreach (Item item in eable) - { - if (item.Visible) - contains = false; - - if (!contains) - break; - } + contains = !eable.Any(item => item.Visible); eable.Free(); diff --git a/Server/Menus/ItemListMenu.cs b/Server/Menus/ItemListMenu.cs index a456ff5e2..8fc57a153 100644 --- a/Server/Menus/ItemListMenu.cs +++ b/Server/Menus/ItemListMenu.cs @@ -24,11 +24,7 @@ namespace Server.Menus.ItemLists { public class ItemListEntry { - public ItemListEntry(string name, int itemID) : this(name, itemID, 0) - { - } - - public ItemListEntry(string name, int itemID, int hue) + public ItemListEntry(string name, int itemID, int hue = 0) { Name = name; ItemID = itemID; @@ -83,4 +79,4 @@ namespace Server.Menus.ItemLists state.Send(new DisplayItemListMenu(this)); } } -} \ No newline at end of file +} diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 8ffad92a9..87aae8bc3 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -457,7 +457,7 @@ namespace Server /// /// Base class representing players, npcs, and creatures. /// - public class Mobile : IHued, IComparable, ISerializable, ISpawnable + public class Mobile : IHued, IComparable, ISerializable, ISpawnable, IPropertyListObject { private const int WarmodeCatchCount = 4; // Allow four warmode changes in 0.5 seconds, any more will be delay for two seconds @@ -551,14 +551,8 @@ namespace Server private string m_NameMod; - private Packet m_OPLPacket; - - private ObjectPropertyList m_PropertyList; - private QuestArrow m_QuestArrow; - private Packet m_RemovePacket; - private int m_SolidHueOverride = -1; private StatLockType m_StrLock, m_DexLock, m_IntLock; @@ -614,21 +608,12 @@ namespace Server [CommandProperty(AccessLevel.GameMaster)] public Race Race { - get - { - if (m_Race == null) - m_Race = Race.DefaultRace; - - return m_Race; - } + get => m_Race ?? (m_Race = Race.DefaultRace); set { Race oldRace = Race; - m_Race = value; - - if (m_Race == null) - m_Race = Race.DefaultRace; + m_Race = value ?? Race.DefaultRace; Body = m_Race.Body(this); UpdateResistances(); @@ -1465,7 +1450,8 @@ namespace Server { get { - if (m_NetState != null && m_NetState.Socket == null && !m_NetState.IsDisposing) NetState = null; + if (m_NetState != null && m_NetState.Socket == null && !m_NetState.IsDisposing) + NetState = null; return m_NetState; } @@ -1489,7 +1475,7 @@ namespace Server BankBox box = FindBankNoCreate(); - if (box != null && box.Opened) + if (box?.Opened == true) box.Close(); // REMOVED: @@ -1591,7 +1577,7 @@ namespace Server { m_GuildTitle = value; - if (m_Guild != null && !m_Guild.Disbanded && m_GuildTitle != null) + if (m_Guild?.Disbanded == false && m_GuildTitle != null) SendLocalizedMessage(1018026, true, m_GuildTitle); // Your guild title has changed : InvalidateProperties(); @@ -1789,72 +1775,11 @@ namespace Server [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public Map LogoutMap{ get; set; } - public Region Region - { - get - { - if (m_Region == null) - if (Map == null) - return Map.Internal.DefaultRegion; - else - return Map.DefaultRegion; - return m_Region; - } - } + public Region Region => m_Region ?? (Map == null ? Map.Internal.DefaultRegion : Map.DefaultRegion); - public Packet RemovePacket - { - get - { - if (m_RemovePacket == null) - lock (rpLock) - { - if (m_RemovePacket == null) - { - m_RemovePacket = new RemoveMobile(this); - m_RemovePacket.SetStatic(); - } - } - - return m_RemovePacket; - } - } - - public Packet OPLPacket - { - get - { - if (m_OPLPacket == null) - lock (oplLock) - { - if (m_OPLPacket == null) - { - m_OPLPacket = new OPLInfo(PropertyList); - m_OPLPacket.SetStatic(); - } - } - - return m_OPLPacket; - } - } - - public ObjectPropertyList PropertyList - { - get - { - if (m_PropertyList == null) - { - m_PropertyList = new ObjectPropertyList(this); - - GetProperties(m_PropertyList); - - m_PropertyList.Terminate(); - m_PropertyList.SetStatic(); - } - - return m_PropertyList; - } - } + public Packet RemovePacket => StaticPacketHandlers.GetRemoveEntityPacket(this); + public OPLInfo OPLPacket => StaticPacketHandlers.GetOPLInfoPacket(this); + public ObjectPropertyList PropertyList => StaticPacketHandlers.GetOPLPacket(this); [CommandProperty(AccessLevel.GameMaster)] public int SolidHueOverride @@ -1892,7 +1817,7 @@ namespace Server { get { - if (m_BankBox != null && !m_BankBox.Deleted && m_BankBox.Parent == this) + if (m_BankBox?.Deleted == false && m_BankBox.Parent == this) return m_BankBox; m_BankBox = FindItemOnLayer(Layer.Bank) as BankBox; @@ -1909,10 +1834,10 @@ namespace Server { get { - if (m_Backpack != null && !m_Backpack.Deleted && m_Backpack.Parent == this) - return m_Backpack; + if (m_Backpack?.Deleted != false || m_Backpack.Parent != this) + m_Backpack = FindItemOnLayer(Layer.Backpack) as Container; - return m_Backpack = FindItemOnLayer(Layer.Backpack) as Container; + return m_Backpack; } } @@ -2408,9 +2333,7 @@ namespace Server public virtual void ProcessDelta() { Mobile m = this; - MobileDelta delta; - - delta = m.m_DeltaFlags; + MobileDelta delta = m.m_DeltaFlags; if (delta == MobileDelta.None) return; @@ -3087,10 +3010,7 @@ namespace Server public virtual void AddNameProperties(ObjectPropertyList list) { - string name = Name; - - if (name == null) - name = string.Empty; + string name = Name ?? string.Empty; string prefix = ""; @@ -3106,10 +3026,8 @@ namespace Server if (guild != null && (m_Player || m_DisplayGuildTitle)) { - if (suffix.Length > 0) - suffix = string.Format("{0} [{1}]", suffix, Utility.FixHtml(guild.Abbreviation)); - else - suffix = string.Format("[{0}]", Utility.FixHtml(guild.Abbreviation)); + suffix = suffix.Length > 0 ? $"{suffix} [{Utility.FixHtml(guild.Abbreviation)}]" + : $"[{Utility.FixHtml(guild.Abbreviation)}]"; } suffix = ApplyNameSuffix(suffix); @@ -3125,12 +3043,7 @@ namespace Server else type = ""; - string title = GuildTitle; - - if (title == null) - title = ""; - else - title = title.Trim(); + string title = GuildTitle?.Trim() ?? ""; if (NewGuildDisplay && title.Length > 0) { @@ -3360,12 +3273,7 @@ namespace Server public bool InLOS(Point3D target) { - if (Deleted || m_Map == null) - return false; - if (m_AccessLevel > AccessLevel.Player) - return true; - - return m_Map.LineOfSight(this, target); + return !Deleted && m_Map != null && (m_AccessLevel > AccessLevel.Player || m_Map.LineOfSight(this, target)); } public bool BeginAction() @@ -3444,7 +3352,7 @@ namespace Server public override string ToString() { - return string.Format("0x{0:X} \"{1}\"", Serial.Value, Name); + return $"0x{Serial.Value:X} \"{Name}\""; } public virtual void SendSkillMessage() @@ -3860,7 +3768,7 @@ namespace Server BankBox box = FindBankNoCreate(); - if (box != null && box.Opened) + if (box?.Opened == true) box.Close(); Point3D newLocation = m_Location; @@ -3870,7 +3778,7 @@ namespace Server { // We are actually moving (not just a direction change) - if (m_Spell != null && !m_Spell.OnCasterMoving(d)) + if (m_Spell?.OnCasterMoving(d) == false) return false; if (m_Paralyzed || m_Frozen) @@ -4101,9 +4009,8 @@ namespace Server { if (ns.StygianAbyss) { - Packet p; int noto = Notoriety.Compute(m, this); - p = cache[0][noto]; + Packet p = cache[0][noto]; if (p == null) cache[0][noto] = p = Packet.Acquire(new MobileMoving(this, noto)); @@ -4112,9 +4019,8 @@ namespace Server } else { - Packet p; int noto = Notoriety.Compute(m, this); - p = cache[1][noto]; + Packet p = cache[1][noto]; if (p == null) cache[1][noto] = p = Packet.Acquire(new MobileMovingOld(this, noto)); @@ -4125,8 +4031,8 @@ namespace Server } for (int i = 0; i < cache.Length; ++i) - for (int j = 0; j < cache[i].Length; ++j) - Packet.Release(ref cache[i][j]); + for (int j = 0; j < cache[i].Length; ++j) + Packet.Release(ref cache[i][j]); for (int i = 0; i < m_MoveList.Count; ++i) { @@ -4297,7 +4203,7 @@ namespace Server BankBox box = FindBankNoCreate(); - if (box != null && box.Opened) + if (box?.Opened == true) box.Close(); Poison = null; @@ -4458,7 +4364,7 @@ namespace Server BankBox box = FindBankNoCreate(); - if (box != null && box.Opened) + if (box?.Opened == true) box.Close(); m_NetState?.CancelAllTrades(); @@ -4670,15 +4576,15 @@ namespace Server public virtual void Use(Item item) { - if (item == null || item.Deleted || item.QuestItem || Deleted) + if (item?.Deleted != false || item.QuestItem || Deleted) return; DisruptiveAction(); - if (m_Spell != null && !m_Spell.OnCasterUsingObject(item)) + if (m_Spell?.OnCasterUsingObject(item) == false) return; - object root = item.RootParent; + IEntity root = item.RootParent; bool okay = false; if (!Utility.InUpdateRange(this, item.GetWorldLocation())) @@ -4733,12 +4639,12 @@ namespace Server public virtual void Use(Mobile m) { - if (m == null || m.Deleted || Deleted) + if (m?.Deleted != false || Deleted) return; DisruptiveAction(); - if (m_Spell != null && !m_Spell.OnCasterUsingObject(m)) + if (m_Spell?.OnCasterUsingObject(m) == false) return; if (!Utility.InUpdateRange(this, m)) @@ -4800,7 +4706,7 @@ namespace Server } else { - object root = item.RootParent; + IEntity root = item.RootParent; if (root is Mobile mobile && !mobile.CheckNonlocalLift(from, item)) { @@ -4939,7 +4845,7 @@ namespace Server catch { Console.WriteLine( - "Warning: 0x{0:X}: Item must have a zero paramater constructor to be separated from a stack. '{1}'.", + "Warning: 0x{0:X}: Item must have a zero parameter constructor to be separated from a stack. '{1}'.", oldItem.Serial.Value, oldItem.GetType().Name); return null; } @@ -4975,7 +4881,7 @@ namespace Server if (DragEffects && !item.Deleted) { Map map = m_Map; - object root = item.RootParent; + IEntity root = item.RootParent; if (map != null && (root == null || root is Item)) { @@ -5213,24 +5119,24 @@ namespace Server foreach (IEntity o in eable) if (o is Mobile heard) { - if (heard.CanSee(this) && (NoSpeechLOS || !heard.Player || heard.InLOS(this))) + if (!heard.CanSee(this) || !NoSpeechLOS && heard.Player && !heard.InLOS(this)) + continue; + + if (heard.m_NetState != null) + hears.Add(heard); + + if (heard.HandlesOnSpeech(this)) + onSpeech.Add(heard); + + for (int i = 0; i < heard.Items.Count; ++i) { - if (heard.m_NetState != null) - hears.Add(heard); + Item item = heard.Items[i]; - if (heard.HandlesOnSpeech(this)) - onSpeech.Add(heard); + if (item.HandlesOnSpeech) + onSpeech.Add(item); - for (int i = 0; i < heard.Items.Count; ++i) - { - Item item = heard.Items[i]; - - if (item.HandlesOnSpeech) - onSpeech.Add(item); - - if (item is Container container) - AddSpeechItemsFrom(onSpeech, container); - } + if (item is Container container) + AddSpeechItemsFrom(onSpeech, container); } } else if (o is Item item) @@ -6255,7 +6161,7 @@ namespace Server public void AddItem(Item item) { - if (item == null || item.Deleted) + if (item?.Deleted != false) return; if (item.Parent == this) @@ -6801,17 +6707,17 @@ namespace Server return delta != 0 ? body : 0; } - public void FreeCache() + public virtual void FreeCache() { - Packet.Release(ref m_RemovePacket); - Packet.Release(ref m_PropertyList); - Packet.Release(ref m_OPLPacket); + StaticPacketHandlers.FreeRemoveItemPacket(this); + StaticPacketHandlers.FreeOPLInfoPacket(this); + StaticPacketHandlers.FreeOPLPacket(this); } public void ClearProperties() { - Packet.Release(ref m_PropertyList); - Packet.Release(ref m_OPLPacket); + StaticPacketHandlers.FreeOPLPacket(this); + StaticPacketHandlers.FreeOPLInfoPacket(this); } public void InvalidateProperties() @@ -6821,13 +6727,11 @@ namespace Server if (m_Map != null && m_Map != Map.Internal && !World.Loading) { - ObjectPropertyList oldList = m_PropertyList; - Packet.Release(ref m_PropertyList); - ObjectPropertyList newList = PropertyList; + ObjectPropertyList oldList = StaticPacketHandlers.FreeOPLPacket(this); - if (oldList == null || oldList.Hash != newList.Hash) + if (oldList?.Hash != PropertyList.Hash) { - Packet.Release(ref m_OPLPacket); + StaticPacketHandlers.FreeOPLInfoPacket(this); Delta(MobileDelta.Properties); } } @@ -6844,148 +6748,148 @@ namespace Server Point3D oldLocation = m_Location; - if (oldLocation != newLocation) + if (oldLocation == newLocation) + return; + + m_Location = newLocation; + UpdateRegion(); + + BankBox box = FindBankNoCreate(); + + if (box?.Opened == true) + box.Close(); + + m_NetState?.ValidateAllTrades(); + + m_Map?.OnMove(oldLocation, this); + + if (isTeleport && m_NetState != null && (!m_NetState.HighSeas || !NoMoveHS)) { - m_Location = newLocation; - UpdateRegion(); + m_NetState.Sequence = 0; - BankBox box = FindBankNoCreate(); + if (m_NetState.StygianAbyss) + m_NetState.Send(new MobileUpdate(this)); + else + m_NetState.Send(new MobileUpdateOld(this)); - if (box != null && box.Opened) - box.Close(); + ClearFastwalkStack(); + } - m_NetState?.ValidateAllTrades(); + Map map = m_Map; - m_Map?.OnMove(oldLocation, this); + if (map != null) + { + // First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange) - if (isTeleport && m_NetState != null && (!m_NetState.HighSeas || !NoMoveHS)) + IPooledEnumerable eable = map.GetClientsInRange(oldLocation); + + foreach (NetState ns in eable) + if (ns != m_NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location)) + ns.Send(RemovePacket); + + eable.Free(); + + NetState ourState = m_NetState; + + // Check to see if we are attached to a client + if (ourState != null) { - m_NetState.Sequence = 0; + IPooledEnumerable eeable = map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange); - if (m_NetState.StygianAbyss) - m_NetState.Send(new MobileUpdate(this)); - else - m_NetState.Send(new MobileUpdateOld(this)); + // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients - ClearFastwalkStack(); - } + foreach (IEntity o in eeable) + if (o is Item item) + { + int range = item.GetUpdateRange(this); + Point3D loc = item.Location; - Map map = m_Map; + if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) && + CanSee(item)) + item.SendInfoTo(ourState); + } + else if (o != this && o is Mobile m) + { + if (!Utility.InUpdateRange(newLocation, m.m_Location)) + continue; - if (map != null) - { - // First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange) + bool inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location); - IPooledEnumerable eable = map.GetClientsInRange(oldLocation); - - foreach (NetState ns in eable) - if (ns != m_NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location)) - ns.Send(RemovePacket); - - eable.Free(); - - NetState ourState = m_NetState; - - // Check to see if we are attached to a client - if (ourState != null) - { - IPooledEnumerable eeable = map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange); - - // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients - - foreach (IEntity o in eeable) - if (o is Item item) + if (m.m_NetState != null && + (isTeleport && (!m.m_NetState.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this)) { - int range = item.GetUpdateRange(this); - Point3D loc = item.Location; + m.m_NetState.Send(MobileIncoming.Create(m.m_NetState, m, this)); - if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) && - CanSee(item)) - item.SendInfoTo(ourState); - } - else if (o != this && o is Mobile m) - { - if (!Utility.InUpdateRange(newLocation, m.m_Location)) - continue; - - bool inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location); - - if (m.m_NetState != null && - (isTeleport && (!m.m_NetState.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this)) - { - m.m_NetState.Send(MobileIncoming.Create(m.m_NetState, m, this)); - - if (m.m_NetState.StygianAbyss) - { - //if ( m_Poison != null ) - m.m_NetState.Send(new HealthbarPoison(this)); - - //if ( m_Blessed || m_YellowHealthbar ) - m.m_NetState.Send(new HealthbarYellow(this)); - } - - if (IsDeadBondedPet) - m.m_NetState.Send(new BondedStatus(0, Serial, 1)); - - if (ObjectPropertyList.Enabled) m.m_NetState.Send(OPLPacket); - } - - if (!inOldRange && CanSee(m)) - { - ourState.Send(MobileIncoming.Create(ourState, this, m)); - - if (ourState.StygianAbyss) - { - //if ( m.Poisoned ) - ourState.Send(new HealthbarPoison(m)); - - //if ( m.Blessed || m.YellowHealthbar ) - ourState.Send(new HealthbarYellow(m)); - } - - if (m.IsDeadBondedPet) - ourState.Send(new BondedStatus(0, m.Serial, 1)); - - if (ObjectPropertyList.Enabled) ourState.Send(m.OPLPacket); - } - } - - eeable.Free(); - } - else - { - eable = map.GetClientsInRange(newLocation); - - // We're not attached to a client, so simply send an Incoming - foreach (NetState ns in eable) - if ((isTeleport && (!ns.HighSeas || !NoMoveHS) || - !Utility.InUpdateRange(oldLocation, ns.Mobile.Location)) && ns.Mobile.CanSee(this)) - { - ns.Send(MobileIncoming.Create(ns, ns.Mobile, this)); - - if (ns.StygianAbyss) + if (m.m_NetState.StygianAbyss) { //if ( m_Poison != null ) - ns.Send(new HealthbarPoison(this)); + m.m_NetState.Send(new HealthbarPoison(this)); //if ( m_Blessed || m_YellowHealthbar ) - ns.Send(new HealthbarYellow(this)); + m.m_NetState.Send(new HealthbarYellow(this)); } if (IsDeadBondedPet) - ns.Send(new BondedStatus(0, Serial, 1)); + m.m_NetState.Send(new BondedStatus(0, Serial, 1)); - if (ObjectPropertyList.Enabled) ns.Send(OPLPacket); + if (ObjectPropertyList.Enabled) m.m_NetState.Send(OPLPacket); } - eable.Free(); - } + if (inOldRange || !CanSee(m)) + continue; + + ourState.Send(MobileIncoming.Create(ourState, this, m)); + + if (ourState.StygianAbyss) + { + //if ( m.Poisoned ) + ourState.Send(new HealthbarPoison(m)); + + //if ( m.Blessed || m.YellowHealthbar ) + ourState.Send(new HealthbarYellow(m)); + } + + if (m.IsDeadBondedPet) + ourState.Send(new BondedStatus(0, m.Serial, 1)); + + if (ObjectPropertyList.Enabled) ourState.Send(m.OPLPacket); + } + + eeable.Free(); } + else + { + eable = map.GetClientsInRange(newLocation); - OnLocationChange(oldLocation); + // We're not attached to a client, so simply send an Incoming + foreach (NetState ns in eable) + if ((isTeleport && (!ns.HighSeas || !NoMoveHS) || + !Utility.InUpdateRange(oldLocation, ns.Mobile.Location)) && ns.Mobile.CanSee(this)) + { + ns.Send(MobileIncoming.Create(ns, ns.Mobile, this)); - Region.OnLocationChanged(this, oldLocation); + if (ns.StygianAbyss) + { + //if ( m_Poison != null ) + ns.Send(new HealthbarPoison(this)); + + //if ( m_Blessed || m_YellowHealthbar ) + ns.Send(new HealthbarYellow(this)); + } + + if (IsDeadBondedPet) + ns.Send(new BondedStatus(0, Serial, 1)); + + if (ObjectPropertyList.Enabled) ns.Send(OPLPacket); + } + + eable.Free(); + } } + + OnLocationChange(oldLocation); + + Region.OnLocationChanged(this, oldLocation); } /// @@ -7007,10 +6911,8 @@ namespace Server public BankBox FindBankNoCreate() { - if (m_BankBox != null && !m_BankBox.Deleted && m_BankBox.Parent == this) - return m_BankBox; - - m_BankBox = FindItemOnLayer(Layer.Bank) as BankBox; + if (m_BankBox?.Deleted != false || m_BankBox.Parent != this) + m_BankBox = FindItemOnLayer(Layer.Bank) as BankBox; return m_BankBox; } @@ -7032,32 +6934,32 @@ namespace Server public void SendIncomingPacket() { - if (m_Map != null) - { - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + if (m_Map == null) + return; - foreach (NetState state in eable) - if (state.Mobile.CanSee(this)) + IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + + foreach (NetState state in eable) + if (state.Mobile.CanSee(this)) + { + state.Send(MobileIncoming.Create(state, state.Mobile, this)); + + if (state.StygianAbyss) { - state.Send(MobileIncoming.Create(state, state.Mobile, this)); + if (m_Poison != null) + state.Send(new HealthbarPoison(this)); - if (state.StygianAbyss) - { - if (m_Poison != null) - state.Send(new HealthbarPoison(this)); - - if (m_Blessed || m_YellowHealthbar) - state.Send(new HealthbarYellow(this)); - } - - if (IsDeadBondedPet) - state.Send(new BondedStatus(0, Serial, 1)); - - if (ObjectPropertyList.Enabled) state.Send(OPLPacket); + if (m_Blessed || m_YellowHealthbar) + state.Send(new HealthbarYellow(this)); } - eable.Free(); - } + if (IsDeadBondedPet) + state.Send(new BondedStatus(0, Serial, 1)); + + if (ObjectPropertyList.Enabled) state.Send(OPLPacket); + } + + eable.Free(); } public bool PlaceInBackpack(Item item) @@ -7065,9 +6967,7 @@ namespace Server if (item.Deleted) return false; - Container pack = Backpack; - - return pack != null && pack.TryDropItem(this, item, false); + return Backpack?.TryDropItem(this, item, false) == true; } public bool AddToBackpack(Item item) @@ -7100,10 +7000,7 @@ namespace Server public virtual bool CheckNonlocalLift(Mobile from, Item item) { - if (from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster) - return true; - - return false; + return from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster; } public virtual bool CheckTrade(Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems, @@ -7112,12 +7009,7 @@ namespace Server return true; } - public bool OpenTrade(Mobile from) - { - return OpenTrade(from, null); - } - - public virtual bool OpenTrade(Mobile from, Item offer) + public virtual bool OpenTrade(Mobile from, Item offer = null) { if (!from.Player || !Player || !from.Alive || !Alive) return false; @@ -7149,15 +7041,10 @@ namespace Server if (from == this) { Container pack = Backpack; - - if (pack != null) - return dropped.DropToItem(from, pack, new Point3D(-1, -1, 0)); - - return false; + return pack != null && dropped.DropToItem(from, pack, new Point3D(-1, -1, 0)); } - if (from.InRange(Location, 2)) return OpenTrade(from, dropped); - return false; + return from.InRange(Location, 2) && OpenTrade(from, dropped); } public virtual bool CheckEquip(Item item) @@ -7278,10 +7165,7 @@ namespace Server public virtual bool CheckNonlocalDrop(Mobile from, Item item, Item target) { - if (from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster) - return true; - - return false; + return from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster; } public virtual bool CheckItemUse(Mobile from, Item item) @@ -7310,12 +7194,12 @@ namespace Server public virtual bool EquipItem(Item item) { - if (item == null || item.Deleted || !item.CanEquip(this)) + if (item?.Deleted != false || !item.CanEquip(this)) return false; if (CheckEquip(item) && OnEquip(item) && item.OnEquip(this)) { - if (m_Spell != null && !m_Spell.OnCasterEquipping(item)) + if (m_Spell?.OnCasterEquipping(item) == false) return false; //if ( m_Spell != null && m_Spell.State == SpellState.Casting ) @@ -7375,6 +7259,7 @@ namespace Server } catch { + // ignored } } else @@ -7395,34 +7280,29 @@ namespace Server } else { - while (m_DeltaQueue.Count > 0) m_DeltaQueue.Dequeue().ProcessDelta(); + while (m_DeltaQueue.Count > 0) + m_DeltaQueue.Dequeue().ProcessDelta(); } _processing = false; - while (m_DeltaQueueR.Count > 0) m_DeltaQueueR.Dequeue().ProcessDelta(); + while (m_DeltaQueueR.Count > 0) + m_DeltaQueueR.Dequeue().ProcessDelta(); } public virtual void OnKillsChange(int oldValue) { } - public bool CheckAlive() + public bool CheckAlive(bool message = true) { - return CheckAlive(true); - } + if (Alive) + return true; - public bool CheckAlive(bool message) - { - if (!Alive) - { - if (message) - LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019048); // I am dead and cannot do that. + if (message) + LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019048); // I am dead and cannot do that. - return false; - } - - return true; + return false; } public void LaunchBrowser(string url) @@ -7494,9 +7374,8 @@ namespace Server /// public virtual void OnSingleClick(Mobile from) { - if (Deleted) - return; - if (AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this) + if (Deleted || + AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this) return; if (GuildClickMessage) @@ -7534,10 +7413,7 @@ namespace Server else hue = Notoriety.GetHue(Notoriety.Compute(from, this)); - string name = Name; - - if (name == null) - name = string.Empty; + string name = Name ?? string.Empty; string prefix = ""; @@ -7546,7 +7422,7 @@ namespace Server string suffix = ""; - if (ClickTitle && Title != null && Title.Length > 0) + if (ClickTitle && !string.IsNullOrEmpty(Title)) suffix = Title; suffix = ApplyNameSuffix(suffix); @@ -7567,32 +7443,22 @@ namespace Server public bool CheckSkill(SkillName skill, double minSkill, double maxSkill) { - if (SkillCheckLocationHandler == null) - return false; - return SkillCheckLocationHandler(this, skill, minSkill, maxSkill); + return SkillCheckLocationHandler?.Invoke(this, skill, minSkill, maxSkill) == true; } public bool CheckSkill(SkillName skill, double chance) { - if (SkillCheckDirectLocationHandler == null) - return false; - return SkillCheckDirectLocationHandler(this, skill, chance); + return SkillCheckDirectLocationHandler?.Invoke(this, skill, chance) == true; } public bool CheckTargetSkill(SkillName skill, object target, double minSkill, double maxSkill) { - if (SkillCheckTargetHandler == null) - return false; - - return SkillCheckTargetHandler(this, skill, target, minSkill, maxSkill); + return SkillCheckTargetHandler?.Invoke(this, skill, target, minSkill, maxSkill) == true; } public bool CheckTargetSkill(SkillName skill, object target, double chance) { - if (SkillCheckDirectTargetHandler == null) - return false; - - return SkillCheckDirectTargetHandler(this, skill, target, chance); + return SkillCheckDirectTargetHandler?.Invoke(this, skill, target, chance) == true; } public virtual void DisruptiveAction() @@ -7770,31 +7636,16 @@ namespace Server } } - #region CompareTo(...) - - public int CompareTo(IEntity other) + int IComparable.CompareTo(IEntity other) { - if (other == null) - return -1; - - return Serial.CompareTo(other.Serial); + return other == null ? -1 : Serial.CompareTo(other.Serial); } public int CompareTo(Mobile other) { - return CompareTo((IEntity)other); + return other == null ? -1 : Serial.CompareTo(other.Serial); } - public int CompareTo(object other) - { - if (other == null || other is IEntity) - return CompareTo((IEntity)other); - - throw new ArgumentException(); - } - - #endregion - #region Handlers public static AllowBeneficialHandler AllowBeneficialHandler{ get; set; } @@ -8033,8 +7884,7 @@ namespace Server { private Mobile m_Mobile; - public CombatTimer(Mobile m) - : base(TimeSpan.FromSeconds(0.0), TimeSpan.FromSeconds(0.01), 0) + public CombatTimer(Mobile m) : base(TimeSpan.FromSeconds(0.0), TimeSpan.FromSeconds(0.01)) { m_Mobile = m; @@ -8044,32 +7894,32 @@ namespace Server protected override void OnTick() { - if (Core.TickCount - m_Mobile.NextCombatTime >= 0) + if (Core.TickCount - m_Mobile.NextCombatTime < 0) + return; + + Mobile combatant = m_Mobile.Combatant; + + // If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat + if (combatant?.Deleted != false || m_Mobile.Deleted || combatant.m_Map != m_Mobile.m_Map || + !combatant.Alive || !m_Mobile.Alive || !m_Mobile.CanSee(combatant) || combatant.IsDeadBondedPet || + m_Mobile.IsDeadBondedPet) { - Mobile combatant = m_Mobile.Combatant; + m_Mobile.Combatant = null; + return; + } - // If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat - if (combatant == null || combatant.Deleted || m_Mobile.Deleted || combatant.m_Map != m_Mobile.m_Map || - !combatant.Alive || !m_Mobile.Alive || !m_Mobile.CanSee(combatant) || combatant.IsDeadBondedPet || - m_Mobile.IsDeadBondedPet) - { - m_Mobile.Combatant = null; - return; - } + IWeapon weapon = m_Mobile.Weapon; - IWeapon weapon = m_Mobile.Weapon; + if (!m_Mobile.InRange(combatant, weapon.MaxRange)) + return; - if (!m_Mobile.InRange(combatant, weapon.MaxRange)) - return; - - if (m_Mobile.InLOS(combatant)) - { - weapon.OnBeforeSwing(m_Mobile, - combatant); //OnBeforeSwing for checking in regards to being hidden and whatnot - m_Mobile.RevealingAction(); - m_Mobile.NextCombatTime = - Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds; - } + if (m_Mobile.InLOS(combatant)) + { + weapon.OnBeforeSwing(m_Mobile, + combatant); //OnBeforeSwing for checking in regards to being hidden and whatnot + m_Mobile.RevealingAction(); + m_Mobile.NextCombatTime = + Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds; } } } @@ -8404,12 +8254,7 @@ namespace Server PublicOverheadMessage(MessageType.Regular, SpeechHue, number, type, affix, args); } - public void Say(int number) - { - Say(number, ""); - } - - public void Say(int number, string args) + public void Say(int number, string args = "") { PublicOverheadMessage(MessageType.Regular, SpeechHue, number, args); } @@ -8424,12 +8269,7 @@ namespace Server Emote(string.Format(format, args)); } - public void Emote(int number) - { - Emote(number, ""); - } - - public void Emote(int number, string args) + public void Emote(int number, string args = "") { PublicOverheadMessage(MessageType.Emote, EmoteHue, number, args); } @@ -8444,12 +8284,7 @@ namespace Server Whisper(string.Format(format, args)); } - public void Whisper(int number) - { - Whisper(number, ""); - } - - public void Whisper(int number, string args) + public void Whisper(int number, string args = "") { PublicOverheadMessage(MessageType.Whisper, WhisperHue, number, args); } @@ -8464,12 +8299,7 @@ namespace Server Yell(string.Format(format, args)); } - public void Yell(int number) - { - Yell(number, ""); - } - - public void Yell(int number, string args) + public void Yell(int number, string args = "") { PublicOverheadMessage(MessageType.Yell, YellHue, number, args); } @@ -8478,12 +8308,7 @@ namespace Server #region Gumps/Menus - public bool SendHuePicker(HuePicker p) - { - return SendHuePicker(p, false); - } - - public bool SendHuePicker(HuePicker p, bool throwOnOffline) + public bool SendHuePicker(HuePicker p, bool throwOnOffline = false) { if (m_NetState != null) { @@ -9750,88 +9575,64 @@ namespace Server #region Overhead messages - public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text) + public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight = true) { - PublicOverheadMessage(type, hue, ascii, text, true); + if (m_Map == null) + return; + + Packet p = ascii + ? (Packet)new AsciiMessage(Serial, Body, type, hue, 3, Name, text) + : new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text); + + p.Acquire(); + + IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + + foreach (NetState state in eable) + if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) + state.Send(p); + + Packet.Release(p); + + eable.Free(); } - public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight) + public void PublicOverheadMessage(MessageType type, int hue, int number, string args = "", bool noLineOfSight = true) { - if (m_Map != null) - { - Packet p = null; + if (m_Map == null) + return; - if (ascii) - p = new AsciiMessage(Serial, Body, type, hue, 3, Name, text); - else - p = new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text); + Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); - p.Acquire(); + IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + foreach (NetState state in eable) + if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) + state.Send(p); - foreach (NetState state in eable) - if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) - state.Send(p); + Packet.Release(p); - Packet.Release(p); - - eable.Free(); - } - } - - public void PublicOverheadMessage(MessageType type, int hue, int number) - { - PublicOverheadMessage(type, hue, number, "", true); - } - - public void PublicOverheadMessage(MessageType type, int hue, int number, string args) - { - PublicOverheadMessage(type, hue, number, args, true); - } - - public void PublicOverheadMessage(MessageType type, int hue, int number, string args, bool noLineOfSight) - { - if (m_Map != null) - { - Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); - - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); - - foreach (NetState state in eable) - if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) - state.Send(p); - - Packet.Release(p); - - eable.Free(); - } + eable.Free(); } public void PublicOverheadMessage(MessageType type, int hue, int number, AffixType affixType, string affix, - string args) + string args = "", bool noLineOfSight = false) { - PublicOverheadMessage(type, hue, number, affixType, affix, args, true); - } + if (m_Map == null) + return; - public void PublicOverheadMessage(MessageType type, int hue, int number, AffixType affixType, string affix, - string args, bool noLineOfSight) - { - if (m_Map != null) - { - Packet p = Packet.Acquire(new MessageLocalizedAffix(Serial, Body, type, hue, 3, number, Name, affixType, - affix, args)); + Packet p = Packet.Acquire(new MessageLocalizedAffix(Serial, Body, type, hue, 3, number, Name, affixType, + affix, args)); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) - if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) - state.Send(p); + foreach (NetState state in eable) + if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) + state.Send(p); - Packet.Release(p); + Packet.Release(p); - eable.Free(); - } + eable.Free(); } public void PrivateOverheadMessage(MessageType type, int hue, bool ascii, string text, NetState state) @@ -9859,73 +9660,58 @@ namespace Server { NetState ns = m_NetState; - if (ns != null) - { - if (ascii) - ns.Send(new AsciiMessage(Serial, Body, type, hue, 3, Name, text)); - else - ns.Send(new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text)); - } + if (ns == null) + return; + + if (ascii) + ns.Send(new AsciiMessage(Serial, Body, type, hue, 3, Name, text)); + else + ns.Send(new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text)); } - public void LocalOverheadMessage(MessageType type, int hue, int number) + public void LocalOverheadMessage(MessageType type, int hue, int number, string args = "") { - LocalOverheadMessage(type, hue, number, ""); + m_NetState?.Send(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); } - public void LocalOverheadMessage(MessageType type, int hue, int number, string args) + public void NonlocalOverheadMessage(MessageType type, int hue, int number, string args = "") { - NetState ns = m_NetState; + if (m_Map == null) + return; - ns?.Send(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); - } + Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); - public void NonlocalOverheadMessage(MessageType type, int hue, int number) - { - NonlocalOverheadMessage(type, hue, number, ""); - } + IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); - public void NonlocalOverheadMessage(MessageType type, int hue, int number, string args) - { - if (m_Map != null) - { - Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); + foreach (NetState state in eable) + if (state != m_NetState && state.Mobile.CanSee(this)) + state.Send(p); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + Packet.Release(p); - foreach (NetState state in eable) - if (state != m_NetState && state.Mobile.CanSee(this)) - state.Send(p); - - Packet.Release(p); - - eable.Free(); - } + eable.Free(); } public void NonlocalOverheadMessage(MessageType type, int hue, bool ascii, string text) { - if (m_Map != null) - { - Packet p = null; + if (m_Map == null) + return; - if (ascii) - p = new AsciiMessage(Serial, Body, type, hue, 3, Name, text); - else - p = new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text); + Packet p = ascii + ? (Packet)new AsciiMessage(Serial, Body, type, hue, 3, Name, text) + : new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text); - p.Acquire(); + p.Acquire(); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) - if (state != m_NetState && state.Mobile.CanSee(this)) - state.Send(p); + foreach (NetState state in eable) + if (state != m_NetState && state.Mobile.CanSee(this)) + state.Send(p); - Packet.Release(p); + Packet.Release(p); - eable.Free(); - } + eable.Free(); } #endregion @@ -9934,47 +9720,20 @@ namespace Server public void SendLocalizedMessage(int number) { - NetState ns = m_NetState; - - ns?.Send(MessageLocalized.InstantiateGeneric(number)); + m_NetState?.Send(MessageLocalized.InstantiateGeneric(number)); } - public void SendLocalizedMessage(int number, string args) + public void SendLocalizedMessage(int number, string args, int hue = 0x3B2) { - SendLocalizedMessage(number, args, 0x3B2); - } - - public void SendLocalizedMessage(int number, string args, int hue) - { - if (hue == 0x3B2 && (args == null || args.Length == 0)) - { - NetState ns = m_NetState; - - ns?.Send(MessageLocalized.InstantiateGeneric(number)); - } + if (hue == 0x3B2 && string.IsNullOrEmpty(args)) + m_NetState?.Send(MessageLocalized.InstantiateGeneric(number)); else - { - NetState ns = m_NetState; - - ns?.Send(new MessageLocalized(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", args)); - } + m_NetState?.Send(new MessageLocalized(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", args)); } - public void SendLocalizedMessage(int number, bool append, string affix) + public void SendLocalizedMessage(int number, bool append, string affix, string args = "", int hue = 0x3B2) { - SendLocalizedMessage(number, append, affix, "", 0x3B2); - } - - public void SendLocalizedMessage(int number, bool append, string affix, string args) - { - SendLocalizedMessage(number, append, affix, args, 0x3B2); - } - - public void SendLocalizedMessage(int number, bool append, string affix, string args, int hue) - { - NetState ns = m_NetState; - - ns?.Send(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", + m_NetState?.Send(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Regular, hue, 3, number, "System", (append ? AffixType.Append : AffixType.Prepend) | AffixType.System, affix, args)); } @@ -9994,9 +9753,7 @@ namespace Server public void SendMessage(int hue, string text) { - NetState ns = m_NetState; - - ns?.Send(new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text)); + m_NetState?.Send(new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text)); } public void SendMessage(int hue, string format, params object[] args) @@ -10016,9 +9773,7 @@ namespace Server public void SendAsciiMessage(int hue, string text) { - NetState ns = m_NetState; - - ns?.Send(new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text)); + m_NetState?.Send(new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text)); } public void SendAsciiMessage(int hue, string format, params object[] args) diff --git a/Server/NativeReader.cs b/Server/NativeReader.cs index 788d9d951..c561a051b 100644 --- a/Server/NativeReader.cs +++ b/Server/NativeReader.cs @@ -51,12 +51,11 @@ namespace Server { public unsafe void Read(IntPtr ptr, void* buffer, int length) { - //UnsafeNativeMethods._lread( ptr, buffer, length ); uint lpNumberOfBytesRead = 0; UnsafeNativeMethods.ReadFile(ptr, buffer, (uint)length, ref lpNumberOfBytesRead, null); } - internal class UnsafeNativeMethods + internal static class UnsafeNativeMethods { /*[DllImport("kernel32")] internal unsafe static extern int _lread(IntPtr hFile, void* lpBuffer, int wBytes);*/ @@ -74,10 +73,10 @@ namespace Server UnsafeNativeMethods.read(ptr, buffer, length); } - internal class UnsafeNativeMethods + internal static class UnsafeNativeMethods { [DllImport("libc")] internal static extern unsafe int read(IntPtr ptr, void* buffer, int length); } } -} \ No newline at end of file +} diff --git a/Server/Network/Listener.cs b/Server/Network/Listener.cs index a45d1e053..13a9afef9 100644 --- a/Server/Network/Listener.cs +++ b/Server/Network/Listener.cs @@ -35,11 +35,7 @@ namespace Server.Network private Queue m_Accepted; private object m_AcceptedSyncRoot; -#if NewAsyncSockets private SocketAsyncEventArgs m_EventArgs; -#else - private AsyncCallback m_OnAccept; -#endif private static Socket[] m_EmptySockets = new Socket[0]; @@ -57,19 +53,9 @@ namespace Server.Network DisplayListener(); -#if NewAsyncSockets m_EventArgs = new SocketAsyncEventArgs(); m_EventArgs.Completed += Accept_Completion; Accept_Start(); -#else - m_OnAccept = new AsyncCallback( OnAccept ); - try { - IAsyncResult res = m_Listener.BeginAccept( m_OnAccept, m_Listener ); - } catch ( SocketException ex ) { - NetState.TraceException( ex ); - } catch ( ObjectDisposedException ) { - } -#endif } private Socket Bind(IPEndPoint ipep) @@ -144,10 +130,9 @@ namespace Server.Network } } -#if NewAsyncSockets private void Accept_Start() { - bool result = false; + bool result; do { @@ -187,36 +172,6 @@ namespace Server.Network e.AcceptSocket = null; } -#else - private void OnAccept( IAsyncResult asyncResult ) { - Socket listener = (Socket) asyncResult.AsyncState; - - Socket accepted = null; - - try { - accepted = listener.EndAccept( asyncResult ); - } catch ( SocketException ex ) { - NetState.TraceException( ex ); - } catch ( ObjectDisposedException ) { - return; - } - - if ( accepted != null ) { - if ( VerifySocket( accepted ) ) { - Enqueue( accepted ); - } else { - Release( accepted ); - } - } - - try { - listener.BeginAccept( m_OnAccept, listener ); - } catch ( SocketException ex ) { - NetState.TraceException( ex ); - } catch ( ObjectDisposedException ) { - } - } -#endif private bool VerifySocket(Socket socket) { @@ -299,4 +254,4 @@ namespace Server.Network GC.SuppressFinalize(this); } } -} \ No newline at end of file +} diff --git a/Server/Network/MessagePump.cs b/Server/Network/MessagePump.cs index 05a5042c0..e1d324f81 100644 --- a/Server/Network/MessagePump.cs +++ b/Server/Network/MessagePump.cs @@ -252,7 +252,7 @@ namespace Server.Network ThrottlePacketCallback throttler = handler.ThrottleCallback; - if (throttler != null && !throttler(ns)) + if (throttler?.Invoke(ns) == false) { m_Throttled.Enqueue(ns); return; @@ -260,7 +260,8 @@ namespace Server.Network PacketReceiveProfile prof = null; - if (Core.Profiling) prof = PacketReceiveProfile.Acquire(packetID); + if (Core.Profiling) + prof = PacketReceiveProfile.Acquire(packetID); prof?.Start(); @@ -286,4 +287,4 @@ namespace Server.Network } } } -} \ No newline at end of file +} diff --git a/Server/Network/NetState.cs b/Server/Network/NetState.cs index d483d97b4..2bfa00c6d 100644 --- a/Server/Network/NetState.cs +++ b/Server/Network/NetState.cs @@ -48,11 +48,8 @@ namespace Server.Network private byte[] m_RecvBuffer; private SendQueue m_SendQueue; -#if NewAsyncSockets - private SocketAsyncEventArgs m_ReceiveEventArgs, m_SendEventArgs; -#else - private AsyncCallback m_OnReceive, m_OnSend; -#endif + private SocketAsyncEventArgs m_ReceiveEventArgs; + private SocketAsyncEventArgs m_SendEventArgs; private MessagePump m_MessagePump; private string m_ToString; @@ -451,62 +448,7 @@ namespace Server.Network byte[] buffer = p.Compile(CompressionEnabled, out int length); - if (buffer != null) - { - if (buffer.Length <= 0 || length <= 0) - { - p.OnSend(); - return; - } - - PacketSendProfile prof = null; - - if (Core.Profiling) prof = PacketSendProfile.Acquire(p.GetType()); - - prof?.Start(); - - PacketEncoder?.EncodeOutgoingPacket(this, ref buffer, ref length); - - try - { - SendQueue.Gram gram; - - lock (_sendL) - { - lock (m_SendQueue) - { - gram = m_SendQueue.Enqueue(buffer, length); - } - - if (gram != null && !_sending) - { - _sending = true; -#if NewAsyncSockets - m_SendEventArgs.SetBuffer(gram.Buffer, 0, gram.Length); - Send_Start(); -#else - try { - m_Socket.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, m_Socket); - } - catch (Exception ex) { - TraceException(ex); - Dispose(false); - } -#endif - } - } - } - catch (CapacityExceededException) - { - Console.WriteLine("Client: {0}: Too much data pending, disconnecting...", this); - Dispose(false); - } - - p.OnSend(); - - prof?.Finish(length); - } - else + if (buffer == null) { Console.WriteLine("Client: {0}: null buffer send, disconnecting...", this); using (StreamWriter op = new StreamWriter("null_send.log", true)) @@ -516,10 +458,53 @@ namespace Server.Network } Dispose(); + return; } + + if (buffer.Length <= 0 || length <= 0) + { + p.OnSend(); + return; + } + + PacketSendProfile prof = null; + + if (Core.Profiling) + prof = PacketSendProfile.Acquire(p.GetType()); + + prof?.Start(); + + PacketEncoder?.EncodeOutgoingPacket(this, ref buffer, ref length); + + try + { + lock (_sendL) + { + SendQueue.Gram gram; + lock (m_SendQueue) + { + gram = m_SendQueue.Enqueue(buffer, length); + } + + if (gram != null && !_sending) + { + _sending = true; + m_SendEventArgs.SetBuffer(gram.Buffer, 0, gram.Length); + Send_Start(); + } + } + } + catch (CapacityExceededException) + { + Console.WriteLine("Client: {0}: Too much data pending, disconnecting...", this); + Dispose(false); + } + + p.OnSend(); + + prof?.Finish(length); } -#if NewAsyncSockets public void Start() { m_ReceiveEventArgs = new SocketAsyncEventArgs(); @@ -582,7 +567,8 @@ namespace Server.Network return; } - if (IsDisposing) return; + if (IsDisposing) + return; m_NextCheckActivity = Core.TickCount + 90000; @@ -607,7 +593,7 @@ namespace Server.Network { try { - bool result = false; + bool result; do { @@ -736,190 +722,10 @@ namespace Server.Network return false; } -#else - public void Start() { - m_OnReceive = new AsyncCallback( OnReceive ); - m_OnSend = new AsyncCallback( OnSend ); - - m_Running = true; - - if ( m_Socket == null || m_Paused ) { - return; - } - - try { - lock ( m_AsyncLock ) { - if ( ( m_AsyncState & ( AsyncState.Pending | AsyncState.Paused ) ) == 0 ) { - InternalBeginReceive(); - } - } - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } - } - - private void InternalBeginReceive() { - m_AsyncState |= AsyncState.Pending; - - m_Socket.BeginReceive( m_RecvBuffer, 0, m_RecvBuffer.Length, SocketFlags.None, m_OnReceive, m_Socket ); - } - - private void OnReceive( IAsyncResult asyncResult ) { - Socket s = (Socket)asyncResult.AsyncState; - - try { - int byteCount = s.EndReceive( asyncResult ); - - if ( byteCount > 0 ) { - m_NextCheckActivity = Core.TickCount + 90000; - - byte[] buffer = m_RecvBuffer; - - if ( m_Encoder != null ) - m_Encoder.DecodeIncomingPacket( this, ref buffer, ref byteCount ); - - lock ( m_Buffer ) - m_Buffer.Enqueue( buffer, 0, byteCount ); - - m_MessagePump.OnReceive( this ); - - lock ( m_AsyncLock ) { - m_AsyncState &= ~AsyncState.Pending; - - if ( ( m_AsyncState & AsyncState.Paused ) == 0 ) { - try { - InternalBeginReceive(); - } catch ( Exception ex ) { - TraceException( ex ); - Dispose( false ); - } - } - } - } else { - Dispose( false ); - } - } catch { - Dispose( false ); - } - } - - private void OnSend( IAsyncResult asyncResult ) { - Socket s = (Socket)asyncResult.AsyncState; - - try { - int bytes = s.EndSend( asyncResult ); - - if ( bytes <= 0 ) { - Dispose( false ); - return; - } - - m_NextCheckActivity = Core.TickCount + 90000; - - if (m_CoalesceSleep >= 0) { - Thread.Sleep(m_CoalesceSleep); - } - - SendQueue.Gram gram; - - lock (m_SendQueue) { - gram = m_SendQueue.Dequeue(); - - if (gram == null && m_SendQueue.IsFlushReady) - gram = m_SendQueue.CheckFlushReady(); - } - - if (gram != null) { - try { - s.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, s); - } catch (Exception ex) { - TraceException(ex); - Dispose(false); - } - } else { - lock (_sendL) - _sending = false; - } - } catch ( Exception ){ - Dispose( false ); - } - } - - public static void Pause() { - m_Paused = true; - - for ( int i = 0; i < m_Instances.Count; ++i ) { - NetState ns = m_Instances[i]; - - lock ( ns.m_AsyncLock ) { - ns.m_AsyncState |= AsyncState.Paused; - } - } - } - - public static void Resume() { - m_Paused = false; - - for ( int i = 0; i < m_Instances.Count; ++i ) { - NetState ns = m_Instances[i]; - - if ( ns.m_Socket == null ) { - continue; - } - - lock ( ns.m_AsyncLock ) { - ns.m_AsyncState &= ~AsyncState.Paused; - - try { - if ( ( ns.m_AsyncState & AsyncState.Pending ) == 0 ) - ns.InternalBeginReceive(); - } catch ( Exception ex ) { - TraceException( ex ); - ns.Dispose( false ); - } - } - } - } - - public bool Flush() { - if (m_Socket == null) - return false; - - lock (_sendL) { - if (_sending) - return false; - - SendQueue.Gram gram; - - lock (m_SendQueue) { - if (!m_SendQueue.IsFlushReady) - return false; - - gram = m_SendQueue.CheckFlushReady(); - } - - if (gram != null) { - try { - _sending = true; - m_Socket.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, m_Socket); - return true; - } catch (Exception ex) { - TraceException(ex); - Dispose(false); - } - } - } - - return false; - } -#endif - public PacketHandler GetHandler(int packetID) { - if (ContainerGridLines) - return PacketHandlers.Get6017Handler(packetID); - return PacketHandlers.GetHandler(packetID); + return ContainerGridLines ? PacketHandlers.Get6017Handler(packetID) : + PacketHandlers.GetHandler(packetID); } public static void FlushAll() @@ -937,13 +743,10 @@ namespace Server.Network public void CheckAlive(long curTicks) { - if (Socket == null) + if (Socket == null || m_NextCheckActivity - curTicks >= 0) return; - if (m_NextCheckActivity - curTicks >= 0) return; - Console.WriteLine("Client: {0}: Disconnecting due to inactivity...", this); - Dispose(); } @@ -966,6 +769,7 @@ namespace Server.Network } catch { + // ignored } try @@ -974,19 +778,16 @@ namespace Server.Network } catch { + // ignored } } public bool IsDisposing{ get; private set; } - public void Dispose() + public virtual void Dispose(bool flush = true) { - Dispose(true); - } - - public virtual void Dispose(bool flush) - { - if (Socket == null || IsDisposing) return; + if (Socket == null || IsDisposing) + return; IsDisposing = true; @@ -1022,13 +823,8 @@ namespace Server.Network Buffer = null; m_RecvBuffer = null; -#if NewAsyncSockets m_ReceiveEventArgs = null; m_SendEventArgs = null; -#else - m_OnReceive = null; - m_OnSend = null; -#endif Running = false; @@ -1132,38 +928,22 @@ namespace Server.Network public Expansion Expansion => (Expansion)ExpansionInfo.ID; - public bool SupportsExpansion(ExpansionInfo info, bool checkCoreExpansion) + public bool SupportsExpansion(ExpansionInfo info, bool checkCoreExpansion = true) { if (info == null || checkCoreExpansion && (int)Core.Expansion < info.ID) return false; - if (info.RequiredClient != null) - return Version >= info.RequiredClient; - - return (Flags & info.ClientFlags) != 0; + return info.RequiredClient != null ? Version >= info.RequiredClient : (Flags & info.ClientFlags) != 0; } - public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion) + public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion = true) { return SupportsExpansion(ExpansionInfo.GetInfo(ex), checkCoreExpansion); } - public bool SupportsExpansion(Expansion ex) - { - return SupportsExpansion(ex, true); - } - - public bool SupportsExpansion(ExpansionInfo info) - { - return SupportsExpansion(info, true); - } - public int CompareTo(NetState other) { - if (other == null) - return 1; - - return m_ToString.CompareTo(other.m_ToString); + return other == null ? 1 : m_ToString.CompareTo(other.m_ToString); } } -} \ No newline at end of file +} diff --git a/Server/Network/PacketHandlers.cs b/Server/Network/PacketHandlers.cs index 0fdd794aa..b0b62e192 100644 --- a/Server/Network/PacketHandlers.cs +++ b/Server/Network/PacketHandlers.cs @@ -801,6 +801,7 @@ namespace Server.Network } catch { + // ignored } break; @@ -1025,10 +1026,7 @@ namespace Server.Network if (!valid) return; pvSrc.Seek(5, SeekOrigin.Current); - Mobile to = World.FindMobile(pvSrc.ReadUInt32()); - - if (to == null) - to = from; + Mobile to = World.FindMobile(pvSrc.ReadUInt32()) ?? from; if (!to.AllowEquipFrom(from) || !to.EquipItem(item)) item.Bounce(from); @@ -1478,14 +1476,14 @@ namespace Server.Network { Mobile m = World.FindMobile(s); - if (m != null && !m.Deleted) + if (m?.Deleted == false) from.Use(m); } else if (s.IsItem) { Item item = World.FindItem(s); - if (item != null && !item.Deleted) + if (item?.Deleted == false) from.Use(item); } } @@ -1525,7 +1523,7 @@ namespace Server.Network { Item item = World.FindItem(s); - if (item != null && !item.Deleted && from.CanSee(item) && + if (item?.Deleted == false && from.CanSee(item) && Utility.InUpdateRange(from.Location, item.GetWorldLocation())) { if (SingleClickProps) @@ -1705,7 +1703,7 @@ namespace Server.Network { Item item = World.FindItem(s); - if (item != null && !item.Deleted && from.CanSee(item) && + if (item?.Deleted == false && from.CanSee(item) && Utility.InUpdateRange(from.Location, item.GetWorldLocation())) item.SendPropertiesTo(from); } @@ -1732,7 +1730,7 @@ namespace Server.Network { Item item = World.FindItem(s); - if (item != null && !item.Deleted && from.CanSee(item) && + if (item?.Deleted == false && from.CanSee(item) && Utility.InUpdateRange(from.Location, item.GetWorldLocation())) item.SendPropertiesTo(from); } @@ -2374,13 +2372,10 @@ namespace Server.Network bool female = genderRace % 2 != 0; - Race race = null; + Race race; byte raceID = (byte)(genderRace < 4 ? 0 : genderRace / 2 - 1); - race = Race.Races[raceID]; - - if (race == null) - race = Race.DefaultRace; + race = Race.Races[raceID] ?? Race.DefaultRace; CityInfo[] info = state.CityInfo; IAccount a = state.Account; diff --git a/Server/Network/PacketWriter.cs b/Server/Network/PacketWriter.cs index 3aabd432e..e45a1e12b 100644 --- a/Server/Network/PacketWriter.cs +++ b/Server/Network/PacketWriter.cs @@ -44,18 +44,11 @@ namespace Server.Network ///
private MemoryStream m_Stream; - /// - /// Instantiates a new PacketWriter instance with the default capacity of 4 bytes. - /// - public PacketWriter() : this(32) - { - } - /// /// Instantiates a new PacketWriter instance with a given capacity. /// /// Initial capacity for the internal stream. - public PacketWriter(int capacity) + public PacketWriter(int capacity = 32) { m_Stream = new MemoryStream(capacity); m_Capacity = capacity; @@ -103,10 +96,7 @@ namespace Server.Network } } - if (pw == null) - pw = new PacketWriter(capacity); - - return pw; + return pw ?? new PacketWriter(capacity); } public static void ReleaseInstance(PacketWriter pw) @@ -456,4 +446,4 @@ namespace Server.Network return m_Stream.ToArray(); } } -} \ No newline at end of file +} diff --git a/Server/Network/Packets.cs b/Server/Network/Packets.cs index 42fbf30f6..a08633c70 100644 --- a/Server/Network/Packets.cs +++ b/Server/Network/Packets.cs @@ -382,10 +382,7 @@ namespace Server.Network m_Stream.Write(bis.Price); - string desc = bis.Description; - - if (desc == null) - desc = ""; + string desc = bis.Description ?? ""; m_Stream.Write((byte)(desc.Length + 1)); m_Stream.WriteAsciiNull(desc); @@ -466,11 +463,7 @@ namespace Server.Network m_Stream.Write(m.Serial); m_Stream.Write((byte)0); - int lockBits = 0; - - lockBits |= (int)m.StrLock << 4; - lockBits |= (int)m.DexLock << 2; - lockBits |= (int)m.IntLock; + int lockBits = (int)m.StrLock << 4 | (int)m.DexLock << 2 | (int)m.IntLock; m_Stream.Write((byte)lockBits); } @@ -478,11 +471,7 @@ namespace Server.Network public class EquipInfoAttribute { - public EquipInfoAttribute(int number) : this(number, -1) - { - } - - public EquipInfoAttribute(int number, int charges) + public EquipInfoAttribute(int number, int charges = -1) { Number = number; Charges = charges; @@ -1046,9 +1035,8 @@ namespace Server.Network int hue = item.Hue; - if (parent != null) - if (parent.SolidHueOverride >= 0) - hue = parent.SolidHueOverride; + if (parent?.SolidHueOverride >= 0) + hue = parent.SolidHueOverride; m_Stream.Write(item.Serial); m_Stream.Write((short)item.ItemID); @@ -1070,7 +1058,7 @@ namespace Server.Network // +2 - Hue // +1 - Flags - uint serial = (uint)item.Serial.Value; + uint serial = item.Serial.Value; int itemID = item.ItemID & 0x3FFF; int amount = item.Amount; Point3D loc = item.Location; @@ -2030,19 +2018,11 @@ namespace Server.Network } } - public sealed class RemoveItem : Packet + public sealed class RemoveEntity : Packet { - public RemoveItem(Item item) : base(0x1D, 5) + public RemoveEntity(IEntity entity) : base(0x1D, 5) { - m_Stream.Write(item.Serial); - } - } - - public sealed class RemoveMobile : Packet - { - public RemoveMobile(Mobile m) : base(0x1D, 5) - { - m_Stream.Write(m.Serial); + m_Stream.Write(entity.Serial); } } @@ -2441,10 +2421,7 @@ namespace Server.Network for (int i = 0; i < strings.Count; ++i) { - string v = strings[i]; - - if (v == null) - v = string.Empty; + string v = strings[i] ?? ""; m_Strings.Write((ushort)v.Length); m_Strings.WriteBigUniFixed(v, v.Length); @@ -2603,10 +2580,7 @@ namespace Server.Network for (int i = 0; i < text.Count; ++i) { - string v = text[i]; - - if (v == null) - v = string.Empty; + string v = text[i] ?? ""; int length = (ushort)v.Length; @@ -2639,13 +2613,11 @@ namespace Server.Network for (int i = 0; i < text.Length; ++i) { - string v = text[i]; + string v = text[i] ?? ""; - if (v == null) v = ""; + ushort length = (ushort)v.Length; - int length = (ushort)v.Length; - - m_Stream.Write((ushort)length); + m_Stream.Write(length); m_Stream.WriteBigUniFixed(v, length); } } @@ -2774,11 +2746,7 @@ namespace Server.Network new SeasonChange[2] }; - public SeasonChange(int season) : this(season, true) - { - } - - public SeasonChange(int season, bool playSound) : base(0xBC, 3) + public SeasonChange(int season, bool playSound = true) : base(0xBC, 3) { m_Stream.Write((byte)season); m_Stream.Write(playSound); @@ -2979,14 +2947,10 @@ namespace Server.Network { public MobileName(Mobile m) : base(0x98) { - string name = m.Name; - - if (name == null) name = ""; - EnsureCapacity(37); m_Stream.Write(m.Serial); - m_Stream.WriteAsciiFixed(name, 30); + m_Stream.WriteAsciiFixed(m.Name ?? "", 30); } } @@ -3020,13 +2984,10 @@ namespace Server.Network { public MobileStatusCompact(bool canBeRenamed, Mobile m) : base(0x11) { - string name = m.Name; - if (name == null) name = ""; - EnsureCapacity(43); m_Stream.Write(m.Serial); - m_Stream.WriteAsciiFixed(name, 30); + m_Stream.WriteAsciiFixed(m.Name ?? "", 30); AttributeNormalizer.WriteReverse(m_Stream, m.Hits, m.HitsMax); @@ -3044,17 +3005,16 @@ namespace Server.Network public MobileStatusExtended(Mobile m, NetState ns) : base(0x11) { - string name = m.Name; - if (name == null) name = ""; + string name = m.Name ?? ""; int type; - if (Core.HS && ns != null && ns.ExtendedStatus) + if (Core.HS && ns?.ExtendedStatus == true) { type = 6; EnsureCapacity(121); } - else if (Core.ML && ns != null && ns.SupportsExpansion(Expansion.ML)) + else if (Core.ML && ns?.SupportsExpansion(Expansion.ML) == true) { type = 5; EnsureCapacity(91); @@ -3141,8 +3101,7 @@ namespace Server.Network public MobileStatus(Mobile beholder, Mobile beheld, NetState ns) : base(0x11) { - string name = beheld.Name; - if (name == null) name = ""; + string name = beheld.Name ?? ""; int type; @@ -3151,12 +3110,12 @@ namespace Server.Network type = 0; EnsureCapacity(43); } - else if (Core.HS && ns != null && ns.ExtendedStatus) + else if (Core.HS && ns?.ExtendedStatus == true) { type = 6; EnsureCapacity(121); } - else if (Core.ML && ns != null && ns.SupportsExpansion(Expansion.ML)) + else if (Core.ML && ns?.SupportsExpansion(Expansion.ML) == true) { type = 5; EnsureCapacity(91); @@ -3180,61 +3139,61 @@ namespace Server.Network m_Stream.Write((byte)type); - if (type > 0) + if (type <= 0) + return; + + m_Stream.Write(beheld.Female); + + m_Stream.Write((short)beheld.Str); + m_Stream.Write((short)beheld.Dex); + m_Stream.Write((short)beheld.Int); + + WriteAttr(beheld.Stam, beheld.StamMax); + WriteAttr(beheld.Mana, beheld.ManaMax); + + m_Stream.Write(beheld.TotalGold); + m_Stream.Write((short)(Core.AOS ? beheld.PhysicalResistance : (int)(beheld.ArmorRating + 0.5))); + m_Stream.Write((short)(Mobile.BodyWeight + beheld.TotalWeight)); + + if (type >= 5) { - m_Stream.Write(beheld.Female); - - m_Stream.Write((short)beheld.Str); - m_Stream.Write((short)beheld.Dex); - m_Stream.Write((short)beheld.Int); - - WriteAttr(beheld.Stam, beheld.StamMax); - WriteAttr(beheld.Mana, beheld.ManaMax); - - m_Stream.Write(beheld.TotalGold); - m_Stream.Write((short)(Core.AOS ? beheld.PhysicalResistance : (int)(beheld.ArmorRating + 0.5))); - m_Stream.Write((short)(Mobile.BodyWeight + beheld.TotalWeight)); - - if (type >= 5) - { - m_Stream.Write((short)beheld.MaxWeight); - m_Stream.Write((byte)(beheld.Race.RaceID + 1)); // Would be 0x00 if it's a non-ML enabled account but... - } - - m_Stream.Write((short)beheld.StatCap); - - m_Stream.Write((byte)beheld.Followers); - m_Stream.Write((byte)beheld.FollowersMax); - - if (type >= 4) - { - m_Stream.Write((short)beheld.FireResistance); // Fire - m_Stream.Write((short)beheld.ColdResistance); // Cold - m_Stream.Write((short)beheld.PoisonResistance); // Poison - m_Stream.Write((short)beheld.EnergyResistance); // Energy - m_Stream.Write((short)beheld.Luck); // Luck - - IWeapon weapon = beheld.Weapon; - - if (weapon != null) - { - weapon.GetStatusDamage(beheld, out int min, out int max); - m_Stream.Write((short)min); // Damage min - m_Stream.Write((short)max); // Damage max - } - else - { - m_Stream.Write((short)0); // Damage min - m_Stream.Write((short)0); // Damage max - } - - m_Stream.Write(beheld.TithingPoints); - } - - if (type >= 6) - for (int i = 0; i < 15; ++i) - m_Stream.Write((short)beheld.GetAOSStatus(i)); + m_Stream.Write((short)beheld.MaxWeight); + m_Stream.Write((byte)(beheld.Race.RaceID + 1)); // Would be 0x00 if it's a non-ML enabled account but... } + + m_Stream.Write((short)beheld.StatCap); + + m_Stream.Write((byte)beheld.Followers); + m_Stream.Write((byte)beheld.FollowersMax); + + if (type >= 4) + { + m_Stream.Write((short)beheld.FireResistance); // Fire + m_Stream.Write((short)beheld.ColdResistance); // Cold + m_Stream.Write((short)beheld.PoisonResistance); // Poison + m_Stream.Write((short)beheld.EnergyResistance); // Energy + m_Stream.Write((short)beheld.Luck); // Luck + + IWeapon weapon = beheld.Weapon; + + if (weapon != null) + { + weapon.GetStatusDamage(beheld, out int min, out int max); + m_Stream.Write((short)min); // Damage min + m_Stream.Write((short)max); // Damage max + } + else + { + m_Stream.Write((short)0); // Damage min + m_Stream.Write((short)0); // Damage max + } + + m_Stream.Write(beheld.TithingPoints); + } + + if (type >= 6) + for (int i = 0; i < 15; ++i) + m_Stream.Write((short)beheld.GetAOSStatus(i)); } private void WriteAttr(int current, int maximum) @@ -4395,38 +4354,9 @@ namespace Server.Network return p; } - public static void Release(ref ObjectPropertyList p) - { - p?.Release(); - - p = null; - } - - public static void Release(ref RemoveItem p) - { - p?.Release(); - - p = null; - } - - public static void Release(ref RemoveMobile p) - { - p?.Release(); - - p = null; - } - - public static void Release(ref OPLInfo p) - { - p?.Release(); - - p = null; - } - public static void Release(ref Packet p) { p?.Release(); - p = null; } @@ -4501,6 +4431,7 @@ namespace Server.Network } catch { + // ignored } } diff --git a/Server/Network/StaticPacketHandlers.cs b/Server/Network/StaticPacketHandlers.cs new file mode 100644 index 000000000..ff09ffd50 --- /dev/null +++ b/Server/Network/StaticPacketHandlers.cs @@ -0,0 +1,115 @@ +using System.Collections.Concurrent; + +namespace Server.Network +{ + public static class StaticPacketHandlers + { + private static ConcurrentDictionary OPLInfoPackets = new ConcurrentDictionary(); + private static ConcurrentDictionary ObjectPropertyListPackets = new ConcurrentDictionary(); + private static ConcurrentDictionary RemoveEntityPackets = new ConcurrentDictionary(); + + private static ConcurrentDictionary WorldItemPackets = new ConcurrentDictionary(); + private static ConcurrentDictionary WorldItemSAPackets = new ConcurrentDictionary(); + private static ConcurrentDictionary WorldItemHSPackets = new ConcurrentDictionary(); + + public static OPLInfo GetOPLInfoPacket(IPropertyListObject obj) + { + return OPLInfoPackets.GetOrAdd(obj, value => + { + OPLInfo packet = new OPLInfo(value.PropertyList); + packet.SetStatic(); + return packet; + }); + } + + public static OPLInfo FreeOPLInfoPacket(IPropertyListObject obj) + { + if (OPLInfoPackets.TryRemove(obj, out OPLInfo p)) + Packet.Release(p); + + return p; + } + + public static ObjectPropertyList GetOPLPacket(IPropertyListObject obj) + { + return ObjectPropertyListPackets.GetOrAdd(obj, value => + { + ObjectPropertyList list = new ObjectPropertyList(value); + + value.GetProperties(list); + if (value is Item item) + item.AppendChildProperties(list); + + list.Terminate(); + list.SetStatic(); + return list; + }); + } + + public static ObjectPropertyList FreeOPLPacket(IPropertyListObject obj) + { + if (ObjectPropertyListPackets.TryRemove(obj, out ObjectPropertyList list)) + Packet.Release(list); + + return list; + } + + public static RemoveEntity GetRemoveEntityPacket(IEntity entity) + { + return RemoveEntityPackets.GetOrAdd(entity, value => + { + RemoveEntity packet = new RemoveEntity(value); + packet.SetStatic(); + return packet; + }); + } + + public static void FreeRemoveItemPacket(IEntity entity) + { + if (RemoveEntityPackets.TryRemove(entity, out RemoveEntity p)) + Packet.Release(p); + } + + public static WorldItem GetWorldItemPacket(Item item) + { + return WorldItemPackets.GetOrAdd(item, value => + { + WorldItem packet = new WorldItem(value); + packet.SetStatic(); + return packet; + }); + } + + public static WorldItemSA GetWorldItemSAPacket(Item item) + { + return WorldItemSAPackets.GetOrAdd(item, value => + { + WorldItemSA packet = new WorldItemSA(value); + packet.SetStatic(); + return packet; + }); + } + + public static WorldItemHS GetWorldItemHSPacket(Item item) + { + return WorldItemHSPackets.GetOrAdd(item, value => + { + WorldItemHS packet = new WorldItemHS(value); + packet.SetStatic(); + return packet; + }); + } + + public static void FreeWorldItemPackets(Item item) + { + if (WorldItemPackets.TryRemove(item, out WorldItem wi)) + Packet.Release(wi); + + if (WorldItemSAPackets.TryRemove(item, out WorldItemSA wisa)) + Packet.Release(wisa); + + if (WorldItemHSPackets.TryRemove(item, out WorldItemHS wihs)) + Packet.Release(wihs); + } + } +} diff --git a/Server/ObjectPropertyList.cs b/Server/ObjectPropertyList.cs index 756147113..b56e1c1da 100644 --- a/Server/ObjectPropertyList.cs +++ b/Server/ObjectPropertyList.cs @@ -24,6 +24,14 @@ using Server.Network; namespace Server { + public interface IPropertyListObject : IEntity + { + ObjectPropertyList PropertyList{ get; } + OPLInfo OPLPacket{ get; } + + void GetProperties(ObjectPropertyList list); + } + public sealed class ObjectPropertyList : Packet { private static byte[] m_Buffer = new byte[1024]; @@ -191,4 +199,4 @@ namespace Server m_Stream.Write(list.Hash); } } -} \ No newline at end of file +} diff --git a/Server/Persistence/DynamicSaveStrategy.cs b/Server/Persistence/DynamicSaveStrategy.cs index 60565b937..384d6f506 100644 --- a/Server/Persistence/DynamicSaveStrategy.cs +++ b/Server/Persistence/DynamicSaveStrategy.cs @@ -219,9 +219,7 @@ namespace Server public override void ProcessDecay() { - Item item; - - while (_decayBag.TryTake(out item)) + while (_decayBag.TryTake(out Item item)) if (item.OnDecay()) item.Delete(); } diff --git a/Server/Persistence/FileOperations.cs b/Server/Persistence/FileOperations.cs index 2d484d849..774d91503 100644 --- a/Server/Persistence/FileOperations.cs +++ b/Server/Persistence/FileOperations.cs @@ -48,10 +48,11 @@ namespace Server { FileOptions options = FileOptions.SequentialScan; - if (Concurrency > 0) options |= FileOptions.Asynchronous; + if (Concurrency > 0) + options |= FileOptions.Asynchronous; #if MONO - return new FileStream( path, mode, access, share, bufferSize, options ); + return new FileStream( path, mode, access, share, BufferSize, options ); #else if (Unbuffered) options |= NoBuffering; @@ -109,4 +110,4 @@ namespace Server } #endif } -} \ No newline at end of file +} diff --git a/Server/Persistence/Persistence.cs b/Server/Persistence/Persistence.cs index 1da7d14e4..921206a71 100644 --- a/Server/Persistence/Persistence.cs +++ b/Server/Persistence/Persistence.cs @@ -1,105 +1,107 @@ -#region References - -using System; -using System.IO; - -#endregion - -namespace Server -{ - public static class Persistence - { - public static void Serialize(string path, Action serializer) - { - Serialize(new FileInfo(path), serializer); - } - - public static void Serialize(FileInfo file, Action serializer) - { - file.Refresh(); - - if (file.Directory != null && !file.Directory.Exists) file.Directory.Create(); - - if (!file.Exists) file.Create().Close(); - - file.Refresh(); - - using (FileStream fs = file.OpenWrite()) - { - BinaryFileWriter writer = new BinaryFileWriter(fs, true); - - try - { - serializer(writer); - } - finally - { - writer.Flush(); - writer.Close(); - } - } - } - - public static void Deserialize(string path, Action deserializer) - { - Deserialize(path, deserializer, true); - } - - public static void Deserialize(FileInfo file, Action deserializer) - { - Deserialize(file, deserializer, true); - } - - public static void Deserialize(string path, Action deserializer, bool ensure) - { - Deserialize(new FileInfo(path), deserializer, ensure); - } - - public static void Deserialize(FileInfo file, Action deserializer, bool ensure) - { - file.Refresh(); - - if (file.Directory != null && !file.Directory.Exists) - { - if (!ensure) throw new DirectoryNotFoundException(); - - file.Directory.Create(); - } - - if (!file.Exists) - { - if (!ensure) - throw new FileNotFoundException - { - Source = file.FullName - }; - - file.Create().Close(); - } - - file.Refresh(); - - using (FileStream fs = file.OpenRead()) - { - BinaryFileReader reader = new BinaryFileReader(new BinaryReader(fs)); - - try - { - deserializer(reader); - } - catch (EndOfStreamException eos) - { - if (file.Length > 0) Console.WriteLine("[Persistence]: {0}", eos); - } - catch (Exception e) - { - Console.WriteLine("[Persistence]: {0}", e); - } - finally - { - reader.Close(); - } - } - } - } -} \ No newline at end of file +#region References + +using System; +using System.IO; + +#endregion + +namespace Server +{ + public static class Persistence + { + public static void Serialize(string path, Action serializer) + { + Serialize(new FileInfo(path), serializer); + } + + public static void Serialize(FileInfo file, Action serializer) + { + file.Refresh(); + + if (file.Directory?.Exists == false) + file.Directory.Create(); + + if (!file.Exists) file.Create().Close(); + + file.Refresh(); + + using (FileStream fs = file.OpenWrite()) + { + BinaryFileWriter writer = new BinaryFileWriter(fs, true); + + try + { + serializer(writer); + } + finally + { + writer.Flush(); + writer.Close(); + } + } + } + + public static void Deserialize(string path, Action deserializer) + { + Deserialize(path, deserializer, true); + } + + public static void Deserialize(FileInfo file, Action deserializer) + { + Deserialize(file, deserializer, true); + } + + public static void Deserialize(string path, Action deserializer, bool ensure) + { + Deserialize(new FileInfo(path), deserializer, ensure); + } + + public static void Deserialize(FileInfo file, Action deserializer, bool ensure) + { + file.Refresh(); + + if (file.Directory?.Exists == false) + { + if (!ensure) + throw new DirectoryNotFoundException(); + + file.Directory.Create(); + } + + if (!file.Exists) + { + if (!ensure) + throw new FileNotFoundException + { + Source = file.FullName + }; + + file.Create().Close(); + } + + file.Refresh(); + + using (FileStream fs = file.OpenRead()) + { + BinaryFileReader reader = new BinaryFileReader(new BinaryReader(fs)); + + try + { + deserializer(reader); + } + catch (EndOfStreamException eos) + { + if (file.Length > 0) Console.WriteLine("[Persistence]: {0}", eos); + } + catch (Exception e) + { + Console.WriteLine("[Persistence]: {0}", e); + } + finally + { + reader.Close(); + } + } + } + } +} diff --git a/Server/Persistence/SaveMetrics.cs b/Server/Persistence/SaveMetrics.cs index 0ee2136d6..b1384ffde 100644 --- a/Server/Persistence/SaveMetrics.cs +++ b/Server/Persistence/SaveMetrics.cs @@ -79,10 +79,8 @@ namespace Server ) ); -#if !MONO PerformanceCounterCategory.Create(PerformanceCategoryName, PerformanceCategoryDesc, PerformanceCounterCategoryType.SingleInstance, counters); -#endif } numberOfWorldSaves = new PerformanceCounter(PerformanceCategoryName, "Save - Count", false); @@ -137,4 +135,4 @@ namespace Server writtenBytesPerSecond.IncrementBy(numberOfBytes); } } -} \ No newline at end of file +} diff --git a/Server/Race.cs b/Server/Race.cs index e7d567d2e..724bf1084 100644 --- a/Server/Race.cs +++ b/Server/Race.cs @@ -94,16 +94,16 @@ namespace Server if (Insensitive.Equals(m_RaceNames[i], value)) return m_RaceValues[i]; - if (int.TryParse(value, out int index)) - if (index >= 0 && index < Races.Length && Races[index] != null) - return Races[index]; + if (int.TryParse(value, out int index) && index >= 0 && index < Races.Length && + Races[index] != null) + return Races[index]; throw new ArgumentException("Invalid race name"); } private static void CheckNamesAndValues() { - if (m_RaceNames != null && m_RaceNames.Length == AllRaces.Count) + if (m_RaceNames?.Length == AllRaces.Count) return; m_RaceNames = new string[AllRaces.Count]; @@ -182,4 +182,4 @@ namespace Server return female ? FemaleGhostBody : MaleGhostBody; } } -} \ No newline at end of file +} diff --git a/Server/Region.cs b/Server/Region.cs index 3b7e9458c..07133e68a 100644 --- a/Server/Region.cs +++ b/Server/Region.cs @@ -99,7 +99,7 @@ namespace Server ValoriaShips } - public class Region : IComparable + public class Region : IComparable { public static readonly int DefaultPriority = 50; @@ -249,14 +249,11 @@ namespace Server public bool IsDefault => Map.DefaultRegion == this; public virtual MusicName DefaultMusic => Parent?.Music ?? MusicName.Invalid; - int IComparable.CompareTo(object obj) + public int CompareTo(Region reg) { - if (obj == null) + if (reg == null) return 1; - if (!(obj is Region reg)) - throw new ArgumentException("obj is not a Region", nameof(obj)); - // Dynamic regions go first if (Dynamic) { @@ -416,7 +413,7 @@ namespace Server return false; } - + // TODO: Memoize this public T GetRegion() where T : Region { @@ -468,7 +465,7 @@ namespace Server return null; } - + public bool IsPartOf() where T : Region { return GetRegion() != null; @@ -493,15 +490,14 @@ namespace Server { List list = new List(); - if (Sectors != null) - for (int i = 0; i < Sectors.Length; i++) - { - Sector sector = Sectors[i]; + for (int i = 0; i < Sectors?.Length; i++) + { + Sector sector = Sectors[i]; - foreach (Mobile player in sector.Players) - if (player.Region.IsPartOf(this)) - list.Add(player); - } + foreach (Mobile player in sector.Players) + if (player.Region.IsPartOf(this)) + list.Add(player); + } return list; } @@ -510,16 +506,14 @@ namespace Server { int count = 0; - if (Sectors != null) - for (int i = 0; i < Sectors.Length; i++) - { - Sector sector = Sectors[i]; - - foreach (Mobile player in sector.Players) - if (player.Region.IsPartOf(this)) - count++; - } + for (int i = 0; i < Sectors?.Length; i++) + { + Sector sector = Sectors[i]; + foreach (Mobile player in sector.Players) + if (player.Region.IsPartOf(this)) + count++; + } return count; } @@ -527,16 +521,14 @@ namespace Server { List list = new List(); - if (Sectors != null) - for (int i = 0; i < Sectors.Length; i++) - { - Sector sector = Sectors[i]; - - foreach (Mobile mobile in sector.Mobiles) - if (mobile.Region.IsPartOf(this)) - list.Add(mobile); - } + for (int i = 0; i < Sectors?.Length; i++) + { + Sector sector = Sectors[i]; + foreach (Mobile mobile in sector.Mobiles) + if (mobile.Region.IsPartOf(this)) + list.Add(mobile); + } return list; } @@ -544,15 +536,14 @@ namespace Server { int count = 0; - if (Sectors != null) - for (int i = 0; i < Sectors.Length; i++) - { - Sector sector = Sectors[i]; + for (int i = 0; i < Sectors?.Length; i++) + { + Sector sector = Sectors[i]; - foreach (Mobile mobile in sector.Mobiles) - if (mobile.Region.IsPartOf(this)) - count++; - } + foreach (Mobile mobile in sector.Mobiles) + if (mobile.Region.IsPartOf(this)) + count++; + } return count; } @@ -599,12 +590,12 @@ namespace Server public virtual Type GetResource(Type type) { - return Parent != null ? Parent.GetResource(type) : type; + return Parent?.GetResource(type) ?? type; } public virtual bool CanUseStuckMenu(Mobile m) { - return Parent == null || Parent.CanUseStuckMenu(m); + return Parent?.CanUseStuckMenu(m) != false; } public virtual void OnAggressed(Mobile aggressor, Mobile aggressed, bool criminal) @@ -629,39 +620,37 @@ namespace Server public virtual bool OnTarget(Mobile m, Target t, object o) { - return Parent == null || Parent.OnTarget(m, t, o); + return Parent?.OnTarget(m, t, o) != false; } public virtual bool OnCombatantChange(Mobile m, Mobile Old, Mobile New) { - return Parent == null || Parent.OnCombatantChange(m, Old, New); + return Parent?.OnCombatantChange(m, Old, New) != false; } public virtual bool AllowHousing(Mobile from, Point3D p) { - return Parent == null || Parent.AllowHousing(from, p); + return Parent?.AllowHousing(from, p) != false; } public virtual bool SendInaccessibleMessage(Item item, Mobile from) { - return Parent != null && Parent.SendInaccessibleMessage(item, from); + return Parent?.SendInaccessibleMessage(item, from) == true; } public virtual bool CheckAccessibility(Item item, Mobile from) { - return Parent == null || Parent.CheckAccessibility(item, from); + return Parent?.CheckAccessibility(item, from) != false; } public virtual bool OnDecay(Item item) { - return Parent == null || Parent.OnDecay(item); + return Parent?.OnDecay(item) != false; } public virtual bool AllowHarmful(Mobile from, Mobile target) { - return Parent?.AllowHarmful(from, target) == true || - Mobile.AllowHarmfulHandler == null || - Mobile.AllowHarmfulHandler(from, target); + return Parent?.AllowHarmful(from, target) ?? Mobile.AllowHarmfulHandler?.Invoke(from, target) ?? true; } public virtual void OnCriminalAction(Mobile m, bool message) @@ -674,9 +663,8 @@ namespace Server public virtual bool AllowBeneficial(Mobile from, Mobile target) { - return Parent?.AllowBeneficial(from, target) == true || - Mobile.AllowBeneficialHandler == null || - Mobile.AllowBeneficialHandler(from, target); + return Parent?.AllowBeneficial(from, target) ?? + Mobile.AllowBeneficialHandler?.Invoke(from, target) ?? true; } public virtual void OnBeneficialAction(Mobile helper, Mobile target) @@ -701,12 +689,12 @@ namespace Server public virtual bool OnSkillUse(Mobile m, int Skill) { - return Parent == null || Parent.OnSkillUse(m, Skill); + return Parent?.OnSkillUse(m, Skill) != false; } public virtual bool OnBeginSpellCast(Mobile m, ISpell s) { - return Parent == null || Parent.OnBeginSpellCast(m, s); + return Parent?.OnBeginSpellCast(m, s) != false; } public virtual void OnSpellCast(Mobile m, ISpell s) @@ -716,12 +704,12 @@ namespace Server public virtual bool OnResurrect(Mobile m) { - return Parent == null || Parent.OnResurrect(m); + return Parent?.OnResurrect(m) != false; } public virtual bool OnBeforeDeath(Mobile m) { - return Parent == null || Parent.OnBeforeDeath(m); + return Parent?.OnBeforeDeath(m) != false; } public virtual void OnDeath(Mobile m) @@ -731,27 +719,27 @@ namespace Server public virtual bool OnDamage(Mobile m, ref int Damage) { - return Parent == null || Parent.OnDamage(m, ref Damage); + return Parent?.OnDamage(m, ref Damage) != false; } public virtual bool OnHeal(Mobile m, ref int Heal) { - return Parent == null || Parent.OnHeal(m, ref Heal); + return Parent?.OnHeal(m, ref Heal) != false; } public virtual bool OnDoubleClick(Mobile m, object o) { - return Parent == null || Parent.OnDoubleClick(m, o); + return Parent?.OnDoubleClick(m, o) != false; } public virtual bool OnSingleClick(Mobile m, object o) { - return Parent == null || Parent.OnSingleClick(m, o); + return Parent?.OnSingleClick(m, o) != false; } public virtual bool AllowSpawn() { - return Parent == null || Parent.AllowSpawn(); + return Parent?.AllowSpawn() != false; } public virtual void AlterLightLevel(Mobile m, ref int global, ref int personal) @@ -763,9 +751,8 @@ namespace Server { if (Parent != null) return Parent.GetLogoutDelay(m); - if (m.AccessLevel > AccessLevel.Player) - return StaffLogoutDelay; - return DefaultLogoutDelay; + + return m.AccessLevel > AccessLevel.Player ? StaffLogoutDelay : DefaultLogoutDelay; } @@ -840,7 +827,7 @@ namespace Server Console.WriteLine("Could not find root element 'ServerRegions' in Regions.xml"); return; } - + foreach (XmlElement facet in root.SelectNodes("Facet")) { Map map = null; @@ -1172,4 +1159,4 @@ namespace Server return true; } } -} \ No newline at end of file +} diff --git a/Server/ScriptCompiler.cs b/Server/ScriptCompiler.cs index f6a41c46c..8ecf26c7b 100644 --- a/Server/ScriptCompiler.cs +++ b/Server/ScriptCompiler.cs @@ -80,10 +80,6 @@ namespace Server AppendCompilerOption(ref sb, "/d:NEWTIMERS"); #endif -#if NEWPARENT - AppendCompilerOption(ref sb, "/d:NEWPARENT"); -#endif - return sb?.ToString(); } @@ -368,6 +364,7 @@ namespace Server } catch { + // ignored } assembly = results.CompiledAssembly; diff --git a/Server/Sector.cs b/Server/Sector.cs index e4e22c13a..9e9ad639d 100644 --- a/Server/Sector.cs +++ b/Server/Sector.cs @@ -25,7 +25,7 @@ using Server.Network; namespace Server { - public class RegionRect : IComparable + public class RegionRect : IComparable { private Rectangle3D m_Rect; @@ -39,15 +39,9 @@ namespace Server public Rectangle3D Rect => m_Rect; - int IComparable.CompareTo(object obj) + public int CompareTo(RegionRect regRect) { - if (obj == null) - return 1; - - if (!(obj is RegionRect regRect)) - throw new ArgumentException("obj is not a RegionRect", nameof(obj)); - - return ((IComparable)Region).CompareTo(regRect.Region); + return regRect == null ? 1 : Region.CompareTo(regRect.Region); } public bool Contains(Point3D loc) @@ -81,71 +75,17 @@ namespace Server m_Active = false; } - public List RegionRects - { - get - { - if (m_RegionRects == null) - return m_DefaultRectList; + public List RegionRects => m_RegionRects ?? m_DefaultRectList; - return m_RegionRects; - } - } + public List Multis => m_Multis ?? m_DefaultMultiList; - public List Multis - { - get - { - if (m_Multis == null) - return m_DefaultMultiList; + public List Mobiles => m_Mobiles ?? m_DefaultMobileList; - return m_Multis; - } - } + public List Items => m_Items ?? m_DefaultItemList; - public List Mobiles - { - get - { - if (m_Mobiles == null) - return m_DefaultMobileList; + public List Clients => m_Clients ?? m_DefaultClientList; - return m_Mobiles; - } - } - - public List Items - { - get - { - if (m_Items == null) - return m_DefaultItemList; - - return m_Items; - } - } - - public List Clients - { - get - { - if (m_Clients == null) - return m_DefaultClientList; - - return m_Clients; - } - } - - public List Players - { - get - { - if (m_Players == null) - return m_DefaultMobileList; - - return m_Players; - } - } + public List Players => m_Players ?? m_DefaultMobileList; public bool Active => m_Active && Owner != Map.Internal; @@ -314,4 +254,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Server/SecureTrade.cs b/Server/SecureTrade.cs index c023b5732..0af012e8b 100644 --- a/Server/SecureTrade.cs +++ b/Server/SecureTrade.cs @@ -39,11 +39,11 @@ namespace Server From = new SecureTradeInfo(this, from, new SecureTradeContainer(this)); To = new SecureTradeInfo(this, to, new SecureTradeContainer(this)); - bool from6017 = from.NetState != null && from.NetState.ContainerGridLines; - bool to6017 = to.NetState != null && to.NetState.ContainerGridLines; + bool from6017 = from.NetState?.ContainerGridLines == true; + bool to6017 = to.NetState?.ContainerGridLines == true; - bool from704565 = from.NetState != null && from.NetState.NewSecureTrading; - bool to704565 = to.NetState != null && to.NetState.NewSecureTrading; + bool from704565 = from.NetState?.NewSecureTrading == true; + bool to704565 = to.NetState?.NewSecureTrading == true; from.Send(new MobileStatus(from, to)); from.Send(new UpdateSecureTrade(From.Container, false, false)); @@ -364,7 +364,7 @@ namespace Server Mobile.AddItem(Container); - VirtualCheck = new VirtualCheck(0, 0); + VirtualCheck = new VirtualCheck(); Container.DropItem(VirtualCheck); } @@ -403,4 +403,4 @@ namespace Server IsDisposed = true; } } -} \ No newline at end of file +} diff --git a/Server/Serial.cs b/Server/Serial.cs index 3ea527f6a..bbf06ed1d 100644 --- a/Server/Serial.cs +++ b/Server/Serial.cs @@ -22,7 +22,7 @@ using System; namespace Server { - public struct Serial : IComparable, IComparable, IComparable + public struct Serial : IComparable, IComparable { public static readonly Serial MinusOne = new Serial(0xFFFFFFFF); public static readonly Serial Zero = new Serial(0); @@ -72,17 +72,12 @@ namespace Server { return Value.GetHashCode(); } - + public int CompareTo(Serial other) { return Value.CompareTo(other.Value); } - public int CompareTo(object obj) - { - return Value.CompareTo(obj); - } - public int CompareTo(uint other) { return Value.CompareTo(other); @@ -148,4 +143,4 @@ namespace Server return new Serial(a); } } -} \ No newline at end of file +} diff --git a/Server/Serialization.cs b/Server/Serialization.cs index f053688cb..4018e359e 100644 --- a/Server/Serialization.cs +++ b/Server/Serialization.cs @@ -19,7 +19,6 @@ ***************************************************************************/ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Net; @@ -561,7 +560,7 @@ namespace Server public override void WriteEntity(IEntity value) { - if (value == null || value.Deleted) + if (value?.Deleted != false) Write(Serial.MinusOne); else Write(value.Serial); @@ -569,7 +568,7 @@ namespace Server public override void Write(Item value) { - if (value == null || value.Deleted) + if (value?.Deleted != false) Write(Serial.MinusOne); else Write(value.Serial); @@ -577,7 +576,7 @@ namespace Server public override void Write(Mobile value) { - if (value == null || value.Deleted) + if (value?.Deleted != false) Write(Serial.MinusOne); else Write(value.Serial); @@ -1461,7 +1460,7 @@ namespace Server public override void WriteEntity(IEntity value) { - if (value == null || value.Deleted) + if (value?.Deleted != false) Write(Serial.MinusOne); else Write(value.Serial); @@ -1469,7 +1468,7 @@ namespace Server public override void Write(Item value) { - if (value == null || value.Deleted) + if (value?.Deleted != false) Write(Serial.MinusOne); else Write(value.Serial); @@ -1477,7 +1476,7 @@ namespace Server public override void Write(Mobile value) { - if (value == null || value.Deleted) + if (value?.Deleted != false) Write(Serial.MinusOne); else Write(value.Serial); @@ -1735,7 +1734,7 @@ namespace Server mem = m_Owner.m_WriteQueue.Dequeue(); } - if (mem != null && mem.Length > 0) + if (mem?.Length > 0) mem.WriteTo(m_Owner.m_File); } while (lastCount > 1); diff --git a/Server/Server.csproj b/Server/Server.csproj index 5f1395219..6fbb90173 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -42,7 +42,7 @@ true ..\ - TRACE;DEBUG;NEWTIMERS;NEWPARENT;NewAsyncSockets + TRACE;DEBUG;NEWTIMERS true full AnyCPU @@ -53,7 +53,7 @@ ..\ - TRACE;NEWTIMERS;NEWPARENT;NewAsyncSockets + TRACE;NEWTIMERS true true pdbonly @@ -66,7 +66,7 @@ true ..\ - TRACE;DEBUG;NEWTIMERS,NEWPARENT;NewAsyncSockets + TRACE;DEBUG;NEWTIMERS true full x64 @@ -77,7 +77,7 @@ ..\ - TRACE;NEWTIMERS,NEWPARENT;NewAsyncSockets + TRACE;NEWTIMERS true true pdbonly @@ -155,6 +155,8 @@ + + @@ -169,6 +171,7 @@ + diff --git a/Server/Targeting/MultiTarget.cs b/Server/Targeting/MultiTarget.cs index 0d3c2fcaf..b0f7ac754 100644 --- a/Server/Targeting/MultiTarget.cs +++ b/Server/Targeting/MultiTarget.cs @@ -24,12 +24,7 @@ namespace Server.Targeting { public abstract class MultiTarget : Target { - protected MultiTarget(int multiID, Point3D offset) - : this(multiID, offset, 10, true, TargetFlags.None) - { - } - - protected MultiTarget(int multiID, Point3D offset, int range, bool allowGround, TargetFlags flags) + protected MultiTarget(int multiID, Point3D offset, int range = 10, bool allowGround = true, TargetFlags flags = TargetFlags.None) : base(range, allowGround, flags) { MultiID = multiID; @@ -47,4 +42,4 @@ namespace Server.Targeting return new MultiTargetReq(this); } } -} \ No newline at end of file +} diff --git a/Server/Targeting/Target.cs b/Server/Targeting/Target.cs index 9df06fba1..64c209ada 100644 --- a/Server/Targeting/Target.cs +++ b/Server/Targeting/Target.cs @@ -165,9 +165,7 @@ namespace Server.Targeting return; } - object root = item.RootParent; - - if (!AllowNonlocal && root is Mobile && root != from && from.AccessLevel == AccessLevel.Player) + if (!AllowNonlocal && item.RootParent is Mobile && item.RootParent != from && from.AccessLevel == AccessLevel.Player) { OnNonlocalTarget(from, item); OnTargetFinish(from); @@ -290,4 +288,4 @@ namespace Server.Targeting } } } -} \ No newline at end of file +} diff --git a/Server/TileMatrix.cs b/Server/TileMatrix.cs index 03aa5e192..49c2a4323 100644 --- a/Server/TileMatrix.cs +++ b/Server/TileMatrix.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -52,7 +53,7 @@ namespace Server private StaticTile[] m_TileBuffer = new StaticTile[128]; private TileList m_TilesList = new TileList(); - private int m_Width, m_Height; + // private int m_Width, m_Height; public TileMatrix(Map owner, int fileIndex, int mapID, int width, int height) { @@ -77,8 +78,8 @@ namespace Server } m_FileIndex = fileIndex; - m_Width = width; - m_Height = height; +// m_Width = width; +// m_Height = height; BlockWidth = width >> 3; BlockHeight = height >> 3; @@ -212,42 +213,37 @@ namespace Server StaticTile[][][] tiles = m_StaticTiles[x][y]; - if (tiles == null) + if (tiles != null) + return tiles; + + lock (m_FileShare) { - lock (m_FileShare) + for (int i = 0; tiles == null && i < m_FileShare.Count; ++i) { - for (int i = 0; tiles == null && i < m_FileShare.Count; ++i) + TileMatrix shared = m_FileShare[i]; + + lock (shared) { - TileMatrix shared = m_FileShare[i]; - - lock (shared) + if (x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight) { - if (x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight) + StaticTile[][][][] theirTiles = shared.m_StaticTiles[x]; + + if (theirTiles != null) + tiles = theirTiles[y]; + + if (tiles != null) { - StaticTile[][][][] theirTiles = shared.m_StaticTiles[x]; + int[] theirBits = shared.m_StaticPatches[x]; - if (theirTiles != null) - tiles = theirTiles[y]; - - if (tiles != null) - { - int[] theirBits = shared.m_StaticPatches[x]; - - if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0) - tiles = null; - } + if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0) + tiles = null; } } } } - - if (tiles == null) - tiles = ReadStaticBlock(x, y); - - m_StaticTiles[x][y] = tiles; } - return tiles; + return m_StaticTiles[x][y] = tiles ?? ReadStaticBlock(x, y); } public StaticTile[] GetStaticTiles(int x, int y) @@ -262,34 +258,27 @@ namespace Server { StaticTile[][][] tiles = GetStaticBlock(x >> 3, y >> 3); - if (multis) - { - IPooledEnumerable eable = m_Owner.GetMultiTilesAt(x, y); + if (!multis) + return tiles[x & 0x7][y & 0x7]; - if (eable == Map.NullEnumerable.Instance) - return tiles[x & 0x7][y & 0x7]; + IPooledEnumerable eable = m_Owner.GetMultiTilesAt(x, y); - bool any = false; + if (eable == Map.NullEnumerable.Instance) + return tiles[x & 0x7][y & 0x7]; - foreach (StaticTile[] multiTiles in eable) - { - if (!any) - any = true; + bool any = false; - m_TilesList.AddRange(multiTiles); - } + m_TilesList.AddRange(eable.SelectMany(t => { any = true; return t; }).ToArray()); - eable.Free(); + eable.Free(); - if (!any) - return tiles[x & 0x7][y & 0x7]; + if (!any) + return tiles[x & 0x7][y & 0x7]; - m_TilesList.AddRange(tiles[x & 0x7][y & 0x7]); + m_TilesList.AddRange(tiles[x & 0x7][y & 0x7]); - return m_TilesList.ToArray(); - } + return m_TilesList.ToArray(); - return tiles[x & 0x7][y & 0x7]; } [MethodImpl(MethodImplOptions.Synchronized)] @@ -320,49 +309,42 @@ namespace Server LandTile[] tiles = m_LandTiles[x][y]; - if (tiles == null) + if (tiles != null) + return tiles; + + lock (m_FileShare) { - lock (m_FileShare) + for (int i = 0; tiles == null && i < m_FileShare.Count; ++i) { - for (int i = 0; tiles == null && i < m_FileShare.Count; ++i) + TileMatrix shared = m_FileShare[i]; + + lock (shared) { - TileMatrix shared = m_FileShare[i]; - - lock (shared) + if (x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight) { - if (x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight) + LandTile[][] theirTiles = shared.m_LandTiles[x]; + + if (theirTiles != null) + tiles = theirTiles[y]; + + if (tiles != null) { - LandTile[][] theirTiles = shared.m_LandTiles[x]; + int[] theirBits = shared.m_LandPatches[x]; - if (theirTiles != null) - tiles = theirTiles[y]; - - if (tiles != null) - { - int[] theirBits = shared.m_LandPatches[x]; - - if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0) - tiles = null; - } + if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0) + tiles = null; } } } } - - if (tiles == null) - tiles = ReadLandBlock(x, y); - - m_LandTiles[x][y] = tiles; } - return tiles; + return m_LandTiles[x][y] = tiles ?? ReadLandBlock(x, y); } public LandTile GetLandTile(int x, int y) { - LandTile[] tiles = GetLandBlock(x >> 3, y >> 3); - - return tiles[((y & 0x7) << 3) + (x & 0x7)]; + return GetLandBlock(x >> 3, y >> 3)[((y & 0x7) << 3) + (x & 0x7)]; } [MethodImpl(MethodImplOptions.Synchronized)] @@ -375,7 +357,8 @@ namespace Server int lookup = IndexReader.ReadInt32(); int length = IndexReader.ReadInt32(); - if (lookup < 0 || length <= 0) return EmptyStaticBlock; + if (lookup < 0 || length <= 0) + return EmptyStaticBlock; int count = length / 7; @@ -388,11 +371,7 @@ namespace Server fixed (StaticTile* pTiles = staTiles) { -#if !MONO NativeReader.Read(DataStream.SafeFileHandle.DangerousGetHandle(), pTiles, length); -#else - NativeReader.Read( m_Statics.Handle, pTiles, length ); -#endif if (m_Lists == null) { m_Lists = new TileList[8][]; @@ -463,11 +442,7 @@ namespace Server fixed (LandTile* pTiles = tiles) { -#if !MONO NativeReader.Read(MapStream.SafeFileHandle.DangerousGetHandle(), pTiles, 192); -#else - NativeReader.Read( m_Map.Handle, pTiles, 192 ); -#endif } return tiles; @@ -718,9 +693,9 @@ namespace Server if (y == null) return -1; - + return x.m_Offset.CompareTo(y.m_Offset); } } } -} \ No newline at end of file +} diff --git a/Server/TileMatrixPatch.cs b/Server/TileMatrixPatch.cs index cff17809f..aeea0e751 100644 --- a/Server/TileMatrixPatch.cs +++ b/Server/TileMatrixPatch.cs @@ -95,11 +95,7 @@ namespace Server fixed (LandTile* pTiles = tiles) { -#if !MONO NativeReader.Read(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192); -#else - NativeReader.Read( fsData.Handle, pTiles, 192 ); -#endif } matrix.SetLandBlock(x, y, tiles); @@ -163,11 +159,7 @@ namespace Server fixed (StaticTile* pTiles = staTiles) { -#if !MONO NativeReader.Read(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, length); -#else - NativeReader.Read( fsData.Handle, pTiles, length ); -#endif StaticTile* pCur = pTiles, pEnd = pTiles + tileCount; while (pCur < pEnd) @@ -199,4 +191,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Server/Timer.cs b/Server/Timer.cs index 9028e3cf2..4c65848b9 100644 --- a/Server/Timer.cs +++ b/Server/Timer.cs @@ -62,11 +62,7 @@ namespace Server { } - public Timer(TimeSpan delay, TimeSpan interval) : this(delay, interval, 0) - { - } - - public Timer(TimeSpan delay, TimeSpan interval, int count) + public Timer(TimeSpan delay, TimeSpan interval, int count = 0) { m_Delay = (long)delay.TotalMilliseconds; m_Interval = (long)interval.TotalMilliseconds; @@ -378,10 +374,6 @@ namespace Server public void TimerMain() { - long now; - int i, j; - bool loaded; - while (!Core.Closing) { if (World.Loading || World.Saving) @@ -392,17 +384,17 @@ namespace Server ProcessChanged(); - loaded = false; + bool loaded = false; - for (i = 0; i < m_Timers.Length; i++) + for (int i = 0; i < m_Timers.Length; i++) { - now = Core.TickCount; + long now = Core.TickCount; if (now < m_NextPriorities[i]) break; m_NextPriorities[i] = now + m_PriorityDelays[i]; - for (j = 0; j < m_Timers[i].Count; j++) + for (int j = 0; j < m_Timers[i].Count; j++) { Timer t = m_Timers[i][j]; @@ -501,11 +493,7 @@ namespace Server { Timer t = new DelayCallTimer(delay, interval, count, callback); - if (count == 1) - t.Priority = ComputePriority(delay); - else - t.Priority = ComputePriority(interval); - + t.Priority = ComputePriority(count == 1 ? delay : interval); t.Start(); return t; diff --git a/Server/Utility.cs b/Server/Utility.cs index 297a0673f..dd8420927 100644 --- a/Server/Utility.cs +++ b/Server/Utility.cs @@ -19,7 +19,6 @@ ***************************************************************************/ using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -132,10 +131,7 @@ namespace Server public static string Intern(string str) { - if (str == null) - return null; - - return str.Length == 0 ? string.Empty : string.Intern(str); + return str == null ? null : str.Length == 0 ? string.Empty : string.Intern(str); } public static void Intern(ref string str) @@ -501,7 +497,7 @@ namespace Server } else { - valid = false; //high & lowpart would be 0 if it got to here. + valid = false; //high & lowp art would be 0 if it got to here. } } } @@ -560,9 +556,7 @@ namespace Server return Direction.Right; } - if (dy > 0) - return Direction.Left; - return Direction.Up; + return dy > 0 ? Direction.Left : Direction.Up; } /* Should probably be rewritten to use an ITile interface @@ -614,12 +608,7 @@ namespace Server } */ - public static object GetArrayCap(Array array, int index) - { - return GetArrayCap(array, index, null); - } - - public static object GetArrayCap(Array array, int index, object emptyValue) + public static object GetArrayCap(Array array, int index, object emptyValue = null) { if (array.Length > 0) { @@ -791,18 +780,13 @@ namespace Server return num < bound2 + allowance && num > bound1 - allowance; } - public static void AssignRandomHair(Mobile m) - { - AssignRandomHair(m, true); - } - public static void AssignRandomHair(Mobile m, int hue) { m.HairItemID = m.Race.RandomHair(m); m.HairHue = hue; } - public static void AssignRandomHair(Mobile m, bool randomHue) + public static void AssignRandomHair(Mobile m, bool randomHue = true) { m.HairItemID = m.Race.RandomHair(m); @@ -810,18 +794,13 @@ namespace Server m.HairHue = m.Race.RandomHairHue(); } - public static void AssignRandomFacialHair(Mobile m) - { - AssignRandomFacialHair(m, true); - } - public static void AssignRandomFacialHair(Mobile m, int hue) { m.FacialHairItemID = m.Race.RandomFacialHair(m); m.FacialHairHue = hue; } - public static void AssignRandomFacialHair(Mobile m, bool randomHue) + public static void AssignRandomFacialHair(Mobile m, bool randomHue = true) { m.FacialHairItemID = m.Race.RandomFacialHair(m); @@ -979,12 +958,7 @@ namespace Server public static string GetAttribute(XmlElement node, string attributeName, string defaultValue = null) { - if (node == null) - return defaultValue; - - XmlAttribute attr = node.Attributes[attributeName]; - - return attr == null ? defaultValue : attr.Value; + return node?.Attributes[attributeName]?.Value ?? defaultValue; } public static string GetText(XmlElement node, string defaultValue) @@ -1237,9 +1211,8 @@ namespace Server { if (hue < 2) return 2; - if (hue > 1001) - return 1001; - return hue; + + return hue > 1001 ? 1001 : hue; } /// @@ -1255,10 +1228,8 @@ namespace Server /// public static int RandomBrightHue() { - if (RandomDouble() < 0.1) - return RandomList(0x62, 0x71); - - return RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59); + return RandomDouble() < 0.1 ? RandomList(0x62, 0x71) : + RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59); } #endregion diff --git a/Server/World.cs b/Server/World.cs index 81daa0fd4..7dff0cfdd 100644 --- a/Server/World.cs +++ b/Server/World.cs @@ -46,7 +46,7 @@ namespace Server public static readonly string GuildIndexPath = Path.Combine("Saves/Guilds/", "Guilds.idx"); public static readonly string GuildDataPath = Path.Combine("Saves/Guilds/", "Guilds.bin"); - private static readonly Type[] m_SerialTypeArray = new Type[] { typeof(Serial) }; + private static readonly Type[] m_SerialTypeArray = { typeof(Serial) }; internal static int m_Saves; @@ -558,12 +558,9 @@ namespace Server private static void AppendSafetyLog(string action, IEntity entity) { - string message = string.Format("Warning: Attempted to {1} {2} during world save." + - "{0}This action could cause inconsistent state." + - "{0}It is strongly advised that the offending scripts be corrected.", - Environment.NewLine, - action, entity - ); + string message = $"Warning: Attempted to {action} {entity} during world save." + + $"{Environment.NewLine}This action could cause inconsistent state." + + $"{Environment.NewLine}It is strongly advised that the offending scripts be corrected."; Console.WriteLine(message);