diff --git a/Scripts/Engines/Factions/Items/TownStone.cs b/Scripts/Engines/Factions/Items/TownStone.cs
index 90c1ce9ef..ee58c34a2 100644
--- a/Scripts/Engines/Factions/Items/TownStone.cs
+++ b/Scripts/Engines/Factions/Items/TownStone.cs
@@ -51,7 +51,7 @@ namespace Server.Factions
from.SendLocalizedMessage( 1005242 ); // Only faction Leaders can use townstones
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
- else if ( @from is PlayerMobile mobile )
+ else if ( from is PlayerMobile mobile )
mobile.SendGump( new TownStoneGump( mobile, m_Town.Owner, m_Town ) );
}
diff --git a/Scripts/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs b/Scripts/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs
index 7faf92b7e..9c3e6a63e 100644
--- a/Scripts/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs
+++ b/Scripts/Engines/Factions/Mobiles/Vendors/FactionHorseVendor.cs
@@ -48,7 +48,7 @@ namespace Server.Factions
PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1042201, from.NetState ); // You are not in my faction, I cannot sell you a horse!
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
- else if ( @from is PlayerMobile mobile )
+ else if ( from is PlayerMobile mobile )
mobile.SendGump( new HorseBreederGump( mobile, this.Faction ) );
}
diff --git a/Scripts/Engines/Harvest/Fishing.cs b/Scripts/Engines/Harvest/Fishing.cs
index 03eb00009..9bb5f467e 100644
--- a/Scripts/Engines/Harvest/Fishing.cs
+++ b/Scripts/Engines/Harvest/Fishing.cs
@@ -228,7 +228,7 @@ namespace Server.Engines.Harvest
if ( type == typeof( TreasureMap ) )
{
int level;
- if ( @from is PlayerMobile mobile && mobile.Young && mobile.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
+ if ( from is PlayerMobile mobile && mobile.Young && mobile.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
level = 0;
else
level = 1;
diff --git a/Scripts/Engines/Harvest/Lumberjacking.cs b/Scripts/Engines/Harvest/Lumberjacking.cs
index 7bdcaab8f..f3852def6 100644
--- a/Scripts/Engines/Harvest/Lumberjacking.cs
+++ b/Scripts/Engines/Harvest/Lumberjacking.cs
@@ -162,10 +162,10 @@ namespace Server.Engines.Harvest
public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
- if ( toHarvest is Mobile )
- ( (Mobile)toHarvest ).PrivateOverheadMessage( MessageType.Regular, 0x3B2, 500450, from.NetState ); // You can only skin dead creatures.
- else if ( toHarvest is Item )
- ( (Item)toHarvest ).LabelTo( from, 500464 ); // Use this on corpses to carve away meat and hide
+ if ( toHarvest is Mobile mobile )
+ mobile.PrivateOverheadMessage( MessageType.Regular, 0x3B2, 500450, from.NetState ); // You can only skin dead creatures.
+ else if ( toHarvest is Item item )
+ item.LabelTo( from, 500464 ); // Use this on corpses to carve away meat and hide
else if ( toHarvest is Targeting.StaticTarget || toHarvest is Targeting.LandTarget )
from.SendLocalizedMessage( 500489 ); // You can't use an axe on that.
else
diff --git a/Scripts/Engines/Harvest/Mining.cs b/Scripts/Engines/Harvest/Mining.cs
index bc4d7a4e2..859ce999c 100644
--- a/Scripts/Engines/Harvest/Mining.cs
+++ b/Scripts/Engines/Harvest/Mining.cs
@@ -194,8 +194,7 @@ namespace Server.Engines.Harvest
{
if ( def == m_OreAndStone )
{
- PlayerMobile pm = from as PlayerMobile;
- if ( pm != null && pm.StoneMining && pm.ToggleMiningStone && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
+ if ( from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
return resource.Types[1];
return resource.Types[0];
@@ -236,17 +235,17 @@ namespace Server.Engines.Harvest
if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
return false;
- if ( def == m_Sand && !(from is PlayerMobile && from.Skills[SkillName.Mining].Base >= 100.0 && ((PlayerMobile)from).SandMining) )
+ if ( def == m_Sand && !(from is PlayerMobile mobile && mobile.Skills[SkillName.Mining].Base >= 100.0 && mobile.SandMining) )
{
OnBadHarvestTarget( from, tool, toHarvest );
return false;
}
- else if ( from.Mounted )
+ if ( from.Mounted )
{
from.SendLocalizedMessage( 501864 ); // You can't mine while riding.
return false;
}
- else if ( from.IsBodyMod && !from.Body.IsHuman )
+ if ( from.IsBodyMod && !from.Body.IsHuman )
{
from.SendLocalizedMessage( 501865 ); // You can't mine while polymorphed.
return false;
@@ -295,9 +294,7 @@ namespace Server.Engines.Harvest
if ( map == null )
return;
- BaseCreature spawned = Activator.CreateInstance( res.Types[2], new object[]{ 25 } ) as BaseCreature;
-
- if ( spawned != null )
+ if ( Activator.CreateInstance( res.Types[2], new object[]{ 25 } ) is BaseCreature spawned )
{
int offset = Utility.Random( 8 ) * 2;
@@ -313,17 +310,15 @@ namespace Server.Engines.Harvest
spawned.Combatant = from;
return;
}
- else
- {
- int z = map.GetAverageZ( x, y );
- if ( Math.Abs( z - from.Z ) < 10 && map.CanSpawnMobile( x, y, z ) )
- {
- spawned.OnBeforeSpawn( new Point3D( x, y, z ), map );
- spawned.MoveToWorld( new Point3D( x, y, z ), map );
- spawned.Combatant = from;
- return;
- }
+ int z = map.GetAverageZ( x, y );
+
+ if ( Math.Abs( z - from.Z ) < 10 && map.CanSpawnMobile( x, y, z ) )
+ {
+ spawned.OnBeforeSpawn( new Point3D( x, y, z ), map );
+ spawned.MoveToWorld( new Point3D( x, y, z ), map );
+ spawned.Combatant = from;
+ return;
}
}
@@ -430,4 +425,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 6d28ba7e6..0c02b3767 100644
--- a/Scripts/Engines/Help/HelpGump.cs
+++ b/Scripts/Engines/Help/HelpGump.cs
@@ -74,10 +74,7 @@ namespace Server.Engines.Help
private static bool IsYoung( Mobile m )
{
- if ( m is PlayerMobile )
- return ((PlayerMobile)m).Young;
-
- return false;
+ return m is PlayerMobile mobile && mobile.Young;
}
public static bool CheckCombat( Mobile m )
@@ -162,21 +159,21 @@ namespace Server.Engines.Help
* Use this option when another player is verbally harassing your character.
* Verbal harassment behaviors include but are not limited to, using bad language, threats etc..
* Before you submit a complaint be sure you understand what constitutes harassment
- * – what is verbal harassment? -
+ * � what is verbal harassment? -
* and that you have followed these steps:
* 1. You have asked the player to stop and they have continued.
* 2. You have tried to remove yourself from the situation.
* 3. You have done nothing to instigate or further encourage the harassment.
* 4. You have added the player to your ignore list.
* - How do I ignore a player?
- * 5. You have read and understand Origin’s definition of harassment.
+ * 5. You have read and understand Origin�s definition of harassment.
* 6. Your account information is up to date. (Including a current email address)
* *If these steps have not been taken, GMs may be unable to take action against the offending player.
* **A chat log will be review by a GM to assess the validity of this complaint.
* Abuse of this system is a violation of the Rules of Conduct.
* EXPLOITING
* Use this option to report someone who may be exploiting or cheating.
- * – What constitutes an exploit?
+ * � What constitutes an exploit?
*/
AddButton( 80, 240, 5540, 5541, 8, GumpButtonType.Reply, 0 );
@@ -186,14 +183,14 @@ namespace Server.Engines.Help
* Use this option when another player is harassing your character using game mechanics.
* Physical harassment includes but is not limited to luring, Kill Stealing, and any act that causes a players death in Trammel.
* Before you submit a complaint be sure you understand what constitutes harassment
- * – what is physical harassment?
+ * � what is physical harassment?
* and that you have followed these steps:
* 1. You have asked the player to stop and they have continued.
* 2. You have tried to remove yourself from the situation.
* 3. You have done nothing to instigate or further encourage the harassment.
* 4. You have added the player to your ignore list.
* - how do I ignore a player?
- * 5. You have read and understand Origin’s definition of harassment.
+ * 5. You have read and understand Origin�s definition of harassment.
* 6. Your account information is up to date. (Including a current email address)
* *If these steps have not been taken, GMs may be unable to take action against the offending player.
* **This issue will be reviewed by a GM to assess the validity of this complaint.
@@ -239,13 +236,13 @@ namespace Server.Engines.Help
{
from.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
}
- else if ( from is PlayerMobile && ((PlayerMobile)from).CanUseStuckMenu() && from.Region.CanUseStuckMenu( from ) && !CheckCombat( from ) && !from.Frozen && !from.Criminal && (Core.AOS || from.Kills < 5) )
+ else if ( from is PlayerMobile mobile && mobile.CanUseStuckMenu() && mobile.Region.CanUseStuckMenu( mobile ) && !CheckCombat( mobile ) && !mobile.Frozen && !mobile.Criminal && (Core.AOS || mobile.Kills < 5) )
{
- StuckMenu menu = new StuckMenu( from, from, true );
+ StuckMenu menu = new StuckMenu( mobile, mobile, true );
menu.BeginClose();
- from.SendGump( menu );
+ mobile.SendGump( menu );
}
else
{
@@ -310,4 +307,4 @@ namespace Server.Engines.Help
from.SendGump( new PagePromptGump( from, type ) );
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Help/PageQueue.cs b/Scripts/Engines/Help/PageQueue.cs
index 45d36b88f..81a2019ec 100644
--- a/Scripts/Engines/Help/PageQueue.cs
+++ b/Scripts/Engines/Help/PageQueue.cs
@@ -149,8 +149,7 @@ namespace Server.Engines.Help
m_PageLocation = sender.Location;
m_PageMap = sender.Map;
- PlayerMobile pm = sender as PlayerMobile;
- if ( pm != null && pm.SpeechLog != null && Array.IndexOf( SpeechLogAttachment, type ) >= 0 )
+ if ( sender is PlayerMobile pm && pm.SpeechLog != null && Array.IndexOf( SpeechLogAttachment, type ) >= 0 )
m_SpeechLog = new List( pm.SpeechLog );
m_Timer = new InternalTimer( this );
@@ -183,7 +182,7 @@ namespace Server.Engines.Help
if ( m_Entry.Sender.NetState != null && index != -1 )
{
- m_Entry.Sender.SendLocalizedMessage( 1008077, true, (index + 1).ToString() ); // Thank you for paging. Queue status :
+ m_Entry.Sender.SendLocalizedMessage( 1008077, true, (index + 1).ToString() ); // Thank you for paging. Queue status :
m_Entry.Sender.SendLocalizedMessage( 1008084 ); // You can reference our website at www.uo.com or contact us at support@uo.com. To cancel your page, please select the help button again and select cancel.
if ( m_Entry.Handler != null && m_Entry.Handler.NetState == null ) {
@@ -214,9 +213,7 @@ namespace Server.Engines.Help
public static bool CheckAllowedToPage( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm == null )
+ if ( !(from is PlayerMobile pm) )
return true;
if ( pm.DesignContext != null )
@@ -224,7 +221,7 @@ namespace Server.Engines.Help
from.SendLocalizedMessage( 500182 ); // You cannot request help while customizing a house or transferring a character.
return false;
}
- else if ( pm.PagingSquelched )
+ if ( pm.PagingSquelched )
{
from.SendMessage( "You cannot request help, sorry." );
return false;
@@ -392,4 +389,4 @@ namespace Server.Engines.Help
Email.AsyncSend( mail );
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Help/SpeechLog.cs b/Scripts/Engines/Help/SpeechLog.cs
index 2075045f5..4681f69cb 100644
--- a/Scripts/Engines/Help/SpeechLog.cs
+++ b/Scripts/Engines/Help/SpeechLog.cs
@@ -43,9 +43,7 @@ namespace Server.Engines.Help
protected override void OnTarget( Mobile from, object targeted )
{
- PlayerMobile pm = targeted as PlayerMobile;
-
- if ( pm == null )
+ if ( !(targeted is PlayerMobile pm) )
{
from.SendMessage( "Speech logs aren't supported on that target." );
}
@@ -145,4 +143,4 @@ namespace Server.Engines.Help
m_Created = DateTime.UtcNow;
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Help/StuckMenu.cs b/Scripts/Engines/Help/StuckMenu.cs
index 7eb674ec3..22246aaf5 100644
--- a/Scripts/Engines/Help/StuckMenu.cs
+++ b/Scripts/Engines/Help/StuckMenu.cs
@@ -133,8 +133,8 @@ namespace Server.Menus.Questions
m_Mobile = beheld;
m_MarkUse = markUse;
- Closable = false;
- Dragable = false;
+ Closable = false;
+ Dragable = false;
Disposable = false;
AddBackground( 0, 0, 270, 320, 2600 );
@@ -198,14 +198,14 @@ namespace Server.Menus.Questions
private void Teleport( StuckMenuEntry entry )
{
- if ( m_MarkUse )
+ if ( m_MarkUse )
{
m_Mobile.SendLocalizedMessage( 1010589 ); // You will be teleported within the next two minutes.
new TeleportTimer( m_Mobile, entry, TimeSpan.FromSeconds( 10.0 + (Utility.RandomDouble() * 110.0) ) ).Start();
- if (m_Mobile is PlayerMobile)
- ((PlayerMobile)m_Mobile).UsedStuckMenu();
+ if (m_Mobile is PlayerMobile mobile)
+ mobile.UsedStuckMenu();
}
else
{
@@ -237,8 +237,8 @@ namespace Server.Menus.Questions
{
m_Mobile.Frozen = true;
}
- }
- }
+ }
+ }
private class TeleportTimer : Timer
{
@@ -289,4 +289,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 341516c90..0be57f7f0 100644
--- a/Scripts/Engines/Khaldun/KhaldunGen.cs
+++ b/Scripts/Engines/Khaldun/KhaldunGen.cs
@@ -7,19 +7,19 @@ namespace Server.Commands
public class GenKhaldun
{
private static int m_Count;
-
+
public static void Initialize()
{
CommandSystem.Register( "GenKhaldun", AccessLevel.Administrator, new CommandEventHandler( GenKhaldun_OnCommand ) );
}
-
+
public static bool FindMorphItem( int x, int y, int z, int inactiveItemID, int activeItemID )
{
IPooledEnumerable- eable = Map.Felucca.GetItemsInRange( new Point3D( x, y, z ), 0 );
foreach ( Item item in eable )
{
- if ( item is MorphItem && item.Z == z && ((MorphItem)item).InactiveItemID == inactiveItemID && ((MorphItem)item).ActiveItemID == activeItemID )
+ if ( item is MorphItem morphItem && morphItem.Z == z && morphItem.InactiveItemID == inactiveItemID && morphItem.ActiveItemID == activeItemID )
{
eable.Free();
return true;
@@ -29,7 +29,7 @@ namespace Server.Commands
eable.Free();
return false;
}
-
+
public static bool FindEffectController( int x, int y, int z )
{
IPooledEnumerable eable = Map.Felucca.GetItemsInRange( new Point3D( x, y, z ), 0 );
@@ -46,7 +46,7 @@ namespace Server.Commands
eable.Free();
return false;
}
-
+
public static Item TryCreateItem( int x, int y, int z, Item srcItem )
{
IPooledEnumerable
- eable = Map.Felucca.GetItemsInBounds( new Rectangle2D( x, y, 1, 1 ) );
@@ -64,68 +64,68 @@ namespace Server.Commands
eable.Free();
srcItem.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
-
+
return srcItem;
}
-
+
public static void CreateMorphItem( int x, int y, int z, int inactiveItemID, int activeItemID, int range )
{
if ( FindMorphItem( x, y, z, inactiveItemID, activeItemID ) )
return;
-
+
MorphItem item = new MorphItem( inactiveItemID, activeItemID, range, 3 );
-
+
item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
}
-
+
public static void CreateApproachLight( int x, int y, int z, int off, int on, LightType light )
{
if ( FindMorphItem( x, y, z, off, on ) )
return;
-
+
MorphItem item = new MorphItem( off, on, 2, 3 );
item.Light = light;
-
+
item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
}
-
+
public static void CreateSoundEffect( int x, int y, int z, int sound, int range )
{
if ( FindEffectController( x, y, z ) )
return;
-
+
EffectController item = new EffectController();
item.SoundID = sound;
item.TriggerType = EffectTriggerType.InRange;
item.TriggerRange = range;
-
+
item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
}
-
+
public static void CreateBigTeleporterItem( int x, int y, bool reverse )
{
if ( FindMorphItem( x, y, 0, reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC ) )
return;
-
+
MorphItem item = new MorphItem( reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC, 1, 3 );
-
+
item.MoveToWorld( new Point3D( x, y, 0 ), Map.Felucca );
m_Count++;
}
-
+
public static void GenKhaldun_OnCommand( CommandEventArgs e )
{
m_Count = 0;
-
+
// Generate Morph Items
- CreateMorphItem( 5459, 1416, 0, 0x1D0, 0x1, 1 );
+ CreateMorphItem( 5459, 1416, 0, 0x1D0, 0x1, 1 );
CreateMorphItem( 5460, 1416, 0, 0x1D0, 0x1, 1 );
CreateMorphItem( 5459, 1416, 0, 0x1, 0x53D, 1 );
CreateMorphItem( 5460, 1416, 0, 0x1, 0x53B, 1 );
-
+
CreateMorphItem( 5459, 1425, 0, 0x1, 0x53B, 2 );
CreateMorphItem( 5459, 1426, 0, 0x1, 0x53B, 2 );
CreateMorphItem( 5459, 1427, 0, 0x1, 0x53B, 2 );
@@ -151,7 +151,7 @@ namespace Server.Commands
CreateMorphItem( 5459, 1417, 0, 0x1, 0x54C, 1 );
CreateMorphItem( 5459, 1419, 0, 0x1, 0x54C, 2 );
CreateMorphItem( 5459, 1424, 0, 0x1, 0x54C, 2 );
-
+
CreateMorphItem( 5458, 1426, 0, 0x1, 0x1D1, 2 );
CreateMorphItem( 5459, 1427, 0, 0x1, 0x1E3, 2 );
CreateMorphItem( 5458, 1425, 3, 0x1, 0x1E4, 2 );
@@ -161,50 +161,50 @@ namespace Server.Commands
CreateMorphItem( 5458, 1425, 0, 0x1, 0x1EA, 2 );
CreateMorphItem( 5458, 1427, 0, 0x1, 0x1EA, 2 );
CreateMorphItem( 5458, 1427, 3, 0x1, 0x1EA, 2 );
-
+
// Generate Approach Lights
CreateApproachLight( 5393, 1417, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5393, 1420, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5395, 1421, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5396, 1417, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5397, 1419, 0, 0x1857, 0x1858, LightType.Circle150 );
-
+
CreateApproachLight( 5441, 1393, 5, 0x1F2B, 0x19BB, LightType.Circle225 );
CreateApproachLight( 5446, 1393, 5, 0x1F2B, 0x19BB, LightType.Circle225 );
-
+
// Generate Sound Effects
CreateSoundEffect( 5425, 1489, 5, 0x102, 1 );
CreateSoundEffect( 5425, 1491, 5, 0x102, 1 );
-
+
CreateSoundEffect( 5449, 1499, 10, 0xF5, 1 );
CreateSoundEffect( 5451, 1499, 10, 0xF5, 1 );
CreateSoundEffect( 5453, 1499, 10, 0xF5, 1 );
-
+
CreateSoundEffect( 5524, 1367, 0, 0x102, 1 );
-
+
CreateSoundEffect( 5450, 1370, 0, 0x220, 2 );
CreateSoundEffect( 5450, 1372, 0, 0x220, 2 );
-
+
CreateSoundEffect( 5460, 1416, 0, 0x244, 2 );
-
+
CreateSoundEffect( 5483, 1439, 5, 0x14, 3 );
-
+
// Generate Big Teleporter
CreateBigTeleporterItem( 5387, 1325, true );
CreateBigTeleporterItem( 5388, 1326, true );
CreateBigTeleporterItem( 5388, 1325, false );
CreateBigTeleporterItem( 5387, 1326, false );
-
+
// Generate Central Khaldun entrance
DisappearingRaiseSwitch sw = TryCreateItem( 5459, 1426, 10, new DisappearingRaiseSwitch() ) as DisappearingRaiseSwitch;
RaiseSwitch lv = TryCreateItem( 5403, 1359, 0, new RaiseSwitch() ) as RaiseSwitch;
-
+
RaisableItem stone = TryCreateItem( 5403, 1360, 0, new RaisableItem( 0x788, 10, 0x477, 0x475, TimeSpan.FromMinutes( 1.5 ) ) ) as RaisableItem;
RaisableItem door = TryCreateItem( 5524, 1367, 0, new RaisableItem( 0x1D0, 20, 0x477, 0x475, TimeSpan.FromMinutes( 5.0 ) ) ) as RaisableItem;
-
+
sw.RaisableItem = stone;
lv.RaisableItem = door;
-
+
e.Mobile.SendMessage( String.Format( "{0} dynamic Khaldun item{1} generated.", m_Count, m_Count == 1 ? "" : "s" ) );
}
}
diff --git a/Scripts/Engines/Khaldun/PuzzleChest.cs b/Scripts/Engines/Khaldun/PuzzleChest.cs
index eadc51353..cedc306c1 100644
--- a/Scripts/Engines/Khaldun/PuzzleChest.cs
+++ b/Scripts/Engines/Khaldun/PuzzleChest.cs
@@ -591,16 +591,11 @@ namespace Server.Items
else
item = Loot.RandomArmorOrShieldOrWeapon();
- if ( item is BaseWeapon )
+ if ( item is BaseWeapon weapon )
{
- BaseWeapon weapon = (BaseWeapon)item;
-
if ( Core.AOS )
{
- int attributeCount;
- int min, max;
-
- GetRandomAOSStats( out attributeCount, out min, out max );
+ GetRandomAOSStats( out int attributeCount, out int min, out int max );
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
}
@@ -611,18 +606,13 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
}
- DropItem( item );
+ DropItem( weapon );
}
- else if ( item is BaseArmor )
+ else if ( item is BaseArmor armor )
{
- BaseArmor armor = (BaseArmor)item;
-
if ( Core.AOS )
{
- int attributeCount;
- int min, max;
-
- GetRandomAOSStats( out attributeCount, out min, out max );
+ GetRandomAOSStats( out int attributeCount, out int min, out int max );
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
}
@@ -632,34 +622,26 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
}
- DropItem( item );
+ DropItem( armor );
}
- else if ( item is BaseHat )
+ else if ( item is BaseHat hat )
{
- BaseHat hat = (BaseHat)item;
-
if ( Core.AOS )
{
- int attributeCount;
- int min, max;
-
- GetRandomAOSStats( out attributeCount, out min, out max );
+ GetRandomAOSStats( out int attributeCount, out int min, out int max );
BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
}
- DropItem( item );
+ DropItem( hat );
}
- else if ( item is BaseJewel )
+ else if ( item is BaseJewel jewel )
{
- int attributeCount;
- int min, max;
+ GetRandomAOSStats( out int attributeCount, out int min, out int max );
- GetRandomAOSStats( out attributeCount, out min, out max );
+ BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
- BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );
-
- DropItem( item );
+ DropItem( jewel );
}
}
diff --git a/Scripts/Engines/MLQuests/Definitions/Heritage.cs b/Scripts/Engines/MLQuests/Definitions/Heritage.cs
index 2c2ea2c99..dacd88230 100644
--- a/Scripts/Engines/MLQuests/Definitions/Heritage.cs
+++ b/Scripts/Engines/MLQuests/Definitions/Heritage.cs
@@ -126,9 +126,7 @@ namespace Server.Engines.MLQuests.Definitions
public override bool CheckItem( Item item )
{
- Pitcher pitcher = item as Pitcher; // Only pitchers work
-
- return ( pitcher != null && pitcher.Content == BeverageType.Water && pitcher.Quantity > 0 );
+ return ( item is Pitcher pitcher && pitcher.Content == BeverageType.Water && pitcher.Quantity > 0 );
}
}
}
diff --git a/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs b/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs
index 214023eac..f3565538b 100644
--- a/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs
+++ b/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs
@@ -620,9 +620,7 @@ namespace Server.Engines.MLQuests.Definitions
{
Item item = base.CreateItem();
- Spellbook book = item as Spellbook;
-
- if ( book != null )
+ if ( item is Spellbook book )
book.Content = ( 1ul << book.BookCount ) - 1;
return item;
diff --git a/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs b/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs
index 8da954378..72875cc4d 100644
--- a/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs
+++ b/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs
@@ -39,9 +39,7 @@ namespace Server.Engines.MLQuests.Gumps
public override void OnResponse( NetState sender, RelayInfo info )
{
- PlayerMobile pm = sender.Mobile as PlayerMobile;
-
- if ( pm == null )
+ if ( !(sender.Mobile is PlayerMobile pm) )
return;
switch ( info.ButtonID )
diff --git a/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs b/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs
index eded18974..e295f7b27 100644
--- a/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs
+++ b/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs
@@ -193,9 +193,7 @@ namespace Server.Engines.MLQuests.Gumps
CloseCurrent( state );
- PlayerMobile pm = state.Mobile as PlayerMobile;
-
- if ( pm == null )
+ if ( !(state.Mobile is PlayerMobile pm) )
return;
IRaceChanger owner = raceChangeState.m_Owner;
@@ -203,8 +201,7 @@ namespace Server.Engines.MLQuests.Gumps
if ( pvSrc.Size == 5 )
{
- if ( owner != null )
- owner.OnCancel( pm );
+ owner?.OnCancel( pm );
return;
}
@@ -248,8 +245,7 @@ namespace Server.Engines.MLQuests.Gumps
else
pm.SendMessage( "You have fully changed your race to {0}.", targetRace.Name );
- if ( owner != null )
- owner.ConsumeNeeded( pm );
+ owner?.ConsumeNeeded( pm );
}
}
@@ -319,9 +315,7 @@ namespace Server.Engines.MLQuests.Gumps
public override void OnDoubleClick( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm == null )
+ if ( !(from is PlayerMobile pm) )
return;
if ( CheckComplete( pm ) )
diff --git a/Scripts/Engines/MLQuests/Items/BedlamTeleporter.cs b/Scripts/Engines/MLQuests/Items/BedlamTeleporter.cs
index 0d9f5140c..037bf9dd0 100644
--- a/Scripts/Engines/MLQuests/Items/BedlamTeleporter.cs
+++ b/Scripts/Engines/MLQuests/Items/BedlamTeleporter.cs
@@ -27,12 +27,10 @@ namespace Server.Engines.MLQuests.Items
return;
}
- MLQuestContext context;
-
- if ( from is PlayerMobile && ( context = MLQuestSystem.GetContext( (PlayerMobile)from ) ) != null && context.BedlamAccess )
+ if ( from is PlayerMobile mobile && MLQuestSystem.GetContext( mobile )?.BedlamAccess == true )
{
- BaseCreature.TeleportPets( from, PointDest, MapDest );
- from.MoveToWorld( PointDest, MapDest );
+ BaseCreature.TeleportPets( mobile, PointDest, MapDest );
+ mobile.MoveToWorld( PointDest, MapDest );
}
else
{
diff --git a/Scripts/Engines/MLQuests/Items/PrismaticCrystal.cs b/Scripts/Engines/MLQuests/Items/PrismaticCrystal.cs
index 0f211dc3c..9222adb13 100644
--- a/Scripts/Engines/MLQuests/Items/PrismaticCrystal.cs
+++ b/Scripts/Engines/MLQuests/Items/PrismaticCrystal.cs
@@ -24,16 +24,12 @@ namespace Server.Items
public override void OnDoubleClick( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm == null || pm.Backpack == null )
+ if ( !(from is PlayerMobile pm) || pm.Backpack == null )
return;
if ( pm.InRange( GetWorldLocation(), 2 ) )
{
- MLQuestContext context = MLQuestSystem.GetContext( pm );
-
- if ( context != null && context.IsDoingQuest( typeof( UnfadingMemoriesPartOne ) ) && pm.Backpack.FindItemByType( typeof( PrismaticAmber ), false ) == null )
+ if ( MLQuestSystem.GetContext( pm )?.IsDoingQuest( typeof( UnfadingMemoriesPartOne ) ) == true && pm.Backpack.FindItemByType( typeof( PrismaticAmber ), false ) == null )
{
Item amber = new PrismaticAmber();
diff --git a/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs b/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs
index fcf0c8a46..300d214ab 100644
--- a/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs
+++ b/Scripts/Engines/MLQuests/Items/QuestGiverItem.cs
@@ -52,8 +52,8 @@ namespace Server.Engines.MLQuests.Items
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042593 ); // That is not in your backpack.
- else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile )
- MLQuestSystem.OnDoubleClick( this, (PlayerMobile)from );
+ else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile )
+ MLQuestSystem.OnDoubleClick( this, mobile );
}
public override void OnAfterDelete()
@@ -133,8 +133,8 @@ namespace Server.Engines.MLQuests.Items
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042593 ); // That is not in your backpack.
- else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile )
- MLQuestSystem.OnDoubleClick( this, (PlayerMobile)from );
+ else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile )
+ MLQuestSystem.OnDoubleClick( this, mobile );
}
public override void OnAfterDelete()
diff --git a/Scripts/Engines/MLQuests/Items/RewardBags.cs b/Scripts/Engines/MLQuests/Items/RewardBags.cs
index 608c73122..e75051371 100644
--- a/Scripts/Engines/MLQuests/Items/RewardBags.cs
+++ b/Scripts/Engines/MLQuests/Items/RewardBags.cs
@@ -43,14 +43,18 @@ namespace Server.Engines.MLQuests.Items
public static void Enhance( Item loot )
{
- if ( loot is BaseWeapon )
- BaseRunicTool.ApplyAttributesTo( (BaseWeapon)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
- else if ( loot is BaseArmor )
- BaseRunicTool.ApplyAttributesTo( (BaseArmor)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
- else if ( loot is BaseShield )
- BaseRunicTool.ApplyAttributesTo( (BaseShield)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
- else if ( loot is BaseJewel )
- BaseRunicTool.ApplyAttributesTo( (BaseJewel)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
+ switch (loot)
+ {
+ case BaseWeapon weapon:
+ BaseRunicTool.ApplyAttributesTo( weapon, Utility.RandomMinMax( 1, 5 ), 10, 80 );
+ break;
+ case BaseArmor armor:
+ BaseRunicTool.ApplyAttributesTo( armor, Utility.RandomMinMax( 1, 5 ), 10, 80 );
+ break;
+ default:
+ BaseRunicTool.ApplyAttributesTo((BaseJewel)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
+ break;
+ }
}
}
diff --git a/Scripts/Engines/MLQuests/Items/Teleporters.cs b/Scripts/Engines/MLQuests/Items/Teleporters.cs
index 739780ec8..07a14c81a 100644
--- a/Scripts/Engines/MLQuests/Items/Teleporters.cs
+++ b/Scripts/Engines/MLQuests/Items/Teleporters.cs
@@ -51,23 +51,19 @@ namespace Server.Engines.MLQuests.Items
if (!base.CanTeleport(m))
return false;
- if (m_QuestType != null)
- {
- PlayerMobile pm = m as PlayerMobile;
+ if (m_QuestType == null)
+ return true;
+ if (!(m is PlayerMobile pm))
+ return false;
- if (pm == null)
- return false;
+ MLQuestContext context = MLQuestSystem.GetContext(pm);
- MLQuestContext context = MLQuestSystem.GetContext(pm);
+ if (context?.IsDoingQuest(m_QuestType) == true || context?.HasDoneQuest(m_QuestType) == true)
+ return true;
- if (context == null || (!context.IsDoingQuest(m_QuestType) && !context.HasDoneQuest(m_QuestType)))
- {
- TextDefinition.SendMessageTo(m, m_Message);
- return false;
- }
- }
+ TextDefinition.SendMessageTo(m, m_Message);
+ return false;
- return true;
}
public override void GetProperties(ObjectPropertyList list)
@@ -169,7 +165,7 @@ namespace Server.Engines.MLQuests.Items
{
foreach (Item item in m.Items) // Check paperdoll
{
- if (m_TicketType.IsAssignableFrom(item.GetType()))
+ if (m_TicketType.IsInstanceOfType(item))
{
ticket = item;
break;
@@ -183,8 +179,7 @@ namespace Server.Engines.MLQuests.Items
return false;
}
- if (ticket is ITicket)
- ((ITicket)ticket).OnTicketUsed(m);
+ (ticket as ITicket)?.OnTicketUsed(m);
}
return true;
diff --git a/Scripts/Engines/MLQuests/MLQuestSystem.cs b/Scripts/Engines/MLQuests/MLQuestSystem.cs
index 7f33ee602..8ea5c8bbe 100644
--- a/Scripts/Engines/MLQuests/MLQuestSystem.cs
+++ b/Scripts/Engines/MLQuests/MLQuestSystem.cs
@@ -203,9 +203,8 @@ namespace Server.Engines.MLQuests
public override void Execute( CommandEventArgs e, object obj )
{
Mobile from = e.Mobile;
- PlayerMobile pm = obj as PlayerMobile;
- if ( pm == null )
+ if ( !(obj is PlayerMobile pm) )
{
LogFailure( "That is not a player." );
return;
@@ -230,9 +229,7 @@ namespace Server.Engines.MLQuests
public override void Execute( CommandEventArgs e, object obj )
{
- PlayerMobile pm = obj as PlayerMobile;
-
- if ( pm == null )
+ if ( !(obj is PlayerMobile pm) )
LogFailure( "They have no ML quest context." );
else
e.Mobile.SendGump( new PropertiesGump( e.Mobile, GetOrCreateContext( pm ) ) );
@@ -303,13 +300,9 @@ namespace Server.Engines.MLQuests
{
if ( item.QuestItem )
{
- Backpack pack = item.Parent as Backpack;
-
- if ( pack != null )
+ if ( item.Parent is Backpack pack )
{
- PlayerMobile player = pack.Parent as PlayerMobile;
-
- if ( player != null && player.Backpack == pack )
+ if ( pack.Parent is PlayerMobile player && player.Backpack == pack )
continue;
}
@@ -487,9 +480,9 @@ namespace Server.Engines.MLQuests
foreach ( BaseObjectiveInstance objective in instance.Objectives )
{
- if ( !objective.Expired && objective is GainSkillObjectiveInstance && ( (GainSkillObjectiveInstance)objective ).Handles( skill ) )
+ if ( !objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && objectiveInstance.Handles( skill ) )
{
- objective.CheckComplete();
+ objectiveInstance.CheckComplete();
break;
}
}
@@ -520,10 +513,8 @@ namespace Server.Engines.MLQuests
*/
foreach ( BaseObjectiveInstance objective in instance.Objectives )
{
- if ( !objective.Expired && objective is KillObjectiveInstance )
+ if ( !objective.Expired && objective is KillObjectiveInstance kill )
{
- KillObjectiveInstance kill = (KillObjectiveInstance)objective;
-
if ( type == null )
type = mob.GetType();
@@ -558,26 +549,21 @@ namespace Server.Engines.MLQuests
foreach ( BaseObjectiveInstance objective in instance.Objectives )
{
// Note: On OSI, expired deliveries can still be completed. Bug?
- if ( !objective.Expired && objective is DeliverObjectiveInstance )
+ if ( !objective.Expired && objective is DeliverObjectiveInstance deliver && deliver.IsDestination( quester, questerType ) )
{
- DeliverObjectiveInstance deliver = (DeliverObjectiveInstance)objective;
-
- if ( deliver.IsDestination( quester, questerType ) )
+ if ( !deliver.HasCompleted ) // objective completes only once
{
- if ( !deliver.HasCompleted ) // objective completes only once
- {
- deliver.HasCompleted = true;
- deliver.CheckComplete();
+ deliver.HasCompleted = true;
+ deliver.CheckComplete();
- // The quest is continued with this NPC (important for chains)
- instance.Quester = quester;
- }
-
- if ( deliverInstance == null )
- deliverInstance = instance;
-
- break; // don't return, we may have to complete more deliveries
+ // The quest is continued with this NPC (important for chains)
+ instance.Quester = quester;
}
+
+ if ( deliverInstance == null )
+ deliverInstance = instance;
+
+ break; // don't return, we may have to complete more deliveries
}
}
}
@@ -637,9 +623,7 @@ namespace Server.Engines.MLQuests
public static void EventSink_QuestGumpRequest( QuestGumpRequestArgs args )
{
- PlayerMobile pm = args.Mobile as PlayerMobile;
-
- if ( !Enabled || pm == null )
+ if ( !Enabled || !(args.Mobile is PlayerMobile pm) )
return;
pm.SendGump( new QuestLogGump( pm ) );
@@ -681,21 +665,18 @@ namespace Server.Engines.MLQuests
public static void TurnToFace( IQuestGiver quester, Mobile mob )
{
- if ( quester is Mobile )
- {
- Mobile m = (Mobile)quester;
+ if ( quester is Mobile m )
m.Direction = m.GetDirectionTo( mob );
- }
}
public static void Tell( IQuestGiver quester, PlayerMobile pm, int cliloc )
{
TurnToFace( quester, pm );
- if ( quester is Mobile )
- ((Mobile)quester).PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, pm.NetState );
- else if ( quester is Item )
- MessageHelper.SendLocalizedMessageTo( (Item)quester, pm, cliloc, SpeechColor );
+ if ( quester is Mobile mobile )
+ mobile.PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, pm.NetState );
+ else if ( quester is Item item )
+ MessageHelper.SendLocalizedMessageTo( item, pm, cliloc, SpeechColor );
else
pm.SendLocalizedMessage( cliloc, "", SpeechColor );
}
@@ -704,10 +685,10 @@ namespace Server.Engines.MLQuests
{
TurnToFace( quester, pm );
- if ( quester is Mobile )
- ((Mobile)quester).PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, args, pm.NetState );
- else if ( quester is Item )
- MessageHelper.SendLocalizedMessageTo( (Item)quester, pm, cliloc, args, SpeechColor );
+ if ( quester is Mobile mobile )
+ mobile.PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, args, pm.NetState );
+ else if ( quester is Item item )
+ MessageHelper.SendLocalizedMessageTo( item, pm, cliloc, args, SpeechColor );
else
pm.SendLocalizedMessage( cliloc, args, SpeechColor );
}
@@ -716,10 +697,10 @@ namespace Server.Engines.MLQuests
{
TurnToFace( quester, pm );
- if ( quester is Mobile )
- ((Mobile)quester).PrivateOverheadMessage( MessageType.Regular, SpeechColor, false, message, pm.NetState );
- else if ( quester is Item )
- MessageHelper.SendMessageTo( (Item)quester, pm, message, SpeechColor );
+ if ( quester is Mobile mobile )
+ mobile.PrivateOverheadMessage( MessageType.Regular, SpeechColor, false, message, pm.NetState );
+ else if ( quester is Item item )
+ MessageHelper.SendMessageTo( item, pm, message, SpeechColor );
else
pm.SendMessage( SpeechColor, message );
}
diff --git a/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs b/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs
index 602cdf417..f643c026a 100644
--- a/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs
+++ b/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs
@@ -185,8 +185,8 @@ namespace Server.Engines.MLQuests.Objectives
{
bool completed = reader.ReadBool();
- if ( objInstance is EscortObjectiveInstance )
- ( (EscortObjectiveInstance)objInstance ).HasCompleted = completed;
+ if ( objInstance is EscortObjectiveInstance instance )
+ instance.HasCompleted = completed;
break;
}
@@ -194,8 +194,8 @@ namespace Server.Engines.MLQuests.Objectives
{
int slain = reader.ReadInt();
- if ( objInstance is KillObjectiveInstance )
- ( (KillObjectiveInstance)objInstance ).Slain = slain;
+ if ( objInstance is KillObjectiveInstance instance )
+ instance.Slain = slain;
break;
}
@@ -203,8 +203,8 @@ namespace Server.Engines.MLQuests.Objectives
{
bool completed = reader.ReadBool();
- if ( objInstance is DeliverObjectiveInstance )
- ( (DeliverObjectiveInstance)objInstance ).HasCompleted = completed;
+ if ( objInstance is DeliverObjectiveInstance instance )
+ instance.HasCompleted = completed;
break;
}
diff --git a/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs b/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs
index b94e0d230..d78ede244 100644
--- a/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs
+++ b/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs
@@ -76,9 +76,7 @@ namespace Server.Engines.MLQuests.Objectives
for ( int i = 0; i < m_Amount; ++i )
{
- Item item = Activator.CreateInstance( m_Delivery ) as Item;
-
- if ( item == null )
+ if ( !(Activator.CreateInstance( m_Delivery ) is Item item) )
continue;
delivery.Add( item );
diff --git a/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs b/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs
index ae79bec9e..c7fd4971a 100644
--- a/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs
+++ b/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs
@@ -31,7 +31,7 @@ namespace Server.Engines.MLQuests.Objectives
public override bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
{
- if ( ( quester is BaseCreature && ( (BaseCreature)quester ).Controlled ) || ( quester is BaseEscortable && ( (BaseEscortable)quester ).IsBeingDeleted ) )
+ if ( ( quester is BaseCreature creature && creature.Controlled ) || ( quester is BaseEscortable escortable && escortable.IsBeingDeleted ) )
return false;
MLQuestContext context = MLQuestSystem.GetContext( pm );
@@ -145,7 +145,7 @@ namespace Server.Engines.MLQuests.Objectives
if ( pm.Young || m_Escort.Region.IsPartOf( "Haven Island" ) )
Titles.AwardFame( pm, 10, true );
else
- VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, ( m_Escort is BaseEscortable && ( (BaseEscortable)m_Escort ).IsPrisoner ) ? 400 : 200 );
+ VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, ( m_Escort is BaseEscortable escortable && escortable.IsPrisoner ) ? 400 : 200 );
EndFollow( m_Escort );
StopTimer();
@@ -203,8 +203,7 @@ namespace Server.Engines.MLQuests.Objectives
quester.SetControlMaster( null );
- if ( quester is BaseEscortable )
- ( (BaseEscortable)quester ).BeginDelete();
+ (quester as BaseEscortable)?.BeginDelete();
}
public override void OnQuestAccepted()
diff --git a/Scripts/Engines/MyRunUO/DatabaseCommandQueue.cs b/Scripts/Engines/MyRunUO/DatabaseCommandQueue.cs
index d45a02e3f..e1eda4761 100644
--- a/Scripts/Engines/MyRunUO/DatabaseCommandQueue.cs
+++ b/Scripts/Engines/MyRunUO/DatabaseCommandQueue.cs
@@ -162,9 +162,9 @@ namespace Server.Engines.MyRunUO
}
}
}
- else if ( obj is string )
+ else if ( obj is string s )
{
- command.CommandText = (string)obj;
+ command.CommandText = s;
command.ExecuteNonQuery();
}
else
@@ -199,4 +199,4 @@ namespace Server.Engines.MyRunUO
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/MyRunUO/MyRunUO.cs b/Scripts/Engines/MyRunUO/MyRunUO.cs
index 96cc10d80..3808d46e0 100644
--- a/Scripts/Engines/MyRunUO/MyRunUO.cs
+++ b/Scripts/Engines/MyRunUO/MyRunUO.cs
@@ -36,9 +36,7 @@ namespace Server.Engines.MyRunUO
[Description( "Enables showing extended character stats and skills in MyRunUO." )]
public static void PublicChar_OnCommand( CommandEventArgs e )
{
- PlayerMobile pm = e.Mobile as PlayerMobile;
-
- if ( pm != null )
+ if ( e.Mobile is PlayerMobile pm )
{
if ( pm.PublicMyRunUO )
{
@@ -56,9 +54,7 @@ namespace Server.Engines.MyRunUO
[Description( "Disables showing extended character stats and skills in MyRunUO." )]
public static void PrivateChar_OnCommand( CommandEventArgs e )
{
- PlayerMobile pm = e.Mobile as PlayerMobile;
-
- if ( pm != null )
+ if ( e.Mobile is PlayerMobile pm )
{
if ( !pm.PublicMyRunUO )
{
@@ -91,7 +87,7 @@ namespace Server.Engines.MyRunUO
{
if ( m_Command != null && !m_Command.HasCompleted )
return;
- DateTime start = DateTime.Now;
+ // DateTime start = DateTime.Now;
Console.WriteLine( "MyRunUO: Creating tables" );
try
{
@@ -108,8 +104,8 @@ namespace Server.Engines.MyRunUO
Console.WriteLine( "MyRunUO: Error creating tables." );
Console.WriteLine( e );
}
- if ( m_Command != null )
- m_Command.Enqueue( null );
+
+ m_Command?.Enqueue( null );
}
[Usage( "UpdateMyRunUO" )]
@@ -334,7 +330,7 @@ namespace Server.Engines.MyRunUO
sb.Append( ent );
}
-
+
private string SafeString( string input )
{
if ( input == null )
@@ -364,8 +360,7 @@ namespace Server.Engines.MyRunUO
case '\\': AppendCharEntity( input, i, ref sb, c ); break;
default:
{
- if ( sb != null )
- sb.Append( c );
+ sb?.Append( c );
break;
}
@@ -394,8 +389,8 @@ namespace Server.Engines.MyRunUO
string notoTitle = SafeString( Titles.ComputeTitle( null, mob ) );
string female = ( mob.Female ? "1" : "0" );
-
- bool pubBool = ( mob is PlayerMobile ) && ( ((PlayerMobile)mob).PublicMyRunUO );
+
+ bool pubBool = mob is PlayerMobile mobile && mobile.PublicMyRunUO;
string pubString = ( pubBool ? "1" : "0" );
@@ -571,8 +566,8 @@ namespace Server.Engines.MyRunUO
{
Mobile mob = (Mobile)m_List[i];
- if ( mob is PlayerMobile )
- ((PlayerMobile)mob).ChangedMyRunUO = false;
+ if ( mob is PlayerMobile mobile )
+ mobile.ChangedMyRunUO = false;
if ( !mob.Deleted && mob.AccessLevel < Config.HiddenAccessLevel )
{
diff --git a/Scripts/Engines/Party/AddPartyTarget.cs b/Scripts/Engines/Party/AddPartyTarget.cs
index 8217e28f1..086db18f9 100644
--- a/Scripts/Engines/Party/AddPartyTarget.cs
+++ b/Scripts/Engines/Party/AddPartyTarget.cs
@@ -13,9 +13,8 @@ namespace Server.Engines.PartySystem
protected override void OnTarget( Mobile from, object o )
{
- if ( o is Mobile )
+ if ( o is Mobile m )
{
- Mobile m = (Mobile)o;
Party p = Party.Get( from );
Party mp = Party.Get( m );
@@ -44,4 +43,4 @@ namespace Server.Engines.PartySystem
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Party/Party.cs b/Scripts/Engines/Party/Party.cs
index 9c4a2ff43..de02f6228 100644
--- a/Scripts/Engines/Party/Party.cs
+++ b/Scripts/Engines/Party/Party.cs
@@ -35,9 +35,9 @@ namespace Server.Engines.PartySystem
public static void ListenToParty_OnTarget( Mobile from, object obj )
{
- if ( obj is Mobile )
+ if ( obj is Mobile mobile )
{
- Party p = Party.Get( (Mobile) obj );
+ Party p = Party.Get( mobile );
if ( p == null )
{
diff --git a/Scripts/Engines/Party/RemovePartyTarget.cs b/Scripts/Engines/Party/RemovePartyTarget.cs
index b06945bde..6b3261edb 100644
--- a/Scripts/Engines/Party/RemovePartyTarget.cs
+++ b/Scripts/Engines/Party/RemovePartyTarget.cs
@@ -12,9 +12,8 @@ namespace Server.Engines.PartySystem
protected override void OnTarget( Mobile from, object o )
{
- if ( o is Mobile )
+ if ( o is Mobile m )
{
- Mobile m = (Mobile)o;
Party p = Party.Get( from );
if ( p == null || p.Leader != from || !p.Contains( m ) )
@@ -27,4 +26,4 @@ namespace Server.Engines.PartySystem
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Pathing/Movement.cs b/Scripts/Engines/Pathing/Movement.cs
index f1bbf36ca..8c090b2f7 100644
--- a/Scripts/Engines/Pathing/Movement.cs
+++ b/Scripts/Engines/Pathing/Movement.cs
@@ -315,7 +315,7 @@ namespace Server.Movement
List mobsLeft = m_MobPools[1];
List mobsRight = m_MobPools[2];
- bool checkMobs = ( m is BaseCreature && !((BaseCreature)m).Controlled && ( xForward != m_Goal.X || yForward != m_Goal.Y ) );
+ bool checkMobs = ( m is BaseCreature creature && !creature.Controlled && ( xForward != m_Goal.X || yForward != m_Goal.Y ) );
if ( checkDiagonals )
{
@@ -589,4 +589,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 950158559..c700df41c 100644
--- a/Scripts/Engines/Pathing/MovementPath.cs
+++ b/Scripts/Engines/Pathing/MovementPath.cs
@@ -65,9 +65,7 @@ namespace Server
public static void Path_OnTarget( Mobile from, object obj )
{
- IPoint3D p = obj as IPoint3D;
-
- if ( p == null )
+ if ( !(obj is IPoint3D p) )
return;
Spells.SpellHelper.GetSurfaceTop( ref p );
@@ -162,4 +160,4 @@ namespace Server
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Pathing/PathFollower.cs b/Scripts/Engines/Pathing/PathFollower.cs
index 0283e119c..e3e023d5f 100644
--- a/Scripts/Engines/Pathing/PathFollower.cs
+++ b/Scripts/Engines/Pathing/PathFollower.cs
@@ -45,8 +45,8 @@ namespace Server
public Point3D GetGoalLocation()
{
- if ( m_Goal is Item )
- return ((Item)m_Goal).GetWorldLocation();
+ if ( m_Goal is Item item )
+ return item.GetWorldLocation();
return new Point3D( m_Goal );
}
@@ -201,4 +201,4 @@ namespace Server
return Check( m_From.Location, goal, range );
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Plants/MainPlantGump.cs b/Scripts/Engines/Plants/MainPlantGump.cs
index 0184ca97a..f3f680831 100644
--- a/Scripts/Engines/Plants/MainPlantGump.cs
+++ b/Scripts/Engines/Plants/MainPlantGump.cs
@@ -228,7 +228,7 @@ namespace Server.Engines.Plants
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant )
return;
-
+
if ( ( ( info.ButtonID >= 6 && info.ButtonID <= 10 ) || info.ButtonID == 12 ) && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
@@ -293,15 +293,15 @@ namespace Server.Engines.Plants
case 6: // Water
{
Item[] item = from.Backpack.FindItemsByType( typeof( BaseBeverage ) );
-
+
bool foundUsableWater = false;
-
+
if ( item != null && item.Length > 0 )
{
for ( int i = 0; i < item.Length; ++i )
{
BaseBeverage beverage = (BaseBeverage)item[i];
-
+
if ( !beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water )
{
foundUsableWater = true;
@@ -310,7 +310,7 @@ namespace Server.Engines.Plants
}
}
}
-
+
if ( !foundUsableWater )
{
from.Target = new PlantPourTarget( m_Plant );
@@ -400,10 +400,8 @@ namespace Server.Engines.Plants
foreach ( Item item in items )
{
- if ( item is BasePotion )
+ if ( item is BasePotion potion )
{
- BasePotion potion = (BasePotion)item;
-
if ( Array.IndexOf( effects, potion.PotionEffect ) >= 0 )
return potion;
}
@@ -419,4 +417,4 @@ namespace Server.Engines.Plants
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Plants/MiscItems/GreenThorns.cs b/Scripts/Engines/Plants/MiscItems/GreenThorns.cs
index 3ef799b57..db9601cdb 100644
--- a/Scripts/Engines/Plants/MiscItems/GreenThorns.cs
+++ b/Scripts/Engines/Plants/MiscItems/GreenThorns.cs
@@ -78,9 +78,7 @@ namespace Server.Items
return;
}
- LandTarget land = targeted as LandTarget;
-
- if ( land == null )
+ if ( !(targeted is LandTarget land) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061912 ); // * You cannot plant a green thorn there! *
}
diff --git a/Scripts/Engines/Plants/MiscItems/RedLeaves.cs b/Scripts/Engines/Plants/MiscItems/RedLeaves.cs
index 4432e6390..d4e970e7a 100644
--- a/Scripts/Engines/Plants/MiscItems/RedLeaves.cs
+++ b/Scripts/Engines/Plants/MiscItems/RedLeaves.cs
@@ -62,9 +62,7 @@ namespace Server.Items
return;
}
- Item item = targeted as Item;
-
- if ( item == null || !item.IsChildOf( from.Backpack ) )
+ if ( !(targeted is Item item) || !item.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
}
diff --git a/Scripts/Engines/Plants/PlantBowl.cs b/Scripts/Engines/Plants/PlantBowl.cs
index 38c5a44cb..ba7c0050b 100644
--- a/Scripts/Engines/Plants/PlantBowl.cs
+++ b/Scripts/Engines/Plants/PlantBowl.cs
@@ -52,12 +52,10 @@ namespace Server.Engines.Plants
return;
}
- if ( targeted is FertileDirt )
+ if ( targeted is FertileDirt dirt )
{
int _dirtNeeded = Core.ML ? 20 : 40;
- FertileDirt dirt = (FertileDirt)targeted;
-
if ( !dirt.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
@@ -132,12 +130,12 @@ namespace Server.Engines.Plants
{
int tileID;
- if ( obj is Static && !((Static)obj).Movable )
- tileID = (((Static)obj).ItemID & 0x3FFF) | 0x4000;
- else if ( obj is StaticTarget )
- tileID = (((StaticTarget)obj).ItemID & 0x3FFF) | 0x4000;
- else if ( obj is LandTarget )
- tileID = ((LandTarget)obj).TileID;
+ if ( obj is Static staticObj && !staticObj.Movable )
+ tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
+ else if ( obj is StaticTarget staticTarget )
+ tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
+ else if ( obj is LandTarget landTarget )
+ tileID = landTarget.TileID;
else
return false;
diff --git a/Scripts/Engines/Plants/PlantItem.cs b/Scripts/Engines/Plants/PlantItem.cs
index 30209701c..1546c079e 100644
--- a/Scripts/Engines/Plants/PlantItem.cs
+++ b/Scripts/Engines/Plants/PlantItem.cs
@@ -151,8 +151,7 @@ namespace Server.Engines.Plants
return true;
- Mobile owner = RootParent as Mobile;
- if ( owner == null )
+ if ( !(RootParent is Mobile owner) )
return false;
if ( owner.Backpack != null && IsChildOf( owner.Backpack ) )
@@ -318,8 +317,7 @@ namespace Server.Engines.Plants
public bool IsUsableBy( Mobile from )
{
- Item root = RootParent as Item;
- return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || root != null && root.IsSecure && root.IsAccessibleTo( from );
+ return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || RootParent is Item root && root.IsSecure && root.IsAccessibleTo( from );
}
public override void OnDoubleClick( Mobile from )
@@ -408,10 +406,8 @@ namespace Server.Engines.Plants
return;
}
- if ( item is BaseBeverage )
+ if ( item is BaseBeverage beverage )
{
- BaseBeverage beverage = (BaseBeverage)item;
-
if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water )
{
LabelTo( from, 1053069 ); // You can't use that on a plant!
@@ -427,12 +423,9 @@ namespace Server.Engines.Plants
from.PlaySound( 0x4E );
LabelTo( from, 1061858 ); // You soften the dirt with water.
}
- else if ( item is BasePotion )
+ else if ( item is BasePotion potion )
{
- BasePotion potion = (BasePotion)item;
-
- int message;
- if ( ApplyPotion( potion.PotionEffect, false, out message ) )
+ if ( ApplyPotion( potion.PotionEffect, false, out int message ) )
{
potion.Consume();
from.PlaySound( 0x240 );
@@ -440,18 +433,15 @@ namespace Server.Engines.Plants
}
LabelTo( from, message );
}
- else if ( item is PotionKeg )
+ else if ( item is PotionKeg keg )
{
- PotionKeg keg = (PotionKeg)item;
-
if ( keg.Held <= 0 )
{
LabelTo( from, 1053069 ); // You can't use that on a plant!
return;
}
- int message;
- if ( ApplyPotion( keg.Type, false, out message ) )
+ if ( ApplyPotion( keg.Type, false, out int message ) )
{
keg.Held--;
from.PlaySound( 0x240 );
diff --git a/Scripts/Engines/Plants/PlantPourTarget.cs b/Scripts/Engines/Plants/PlantPourTarget.cs
index 16f49f49b..31160ae00 100644
--- a/Scripts/Engines/Plants/PlantPourTarget.cs
+++ b/Scripts/Engines/Plants/PlantPourTarget.cs
@@ -15,9 +15,9 @@ namespace Server.Engines.Plants
protected override void OnTarget( Mobile from, object targeted )
{
- if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item )
+ if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item item )
{
- m_Plant.Pour( from, (Item)targeted );
+ m_Plant.Pour( from, item );
}
}
@@ -32,4 +32,4 @@ namespace Server.Engines.Plants
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Plants/PollinateTarget.cs b/Scripts/Engines/Plants/PollinateTarget.cs
index 73a5b3452..b805649a2 100644
--- a/Scripts/Engines/Plants/PollinateTarget.cs
+++ b/Scripts/Engines/Plants/PollinateTarget.cs
@@ -35,9 +35,7 @@ namespace Server.Engines.Plants
}
else
{
- PlantItem targ = targeted as PlantItem;
-
- if ( targ == null || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
+ if ( !(targeted is PlantItem targ) || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
{
m_Plant.LabelTo( from, 1053070 ); // You can only pollinate other specially grown plants!
}
diff --git a/Scripts/Engines/Plants/Seed.cs b/Scripts/Engines/Plants/Seed.cs
index 45aed26e0..c1686c992 100644
--- a/Scripts/Engines/Plants/Seed.cs
+++ b/Scripts/Engines/Plants/Seed.cs
@@ -158,22 +158,12 @@ namespace Server.Engines.Plants
public override bool StackWith( Mobile from, Item dropped, bool playSound )
{
- if ( dropped is Seed )
- {
- Seed other = (Seed)dropped;
-
- if ( other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType )
- return base.StackWith( from, dropped, playSound );
- }
-
- return false;
+ return dropped is Seed other && other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType && base.StackWith( from, other, playSound );
}
public override void OnAfterDuped( Item newItem )
{
- Seed newSeed = newItem as Seed;
-
- if ( newSeed == null )
+ if ( !(newItem is Seed newSeed) )
return;
newSeed.PlantType = m_PlantType;
@@ -202,15 +192,13 @@ namespace Server.Engines.Plants
return;
}
- if ( targeted is PlantItem )
+ if ( targeted is PlantItem plant )
{
- PlantItem plant = (PlantItem)targeted;
-
plant.PlantSeed( from, m_Seed );
}
- else if ( targeted is Item )
+ else if ( targeted is Item item )
{
- ((Item)targeted).LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
+ item.LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
}
else
{
diff --git a/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs b/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs
index e5b098255..441d2cabe 100644
--- a/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs
+++ b/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs
@@ -34,9 +34,7 @@ namespace Server.Engines.Quests.Ambitious
{
this.Direction = GetDirectionTo( player );
- AmbitiousQueenQuest qs = player.Quest as AmbitiousQueenQuest;
-
- if ( qs != null && qs.RedSolen == this.RedSolen )
+ if ( player.Quest is AmbitiousQueenQuest qs && qs.RedSolen == this.RedSolen )
{
if ( qs.IsObjectiveInProgress( typeof( KillQueensObjective ) ) )
{
@@ -56,9 +54,7 @@ namespace Server.Engines.Quests.Ambitious
}
else
{
- GetRewardObjective lastObj = qs.FindObjective( typeof( GetRewardObjective ) ) as GetRewardObjective;
-
- if ( lastObj != null && !lastObj.Completed )
+ if ( qs.FindObjective( typeof( GetRewardObjective ) ) is GetRewardObjective lastObj && !lastObj.Completed )
{
bool bagOfSending = lastObj.BagOfSending;
bool powderOfTranslocation = lastObj.PowderOfTranslocation;
@@ -101,22 +97,16 @@ namespace Server.Engines.Quests.Ambitious
{
this.Direction = GetDirectionTo( from );
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null )
+ if ( from is PlayerMobile player )
{
- AmbitiousQueenQuest qs = player.Quest as AmbitiousQueenQuest;
-
- if ( qs != null && qs.RedSolen == this.RedSolen )
+ if ( player.Quest is AmbitiousQueenQuest qs && qs.RedSolen == this.RedSolen )
{
QuestObjective obj = qs.FindObjective( typeof( GatherFungiObjective ) );
if ( obj != null && !obj.Completed )
{
- if ( dropped is ZoogiFungus )
+ if ( dropped is ZoogiFungus fungi )
{
- ZoogiFungus fungi = (ZoogiFungus)dropped;
-
if ( fungi.Amount >= 50 )
{
obj.Complete();
@@ -128,16 +118,12 @@ namespace Server.Engines.Quests.Ambitious
fungi.Delete();
return true;
}
- else
- {
- return false;
- }
- }
- else
- {
- SayTo( player, 1054072 ); // Our arrangement was for 50 of the zoogi fungus. Please return to me when you have that amount.
+
return false;
}
+
+ SayTo( player, 1054072 ); // Our arrangement was for 50 of the zoogi fungus. Please return to me when you have that amount.
+ return false;
}
}
}
diff --git a/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs b/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs
index 1df8b1d28..f2ba55573 100644
--- a/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs
+++ b/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs
@@ -22,21 +22,15 @@ namespace Server.Engines.Quests.Collector
public override bool CanDrop( PlayerMobile player )
{
- CollectorQuest qs = player.Quest as CollectorQuest;
-
- if ( qs == null )
- return true;
+ return !(player.Quest is CollectorQuest);
/*return !( qs.IsObjectiveInProgress( typeof( CaptureImagesObjective ) )
|| qs.IsObjectiveInProgress( typeof( ReturnImagesObjective ) ) );*/
- return false;
}
public override void OnDoubleClick( Mobile from )
{
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null )
+ if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
@@ -70,22 +64,17 @@ namespace Server.Engines.Quests.Collector
if ( m_Paints.Deleted || !m_Paints.IsChildOf( from.Backpack ) )
return;
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null )
+ if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is CollectorQuest )
{
- CaptureImagesObjective obj = qs.FindObjective( typeof( CaptureImagesObjective ) ) as CaptureImagesObjective;
-
- if ( obj != null && !obj.Completed )
+ if ( qs.FindObjective( typeof( CaptureImagesObjective ) ) is CaptureImagesObjective obj && !obj.Completed )
{
if ( targeted is Mobile )
{
- ImageType image;
- CaptureResponse response = obj.CaptureImage(( targeted.GetType().Name=="GreaterMongbat" ? new Mongbat().GetType() : targeted.GetType() ), out image );
+ CaptureResponse response = obj.CaptureImage(( targeted.GetType().Name=="GreaterMongbat" ? new Mongbat().GetType() : targeted.GetType() ), out ImageType image );
switch ( response )
{
@@ -138,4 +127,4 @@ namespace Server.Engines.Quests.Collector
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Collector/Items/Obsidian.cs b/Scripts/Engines/Quests/Collector/Items/Obsidian.cs
index 3262ad6d1..2fce97c4b 100644
--- a/Scripts/Engines/Quests/Collector/Items/Obsidian.cs
+++ b/Scripts/Engines/Quests/Collector/Items/Obsidian.cs
@@ -203,13 +203,11 @@ namespace Server.Engines.Quests.Collector
protected override void OnTarget( Mobile from, object targeted )
{
- Item targ = targeted as Item;
- if ( m_Obsidian.Deleted || m_Obsidian.Quantity >= Obsidian.m_Completed || targ == null )
+ if ( m_Obsidian.Deleted || m_Obsidian.Quantity >= Obsidian.m_Completed || !(targeted is Item targ) )
return;
- if ( m_Obsidian.IsChildOf( from.Backpack ) && targ.IsChildOf( from.Backpack ) && targ is Obsidian && targ != m_Obsidian )
+ if ( m_Obsidian.IsChildOf( from.Backpack ) && targ.IsChildOf( from.Backpack ) && targ is Obsidian targObsidian && targ != m_Obsidian )
{
- Obsidian targObsidian = (Obsidian)targ;
if ( targObsidian.Quantity < Obsidian.m_Completed )
{
if ( targObsidian.Quantity + m_Obsidian.Quantity <= Obsidian.m_Completed )
diff --git a/Scripts/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs b/Scripts/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs
index ee536102d..3b6c475a6 100644
--- a/Scripts/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs
+++ b/Scripts/Engines/Quests/Collector/Mobiles/ElwoodMcCarrin.cs
@@ -197,10 +197,10 @@ namespace Server.Engines.Quests.Collector
{
item = Loot.RandomArmorOrShieldOrJewelry();
- if ( item is BaseArmor )
- BaseRunicTool.ApplyAttributesTo( (BaseArmor)item, 2, 20, 30 );
- else if ( item is BaseJewel )
- BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, 2, 20, 30 );
+ if ( item is BaseArmor armor )
+ BaseRunicTool.ApplyAttributesTo( armor, 2, 20, 30 );
+ else if ( item is BaseJewel jewel )
+ BaseRunicTool.ApplyAttributesTo( jewel, 2, 20, 30 );
}
else
{
diff --git a/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs b/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs
index 124057e1e..a663ef5f5 100644
--- a/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs
+++ b/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs
@@ -56,9 +56,7 @@ namespace Server.Engines.Quests.Collector
if ( qs is CollectorQuest )
{
- FindSheetMusicObjective obj = qs.FindObjective( typeof( FindSheetMusicObjective ) ) as FindSheetMusicObjective;
-
- if ( obj != null && !obj.Completed )
+ if ( qs.FindObjective( typeof( FindSheetMusicObjective ) ) is FindSheetMusicObjective obj && !obj.Completed )
{
Direction = GetDirectionTo( player );
@@ -135,20 +133,14 @@ namespace Server.Engines.Quests.Collector
{
if ( info.ButtonID == 1 && info.IsSwitched( 1 ) )
{
- PlayerMobile player = sender.Mobile as PlayerMobile;
-
- if ( player != null )
+ if ( sender.Mobile is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is CollectorQuest )
{
- FindSheetMusicObjective obj = qs.FindObjective( typeof( FindSheetMusicObjective ) ) as FindSheetMusicObjective;
-
- if ( obj != null && !obj.Completed )
+ if ( qs.FindObjective( typeof( FindSheetMusicObjective ) ) is FindSheetMusicObjective obj && !obj.Completed )
{
-
-
if ( player.Backpack!= null && player.Backpack.ConsumeTotal( typeof( Gold ), 10 ) )
{
obj.Complete();
@@ -160,7 +152,7 @@ namespace Server.Engines.Quests.Collector
{
obj.Complete();
}
-
+
else
{
player.SendLocalizedMessage( 1055108 ); // You don't have enough gold to buy the sheet music.
@@ -172,4 +164,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 5474058c4..5ac46daf0 100644
--- a/Scripts/Engines/Quests/Core/BaseQuester.cs
+++ b/Scripts/Engines/Quests/Core/BaseQuester.cs
@@ -21,8 +21,8 @@ namespace Server.Engines.Quests
{
Mobile from = Owner.From;
- if ( from.CheckAlive() && from is PlayerMobile && m_Quester.CanTalkTo( (PlayerMobile)from ) )
- m_Quester.OnTalk( (PlayerMobile)from, true );
+ if ( from.CheckAlive() && from is PlayerMobile mobile && m_Quester.CanTalkTo( mobile ) )
+ m_Quester.OnTalk( mobile, true );
}
}
@@ -82,19 +82,17 @@ namespace Server.Engines.Quests
{
base.AddCustomContextEntries( from, list );
- if ( from.Alive && from is PlayerMobile && TalkNumber > 0 && CanTalkTo( (PlayerMobile)from ) )
+ if ( from.Alive && from is PlayerMobile mobile && TalkNumber > 0 && CanTalkTo( mobile ) )
list.Add( new TalkEntry( this ) );
}
public override void OnMovement( Mobile m, Point3D oldLocation )
{
- if ( m.Alive && m is PlayerMobile )
+ if ( m.Alive && m is PlayerMobile pm )
{
- PlayerMobile pm = (PlayerMobile)m;
-
int range = GetAutoTalkRange( pm );
- if ( m.Alive && range >= 0 && InRange( m, range ) && !InRange( oldLocation, range ) && CanTalkTo( pm ) )
+ if ( pm.Alive && range >= 0 && InRange( m, range ) && !InRange( oldLocation, range ) && CanTalkTo( pm ) )
OnTalk( pm, false );
}
}
diff --git a/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs b/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs
index 3eeb07483..08e8d5571 100644
--- a/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs
+++ b/Scripts/Engines/Quests/Core/Items/DynamicTeleporter.cs
@@ -24,9 +24,7 @@ namespace Server.Engines.Quests
public override bool OnMoveOver( Mobile m )
{
- PlayerMobile pm = m as PlayerMobile;
-
- if ( pm != null )
+ if ( m is PlayerMobile pm )
{
Point3D loc = Point3D.Zero;
Map map = null;
@@ -40,10 +38,8 @@ namespace Server.Engines.Quests
return false;
}
- else
- {
- pm.SendLocalizedMessage( this.NotWorkingMessage );
- }
+
+ pm.SendLocalizedMessage( this.NotWorkingMessage );
}
return base.OnMoveOver( m );
diff --git a/Scripts/Engines/Quests/Core/Items/QuestItem.cs b/Scripts/Engines/Quests/Core/Items/QuestItem.cs
index 2c320c21b..d32462970 100644
--- a/Scripts/Engines/Quests/Core/Items/QuestItem.cs
+++ b/Scripts/Engines/Quests/Core/Items/QuestItem.cs
@@ -90,18 +90,15 @@ namespace Server.Engines.Quests
return false;
}
}
- else
- {
- return ret;
- }
+ return ret;
}
public override DeathMoveResult OnParentDeath( Mobile parent )
{
- if ( parent is PlayerMobile && !CanDrop( (PlayerMobile)parent ) )
+ if ( parent is PlayerMobile mobile && !CanDrop( mobile ) )
return DeathMoveResult.MoveToBackpack;
- else
- return base.OnParentDeath( parent );
+
+ return base.OnParentDeath( parent );
}
public override void Serialize( GenericWriter writer )
diff --git a/Scripts/Engines/Quests/Core/QuestSystem.cs b/Scripts/Engines/Quests/Core/QuestSystem.cs
index 2d11e3516..358e0e13a 100644
--- a/Scripts/Engines/Quests/Core/QuestSystem.cs
+++ b/Scripts/Engines/Quests/Core/QuestSystem.cs
@@ -403,9 +403,7 @@ namespace Server.Engines.Quests
{
inRestartPeriod = false;
- PlayerMobile pm = check as PlayerMobile;
-
- if ( pm == null )
+ if ( !(check is PlayerMobile pm) )
return false;
if ( pm.HasGump( typeof( QuestOfferGump ) ) )
@@ -656,31 +654,19 @@ namespace Server.Engines.Quests
public static ArrayList BuildList( object obj )
{
- ArrayList list = new ArrayList();
-
- list.Add( obj );
-
- return list;
+ return new ArrayList { obj };
}
public void AddHtmlObject( int x, int y, int width, int height, object message, int color, bool back, bool scroll )
{
- if ( message is string )
- {
- string html = (string)message;
-
- AddHtml( x, y, width, height, Color( html, C16232( color ) ), back, scroll );
- }
- else if ( message is int )
- {
- int html = (int)message;
-
+ if ( message is int html )
AddHtmlLocalized( x, y, width, height, html, C16216( color ), back, scroll );
- }
+ else
+ AddHtml( x, y, width, height, Color( message.ToString(), C16232( color ) ), back, scroll );
}
public BaseQuestGump( int x, int y ) : base( x, y )
{
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs b/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs
index e387a9b58..984b3a52c 100644
--- a/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs
+++ b/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs
@@ -28,9 +28,7 @@ namespace Server.Engines.Quests
if ( m_Quest == null )
return true;
- PlayerMobile player = m as PlayerMobile;
-
- if ( player != null && player.Quest != null && player.Quest.GetType() == m_Quest )
+ if ( m is PlayerMobile player && player.Quest != null && player.Quest.GetType() == m_Quest )
{
if ( !player.HasGump( typeof( QuestCancelGump ) ) )
player.Quest.BeginCancelQuest();
@@ -41,4 +39,4 @@ namespace Server.Engines.Quests
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs b/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs
index 811aae452..98bb64db0 100644
--- a/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs
+++ b/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs
@@ -28,9 +28,7 @@ namespace Server.Engines.Quests
if ( m_Quest != null && m_Objective != null )
{
- PlayerMobile player = m as PlayerMobile;
-
- if ( player != null && player.Quest != null && player.Quest.GetType() == m_Quest )
+ if ( m is PlayerMobile player && player.Quest != null && player.Quest.GetType() == m_Quest )
{
QuestObjective obj = player.Quest.FindObjective( m_Objective );
@@ -40,4 +38,4 @@ namespace Server.Engines.Quests
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs b/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs
index 4fa9c6269..4e161626c 100644
--- a/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs
+++ b/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs
@@ -36,32 +36,23 @@ namespace Server.Engines.Quests
if ( m.AccessLevel > AccessLevel.Player )
return true;
- if ( m is BaseCreature )
- {
- BaseCreature bc = m as BaseCreature;
-
- if ( !bc.Controlled && !bc.Summoned )
- return true;
- }
+ if ( m is BaseCreature bc && !bc.Controlled && !bc.Summoned )
+ return true;
if ( m_Quest == null )
return true;
- PlayerMobile player = m as PlayerMobile;
-
- if ( player != null && player.Quest != null && player.Quest.GetType() == m_Quest
+ if ( m is PlayerMobile player && player.Quest != null && player.Quest.GetType() == m_Quest
&& ( m_MinObjective == null || player.Quest.FindObjective( m_MinObjective ) != null )
&& ( m_MaxObjective == null || player.Quest.FindObjective( m_MaxObjective ) == null ) )
{
return true;
}
- else
- {
- if ( m_Message != 0 )
- m.SendLocalizedMessage( m_Message );
- return false;
- }
+ if ( m_Message != 0 )
+ m.SendLocalizedMessage( m_Message );
+
+ return false;
}
}
}
diff --git a/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs b/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs
index ca0bdaf00..fb865d99b 100644
--- a/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs
+++ b/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs
@@ -24,9 +24,7 @@ namespace Server.Engines.Quests
if ( m_Quest == null )
return;
- PlayerMobile player = m as PlayerMobile;
-
- if ( player != null && player.Quest == null && QuestSystem.CanOfferQuest( m, m_Quest ) )
+ if ( m is PlayerMobile player && player.Quest == null && QuestSystem.CanOfferQuest( m, m_Quest ) )
{
try
{
@@ -40,4 +38,4 @@ namespace Server.Engines.Quests
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs b/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs
index b2486d285..75884395f 100644
--- a/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs
+++ b/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs
@@ -130,9 +130,7 @@ namespace Server.Engines.Quests.Necro
public static bool HasLostCallingScroll( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm == null )
+ if ( !(from is PlayerMobile pm) )
return false;
QuestSystem qs = pm.Quest;
@@ -141,9 +139,7 @@ namespace Server.Engines.Quests.Necro
{
if ( qs.IsObjectiveInProgress( typeof( FindMardothAboutKronusObjective ) ) || qs.IsObjectiveInProgress( typeof( FindWellOfTearsObjective ) ) || qs.IsObjectiveInProgress( typeof( UseCallingScrollObjective ) ) )
{
- Container pack = from.Backpack;
-
- return ( pack == null || pack.FindItemByType( typeof( KronusScroll ) ) == null );
+ return ( from.Backpack?.FindItemByType( typeof( KronusScroll ) ) == null );
}
}
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs b/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs
index 3bc88c283..559f6ff07 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs
@@ -25,9 +25,7 @@ namespace Server.Engines.Quests.Necro
if ( m is BaseCreature )
m = ((BaseCreature)m).ControlMaster;
- PlayerMobile pm = m as PlayerMobile;
-
- if ( pm != null )
+ if ( m is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
@@ -69,4 +67,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/DarkTidesHorn.cs b/Scripts/Engines/Quests/Dark Tides/Items/DarkTidesHorn.cs
index b2ee8ac76..d940fc4c3 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/DarkTidesHorn.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/DarkTidesHorn.cs
@@ -11,9 +11,7 @@ namespace Server.Engines.Quests.Necro
{
public override bool ValidateUse( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- return ( pm != null && pm.Quest is DarkTidesQuest );
+ return ( from is PlayerMobile pm && pm.Quest is DarkTidesQuest );
}
[Constructible]
@@ -41,4 +39,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs b/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs
index 60244f286..5e390d4d8 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs
@@ -23,16 +23,12 @@ namespace Server.Engines.Quests.Necro
public override bool CanDrop( PlayerMobile player )
{
- DarkTidesQuest qs = player.Quest as DarkTidesQuest;
-
- if ( qs == null )
- return true;
+ return !(player.Quest is DarkTidesQuest);
/*return !( qs.IsObjectiveInProgress( typeof( FindCallingScrollObjective ) )
|| qs.IsObjectiveInProgress( typeof( FindMardothAboutKronusObjective ) )
|| qs.IsObjectiveInProgress( typeof( FindWellOfTearsObjective ) )
|| qs.IsObjectiveInProgress( typeof( UseCallingScrollObjective ) ) );*/
- return false;
}
private static readonly Rectangle2D m_WellOfTearsArea = new Rectangle2D( 2080, 1346, 10, 10 );
@@ -43,9 +39,7 @@ namespace Server.Engines.Quests.Necro
if ( !IsChildOf( from ) )
return;
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm != null )
+ if ( from is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs b/Scripts/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs
index 858a435c9..e5f444628 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/KronusScrollBox.cs
@@ -27,9 +27,7 @@ namespace Server.Engines.Quests.Necro
public override void OnDoubleClick( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm != null && pm.InRange( GetWorldLocation(), 2 ) )
+ if ( from is PlayerMobile pm && pm.InRange( GetWorldLocation(), 2 ) )
{
QuestSystem qs = pm.Quest;
@@ -74,4 +72,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs b/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs
index 794818343..2328342db 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs
@@ -107,8 +107,8 @@ namespace Server.Engines.Quests.Necro
[CommandProperty( AccessLevel.GameMaster )]
public Point3D SpawnLocation
{
- get { return Addon is MaabusCoffin ? ((MaabusCoffin)Addon).SpawnLocation : Point3D.Zero; }
- set { if ( Addon is MaabusCoffin ) ((MaabusCoffin)Addon).SpawnLocation = value; }
+ get { return Addon is MaabusCoffin coffin ? coffin.SpawnLocation : Point3D.Zero; }
+ set { if ( Addon is MaabusCoffin coffin ) coffin.SpawnLocation = value; }
}
public MaabusCoffinComponent( int itemID ) : this( itemID, itemID )
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs b/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs
index 444015c16..091051eba 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs
@@ -20,22 +20,16 @@ namespace Server.Engines.Quests.Necro
public override bool CanDrop( PlayerMobile player )
{
- DarkTidesQuest qs = player.Quest as DarkTidesQuest;
-
- if ( qs == null )
- return true;
+ return !(player.Quest is DarkTidesQuest);
//return !( qs.IsObjectiveInProgress( typeof( RetrieveAbraxusScrollObjective ) ) || qs.IsObjectiveInProgress( typeof( ReadAbraxusScrollObjective ) ) );
- return false;
}
public override void OnAdded(IEntity parent)
{
base.OnAdded( parent );
- PlayerMobile pm = RootParent as PlayerMobile;
-
- if ( pm != null )
+ if ( RootParent is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
@@ -55,9 +49,7 @@ namespace Server.Engines.Quests.Necro
{
from.SendGump( new ScrollOfAbraxusGump() );
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm != null )
+ if ( from is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
diff --git a/Scripts/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs b/Scripts/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs
index 56d3ccf98..ece08372d 100644
--- a/Scripts/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Items/VaultOfSecretsBarrier.cs
@@ -21,9 +21,7 @@ namespace Server.Engines.Quests.Necro
if ( m.AccessLevel > AccessLevel.Player )
return true;
- PlayerMobile pm = m as PlayerMobile;
-
- if ( pm != null && pm.Profession == 4 )
+ if ( m is PlayerMobile pm && pm.Profession == 4 )
{
m.SendLocalizedMessage( 1060188, "", 0x24 ); // The wicked may not enter!
return false;
@@ -50,4 +48,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/Horus.cs b/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs
index af7264efa..883552612 100644
--- a/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs
@@ -74,9 +74,8 @@ namespace Server.Engines.Quests.Necro
{
base.OnMovement( m, oldLocation );
- if ( InRange( m.Location, 2 ) && !InRange( oldLocation, 2 ) && m is PlayerMobile )
+ if ( InRange( m.Location, 2 ) && !InRange( oldLocation, 2 ) && m is PlayerMobile pm )
{
- PlayerMobile pm = (PlayerMobile)m;
QuestSystem qs = pm.Quest;
if ( qs is DarkTidesQuest )
@@ -121,9 +120,7 @@ namespace Server.Engines.Quests.Necro
if ( from.Alive )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm != null )
+ if ( from is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
diff --git a/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs b/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs
index 68e045485..41d230775 100644
--- a/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs
@@ -27,20 +27,16 @@ namespace Server.Engines.Quests.Necro
public override bool OnDragDrop( Mobile from, Item dropped )
{
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null )
+ if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is DarkTidesQuest )
{
- if ( dropped is DarkTidesHorn )
+ if ( dropped is DarkTidesHorn horn )
{
if ( player.Young )
{
- DarkTidesHorn horn = (DarkTidesHorn)dropped;
-
if ( horn.Charges < 10 )
{
SayTo( from, 1049384 ); // I have recharged the item for you.
@@ -93,9 +89,7 @@ namespace Server.Engines.Quests.Necro
public override bool CanTalkTo( PlayerMobile to )
{
- DarkTidesQuest qs = to.Quest as DarkTidesQuest;
-
- if ( qs == null )
+ if ( !(to.Quest is DarkTidesQuest qs) )
return ( to.Quest == null && QuestSystem.CanOfferQuest( to, typeof( DarkTidesQuest ) ) );
return ( qs.FindObjective( typeof( FindMardothAboutVaultObjective ) ) != null );
diff --git a/Scripts/Engines/Quests/Dark Tides/Objectives.cs b/Scripts/Engines/Quests/Dark Tides/Objectives.cs
index a3f54f46f..f7fb14d29 100644
--- a/Scripts/Engines/Quests/Dark Tides/Objectives.cs
+++ b/Scripts/Engines/Quests/Dark Tides/Objectives.cs
@@ -225,9 +225,7 @@ namespace Server.Engines.Quests.Necro
{
if ( System.From.Map == Map.Malas && System.From.InRange( new Point3D( 1076, 450, -84 ), 5 ) )
{
- HordeMinionFamiliar hmf = Spells.Necromancy.SummonFamiliarSpell.Table[System.From] as HordeMinionFamiliar;
-
- if ( hmf != null && hmf.InRange( System.From, 5 ) && hmf.TargetLocation == null )
+ if ( Spells.Necromancy.SummonFamiliarSpell.Table[System.From] is HordeMinionFamiliar hmf && hmf.InRange( System.From, 5 ) && hmf.TargetLocation == null )
{
System.From.SendLocalizedMessage( 1060113 ); // You instinctively will your familiar to fetch the scroll for you.
hmf.TargetLocation = new Point2D( 1076, 450 );
diff --git a/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs b/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs
index 102fa6b28..1a52e6023 100644
--- a/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs
+++ b/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs
@@ -114,9 +114,7 @@ namespace Server.Engines.Quests.Ninja
public static bool HasLostNoteForZoel( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm == null )
+ if ( !(from is PlayerMobile pm) )
return false;
QuestSystem qs = pm.Quest;
@@ -125,9 +123,7 @@ namespace Server.Engines.Quests.Ninja
{
if ( qs.IsObjectiveInProgress( typeof( GiveZoelNoteObjective ) ) )
{
- Container pack = from.Backpack;
-
- return ( pack == null || pack.FindItemByType( typeof( NoteForZoel ) ) == null );
+ return ( from.Backpack?.FindItemByType( typeof( NoteForZoel ) ) == null );
}
}
@@ -136,9 +132,7 @@ namespace Server.Engines.Quests.Ninja
public static bool HasLostEminosKatana( Mobile from )
{
- PlayerMobile pm = from as PlayerMobile;
-
- if ( pm == null )
+ if ( !(from is PlayerMobile pm) )
return false;
QuestSystem qs = pm.Quest;
@@ -147,9 +141,7 @@ namespace Server.Engines.Quests.Ninja
{
if ( qs.IsObjectiveInProgress( typeof( GiveEminoSwordObjective ) ) )
{
- Container pack = from.Backpack;
-
- return ( pack == null || pack.FindItemByType( typeof( EminosKatana ) ) == null );
+ return ( from.Backpack?.FindItemByType( typeof( EminosKatana ) ) == null );
}
}
diff --git a/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs b/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs
index 764ae0ec5..68371aa83 100644
--- a/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs
+++ b/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs
@@ -20,15 +20,11 @@ namespace Server.Engines.Quests.Ninja
public override bool CanDrop( PlayerMobile player )
{
- EminosUndertakingQuest qs = player.Quest as EminosUndertakingQuest;
-
- if ( qs == null )
- return true;
+ return !(player.Quest is EminosUndertakingQuest);
/*return !qs.IsObjectiveInProgress( typeof( ReturnSwordObjective ) )
&& !qs.IsObjectiveInProgress( typeof( SlayHenchmenObjective ) )
&& !qs.IsObjectiveInProgress( typeof( GiveEminoSwordObjective ) );*/
- return false;
}
public override void Serialize( GenericWriter writer )
diff --git a/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs b/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs
index a8ea9342d..b8d55470c 100644
--- a/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs
+++ b/Scripts/Engines/Quests/Emino's Undertaking/Items/EminosKatanaChest.cs
@@ -41,9 +41,7 @@ namespace Server.Engines.Quests.Ninja
public override void OnDoubleClick( Mobile from )
{
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null && player.InRange( GetWorldLocation(), 2 ) )
+ if ( from is PlayerMobile player && player.InRange( GetWorldLocation(), 2 ) )
{
QuestSystem qs = player.Quest;
@@ -100,13 +98,9 @@ namespace Server.Engines.Quests.Ninja
if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null && player.Quest is EminosUndertakingQuest )
+ if ( from is PlayerMobile player && player.Quest is EminosUndertakingQuest )
{
- HallwayWalkObjective obj = player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) as HallwayWalkObjective;
-
- if ( obj != null )
+ if ( player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) is HallwayWalkObjective obj )
{
if ( obj.StolenTreasure )
from.SendLocalizedMessage( 1063247 ); // The guard is watching you carefully! It would be unwise to remove another item from here.
@@ -120,13 +114,9 @@ namespace Server.Engines.Quests.Ninja
public override void OnItemLifted( Mobile from, Item item )
{
- PlayerMobile player = from as PlayerMobile;
-
- if ( player != null && player.Quest is EminosUndertakingQuest )
+ if ( from is PlayerMobile player && player.Quest is EminosUndertakingQuest )
{
- HallwayWalkObjective obj = player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) as HallwayWalkObjective;
-
- if ( obj != null )
+ if ( player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) is HallwayWalkObjective obj )
obj.StolenTreasure = true;
}
}