Adds more formatting

This commit is contained in:
Kamron Batman 2018-08-19 21:28:24 +08:00
parent e77d695684
commit f674ec2be0
68 changed files with 530 additions and 876 deletions

View file

@ -54,9 +54,7 @@ namespace Server.Items
public void Throw( Mobile from ) public void Throw( Mobile from )
{ {
BaseKnife knife = from.Weapon as BaseKnife; if ( !(from.Weapon is BaseKnife knife) )
if ( knife == null )
{ {
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500751 ); // Try holding a knife... from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500751 ); // Try holding a knife...
return; return;

View file

@ -74,9 +74,7 @@ namespace Server.Items
m_Timer = null; m_Timer = null;
} }
Mobile from = state as Mobile; if ( state is Mobile from && !from.Deleted && !this.Deleted && IsFull )
if ( from != null && !from.Deleted && !this.Deleted && IsFull )
{ {
SackFlour flour = new SackFlour(); SackFlour flour = new SackFlour();
@ -137,9 +135,7 @@ namespace Server.Items
for ( int i = 0; i < components.Count; ++i ) for ( int i = 0; i < components.Count; ++i )
{ {
AddonComponent component = components[i] as AddonComponent; if ( !(components[i] is AddonComponent component) )
if ( component == null )
continue; continue;
int[] itemTable = FindItemTable( component.ItemID ); int[] itemTable = FindItemTable( component.ItemID );

View file

@ -60,9 +60,7 @@ namespace Server.Items
m_Timer = null; m_Timer = null;
} }
Mobile from = state as Mobile; if ( state is Mobile from && !from.Deleted && !this.Deleted && IsFull )
if ( from != null && !from.Deleted && !this.Deleted && IsFull )
{ {
SackFlour flour = new SackFlour(); SackFlour flour = new SackFlour();
@ -123,9 +121,7 @@ namespace Server.Items
for ( int i = 0; i < components.Count; ++i ) for ( int i = 0; i < components.Count; ++i )
{ {
AddonComponent component = components[i] as AddonComponent; if ( !(components[i] is AddonComponent component) )
if ( component == null )
continue; continue;
int[] itemTable = FindItemTable( component.ItemID ); int[] itemTable = FindItemTable( component.ItemID );

View file

@ -76,9 +76,7 @@ namespace Server.Items
{ {
for ( int i = 0; i < Components.Count; ++i ) for ( int i = 0; i < Components.Count; ++i )
{ {
AddonComponent ac = Components[i] as AddonComponent; if ( Components[i] is AddonComponent ac && ac.Hue == 2118 )
if ( ac != null && ac.Hue == 2118 )
ac.Hue = 1161; ac.Hue = 1161;
} }
} ); } );
@ -90,9 +88,7 @@ namespace Server.Items
{ {
for ( int i = 0; i < Components.Count; ++i ) for ( int i = 0; i < Components.Count; ++i )
{ {
AddonComponent ac = Components[i] as AddonComponent; if ( Components[i] is AddonComponent ac )
if ( ac != null )
ac.Name = "jack-o-lantern"; ac.Name = "jack-o-lantern";
} }
} ); } );

View file

@ -17,9 +17,7 @@ namespace Server.Items
{ {
m_Active = value; m_Active = value;
SHTeleporter sourceAddon = Addon as SHTeleporter; if ( Addon is SHTeleporter sourceAddon )
if ( sourceAddon != null )
sourceAddon.ChangeActive( value ); sourceAddon.ChangeActive( value );
} }
} }
@ -46,9 +44,7 @@ namespace Server.Items
{ {
m_TeleDest = value; m_TeleDest = value;
SHTeleporter sourceAddon = Addon as SHTeleporter; if ( Addon is SHTeleporter sourceAddon )
if ( sourceAddon != null )
sourceAddon.ChangeDest( value ); sourceAddon.ChangeDest( value );
} }
} }

View file

@ -208,10 +208,8 @@ namespace Server.Items
bool takeItem = true; bool takeItem = true;
if ( dropped is FishBowl ) if ( dropped is FishBowl bowl )
{ {
FishBowl bowl = (FishBowl) dropped;
if ( bowl.Empty || !AddFish( from, bowl.Fish ) ) if ( bowl.Empty || !AddFish( from, bowl.Fish ) )
return false; return false;
@ -219,10 +217,8 @@ namespace Server.Items
takeItem = false; takeItem = false;
} }
else if ( dropped is BaseFish ) else if ( dropped is BaseFish fish )
{ {
BaseFish fish = (BaseFish) dropped;
if ( !AddFish( from, fish ) ) if ( !AddFish( from, fish ) )
return false; return false;
} }
@ -240,10 +236,8 @@ namespace Server.Items
from.SendLocalizedMessage( 1074259, "1" ); // ~1_NUM~ unit(s) of food have been added to the aquarium. from.SendLocalizedMessage( 1074259, "1" ); // ~1_NUM~ unit(s) of food have been added to the aquarium.
} }
else if ( dropped is BaseBeverage ) else if ( dropped is BaseBeverage beverage )
{ {
BaseBeverage beverage = (BaseBeverage) dropped;
if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water ) if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water )
{ {
from.SendLocalizedMessage( 500840 ); // Can't pour that in there. from.SendLocalizedMessage( 500840 ); // Can't pour that in there.
@ -283,13 +277,8 @@ namespace Server.Items
item.MoveToWorld( loc, Map ); item.MoveToWorld( loc, Map );
if ( item is BaseFish ) if ( item is BaseFish fish && !fish.Dead )
{ fish.StartTimer();
BaseFish fish = (BaseFish) item;
if ( !fish.Dead )
fish.StartTimer();
}
} }
} }
@ -785,10 +774,8 @@ namespace Server.Items
return false; return false;
} }
if ( item is BaseFish ) if ( item is BaseFish fish )
{ {
BaseFish fish = (BaseFish) item;
FishBowl bowl; FishBowl bowl;
if ( (bowl = GetEmptyBowl( from )) != null ) if ( (bowl = GetEmptyBowl( from )) != null )
@ -820,10 +807,8 @@ namespace Server.Items
from.SendLocalizedMessage( 1074514 ); // You have no place to put it. from.SendLocalizedMessage( 1074514 ); // You have no place to put it.
return false; return false;
} }
else
{ from.SendLocalizedMessage( 1074513 ); // You put the item into your pack.
from.SendLocalizedMessage( 1074513 ); // You put the item into your pack.
}
} }
InvalidateProperties(); InvalidateProperties();

View file

@ -41,8 +41,8 @@ namespace Server.Items
AddHtmlLocalized( 20, 217, 250, 20, item.LabelNumber, 0xFFFFFF, false, false ); // Name AddHtmlLocalized( 20, 217, 250, 20, item.LabelNumber, 0xFFFFFF, false, false ); // Name
// item details // item details
if ( item is BaseFish ) if ( item is BaseFish fish )
AddHtmlLocalized( 20, 239, 315, 20, ( (BaseFish) item ).GetDescription(), 0xFFFFFF, false, false ); AddHtmlLocalized( 20, 239, 315, 20, fish.GetDescription(), 0xFFFFFF, false, false );
else else
AddHtmlLocalized( 20, 239, 315, 20, 1073634, 0xFFFFFF, false, false ); // An aquarium decoration AddHtmlLocalized( 20, 239, 315, 20, 1073634, 0xFFFFFF, false, false ); // An aquarium decoration

View file

@ -25,10 +25,7 @@ namespace Server.Items
if ( Empty ) if ( Empty )
return null; return null;
if ( Items[ 0 ] is BaseFish ) return Items[0] as BaseFish;
return (BaseFish) Items[ 0 ];
return null;
} }
} }

View file

@ -101,9 +101,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
BaseArmor armor = newItem as BaseArmor; if ( !(newItem is BaseArmor armor) )
if ( armor == null )
return; return;
armor.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes ); armor.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes );
@ -125,8 +123,7 @@ namespace Server.Items
{ {
if ( m_ArmorBase == -1 ) if ( m_ArmorBase == -1 )
return ArmorBase; return ArmorBase;
else return m_ArmorBase;
return m_ArmorBase;
} }
set set
{ {
@ -258,8 +255,7 @@ namespace Server.Items
Invalidate(); Invalidate();
InvalidateProperties(); InvalidateProperties();
if ( Parent is Mobile ) (Parent as Mobile)?.UpdateResistances();
((Mobile)Parent).UpdateResistances();
ScaleDurability(); ScaleDurability();
} }
@ -353,8 +349,7 @@ namespace Server.Items
Invalidate(); Invalidate();
InvalidateProperties(); InvalidateProperties();
if ( Parent is Mobile ) (Parent as Mobile)?.UpdateResistances();
((Mobile)Parent).UpdateResistances();
} }
} }
} }
@ -609,10 +604,8 @@ namespace Server.Items
Item item = m.Items[i]; Item item = m.Items[i];
if ( item is BaseArmor ) if ( item is BaseArmor armor )
{ {
BaseArmor armor = (BaseArmor)item;
if ( armor.RequiredRace != null && m.Race != armor.RequiredRace ) if ( armor.RequiredRace != null && m.Race != armor.RequiredRace )
{ {
if ( armor.RequiredRace == Race.Elf ) if ( armor.RequiredRace == Race.Elf )
@ -669,10 +662,8 @@ namespace Server.Items
public override void OnAdded(IEntity parent) public override void OnAdded(IEntity parent)
{ {
if ( parent is Mobile ) if ( parent is Mobile from )
{ {
Mobile from = (Mobile)parent;
if ( Core.AOS ) if ( Core.AOS )
m_AosSkillBonuses.AddTo( from ); m_AosSkillBonuses.AddTo( from );
@ -692,8 +683,7 @@ namespace Server.Items
protected void Invalidate() protected void Invalidate()
{ {
if ( Parent is Mobile ) (Parent as Mobile)?.Delta( MobileDelta.Armor ); // Tell them armor rating has changed
((Mobile)Parent).Delta( MobileDelta.Armor ); // Tell them armor rating has changed
} }
public BaseArmor( Serial serial ) : base( serial ) public BaseArmor( Serial serial ) : base( serial )
@ -1105,17 +1095,17 @@ namespace Server.Items
if ( m_AosSkillBonuses == null ) if ( m_AosSkillBonuses == null )
m_AosSkillBonuses = new AosSkillBonuses( this ); m_AosSkillBonuses = new AosSkillBonuses( this );
if ( Core.AOS && Parent is Mobile ) Mobile m = Parent as Mobile;
m_AosSkillBonuses.AddTo( (Mobile)Parent );
if ( Core.AOS && m != null )
m_AosSkillBonuses.AddTo( m );
int strBonus = ComputeStatBonus( StatType.Str ); int strBonus = ComputeStatBonus( StatType.Str );
int dexBonus = ComputeStatBonus( StatType.Dex ); int dexBonus = ComputeStatBonus( StatType.Dex );
int intBonus = ComputeStatBonus( StatType.Int ); int intBonus = ComputeStatBonus( StatType.Int );
if ( Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0) ) if ( m != null && (strBonus != 0 || dexBonus != 0 || intBonus != 0) )
{ {
Mobile m = (Mobile)Parent;
string modName = Serial.ToString(); string modName = Serial.ToString();
if ( strBonus != 0 ) if ( strBonus != 0 )
@ -1128,8 +1118,7 @@ namespace Server.Items
m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) ); m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
} }
if ( Parent is Mobile ) m?.CheckStatTimers();
((Mobile)Parent).CheckStatTimers();
if ( version < 7 ) if ( version < 7 )
m_PlayerConstructed = true; // we don't know, so, assume it's crafted m_PlayerConstructed = true; // we don't know, so, assume it's crafted
@ -1267,9 +1256,8 @@ namespace Server.Items
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
if ( parent is Mobile ) if ( parent is Mobile m )
{ {
Mobile m = (Mobile)parent;
string modName = this.Serial.ToString(); string modName = this.Serial.ToString();
m.RemoveStatMod( modName + "Str" ); m.RemoveStatMod( modName + "Str" );
@ -1279,7 +1267,7 @@ namespace Server.Items
if ( Core.AOS ) if ( Core.AOS )
m_AosSkillBonuses.Remove(); m_AosSkillBonuses.Remove();
((Mobile)parent).Delta( MobileDelta.Armor ); // Tell them armor rating has changed m.Delta( MobileDelta.Armor ); // Tell them armor rating has changed
m.CheckStatTimers(); m.CheckStatTimers();
} }
@ -1288,15 +1276,15 @@ namespace Server.Items
public virtual int OnHit( BaseWeapon weapon, int damageTaken ) public virtual int OnHit( BaseWeapon weapon, int damageTaken )
{ {
double HalfAr = ArmorRating / 2.0; double halfar = ArmorRating / 2.0;
int Absorbed = (int)(HalfAr + HalfAr*Utility.RandomDouble()); int absorbed = (int)(halfar + halfar*Utility.RandomDouble());
damageTaken -= Absorbed; damageTaken -= absorbed;
if ( damageTaken < 0 ) if ( damageTaken < 0 )
damageTaken = 0; damageTaken = 0;
if ( Absorbed < 2 ) if ( absorbed < 2 )
Absorbed = 2; absorbed = 2;
if ( 25 > Utility.Random( 100 ) ) // 25% chance to lower durability if ( 25 > Utility.Random( 100 ) ) // 25% chance to lower durability
{ {
@ -1309,7 +1297,7 @@ namespace Server.Items
int wear; int wear;
if ( weapon.Type == WeaponType.Bashing ) if ( weapon.Type == WeaponType.Bashing )
wear = Absorbed / 2; wear = absorbed / 2;
else else
wear = Utility.Random( 2 ); wear = Utility.Random( 2 );
@ -1332,8 +1320,8 @@ namespace Server.Items
{ {
MaxHitPoints -= wear; MaxHitPoints -= wear;
if ( Parent is Mobile ) if ( Parent is Mobile mobile )
((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged. mobile.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
} }
else else
{ {
@ -1644,8 +1632,8 @@ namespace Server.Items
} }
} }
if ( Core.AOS && tool is BaseRunicTool ) if ( Core.AOS )
((BaseRunicTool)tool).ApplyAttributesTo( this ); (tool as BaseRunicTool)?.ApplyAttributesTo( this );
return quality; return quality;
} }

View file

@ -62,21 +62,21 @@ namespace Server.Items
private BookPageInfo[] m_Pages; private BookPageInfo[] m_Pages;
private bool m_Writable; private bool m_Writable;
private SecureLevel m_SecureLevel; private SecureLevel m_SecureLevel;
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public string Title public string Title
{ {
get { return m_Title; } get { return m_Title; }
set { m_Title = value; InvalidateProperties(); } set { m_Title = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public string Author public string Author
{ {
get { return m_Author; } get { return m_Author; }
set { m_Author = value; InvalidateProperties(); } set { m_Author = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public bool Writable public bool Writable
{ {
@ -147,7 +147,7 @@ namespace Server.Items
} }
public virtual BookContent DefaultContent{ get{ return null; } } public virtual BookContent DefaultContent{ get{ return null; } }
public BaseBook( Serial serial ) : base( serial ) public BaseBook( Serial serial ) : base( serial )
{ {
} }
@ -313,13 +313,13 @@ namespace Server.Items
if ( m_Pages != null && m_Pages.Length > 0 ) if ( m_Pages != null && m_Pages.Length > 0 )
list.Add( 1060660, "Pages\t{0}", m_Pages.Length ); // ~1_val~: ~2_val~ list.Add( 1060660, "Pages\t{0}", m_Pages.Length ); // ~1_val~: ~2_val~
}*/ }*/
public override void OnSingleClick ( Mobile from ) public override void OnSingleClick ( Mobile from )
{ {
LabelTo( from, "{0} by {1}", m_Title, m_Author ); LabelTo( from, "{0} by {1}", m_Title, m_Author );
LabelTo( from, "[{0} pages]", m_Pages.Length ); LabelTo( from, "[{0} pages]", m_Pages.Length );
} }
public override void OnDoubleClick ( Mobile from ) public override void OnDoubleClick ( Mobile from )
{ {
if ( m_Title == null && m_Author == null && m_Writable == true ) if ( m_Title == null && m_Author == null && m_Writable == true )
@ -375,9 +375,8 @@ namespace Server.Items
public static void OldHeaderChange( NetState state, PacketReader pvSrc ) public static void OldHeaderChange( NetState state, PacketReader pvSrc )
{ {
Mobile from = state.Mobile; Mobile from = state.Mobile;
BaseBook book = World.FindItem( pvSrc.ReadInt32() ) as BaseBook;
if ( book == null || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) ) if ( !(World.FindItem( pvSrc.ReadInt32() ) is BaseBook book) || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) )
return; return;
pvSrc.Seek( 4, SeekOrigin.Current ); // Skip flags and page count pvSrc.Seek( 4, SeekOrigin.Current ); // Skip flags and page count
@ -392,9 +391,8 @@ namespace Server.Items
public static void HeaderChange( NetState state, PacketReader pvSrc ) public static void HeaderChange( NetState state, PacketReader pvSrc )
{ {
Mobile from = state.Mobile; Mobile from = state.Mobile;
BaseBook book = World.FindItem( pvSrc.ReadInt32() ) as BaseBook;
if ( book == null || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) ) if ( !(World.FindItem( pvSrc.ReadInt32() ) is BaseBook book) || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) )
return; return;
pvSrc.Seek( 4, SeekOrigin.Current ); // Skip flags and page count pvSrc.Seek( 4, SeekOrigin.Current ); // Skip flags and page count
@ -420,9 +418,8 @@ namespace Server.Items
public static void ContentChange( NetState state, PacketReader pvSrc ) public static void ContentChange( NetState state, PacketReader pvSrc )
{ {
Mobile from = state.Mobile; Mobile from = state.Mobile;
BaseBook book = World.FindItem( pvSrc.ReadInt32() ) as BaseBook;
if ( book == null || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) ) if ( !(World.FindItem( pvSrc.ReadInt32() ) is BaseBook book) || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) )
return; return;
int pageCount = pvSrc.ReadUInt16(); int pageCount = pvSrc.ReadUInt16();
@ -533,4 +530,4 @@ namespace Server.Items
m_Stream.Write( (byte) 0 ); // terminate m_Stream.Write( (byte) 0 ); // terminate
} }
} }
} }

View file

@ -292,10 +292,8 @@ namespace Server.Items
Item item = m.Items[i]; Item item = m.Items[i];
if ( item is BaseClothing ) if ( item is BaseClothing clothing )
{ {
BaseClothing clothing = (BaseClothing)item;
if ( clothing.RequiredRace != null && m.Race != clothing.RequiredRace ) if ( clothing.RequiredRace != null && m.Race != clothing.RequiredRace )
{ {
if ( clothing.RequiredRace == Race.Elf ) if ( clothing.RequiredRace == Race.Elf )
@ -337,9 +335,7 @@ namespace Server.Items
public override void OnAdded(IEntity parent) public override void OnAdded(IEntity parent)
{ {
Mobile mob = parent as Mobile; if ( parent is Mobile mob )
if ( mob != null )
{ {
if ( Core.AOS ) if ( Core.AOS )
m_AosSkillBonuses.AddTo( mob ); m_AosSkillBonuses.AddTo( mob );
@ -353,9 +349,7 @@ namespace Server.Items
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
Mobile mob = parent as Mobile; if ( parent is Mobile mob )
if ( mob != null )
{ {
if ( Core.AOS ) if ( Core.AOS )
m_AosSkillBonuses.Remove(); m_AosSkillBonuses.Remove();
@ -415,8 +409,7 @@ namespace Server.Items
{ {
MaxHitPoints -= wear; MaxHitPoints -= wear;
if ( Parent is Mobile ) (Parent as Mobile)?.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
} }
else else
{ {
@ -452,9 +445,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
BaseClothing clothing = newItem as BaseClothing; if ( !(newItem is BaseClothing clothing) )
if ( clothing == null )
return; return;
clothing.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes ); clothing.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes );
@ -911,9 +902,7 @@ namespace Server.Items
if ( m_MaxHitPoints == 0 && m_HitPoints == 0 ) if ( m_MaxHitPoints == 0 && m_HitPoints == 0 )
m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits ); m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits );
Mobile parent = Parent as Mobile; if ( Parent is Mobile parent )
if ( parent != null )
{ {
if ( Core.AOS ) if ( Core.AOS )
m_AosSkillBonuses.AddTo( parent ); m_AosSkillBonuses.AddTo( parent );

View file

@ -192,16 +192,16 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
((Mobile)parent).VirtualArmorMod += 2; mobile.VirtualArmorMod += 2;
} }
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
base.OnRemoved( parent ); base.OnRemoved( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
((Mobile)parent).VirtualArmorMod -= 2; mobile.VirtualArmorMod -= 2;
} }
public override bool Dye( Mobile from, DyeTub sender ) public override bool Dye( Mobile from, DyeTub sender )
@ -275,8 +275,8 @@ namespace Server.Items
} }
} }
if ( Parent is Mobile ) if ( Parent is Mobile mobile )
((Mobile)Parent).VirtualArmorMod += 2; mobile.VirtualArmorMod += 2;
} }
} }

View file

@ -732,8 +732,8 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
Misc.Titles.AwardKarma( (Mobile)parent, -20, true ); Misc.Titles.AwardKarma( mobile, -20, true );
} }
public OrcishKinMask( Serial serial ) : base( serial ) public OrcishKinMask( Serial serial ) : base( serial )

View file

@ -269,16 +269,16 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
((Mobile)parent).VirtualArmorMod += 2; mobile.VirtualArmorMod += 2;
} }
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
base.OnRemoved( parent ); base.OnRemoved( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
((Mobile)parent).VirtualArmorMod -= 2; mobile.VirtualArmorMod -= 2;
} }
public override bool Dye( Mobile from, DyeTub sender ) public override bool Dye( Mobile from, DyeTub sender )
@ -352,8 +352,8 @@ namespace Server.Items
} }
} }
if ( Parent is Mobile ) if ( Parent is Mobile mobile )
((Mobile)Parent).VirtualArmorMod += 2; mobile.VirtualArmorMod += 2;
} }
} }
@ -394,16 +394,16 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
((Mobile)parent).VirtualArmorMod += 2; mobile.VirtualArmorMod += 2;
} }
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
base.OnRemoved( parent ); base.OnRemoved( parent );
if ( parent is Mobile ) if ( parent is Mobile mobile )
((Mobile)parent).VirtualArmorMod -= 2; mobile.VirtualArmorMod -= 2;
} }
public override bool Dye( Mobile from, DyeTub sender ) public override bool Dye( Mobile from, DyeTub sender )
@ -477,8 +477,8 @@ namespace Server.Items
} }
} }
if ( Parent is Mobile ) if ( Parent is Mobile mobile )
((Mobile)Parent).VirtualArmorMod += 2; mobile.VirtualArmorMod += 2;
} }
} }

View file

@ -16,8 +16,8 @@ namespace Server.Items
public static void GetContextMenuEntries( Mobile from, Item item, List<ContextMenuEntry> list ) public static void GetContextMenuEntries( Mobile from, Item item, List<ContextMenuEntry> list )
{ {
if ( from is PlayerMobile ) if ( from is PlayerMobile mobile )
list.Add( new LockKarmaEntry( (PlayerMobile)from ) ); list.Add( new LockKarmaEntry( mobile ) );
list.Add( new ResurrectEntry( from, item ) ); list.Add( new ResurrectEntry( from, item ) );

View file

@ -53,9 +53,7 @@ namespace Server.Items
private static void Link_OnFirstTarget( Mobile from, object targeted ) private static void Link_OnFirstTarget( Mobile from, object targeted )
{ {
BaseDoor door = targeted as BaseDoor; if ( !(targeted is BaseDoor door) )
if ( door == null )
{ {
from.BeginTarget( -1, false, TargetFlags.None, new TargetCallback( Link_OnFirstTarget ) ); from.BeginTarget( -1, false, TargetFlags.None, new TargetCallback( Link_OnFirstTarget ) );
from.SendMessage( "That is not a door. Try again." ); from.SendMessage( "That is not a door. Try again." );
@ -70,9 +68,8 @@ namespace Server.Items
private static void Link_OnSecondTarget( Mobile from, object targeted, object state ) private static void Link_OnSecondTarget( Mobile from, object targeted, object state )
{ {
BaseDoor first = (BaseDoor)state; BaseDoor first = (BaseDoor)state;
BaseDoor second = targeted as BaseDoor;
if ( second == null ) if ( !(targeted is BaseDoor second) )
{ {
from.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( Link_OnSecondTarget ), first ); from.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( Link_OnSecondTarget ), first );
from.SendMessage( "That is not a door. Try again." ); from.SendMessage( "That is not a door. Try again." );
@ -95,9 +92,7 @@ namespace Server.Items
private static void ChainLink_OnTarget( Mobile from, object targeted, object state ) private static void ChainLink_OnTarget( Mobile from, object targeted, object state )
{ {
BaseDoor door = targeted as BaseDoor; if ( !(targeted is BaseDoor door) )
if ( door == null )
{ {
from.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( ChainLink_OnTarget ), state ); from.BeginTarget( -1, false, TargetFlags.None, new TargetStateCallback( ChainLink_OnTarget ), state );
from.SendMessage( "That is not a door. Try again." ); from.SendMessage( "That is not a door. Try again." );
@ -586,4 +581,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -61,9 +61,9 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt( this ); BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null && house.IsLockedDown( this ) ) if ( house?.IsLockedDown( this ) == true )
{ {
if ( dropped is VendorRentalContract || ( dropped is Container && ((Container)dropped).FindItemByType( typeof( VendorRentalContract ) ) != null ) ) if ( dropped is VendorRentalContract || ( dropped is Container container && container.FindItemByType( typeof( VendorRentalContract ) ) != null ) )
{ {
from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container. from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container.
return false; return false;
@ -95,9 +95,9 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt( this ); BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null && house.IsLockedDown( this ) ) if ( house?.IsLockedDown( this ) == true )
{ {
if ( item is VendorRentalContract || ( item is Container && ((Container)item).FindItemByType( typeof( VendorRentalContract ) ) != null ) ) if ( item is VendorRentalContract || ( item is Container container && container.FindItemByType( typeof( VendorRentalContract ) ) != null ) )
{ {
from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container. from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container.
return false; return false;
@ -119,8 +119,8 @@ namespace Server.Items
{ {
base.UpdateTotal( sender, type, delta ); base.UpdateTotal( sender, type, delta );
if ( type == TotalType.Weight && RootParent is Mobile ) if ( type == TotalType.Weight )
((Mobile) RootParent).InvalidateProperties(); (RootParent as Mobile)?.InvalidateProperties();
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
@ -238,12 +238,7 @@ namespace Server.Items
public override bool CheckContentDisplay( Mobile from ) public override bool CheckContentDisplay( Mobile from )
{ {
object root = this.RootParent; return RootParent is BaseCreature creature && creature.Controlled && creature.ControlMaster == from || base.CheckContentDisplay( from );
if ( root is BaseCreature && ((BaseCreature)root).Controlled && ((BaseCreature)root).ControlMaster == from )
return true;
return base.CheckContentDisplay( from );
} }
public StrongBackpack( Serial serial ) : base( serial ) public StrongBackpack( Serial serial ) : base( serial )
@ -279,16 +274,10 @@ namespace Server.Items
public override int DefaultMaxWeight { public override int DefaultMaxWeight {
get { get {
if ( Core.ML ) { if ( Core.ML && Parent is Mobile m && m.Player && m.Backpack == this )
Mobile m = Parent as Mobile; return 550;
if ( m != null && m.Player && m.Backpack == this ) {
return 550; return base.DefaultMaxWeight;
} else {
return base.DefaultMaxWeight;
}
} else {
return base.DefaultMaxWeight;
}
} }
} }

View file

@ -616,8 +616,8 @@ namespace Server.Items
{ {
Item item = Loot.Construct( m_Types ); Item item = Loot.Construct( m_Types );
if ( item is Key ) if ( item is Key key )
( (Key)item ).ItemID = Utility.RandomList( (int)KeyType.Copper, (int)KeyType.Gold, (int)KeyType.Iron, (int)KeyType.Rusty ); key.ItemID = Utility.RandomList( (int)KeyType.Copper, (int)KeyType.Gold, (int)KeyType.Iron, (int)KeyType.Rusty );
else if ( item is Arrow || item is Bolt ) else if ( item is Arrow || item is Bolt )
item.Amount = Utility.RandomMinMax( 2, 6 ); item.Amount = Utility.RandomMinMax( 2, 6 );
else if ( item is Bandage || item is Lockpick ) else if ( item is Bandage || item is Lockpick )
@ -662,10 +662,8 @@ namespace Server.Items
{ {
item = base.Construct(); item = base.Construct();
if ( item is BaseBeverage ) if ( item is BaseBeverage bev )
{ {
BaseBeverage bev = (BaseBeverage)item;
bev.Content = m_Content; bev.Content = m_Content;
bev.Quantity = bev.MaxQuantity; bev.Quantity = bev.MaxQuantity;
} }
@ -1514,9 +1512,7 @@ namespace Server.Items
if ( nearest != null && mob.GetDistanceToSqrt( loc ) > nearest.GetDistanceToSqrt( loc ) && !( nearest is Cobbler && mob is Provisioner ) ) if ( nearest != null && mob.GetDistanceToSqrt( loc ) > nearest.GetDistanceToSqrt( loc ) && !( nearest is Cobbler && mob is Provisioner ) )
continue; continue;
FillableContent check = m_AcquireTable[ mob.GetType() ] as FillableContent; if ( m_AcquireTable[ mob.GetType() ] is FillableContent check )
if ( check != null )
{ {
nearest = mob; nearest = mob;
content = check; content = check;

View file

@ -202,34 +202,24 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
RecallRune rune = dropped as RecallRune; if ( dropped is RecallRune rune && base.OnDragDrop( from, dropped ) )
if ( rune != null && base.OnDragDrop( from, dropped ) )
{ {
Mark( rune ); Mark( rune );
return true; return true;
} }
else
{ return false;
return false;
}
} }
public override bool OnDragDropInto( Mobile from, Item dropped, Point3D p ) public override bool OnDragDropInto( Mobile from, Item dropped, Point3D p )
{ {
RecallRune rune = dropped as RecallRune; if ( dropped is RecallRune rune && base.OnDragDropInto( from, dropped, p ) )
if ( rune != null && base.OnDragDropInto( from, dropped, p ) )
{ {
Mark( rune ); Mark( rune );
return true; return true;
} }
else
{ return false;
return false;
}
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )

View file

@ -122,17 +122,11 @@ namespace Server.Items
else else
item = Loot.RandomArmorOrShieldOrWeapon(); item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon ) if ( item is BaseWeapon weapon )
{ {
BaseWeapon weapon = (BaseWeapon)item;
if ( Core.AOS ) if ( Core.AOS )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
} }
else else
@ -142,19 +136,13 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 ); 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 ) if ( Core.AOS )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
} }
else else
@ -163,34 +151,24 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 ); 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 ) if ( Core.AOS )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
} }
DropItem( item ); DropItem( hat );
} }
else if ( item is BaseJewel ) else if ( item is BaseJewel jewel )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max; BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
GetRandomAOSStats( out attributeCount, out min, out max ); DropItem( jewel );
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );
DropItem( item );
} }
} }

View file

@ -45,19 +45,14 @@ namespace Server.Items
{ {
foreach( Item i in Items ) foreach( Item i in Items )
{ {
if ( i != null && !i.Deleted ) if (i?.Deleted != false)
continue;
switch (i)
{ {
if ( i is BaseWeapon ) case BaseWeapon weapon when CraftResources.GetType( weapon.Resource ) == CraftResourceType.Metal:
{ case BaseArmor armor when CraftResources.GetType( armor.Resource ) == CraftResourceType.Metal:
if ( CraftResources.GetType( ( (BaseWeapon)i ).Resource ) == CraftResourceType.Metal ) case DragonBardingDeed _:
return true;
}
if ( i is BaseArmor )
{
if ( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Metal )
return true;
}
if ( i is DragonBardingDeed )
return true; return true;
} }
} }
@ -68,20 +63,18 @@ namespace Server.Items
{ {
foreach( Item i in Items ) foreach( Item i in Items )
{ {
if ( i != null && !i.Deleted ) if (!(i is IScissorable && !i.Deleted))
continue;
switch (i)
{ {
if ( i is IScissorable ) case BaseClothing _:
{ case BaseArmor armor when CraftResources.GetType( armor.Resource ) == CraftResourceType.Leather:
if ( i is BaseClothing ) case Cloth _:
return true; case BoltOfCloth _:
if ( i is BaseArmor ) case Hides _:
{ case BonePile _:
if ( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Leather ) return true;
return true;
}
if ( ( i is Cloth ) || ( i is BoltOfCloth ) || ( i is Hides ) || ( i is BonePile ) )
return true;
}
} }
} }
return false; return false;
@ -128,7 +121,7 @@ namespace Server.Items
Type resourceType = info.ResourceTypes[ 0 ]; Type resourceType = info.ResourceTypes[ 0 ];
Item ingot = (Item)Activator.CreateInstance( resourceType ); Item ingot = (Item)Activator.CreateInstance( resourceType );
if ( item is DragonBardingDeed || ( item is BaseArmor && ( (BaseArmor)item ).PlayerConstructed ) || ( item is BaseWeapon && ( (BaseWeapon)item ).PlayerConstructed ) || ( item is BaseClothing && ( (BaseClothing)item ).PlayerConstructed ) ) if ( item is DragonBardingDeed || ( item is BaseArmor armor && armor.PlayerConstructed ) || ( item is BaseWeapon weapon && weapon.PlayerConstructed ) || ( item is BaseClothing clothing && clothing.PlayerConstructed ) )
{ {
double mining = from.Skills[ SkillName.Mining ].Value; double mining = from.Skills[ SkillName.Mining ].Value;
if ( mining > 100.0 ) if ( mining > 100.0 )
@ -176,7 +169,7 @@ namespace Server.Items
bool ToolFound = false; bool ToolFound = false;
foreach( Item tool in tools ) foreach( Item tool in tools )
{ {
if ( tool is BaseTool && ( (BaseTool)tool ).CraftSystem == DefBlacksmithy.CraftSystem ) if ( tool is BaseTool baseTool && baseTool.CraftSystem == DefBlacksmithy.CraftSystem )
ToolFound = true; ToolFound = true;
} }
@ -186,8 +179,7 @@ namespace Server.Items
return; return;
} }
bool anvil, forge; DefBlacksmithy.CheckAnvilAndForge( from, 2, out _, out var forge );
DefBlacksmithy.CheckAnvilAndForge( from, 2, out anvil, out forge );
if ( !forge ) if ( !forge )
{ {
@ -204,31 +196,28 @@ namespace Server.Items
for(int i = Smeltables.Count - 1; i >= 0; i--) for(int i = Smeltables.Count - 1; i >= 0; i--)
{ {
Item item = Smeltables[ i ]; switch (Smeltables[i])
{
if ( item is BaseArmor ) case BaseArmor armor when Resmelt( from, armor, armor.Resource ):
{ salvaged++;
if ( Resmelt( from, item, ( (BaseArmor)item ).Resource ) ) break;
salvaged++; case BaseArmor _:
else notSalvaged++;
notSalvaged++; break;
} case BaseWeapon weapon when Resmelt( from, weapon, weapon.Resource ):
else if ( item is BaseWeapon ) salvaged++;
{ break;
if ( Resmelt( from, item, ( (BaseWeapon)item ).Resource ) ) case BaseWeapon _:
salvaged++; notSalvaged++;
else break;
notSalvaged++; case DragonBardingDeed deed when Resmelt( from, deed, deed.Resource ):
} salvaged++;
else if ( item is DragonBardingDeed ) break;
{ case DragonBardingDeed _:
if ( Resmelt( from, item, ( (DragonBardingDeed)item ).Resource ) ) notSalvaged++;
salvaged++; break;
}
else }
notSalvaged++;
}
}
if ( m_Failure ) if ( m_Failure )
{ {
from.SendLocalizedMessage( 1079975 ); // You failed to smelt some metal for lack of skill. from.SendLocalizedMessage( 1079975 ); // You failed to smelt some metal for lack of skill.
@ -240,8 +229,7 @@ namespace Server.Items
private void SalvageCloth( Mobile from ) private void SalvageCloth( Mobile from )
{ {
Scissors scissors = from.Backpack.FindItemByType( typeof( Scissors ) ) as Scissors; if ( !(from.Backpack.FindItemByType( typeof( Scissors ) ) is Scissors scissors) )
if ( scissors == null )
{ {
from.SendLocalizedMessage( 1079823 ); // You need scissors in order to salvage cloth. from.SendLocalizedMessage( 1079823 ); // You need scissors in order to salvage cloth.
return; return;
@ -258,22 +246,18 @@ namespace Server.Items
{ {
Item item = scissorables[i]; Item item = scissorables[i];
if ( item is IScissorable ) if (!(item is IScissorable scissorable))
{ continue;
IScissorable scissorable = (IScissorable)item;
if ( Scissors.CanScissor( from, scissorable ) && scissorable.Scissor( from, scissors ) ) if ( Scissors.CanScissor( from, scissorable ) && scissorable.Scissor( from, scissors ) )
++salvaged; ++salvaged;
else else
++notSalvaged; ++notSalvaged;
}
} }
from.SendLocalizedMessage( 1079974, String.Format( "{0}\t{1}", salvaged, salvaged + notSalvaged ) ); // Salvaged: ~1_COUNT~/~2_NUM~ tailored items from.SendLocalizedMessage( 1079974, String.Format( "{0}\t{1}", salvaged, salvaged + notSalvaged ) ); // Salvaged: ~1_COUNT~/~2_NUM~ tailored items
Container pack = from.Backpack; foreach (Item i in this.FindItemsByType(typeof(Item), true))
foreach (Item i in ((Container)this).FindItemsByType(typeof(Item), true))
{ {
if ( ( i is Leather ) || ( i is Cloth ) || ( i is SpinedLeather ) || ( i is HornedLeather ) || ( i is BarbedLeather ) || ( i is Bandage ) || ( i is Bone ) ) if ( ( i is Leather ) || ( i is Cloth ) || ( i is SpinedLeather ) || ( i is HornedLeather ) || ( i is BarbedLeather ) || ( i is Bandage ) || ( i is Bone ) )
{ {

View file

@ -198,17 +198,11 @@ namespace Server.Items
else else
item = Loot.RandomArmorOrShieldOrWeapon(); item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon ) if ( item is BaseWeapon weapon )
{ {
BaseWeapon weapon = (BaseWeapon)item;
if ( Core.AOS ) if ( Core.AOS )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
} }
else else
@ -218,19 +212,13 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 ); weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
} }
cont.DropItem( item ); cont.DropItem( weapon );
} }
else if ( item is BaseArmor ) else if ( item is BaseArmor armor )
{ {
BaseArmor armor = (BaseArmor)item;
if ( Core.AOS ) if ( Core.AOS )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
} }
else else
@ -239,34 +227,24 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 ); armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
} }
cont.DropItem( item ); cont.DropItem( armor );
} }
else if ( item is BaseHat ) else if ( item is BaseHat hat )
{ {
BaseHat hat = (BaseHat)item;
if ( Core.AOS ) if ( Core.AOS )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
} }
cont.DropItem( item ); cont.DropItem( hat );
} }
else if ( item is BaseJewel ) else if ( item is BaseJewel jewel )
{ {
int attributeCount; GetRandomAOSStats( out var attributeCount, out var min, out var max );
int min, max; BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
GetRandomAOSStats( out attributeCount, out min, out max ); cont.DropItem( jewel );
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );
cont.DropItem( item );
} }
} }
} }

View file

@ -20,18 +20,12 @@ namespace Server.Items
if ( m_Deed.Deleted || m_Deed.RootParent != from ) if ( m_Deed.Deleted || m_Deed.RootParent != from )
return; return;
if ( target is BaseClothing ) if ( target is BaseClothing item )
{ {
BaseClothing item = (BaseClothing)target; if ( (item as IArcaneEquip)?.IsArcane == true )
if ( item is IArcaneEquip )
{ {
IArcaneEquip eq = (IArcaneEquip)item; from.SendLocalizedMessage( 1005019 ); // This bless deed is for Clothes only.
if ( eq.IsArcane ) return;
{
from.SendLocalizedMessage( 1005019 ); // This bless deed is for Clothes only.
return;
}
} }
if ( item.LootType == LootType.Blessed || item.BlessedFor == from || (Mobile.InsuranceEnabled && item.Insured) ) // Check if its already newbied (blessed) if ( item.LootType == LootType.Blessed || item.BlessedFor == from || (Mobile.InsuranceEnabled && item.Insured) ) // Check if its already newbied (blessed)

View file

@ -27,7 +27,7 @@ namespace Server.Items
{ {
InvalidateProperties(); InvalidateProperties();
if ( m_Commodity == null && item is ICommodity && ((ICommodity)item).IsDeedable ) if ( m_Commodity == null && (item as ICommodity)?.IsDeedable == true )
{ {
m_Commodity = item; m_Commodity = item;
m_Commodity.Internalize(); m_Commodity.Internalize();
@ -35,10 +35,8 @@ namespace Server.Items
return true; return true;
} }
else
{ return false;
return false;
}
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
@ -109,7 +107,7 @@ namespace Server.Items
string args; string args;
if ( m_Commodity.Name == null ) if ( m_Commodity.Name == null )
args = String.Format( "#{0}\t{1}", ( m_Commodity is ICommodity ) ? ((ICommodity)m_Commodity).DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount ); args = String.Format( "#{0}\t{1}", ( m_Commodity is ICommodity commodity ) ? commodity.DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount );
else else
args = String.Format( "{0}\t{1}", m_Commodity.Name, m_Commodity.Amount ); args = String.Format( "{0}\t{1}", m_Commodity.Name, m_Commodity.Amount );
@ -130,7 +128,7 @@ namespace Server.Items
string args; string args;
if ( m_Commodity.Name == null ) if ( m_Commodity.Name == null )
args = String.Format( "#{0}\t{1}", ( m_Commodity is ICommodity ) ? ((ICommodity)m_Commodity).DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount ); args = String.Format( "#{0}\t{1}", ( m_Commodity is ICommodity commodity ) ? commodity.DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount );
else else
args = String.Format( "{0}\t{1}", m_Commodity.Name, m_Commodity.Amount ); args = String.Format( "{0}\t{1}", m_Commodity.Name, m_Commodity.Amount );
@ -228,16 +226,16 @@ namespace Server.Items
{ {
number = 1047028; // The commodity deed has already been filled. number = 1047028; // The commodity deed has already been filled.
} }
else if ( targeted is Item ) else if ( targeted is Item item )
{ {
BankBox box = from.FindBankNoCreate(); BankBox box = from.FindBankNoCreate();
CommodityDeedBox cox = CommodityDeedBox.Find( m_Deed ); CommodityDeedBox cox = CommodityDeedBox.Find( m_Deed );
// Veteran Rewards mods // Veteran Rewards mods
if ( box != null && m_Deed.IsChildOf( box ) && ((Item)targeted).IsChildOf( box ) || if ( box != null && m_Deed.IsChildOf( box ) && item.IsChildOf( box ) ||
cox != null && cox.IsSecure && ((Item)targeted).IsChildOf( cox ) ) cox != null && cox.IsSecure && item.IsChildOf( cox ) )
{ {
if ( m_Deed.SetCommodity( (Item) targeted ) ) if ( m_Deed.SetCommodity( item ) )
{ {
m_Deed.Hue = 0x592; m_Deed.Hue = 0x592;
number = 1047030; // The commodity deed has been filled. number = 1047030; // The commodity deed has been filled.
@ -247,16 +245,13 @@ namespace Server.Items
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with. number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
} }
} }
else if ( Core.ML )
{
number = 1080526; // That must be in your bank box or commodity deed box to use it.
}
else else
{ {
if ( Core.ML ) number = 1047026; // That must be in your bank box to use it.
{
number = 1080526; // That must be in your bank box or commodity deed box to use it.
}
else
{
number = 1047026; // That must be in your bank box to use it.
}
} }
} }
else else

View file

@ -54,9 +54,7 @@ namespace Server.Items
if ( Deleted ) if ( Deleted )
return; return;
SwampDragon pet = obj as SwampDragon; if ( !(obj is SwampDragon pet) || pet.HasBarding )
if ( pet == null || pet.HasBarding )
{ {
from.SendLocalizedMessage( 1053025 ); // That is not an unarmored swamp dragon. from.SendLocalizedMessage( 1053025 ); // That is not an unarmored swamp dragon.
} }

View file

@ -94,12 +94,10 @@ namespace Server.Items
int[][] RacialData = (m_From.Race == Race.Human) ? HumanArray : ElvenArray; int[][] RacialData = (m_From.Race == Race.Human) ? HumanArray : ElvenArray;
if ( m_From is PlayerMobile ) if ( m_From is PlayerMobile pm )
{ {
PlayerMobile pm = (PlayerMobile)m_From;
pm.SetHairMods( -1, -1 ); // clear any hairmods (disguise kit, incognito) pm.SetHairMods( -1, -1 ); // clear any hairmods (disguise kit, incognito)
m_From.HairItemID = (m_From.Female) ? RacialData[info.ButtonID][2] : RacialData[info.ButtonID][3]; pm.HairItemID = (pm.Female) ? RacialData[info.ButtonID][2] : RacialData[info.ButtonID][3];
m_Deed.Delete(); m_Deed.Delete();
} }
} }

View file

@ -86,15 +86,13 @@ namespace Server.Items
public void Placement_OnTarget( Mobile from, object targeted, object state ) public void Placement_OnTarget( Mobile from, object targeted, object state )
{ {
IPoint3D p = targeted as IPoint3D; if ( !(targeted is IPoint3D p) )
if ( p == null )
return; return;
Point3D loc = new Point3D( p ); Point3D loc = new Point3D( p );
if ( p is StaticTarget ) if ( p is StaticTarget target )
loc.Z -= TileData.ItemTable[((StaticTarget)p).ItemID].CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here. loc.Z -= TileData.ItemTable[target.ItemID].CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here.
* A side affect is that you can only place on floors (due to the CanFit call). * A side affect is that you can only place on floors (due to the CanFit call).
* That functionality may be desired. And so, it's included in this script. * That functionality may be desired. And so, it's included in this script.
*/ */
@ -107,9 +105,7 @@ namespace Server.Items
{ {
this.Delete(); this.Delete();
HolidayTree tree = new HolidayTree( from, type, loc ); HolidayTree tree = new HolidayTree( from, type, loc );
BaseHouse house = BaseHouse.FindHouseAt( tree ); BaseHouse.FindHouseAt( tree )?.Addons.Add( tree );
if ( house != null )
house.Addons.Add( tree );
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )

View file

@ -100,9 +100,8 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 501928 ); // You can't target the same ticket! from.SendLocalizedMessage( 501928 ); // You can't target the same ticket!
} }
else if ( targeted is NewPlayerTicket ) else if ( targeted is NewPlayerTicket theirTicket )
{ {
NewPlayerTicket theirTicket = targeted as NewPlayerTicket;
Mobile them = theirTicket.m_Owner; Mobile them = theirTicket.m_Owner;
if ( them == null || them.Deleted ) if ( them == null || them.Deleted )
@ -115,7 +114,7 @@ namespace Server.Items
them.SendGump( new InternalGump( them, theirTicket ) ); them.SendGump( new InternalGump( them, theirTicket ) );
} }
} }
else if ( targeted is Item && ((Item)targeted).ItemID == 0x14F0 ) else if ((targeted as Item)?.ItemID == 0x14F0 )
{ {
from.SendLocalizedMessage( 501931 ); // You need to find another ticket marked NEW PLAYER. from.SendLocalizedMessage( 501931 ); // You need to find another ticket marked NEW PLAYER.
} }

View file

@ -245,8 +245,7 @@ namespace Server.Items
if ( !m_Contract.IsUsableBy( from, false, true, true, true ) ) if ( !m_Contract.IsUsableBy( from, false, true, true, true ) )
return; return;
IPoint3D location = targeted as IPoint3D; if ( !(targeted is IPoint3D location) )
if ( location == null )
return; return;
Point3D pLocation = new Point3D( location ); Point3D pLocation = new Point3D( location );
@ -284,8 +283,7 @@ namespace Server.Items
} }
else else
{ {
bool vendor, contract; BaseHouse.IsThereVendor( pLocation, map, out var vendor, out var contract );
BaseHouse.IsThereVendor( pLocation, map, out vendor, out contract );
if ( vendor ) if ( vendor )
{ {

View file

@ -715,10 +715,8 @@ namespace Server.Items
if ( !IsEmpty || !Fillable || !ValidateUse( from, false ) ) if ( !IsEmpty || !Fillable || !ValidateUse( from, false ) )
return; return;
if ( targ is BaseBeverage ) if ( targ is BaseBeverage bev )
{ {
BaseBeverage bev = (BaseBeverage)targ;
if ( bev.IsEmpty || !bev.ValidateUse( from, true ) ) if ( bev.IsEmpty || !bev.ValidateUse( from, true ) )
return; return;
@ -737,10 +735,8 @@ namespace Server.Items
bev.Quantity = 0; bev.Quantity = 0;
} }
} }
else if ( targ is BaseWaterContainer ) else if ( targ is BaseWaterContainer bwc )
{ {
BaseWaterContainer bwc = targ as BaseWaterContainer;
if ( Quantity == 0 || ( Content == BeverageType.Water && !IsFull ) ) if ( Quantity == 0 || ( Content == BeverageType.Water && !IsFull ) )
{ {
int iNeed = Math.Min( ( MaxQuantity - Quantity ), bwc.Quantity ); int iNeed = Math.Min( ( MaxQuantity - Quantity ), bwc.Quantity );
@ -755,15 +751,12 @@ namespace Server.Items
} }
} }
} }
else if ( targ is Item ) else if ( targ is Item item )
{ {
Item item = (Item)targ; IWaterSource src = ( item as IWaterSource );
IWaterSource src;
src = ( item as IWaterSource ); if ( src == null && item is AddonComponent component )
src = ( component.Addon as IWaterSource );
if ( src == null && item is AddonComponent )
src = ( ( (AddonComponent)item ).Addon as IWaterSource );
if ( src == null || src.Quantity <= 0 ) if ( src == null || src.Quantity <= 0 )
return; return;
@ -791,10 +784,8 @@ namespace Server.Items
from.SendLocalizedMessage( 1010089 ); // You fill the container with water. from.SendLocalizedMessage( 1010089 ); // You fill the container with water.
} }
else if ( targ is Cow ) else if ( targ is Cow cow )
{ {
Cow cow = (Cow)targ;
if ( cow.TryMilk( from ) ) if ( cow.TryMilk( from ) )
{ {
Content = BeverageType.Milk; Content = BeverageType.Milk;
@ -802,21 +793,17 @@ namespace Server.Items
from.SendLocalizedMessage( 1080197 ); // You fill the container with milk. from.SendLocalizedMessage( 1080197 ); // You fill the container with milk.
} }
} }
else if ( targ is LandTarget ) else if ( targ is LandTarget target )
{ {
int tileID = ( (LandTarget)targ ).TileID; int tileID = target.TileID;
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest ) if ( qs is WitchApprenticeQuest )
{ {
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective; if ( qs.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj && !obj.Completed && obj.Ingredient == Ingredient.SwampWater )
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.SwampWater )
{ {
bool contains = false; bool contains = false;
@ -956,10 +943,8 @@ namespace Server.Items
if ( IsEmpty || !Pourable || !ValidateUse( from, false ) ) if ( IsEmpty || !Pourable || !ValidateUse( from, false ) )
return; return;
if ( targ is BaseBeverage ) if ( targ is BaseBeverage bev )
{ {
BaseBeverage bev = (BaseBeverage)targ;
if ( !bev.ValidateUse( from, true ) ) if ( !bev.ValidateUse( from, true ) )
return; return;
@ -1023,10 +1008,8 @@ namespace Server.Items
--Quantity; --Quantity;
} }
else if ( targ is BaseWaterContainer ) else if ( targ is BaseWaterContainer bwc )
{ {
BaseWaterContainer bwc = targ as BaseWaterContainer;
if ( Content != BeverageType.Water ) if ( Content != BeverageType.Water )
{ {
from.SendLocalizedMessage( 500842 ); // Can't pour that in there. from.SendLocalizedMessage( 500842 ); // Can't pour that in there.
@ -1048,27 +1031,23 @@ namespace Server.Items
} }
} }
} }
else if ( targ is PlantItem ) else if ( targ is PlantItem item )
{ {
( (PlantItem)targ ).Pour( from, this ); item.Pour( from, this );
} }
else if ( targ is AddonComponent && else if ( targ is AddonComponent component &&
( ( (AddonComponent)targ ).Addon is WaterVatEast || ( (AddonComponent)targ ).Addon is WaterVatSouth ) && ( component.Addon is WaterVatEast || component.Addon is WaterVatSouth ) &&
this.Content == BeverageType.Water ) this.Content == BeverageType.Water )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest; if ( player.Quest is SolenMatriarchQuest qs )
if ( qs != null )
{ {
QuestObjective obj = qs.FindObjective( typeof( GatherWaterObjective ) ); QuestObjective obj = qs.FindObjective( typeof( GatherWaterObjective ) );
if ( obj != null && !obj.Completed ) if ( obj != null && !obj.Completed )
{ {
BaseAddon vat = ( (AddonComponent)targ ).Addon; BaseAddon vat = component.Addon;
if ( vat.X > 5784 && vat.X < 5814 && vat.Y > 1903 && vat.Y < 1934 && if ( vat.X > 5784 && vat.X < 5814 && vat.Y > 1903 && vat.Y < 1934 &&
( ( qs.RedSolen && vat.Map == Map.Trammel ) || ( !qs.RedSolen && vat.Map == Map.Felucca ) ) ) ( ( qs.RedSolen && vat.Map == Map.Trammel ) || ( !qs.RedSolen && vat.Map == Map.Felucca ) ) )
@ -1127,9 +1106,7 @@ namespace Server.Items
for( int i = 0; i < items.Length; ++i ) for( int i = 0; i < items.Length; ++i )
{ {
BaseBeverage bev = items[ i ] as BaseBeverage; if ( items[i] is BaseBeverage bev && bev.Content == content && !bev.IsEmpty )
if ( bev != null && bev.Content == content && !bev.IsEmpty )
total += bev.Quantity; total += bev.Quantity;
} }
@ -1141,9 +1118,7 @@ namespace Server.Items
for( int i = 0; i < items.Length; ++i ) for( int i = 0; i < items.Length; ++i )
{ {
BaseBeverage bev = items[ i ] as BaseBeverage; if ( !(items[i] is BaseBeverage bev) || bev.Content != content || bev.IsEmpty )
if ( bev == null || bev.Content != content || bev.IsEmpty )
continue; continue;
int theirQuantity = bev.Quantity; int theirQuantity = bev.Quantity;

View file

@ -74,26 +74,26 @@ namespace Server.Items
{ {
int itemID; int itemID;
if ( targeted is Item ) if ( targeted is Item item )
itemID = ((Item)targeted).ItemID; itemID = item.ItemID;
else if ( targeted is StaticTarget ) else if ( targeted is StaticTarget target )
itemID = ((StaticTarget)targeted).ItemID; itemID = target.ItemID;
else else
return false; return false;
if ( itemID >= 0xDE3 && itemID <= 0xDE9 ) if ( itemID >= 0xDE3 && itemID <= 0xDE9 )
return true; // Campfire return true; // Campfire
else if ( itemID >= 0x461 && itemID <= 0x48E ) if ( itemID >= 0x461 && itemID <= 0x48E )
return true; // Sandstone oven/fireplace return true; // Sandstone oven/fireplace
else if ( itemID >= 0x92B && itemID <= 0x96C ) if ( itemID >= 0x92B && itemID <= 0x96C )
return true; // Stone oven/fireplace return true; // Stone oven/fireplace
else if ( itemID == 0xFAC ) if ( itemID == 0xFAC )
return true; // Firepit return true; // Firepit
else if ( itemID >= 0x184A && itemID <= 0x184C ) if ( itemID >= 0x184A && itemID <= 0x184C )
return true; // Heating stand (left) return true; // Heating stand (left)
else if ( itemID >= 0x184E && itemID <= 0x1850 ) if ( itemID >= 0x184E && itemID <= 0x1850 )
return true; // Heating stand (right) return true; // Heating stand (right)
else if ( itemID >= 0x398C && itemID <= 0x399F ) if ( itemID >= 0x398C && itemID <= 0x399F )
return true; // Fire field return true; // Fire field
return false; return false;

View file

@ -71,8 +71,8 @@ namespace Server.Items
{ {
if ( m_Item.Deleted ) return; if ( m_Item.Deleted ) return;
Item targetItem = targeted as Item; if ( !(targeted is Item targetItem) || targetItem.Deleted )
if ( targetItem == null || targetItem.Deleted ) return; return;
m_Item.Consume(); m_Item.Consume();
@ -171,16 +171,16 @@ namespace Server.Items
m_Item.Consume(); m_Item.Consume();
if ( targeted is BowlFlour ) if ( targeted is BowlFlour flour )
{ {
((BowlFlour)targeted).Delete(); flour.Delete();
from.AddToBackpack( new CakeMix() ); from.AddToBackpack( new CakeMix() );
} }
else if ( targeted is Campfire ) else if ( targeted is Campfire campfire )
{ {
from.PlaySound( 0x225 ); from.PlaySound( 0x225 );
InternalTimer t = new InternalTimer( from, (Campfire)targeted ); InternalTimer t = new InternalTimer( from, campfire );
t.Start(); t.Start();
} }
} }
@ -270,16 +270,16 @@ namespace Server.Items
m_Item.Consume(); m_Item.Consume();
if ( targeted is Dough ) if ( targeted is Dough dough )
{ {
((Dough)targeted).Consume(); dough.Consume();
from.AddToBackpack( new SweetDough() ); from.AddToBackpack( new SweetDough() );
} }
if (targeted is BowlFlour) if (targeted is BowlFlour flour)
{ {
((BowlFlour)targeted).Delete(); flour.Delete();
from.AddToBackpack( new CookieMix() ); from.AddToBackpack( new CookieMix() );
} }
@ -618,12 +618,10 @@ namespace Server.Items
public virtual void OnTarget( Mobile from, object obj ) public virtual void OnTarget( Mobile from, object obj )
{ {
if ( obj is AddonComponent ) if ( obj is AddonComponent addon )
obj = (obj as AddonComponent).Addon; obj = addon.Addon;
IFlourMill mill = obj as IFlourMill; if ( obj is IFlourMill mill )
if ( mill != null )
{ {
int needs = mill.MaxFlour - mill.CurFlour; int needs = mill.MaxFlour - mill.CurFlour;

View file

@ -79,16 +79,12 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
BasePiece piece = dropped as BasePiece; return ( dropped is BasePiece piece && piece.Board == this && base.OnDragDrop( from, dropped ) );
return ( piece != null && piece.Board == this && base.OnDragDrop( from, dropped ) );
} }
public override bool OnDragDropInto( Mobile from, Item dropped, Point3D point ) public override bool OnDragDropInto( Mobile from, Item dropped, Point3D point )
{ {
BasePiece piece = dropped as BasePiece; if ( dropped is BasePiece piece && piece.Board == this && base.OnDragDropInto( from, dropped, point ) )
if ( piece != null && piece.Board == this && base.OnDragDropInto( from, dropped, point ) )
{ {
Packet p = new PlaySound( 0x127, GetWorldLocation() ); Packet p = new PlaySound( 0x127, GetWorldLocation() );
@ -108,10 +104,8 @@ namespace Server.Items
return true; return true;
} }
else
{ return false;
return false;
}
} }
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list ) public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )

View file

@ -413,9 +413,7 @@ namespace Server.Items
public void Placement_OnTarget( Mobile from, object targeted, object state ) public void Placement_OnTarget( Mobile from, object targeted, object state )
{ {
IPoint3D p = targeted as IPoint3D; if ( !(targeted is IPoint3D p) || Deleted )
if ( p == null || Deleted )
return; return;
Point3D loc = new Point3D( p ); Point3D loc = new Point3D( p );

View file

@ -116,9 +116,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
BaseJewel jewel = newItem as BaseJewel; if ( !(newItem is BaseJewel jewel) )
if ( jewel == null )
return; return;
jewel.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes ); jewel.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes );
@ -143,10 +141,8 @@ namespace Server.Items
public override void OnAdded(IEntity parent) public override void OnAdded(IEntity parent)
{ {
if ( Core.AOS && parent is Mobile ) if ( Core.AOS && parent is Mobile from )
{ {
Mobile from = (Mobile)parent;
m_AosSkillBonuses.AddTo( from ); m_AosSkillBonuses.AddTo( from );
int strBonus = m_AosAttributes.BonusStr; int strBonus = m_AosAttributes.BonusStr;
@ -173,19 +169,17 @@ namespace Server.Items
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
if ( Core.AOS && parent is Mobile ) if ( Core.AOS && parent is Mobile @from )
{ {
Mobile from = (Mobile)parent;
m_AosSkillBonuses.Remove(); m_AosSkillBonuses.Remove();
string modName = this.Serial.ToString(); string modName = this.Serial.ToString();
from.RemoveStatMod( modName + "Str" ); @from.RemoveStatMod( modName + "Str" );
from.RemoveStatMod( modName + "Dex" ); @from.RemoveStatMod( modName + "Dex" );
from.RemoveStatMod( modName + "Int" ); @from.RemoveStatMod( modName + "Int" );
from.CheckStatTimers(); @from.CheckStatTimers();
} }
} }
@ -327,17 +321,17 @@ namespace Server.Items
m_AosResistances = new AosElementAttributes( this, reader ); m_AosResistances = new AosElementAttributes( this, reader );
m_AosSkillBonuses = new AosSkillBonuses( this, reader ); m_AosSkillBonuses = new AosSkillBonuses( this, reader );
if ( Core.AOS && Parent is Mobile ) Mobile m = Parent as Mobile;
m_AosSkillBonuses.AddTo( (Mobile)Parent );
if ( Core.AOS && m != null )
m_AosSkillBonuses.AddTo( m );
int strBonus = m_AosAttributes.BonusStr; int strBonus = m_AosAttributes.BonusStr;
int dexBonus = m_AosAttributes.BonusDex; int dexBonus = m_AosAttributes.BonusDex;
int intBonus = m_AosAttributes.BonusInt; int intBonus = m_AosAttributes.BonusInt;
if ( Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0) ) if ( m != null && (strBonus != 0 || dexBonus != 0 || intBonus != 0) )
{ {
Mobile m = (Mobile)Parent;
string modName = Serial.ToString(); string modName = Serial.ToString();
if ( strBonus != 0 ) if ( strBonus != 0 )
@ -350,8 +344,7 @@ namespace Server.Items
m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) ); m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
} }
if ( Parent is Mobile ) m?.CheckStatTimers();
((Mobile)Parent).CheckStatTimers();
break; break;
} }

View file

@ -17,10 +17,8 @@ namespace Server.Items
public override void Ignite() public override void Ignite()
{ {
if ( !(Parent is Mobile) && RootParent is Mobile ) if ( !(Parent is Mobile) && RootParent is Mobile holder )
{ {
Mobile holder = (Mobile)RootParent;
if ( holder.EquipItem( this ) ) if ( holder.EquipItem( this ) )
{ {
if ( this is Candle ) if ( this is Candle )
@ -61,4 +59,4 @@ namespace Server.Items
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -28,16 +28,16 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( parent is Mobile && Burning ) if ( parent is Mobile mobile && Burning )
Mobiles.MeerMage.StopEffect( (Mobile)parent, true ); Mobiles.MeerMage.StopEffect( mobile, true );
} }
public override void Ignite() public override void Ignite()
{ {
base.Ignite(); base.Ignite();
if ( Parent is Mobile && Burning ) if ( Parent is Mobile mobile && Burning )
Mobiles.MeerMage.StopEffect( (Mobile)Parent, true ); Mobiles.MeerMage.StopEffect( mobile, true );
} }
public Torch( Serial serial ) : base( serial ) public Torch( Serial serial ) : base( serial )

View file

@ -263,7 +263,7 @@ namespace Server.Items
writer.Write( m_Height ); writer.Write( m_Height );
writer.Write( m_Protected ); writer.Write( m_Protected );
writer.Write( m_Pins.Count ); writer.Write( m_Pins.Count );
for ( int i = 0; i < m_Pins.Count; ++i ) for ( int i = 0; i < m_Pins.Count; ++i )
writer.Write( m_Pins[i] ); writer.Write( m_Pins[i] );
@ -303,9 +303,8 @@ namespace Server.Items
private static void OnMapCommand( NetState state, PacketReader pvSrc ) private static void OnMapCommand( NetState state, PacketReader pvSrc )
{ {
Mobile from = state.Mobile; Mobile from = state.Mobile;
MapItem map = World.FindItem( pvSrc.ReadInt32() ) as MapItem;
if ( map == null ) if ( !(World.FindItem( pvSrc.ReadInt32() ) is MapItem map) )
return; return;
int command = pvSrc.ReadByte(); int command = pvSrc.ReadByte();
@ -366,7 +365,7 @@ namespace Server.Items
m_Stream.Write( (byte) command ); m_Stream.Write( (byte) command );
m_Stream.Write( (byte) number ); m_Stream.Write( (byte) number );
m_Stream.Write( (short) x ); m_Stream.Write( (short) x );
m_Stream.Write( (short) y ); m_Stream.Write( (short) y );
} }
} }
@ -400,4 +399,4 @@ namespace Server.Items
#endregion #endregion
} }
} }

View file

@ -342,11 +342,7 @@ namespace Server.Items
{ {
IPoint3D p = targeted as IPoint3D; IPoint3D p = targeted as IPoint3D;
Point3D targ3D; Point3D targ3D = (p as Item)?.GetWorldLocation() ?? new Point3D(p);
if ( p is Item )
targ3D = ((Item)p).GetWorldLocation();
else
targ3D = new Point3D( p );
int maxRange; int maxRange;
double skillValue = from.Skills[SkillName.Mining].Value; double skillValue = from.Skills[SkillName.Mining].Value;
@ -621,7 +617,7 @@ namespace Server.Items
if ( from.AccessLevel >= AccessLevel.GameMaster ) if ( from.AccessLevel >= AccessLevel.GameMaster )
return true; return true;
if ( from is PlayerMobile && ((PlayerMobile)from).Young ) if ( @from is PlayerMobile mobile && mobile.Young )
return true; return true;
if ( from == this.Decoder ) if ( from == this.Decoder )
@ -935,4 +931,4 @@ namespace Server.Items
Delete(); Delete();
} }
} }
} }

View file

@ -60,8 +60,7 @@ namespace Server.Items
foreach( Mobile m in GetMobilesInRange( 0 ) ) foreach( Mobile m in GetMobilesInRange( 0 ) )
{ {
BaseCreature bc = m as BaseCreature; if ( m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned) )
if ( m.Alive && !m.IsDeadBondedPet && (bc == null || bc.Controlled || bc.Summoned) )
{ {
toDamage.Add( m ); toDamage.Add( m );
} }

View file

@ -59,31 +59,35 @@ namespace Server.Items
return; return;
} }
if ( obj is IArcaneEquip && obj is Item ) if ( obj is IArcaneEquip eq && eq is Item item )
{ {
Item item = (Item)obj;
CraftResource resource = CraftResource.None; CraftResource resource = CraftResource.None;
if ( item is BaseClothing ) switch (item)
resource = ((BaseClothing)item).Resource; {
else if ( item is BaseArmor ) case BaseClothing clothing:
resource = ((BaseArmor)item).Resource; resource = clothing.Resource;
else if ( item is BaseWeapon ) // Sanity, weapons cannot receive gems... break;
resource = ((BaseWeapon)item).Resource; case BaseArmor armor:
resource = armor.Resource;
IArcaneEquip eq = (IArcaneEquip)obj; break;
// Sanity, weapons cannot receive gems...
case BaseWeapon weapon:
resource = weapon.Resource;
break;
}
if ( !item.IsChildOf( from.Backpack ) ) if ( !item.IsChildOf( from.Backpack ) )
{ {
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
return; return;
} }
else if ( item.LootType == LootType.Blessed ) if ( item.LootType == LootType.Blessed )
{ {
from.SendMessage( "You can only use this on exceptionally crafted robes, thigh boots, cloaks, or leather gloves." ); from.SendMessage( "You can only use this on exceptionally crafted robes, thigh boots, cloaks, or leather gloves." );
return; return;
} }
else if ( resource != CraftResource.None && resource != CraftResource.RegularLeather ) if ( resource != CraftResource.None && resource != CraftResource.RegularLeather )
{ {
from.SendLocalizedMessage( 1049690 ); // Arcane gems can not be used on that type of leather. from.SendLocalizedMessage( 1049690 ); // Arcane gems can not be used on that type of leather.
return; return;
@ -117,30 +121,37 @@ namespace Server.Items
{ {
bool isExceptional = false; bool isExceptional = false;
if ( item is BaseClothing ) switch (item)
isExceptional = ( ((BaseClothing)item).Quality == ClothingQuality.Exceptional ); {
else if ( item is BaseArmor ) case BaseClothing clothing:
isExceptional = ( ((BaseArmor)item).Quality == ArmorQuality.Exceptional ); isExceptional = clothing.Quality == ClothingQuality.Exceptional;
else if ( item is BaseWeapon ) break;
isExceptional = ( ((BaseWeapon)item).Quality == WeaponQuality.Exceptional ); case BaseArmor armor:
isExceptional = armor.Quality == ArmorQuality.Exceptional;
break;
case BaseWeapon weapon:
isExceptional = weapon.Quality == WeaponQuality.Exceptional;
break;
}
if ( isExceptional ) if ( isExceptional )
{ {
if ( item is BaseClothing ) switch (item)
{ {
((BaseClothing)item).Quality = ClothingQuality.Regular; case BaseClothing clothing:
((BaseClothing)item).Crafter = from; clothing.Quality = ClothingQuality.Regular;
} clothing.Crafter = @from;
else if ( item is BaseArmor ) break;
{ case BaseArmor armor:
((BaseArmor)item).Quality = ArmorQuality.Regular; armor.Quality = ArmorQuality.Regular;
((BaseArmor)item).Crafter = from; armor.Crafter = @from;
((BaseArmor)item).PhysicalBonus = ((BaseArmor)item).FireBonus = ((BaseArmor)item).ColdBonus = ((BaseArmor)item).PoisonBonus = ((BaseArmor)item).EnergyBonus = 0; // Is there a method to remove bonuses? armor.PhysicalBonus = armor.FireBonus = armor.ColdBonus = armor.PoisonBonus = armor.EnergyBonus = 0; // Is there a method to remove bonuses?
} break;
else if ( item is BaseWeapon ) // Sanity, weapons cannot receive gems... // Sanity, weapons cannot receive gems...
{ case BaseWeapon weapon:
((BaseWeapon)item).Quality = WeaponQuality.Regular; weapon.Quality = WeaponQuality.Regular;
((BaseWeapon)item).Crafter = from; weapon.Crafter = @from;
break;
} }
eq.CurArcaneCharges = eq.MaxArcaneCharges = charges; eq.CurArcaneCharges = eq.MaxArcaneCharges = charges;
@ -177,13 +188,8 @@ namespace Server.Items
{ {
Item obj = items[i]; Item obj = items[i];
if ( obj is IArcaneEquip ) if ( obj is IArcaneEquip eq && eq.IsArcane )
{ avail += eq.CurArcaneCharges;
IArcaneEquip eq = (IArcaneEquip)obj;
if ( eq.IsArcane )
avail += eq.CurArcaneCharges;
}
} }
if ( avail < amount ) if ( avail < amount )
@ -193,23 +199,16 @@ namespace Server.Items
{ {
Item obj = items[i]; Item obj = items[i];
if ( obj is IArcaneEquip ) if ( obj is IArcaneEquip eq && eq.IsArcane )
{ {
IArcaneEquip eq = (IArcaneEquip)obj; if ( eq.CurArcaneCharges > amount )
if ( eq.IsArcane )
{ {
if ( eq.CurArcaneCharges > amount ) eq.CurArcaneCharges -= amount;
{ break;
eq.CurArcaneCharges -= amount;
break;
}
else
{
amount -= eq.CurArcaneCharges;
eq.CurArcaneCharges = 0;
}
} }
amount -= eq.CurArcaneCharges;
eq.CurArcaneCharges = 0;
} }
} }

View file

@ -98,17 +98,15 @@ namespace Server.Items
Container root = parent as Container; Container root = parent as Container;
while (root != null && root.Parent is Container) while (root?.Parent is Container)
{ {
root = (Container)root.Parent; root = (Container)root.Parent;
} }
parent = root ?? parent; parent = root ?? parent;
if (parent is SecureTradeContainer && AccountGold.ConvertOnTrade) if (parent is SecureTradeContainer trade && AccountGold.ConvertOnTrade)
{ {
var trade = (SecureTradeContainer)parent;
if (trade.Trade.From.Container == trade) if (trade.Trade.From.Container == trade)
{ {
tradeInfo = trade.Trade.From; tradeInfo = trade.Trade.From;
@ -120,12 +118,12 @@ namespace Server.Items
owner = tradeInfo.Mobile; owner = tradeInfo.Mobile;
} }
} }
else if (parent is BankBox && AccountGold.ConvertOnBank) else if (parent is BankBox box && AccountGold.ConvertOnBank)
{ {
owner = ((BankBox)parent).Owner; owner = box.Owner;
} }
if (owner == null || owner.Account == null || !owner.Account.DepositGold(Worth)) if (owner?.Account == null || !owner.Account.DepositGold(Worth))
{ {
return; return;
} }
@ -134,17 +132,13 @@ namespace Server.Items
{ {
if (owner.NetState != null && !owner.NetState.NewSecureTrading) if (owner.NetState != null && !owner.NetState.NewSecureTrading)
{ {
int gold; int plat = Math.DivRem(Worth, AccountGold.CurrencyThreshold, out var gold);
int plat = Math.DivRem(Worth, AccountGold.CurrencyThreshold, out gold);
tradeInfo.Plat += plat; tradeInfo.Plat += plat;
tradeInfo.Gold += gold; tradeInfo.Gold += gold;
} }
if (tradeInfo.VirtualCheck != null) tradeInfo.VirtualCheck?.UpdateTrade(tradeInfo.Mobile);
{
tradeInfo.VirtualCheck.UpdateTrade(tradeInfo.Mobile);
}
} }
owner.SendLocalizedMessage(1042763, Worth.ToString("#,0")); owner.SendLocalizedMessage(1042763, Worth.ToString("#,0"));
@ -239,9 +233,7 @@ namespace Server.Items
// Gold was deposited in your account: // Gold was deposited in your account:
from.SendLocalizedMessage(1042672, true, deposited.ToString("#,0")); from.SendLocalizedMessage(1042672, true, deposited.ToString("#,0"));
var pm = from as PlayerMobile; if (@from is PlayerMobile pm)
if (pm != null)
{ {
var qs = pm.Quest; var qs = pm.Quest;

View file

@ -80,23 +80,23 @@ namespace Server.Items
if ( mt != null && !( to is ChaosDragoon || to is ChaosDragoonElite ) ) if ( mt != null && !( to is ChaosDragoon || to is ChaosDragoonElite ) )
mt.Rider = null; mt.Rider = null;
if (to is PlayerMobile) if (to is PlayerMobile mobile)
{ {
if (Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(to)) if (Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(mobile))
{ {
to.SendLocalizedMessage(1114066, from.Name); // ~1_NAME~ knocked you out of animal form! mobile.SendLocalizedMessage(1114066, from.Name); // ~1_NAME~ knocked you out of animal form!
} }
else if (to.Mounted) else if (mobile.Mounted)
{ {
to.SendLocalizedMessage(1040023); // You have been knocked off of your mount! mobile.SendLocalizedMessage(1040023); // You have been knocked off of your mount!
} }
(to as PlayerMobile).SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds( Core.ML ? 10 : 3 ), true); mobile.SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds( Core.ML ? 10 : 3 ), true);
} }
if (Core.AOS && from is PlayerMobile) /* only failsafe, attacker should already be dismounted */ if (Core.AOS) /* only failsafe, attacker should already be dismounted */
{ {
(from as PlayerMobile).SetMountBlock( BlockMountType.BolaRecovery, TimeSpan.FromSeconds( Core.ML ? 10 : 3 ), true ); (from as PlayerMobile)?.SetMountBlock( BlockMountType.BolaRecovery, TimeSpan.FromSeconds( Core.ML ? 10 : 3 ), true );
} }
to.Damage(1); to.Damage(1);
@ -160,10 +160,8 @@ namespace Server.Items
if ( m_Bola.Deleted ) if ( m_Bola.Deleted )
return; return;
if ( obj is Mobile ) if ( obj is Mobile to )
{ {
Mobile to = (Mobile)obj;
if ( !m_Bola.IsChildOf( from.Backpack ) ) if ( !m_Bola.IsChildOf( from.Backpack ) )
{ {
from.SendLocalizedMessage( 1040019 ); // The bola must be in your pack to use it. from.SendLocalizedMessage( 1040019 ); // The bola must be in your pack to use it.
@ -231,4 +229,4 @@ namespace Server.Items
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -88,9 +88,7 @@ namespace Server.Items
if ( i >= items.Count ) if ( i >= items.Count )
continue; continue;
BulletinMessage msg = items[i] as BulletinMessage; if ( !(items[i] is BulletinMessage msg) )
if ( msg == null )
continue; continue;
if ( msg.Thread == null && CheckTime( msg.LastPostTime, ThreadDeletionTime ) ) if ( msg.Thread == null && CheckTime( msg.LastPostTime, ThreadDeletionTime ) )
@ -111,9 +109,7 @@ namespace Server.Items
if ( i >= items.Count ) if ( i >= items.Count )
continue; continue;
BulletinMessage check = items[i] as BulletinMessage; if ( !(items[i] is BulletinMessage check) )
if ( check == null )
continue; continue;
if ( check.Thread == msg ) if ( check.Thread == msg )
@ -134,9 +130,7 @@ namespace Server.Items
for ( int i = 0; i < items.Count; ++i ) for ( int i = 0; i < items.Count; ++i )
{ {
BulletinMessage msg = items[i] as BulletinMessage; if ( !(items[i] is BulletinMessage msg) || msg.Poster != poster )
if ( msg == null || msg.Poster != poster )
continue; continue;
if ( onlyCheckRoot && msg.Thread != null ) if ( onlyCheckRoot && msg.Thread != null )
@ -227,9 +221,8 @@ namespace Server.Items
Mobile from = state.Mobile; Mobile from = state.Mobile;
int packetID = pvSrc.ReadByte(); int packetID = pvSrc.ReadByte();
BaseBulletinBoard board = World.FindItem( pvSrc.ReadInt32() ) as BaseBulletinBoard;
if ( board == null || !board.CheckRange( from ) ) if ( !(World.FindItem( pvSrc.ReadInt32() ) is BaseBulletinBoard board) || !board.CheckRange( from ) )
return; return;
switch ( packetID ) switch ( packetID )
@ -243,9 +236,7 @@ namespace Server.Items
public static void BBRequestContent( Mobile from, BaseBulletinBoard board, PacketReader pvSrc ) public static void BBRequestContent( Mobile from, BaseBulletinBoard board, PacketReader pvSrc )
{ {
BulletinMessage msg = World.FindItem( pvSrc.ReadInt32() ) as BulletinMessage; if ( !(World.FindItem( pvSrc.ReadInt32() ) is BulletinMessage msg) || msg.Parent != board )
if ( msg == null || msg.Parent != board )
return; return;
from.Send( new BBMessageContent( board, msg ) ); from.Send( new BBMessageContent( board, msg ) );
@ -253,9 +244,7 @@ namespace Server.Items
public static void BBRequestHeader( Mobile from, BaseBulletinBoard board, PacketReader pvSrc ) public static void BBRequestHeader( Mobile from, BaseBulletinBoard board, PacketReader pvSrc )
{ {
BulletinMessage msg = World.FindItem( pvSrc.ReadInt32() ) as BulletinMessage; if ( !(World.FindItem( pvSrc.ReadInt32() ) is BulletinMessage msg) || msg.Parent != board )
if ( msg == null || msg.Parent != board )
return; return;
from.Send( new BBMessageHeader( board, msg ) ); from.Send( new BBMessageHeader( board, msg ) );
@ -270,7 +259,7 @@ namespace Server.Items
int breakout = 0; int breakout = 0;
while ( thread != null && thread.Thread != null && breakout++ < 10 ) while ( thread?.Thread != null && breakout++ < 10 )
thread = thread.Thread; thread = thread.Thread;
DateTime lastPostTime = DateTime.MinValue; DateTime lastPostTime = DateTime.MinValue;
@ -306,9 +295,7 @@ namespace Server.Items
public static void BBRemoveMessage( Mobile from, BaseBulletinBoard board, PacketReader pvSrc ) public static void BBRemoveMessage( Mobile from, BaseBulletinBoard board, PacketReader pvSrc )
{ {
BulletinMessage msg = World.FindItem( pvSrc.ReadInt32() ) as BulletinMessage; if ( !(World.FindItem( pvSrc.ReadInt32() ) is BulletinMessage msg) || msg.Parent != board )
if ( msg == null || msg.Parent != board )
return; return;
if ( from.AccessLevel < AccessLevel.GameMaster && msg.Poster != from ) if ( from.AccessLevel < AccessLevel.GameMaster && msg.Poster != from )
@ -476,7 +463,7 @@ namespace Server.Items
public void Validate() public void Validate()
{ {
if ( !( Parent is BulletinBoard && ((BulletinBoard)Parent).Items.Contains( this ) ) ) if ( (Parent as BulletinBoard)?.Items.Contains( this ) == false )
Delete(); Delete();
} }
} }
@ -637,4 +624,4 @@ namespace Server.Items
return v; return v;
} }
} }
} }

View file

@ -210,10 +210,8 @@ namespace Server.Items
} }
} }
} }
else if ( targeted is ReceiverCrystal ) else if ( targeted is ReceiverCrystal receiver )
{ {
ReceiverCrystal receiver = (ReceiverCrystal) targeted;
if ( m_Crystal.Receivers.Count >= 10 ) if ( m_Crystal.Receivers.Count >= 10 )
{ {
from.SendLocalizedMessage( 1010042 ); // This broadcast crystal is already linked to 10 receivers. from.SendLocalizedMessage( 1010042 ); // This broadcast crystal is already linked to 10 receivers.
@ -234,18 +232,16 @@ namespace Server.Items
} }
else if ( targeted == from ) else if ( targeted == from )
{ {
foreach( ReceiverCrystal receiver in new List<ReceiverCrystal>( m_Crystal.Receivers ) ) foreach( ReceiverCrystal rc in new List<ReceiverCrystal>( m_Crystal.Receivers ) )
{ {
receiver.Sender = null; rc.Sender = null;
} }
from.SendLocalizedMessage( 1010046 ); // You unlink the broadcast crystal from all of its receivers. from.SendLocalizedMessage( 1010046 ); // You unlink the broadcast crystal from all of its receivers.
} }
else else
{ {
Item targItem = targeted as Item; if ( targeted is Item targItem && targItem.VerifyMove( from ) )
if ( targItem != null && targItem.VerifyMove( from ) )
{ {
CrystalRechargeInfo info = CrystalRechargeInfo.Get( targItem.GetType() ); CrystalRechargeInfo info = CrystalRechargeInfo.Get( targItem.GetType() );
@ -373,13 +369,13 @@ namespace Server.Items
string text = String.Format( "{0} says {1}", from.Name, message ); string text = String.Format( "{0} says {1}", from.Name, message );
if ( this.RootParent is Mobile ) if ( this.RootParent is Mobile mobile )
{ {
((Mobile)this.RootParent).SendMessage( 0x2B2, "Crystal: " + text ); mobile.SendMessage( 0x2B2, "Crystal: " + text );
} }
else if ( this.RootParent is Item ) else if ( this.RootParent is Item item )
{ {
((Item)this.RootParent).PublicOverheadMessage( MessageType.Regular, 0x2B2, false, "Crystal: " + text ); item.PublicOverheadMessage( MessageType.Regular, 0x2B2, false, "Crystal: " + text );
} }
else else
{ {
@ -445,9 +441,7 @@ namespace Server.Items
} }
else else
{ {
Item targItem = targeted as Item; if ( targeted is Item targItem && targItem.VerifyMove( from ) )
if ( targItem != null && targItem.VerifyMove( from ) )
{ {
CrystalRechargeInfo info = CrystalRechargeInfo.Get( targItem.GetType() ); CrystalRechargeInfo info = CrystalRechargeInfo.Get( targItem.GetType() );

View file

@ -436,13 +436,7 @@ namespace Server.Items
public static string GetCorpseName( Mobile m ) public static string GetCorpseName( Mobile m )
{ {
if ( m is BaseCreature ) return m is BaseCreature bc ? bc.CorpseNameOverride ?? bc.CorpseName : null;
{
BaseCreature bc = (BaseCreature)m;
return bc.CorpseNameOverride ?? bc.CorpseName;
}
return null;
} }
public static void Initialize() public static void Initialize()
@ -484,13 +478,8 @@ namespace Server.Items
{ {
c.AssignInstancedLoot(); c.AssignInstancedLoot();
} }
else if ( Core.AOS ) else if ( Core.AOS && owner is PlayerMobile pm )
{ c.RestoreEquip = pm.EquipSnapshot;
PlayerMobile pm = owner as PlayerMobile;
if ( pm != null )
c.RestoreEquip = pm.EquipSnapshot;
}
} }
else else
{ {
@ -945,9 +934,7 @@ namespace Server.Items
public override void OnClick() public override void OnClick()
{ {
Corpse corpse = Owner.Target as Corpse; if ( Owner.Target is Corpse corpse && Owner.From.CheckAlive() )
if ( corpse != null && Owner.From.CheckAlive() )
corpse.Open( Owner.From, false ); corpse.Open( Owner.From, false );
} }
} }
@ -1034,9 +1021,7 @@ namespace Server.Items
#region Self Looting #region Self Looting
if ( checkSelfLoot && from == m_Owner && !GetFlag( CorpseFlag.SelfLooted ) && this.Items.Count != 0 ) if ( checkSelfLoot && from == m_Owner && !GetFlag( CorpseFlag.SelfLooted ) && this.Items.Count != 0 )
{ {
DeathRobe robe = from.FindItemOnLayer( Layer.OuterTorso ) as DeathRobe; if ( @from.FindItemOnLayer( Layer.OuterTorso ) is DeathRobe robe )
if ( robe != null )
{ {
Map map = from.Map; Map map = from.Map;
@ -1118,17 +1103,14 @@ namespace Server.Items
return; return;
#region Quests #region Quests
PlayerMobile player = from as PlayerMobile;
if ( player != null ) if ( @from is PlayerMobile player )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is UzeraanTurmoilQuest ) if ( qs is UzeraanTurmoilQuest )
{ {
GetDaemonBoneObjective obj = qs.FindObjective( typeof( GetDaemonBoneObjective ) ) as GetDaemonBoneObjective; if ( qs.FindObjective( typeof( GetDaemonBoneObjective ) ) is GetDaemonBoneObjective obj && obj.CorpseWithBone == this && ( !obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone( player ) ) )
if ( obj != null && obj.CorpseWithBone == this && ( !obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone( player ) ) )
{ {
Item bone = new QuestDaemonBone(); Item bone = new QuestDaemonBone();
@ -1151,9 +1133,7 @@ namespace Server.Items
} }
else if ( qs is TheSummoningQuest ) else if ( qs is TheSummoningQuest )
{ {
VanquishDaemonObjective obj = qs.FindObjective( typeof( VanquishDaemonObjective ) ) as VanquishDaemonObjective; if ( qs.FindObjective( typeof( VanquishDaemonObjective ) ) is VanquishDaemonObjective obj && obj.Completed && obj.CorpseWithSkull == this )
if ( obj != null && obj.Completed && obj.CorpseWithSkull == this )
{ {
GoldenSkull sk = new GoldenSkull(); GoldenSkull sk = new GoldenSkull();
@ -1276,9 +1256,9 @@ namespace Server.Items
if ( IsCriminalAction( from ) ) if ( IsCriminalAction( from ) )
from.CriminalAction( true ); from.CriminalAction( true );
} }
else if ( dead is BaseCreature ) else if ( dead is BaseCreature creature )
{ {
((BaseCreature)dead).OnCarve( from, this, item ); creature.OnCarve( from, this, item );
} }
else else
{ {

View file

@ -183,13 +183,13 @@ namespace Server.Items
writer.Write( m_TriggerDelay ); writer.Write( m_TriggerDelay );
writer.Write( m_SoundDelay ); writer.Write( m_SoundDelay );
if ( m_Source is Item ) if ( m_Source is Item srcItem )
writer.Write( m_Source as Item ); writer.Write( srcItem );
else else
writer.Write( m_Source as Mobile ); writer.Write( m_Source as Mobile );
if ( m_Target is Item ) if ( m_Target is Item targItem )
writer.Write( m_Target as Item ); writer.Write( targItem );
else else
writer.Write( m_Target as Mobile ); writer.Write( m_Target as Mobile );
@ -269,12 +269,12 @@ namespace Server.Items
IEntity ent = null; IEntity ent = null;
if (m_PlaySoundAtTrigger) if (m_PlaySoundAtTrigger)
ent = trigger as IEntity; ent = trigger;
if (ent == null) if (ent == null)
ent = this; ent = this;
Effects.PlaySound((ent is Item) ? ((Item)ent).GetWorldLocation() : ent.Location, ent.Map, m_SoundID); Effects.PlaySound((ent as Item)?.GetWorldLocation() ?? ent.Location, ent.Map, m_SoundID);
} }
public void DoEffect(IEntity trigger) public void DoEffect(IEntity trigger)
@ -282,7 +282,7 @@ namespace Server.Items
if (Deleted || m_TriggerType == EffectTriggerType.None) if (Deleted || m_TriggerType == EffectTriggerType.None)
return; return;
if (trigger is Mobile && ((Mobile)trigger).Hidden && ((Mobile)trigger).AccessLevel > AccessLevel.Player) if (trigger is Mobile mobile && mobile.Hidden && mobile.AccessLevel > AccessLevel.Player)
return; return;
if (m_SoundID > 0) if (m_SoundID > 0)

View file

@ -100,23 +100,20 @@ namespace Server.Items
HeldBy.PublicOverheadMessage( MessageType.Regular, 957, false, m_Ticks.ToString() ); HeldBy.PublicOverheadMessage( MessageType.Regular, 957, false, m_Ticks.ToString() );
else if ( RootParent == null ) else if ( RootParent == null )
PublicOverheadMessage( MessageType.Regular, 957, false, m_Ticks.ToString() ); PublicOverheadMessage( MessageType.Regular, 957, false, m_Ticks.ToString() );
else if ( RootParent is Mobile ) else if ( RootParent is Mobile mobile )
((Mobile)RootParent).PublicOverheadMessage( MessageType.Regular, 957, false, m_Ticks.ToString() ); mobile.PublicOverheadMessage( MessageType.Regular, 957, false, m_Ticks.ToString() );
break; break;
} }
default: default:
{ {
if ( HeldBy != null ) HeldBy?.DropHolding();
HeldBy.DropHolding();
if ( m_Users != null ) if ( m_Users != null )
{ {
foreach ( Mobile m in m_Users ) foreach ( Mobile m in m_Users )
{ {
ThrowTarget targ = m.Target as ThrowTarget; if ( m.Target is ThrowTarget targ && targ.Bomb == this )
if ( targ != null && targ.Bomb == this )
Target.Cancel( m ); Target.Cancel( m );
} }
@ -124,9 +121,8 @@ namespace Server.Items
m_Users = null; m_Users = null;
} }
if ( RootParent is Mobile ) if ( RootParent is Mobile parent )
{ {
Mobile parent = (Mobile)RootParent;
parent.SendLocalizedMessage( 1060583 ); // The firebomb explodes in your hand! parent.SendLocalizedMessage( 1060583 ); // The firebomb explodes in your hand!
AOS.Damage( parent, Utility.Random( 3 ) + 4, 0, 100, 0, 0, 0 ); AOS.Damage( parent, Utility.Random( 3 ) + 4, 0, 100, 0, 0, 0 );
} }
@ -140,15 +136,13 @@ namespace Server.Items
eable.Free(); eable.Free();
Mobile victim;
for ( int i = 0; i < toDamage.Count; ++i ) for ( int i = 0; i < toDamage.Count; ++i )
{ {
victim = toDamage[i]; Mobile victim = toDamage[i];
if ( m_LitBy == null || (SpellHelper.ValidIndirectTarget( m_LitBy, victim ) && m_LitBy.CanBeHarmful( victim, false )) ) if ( m_LitBy == null || (SpellHelper.ValidIndirectTarget( m_LitBy, victim ) && m_LitBy.CanBeHarmful( victim, false )) )
{ {
if ( m_LitBy != null ) m_LitBy?.DoHarmful( victim );
m_LitBy.DoHarmful( victim );
AOS.Damage( victim, m_LitBy, Utility.Random( 3 ) + 4, 0, 100, 0, 0, 0 ); AOS.Damage( victim, m_LitBy, Utility.Random( 3 ) + 4, 0, 100, 0, 0, 0 );
} }
@ -168,21 +162,14 @@ namespace Server.Items
if ( Deleted || Map == Map.Internal || !IsChildOf( from.Backpack ) ) if ( Deleted || Map == Map.Internal || !IsChildOf( from.Backpack ) )
return; return;
IPoint3D p = obj as IPoint3D; if ( !(obj is IPoint3D p) )
if ( p == null )
return; return;
SpellHelper.GetSurfaceTop( ref p ); SpellHelper.GetSurfaceTop( ref p );
from.RevealingAction(); from.RevealingAction();
IEntity to; IEntity to = p as IEntity ?? new Entity( Serial.Zero, new Point3D( p ), Map );
if ( p is Mobile )
to = (Mobile)p;
else
to = new Entity( Serial.Zero, new Point3D( p ), Map );
Effects.SendMovingEffect( from, to, ItemID, 7, 0, false, false, Hue, 0 ); Effects.SendMovingEffect( from, to, ItemID, 7, 0, false, false, Hue, 0 );
@ -257,8 +244,7 @@ namespace Server.Items
{ {
if ( ItemID == 0x398C && m_LitBy == null || (SpellHelper.ValidIndirectTarget( m_LitBy, m ) && m_LitBy.CanBeHarmful( m, false )) ) if ( ItemID == 0x398C && m_LitBy == null || (SpellHelper.ValidIndirectTarget( m_LitBy, m ) && m_LitBy.CanBeHarmful( m, false )) )
{ {
if ( m_LitBy != null ) m_LitBy?.DoHarmful( m );
m_LitBy.DoHarmful( m );
AOS.Damage( m, m_LitBy, 2, 0, 100, 0, 0, 0 ); AOS.Damage( m, m_LitBy, 2, 0, 100, 0, 0, 0 );
m.PlaySound( 0x208 ); m.PlaySound( 0x208 );
@ -284,15 +270,13 @@ namespace Server.Items
return; return;
} }
Mobile victim;
for ( int i = 0; i < m_Burning.Count; ) for ( int i = 0; i < m_Burning.Count; )
{ {
victim = m_Burning[i]; Mobile victim = m_Burning[i];
if ( victim.Location == Location && victim.Map == Map && (m_LitBy == null || ( SpellHelper.ValidIndirectTarget( m_LitBy, victim ) && m_LitBy.CanBeHarmful( victim, false ) )) ) if ( victim.Location == Location && victim.Map == Map && (m_LitBy == null || ( SpellHelper.ValidIndirectTarget( m_LitBy, victim ) && m_LitBy.CanBeHarmful( victim, false ) )) )
{ {
if ( m_LitBy != null ) m_LitBy?.DoHarmful( victim );
m_LitBy.DoHarmful( victim );
AOS.Damage( victim, m_LitBy, Utility.Random( 3 ) + 4, 0, 100, 0, 0, 0 ); AOS.Damage( victim, m_LitBy, Utility.Random( 3 ) + 4, 0, 100, 0, 0, 0 );
++i; ++i;

View file

@ -60,10 +60,10 @@ namespace Server.Items
addon.Map = Map.Internal; addon.Map = Map.Internal;
if ( addon is BaseAddon ) if ( addon is BaseAddon baseAddon )
result = ( (BaseAddon) addon ).CouldFit( addon.Location, from.Map, from, ref house ); result = baseAddon.CouldFit( baseAddon.Location, from.Map, from, ref house );
else if ( addon is BaseAddonContainer ) else if ( addon is BaseAddonContainer container )
result = ( (BaseAddonContainer) addon ).CouldFit( addon.Location, from.Map, from, ref house ); result = container.CouldFit( container.Location, from.Map, from, ref house );
addon.Map = from.Map; addon.Map = from.Map;
@ -101,10 +101,8 @@ namespace Server.Items
private void ClearComponents( Item item ) private void ClearComponents( Item item )
{ {
if ( item is BaseAddon ) if ( item is BaseAddon addon )
{ {
BaseAddon addon = (BaseAddon) item;
foreach ( AddonComponent c in addon.Components ) foreach ( AddonComponent c in addon.Components )
{ {
c.Addon = null; c.Addon = null;
@ -113,17 +111,15 @@ namespace Server.Items
addon.Components.Clear(); addon.Components.Clear();
} }
else if ( item is BaseAddonContainer ) else if ( item is BaseAddonContainer addonContainer )
{ {
BaseAddonContainer addon = (BaseAddonContainer) item; foreach ( AddonContainerComponent c in addonContainer.Components )
foreach ( AddonContainerComponent c in addon.Components )
{ {
c.Addon = null; c.Addon = null;
c.Delete(); c.Delete();
} }
addon.Components.Clear(); addonContainer.Components.Clear();
} }
} }
} }

View file

@ -29,14 +29,12 @@ namespace Server.Items
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
if ( targeted is Item ) if ( targeted is Item item )
{ {
Item item = (Item)targeted;
if ( item.Movable == false && from.AccessLevel == AccessLevel.Player ) if ( item.Movable == false && from.AccessLevel == AccessLevel.Player )
return; return;
Type type = targeted.GetType(); Type type = item.GetType();
FlippableAttribute[] AttributeArray = (FlippableAttribute[])type.GetCustomAttributes( typeof( FlippableAttribute ), false ); FlippableAttribute[] AttributeArray = (FlippableAttribute[])type.GetCustomAttributes( typeof( FlippableAttribute ), false );
@ -47,7 +45,7 @@ namespace Server.Items
FlippableAttribute fa = AttributeArray[0]; FlippableAttribute fa = AttributeArray[0];
fa.Flip( (Item)targeted ); fa.Flip( item );
} }
} }
} }

View file

@ -74,10 +74,8 @@ namespace Server.Items
parent = root ?? parent; parent = root ?? parent;
if (parent is SecureTradeContainer && AccountGold.ConvertOnTrade) if (parent is SecureTradeContainer trade && AccountGold.ConvertOnTrade)
{ {
var trade = (SecureTradeContainer)parent;
if (trade.Trade.From.Container == trade) if (trade.Trade.From.Container == trade)
{ {
tradeInfo = trade.Trade.From; tradeInfo = trade.Trade.From;
@ -89,12 +87,12 @@ namespace Server.Items
owner = tradeInfo.Mobile; owner = tradeInfo.Mobile;
} }
} }
else if (parent is BankBox && AccountGold.ConvertOnBank) else if (parent is BankBox box && AccountGold.ConvertOnBank)
{ {
owner = ((BankBox)parent).Owner; owner = box.Owner;
} }
if (owner == null || owner.Account == null || !owner.Account.DepositGold(Amount)) if (owner?.Account == null || !owner.Account.DepositGold(Amount))
{ {
return; return;
} }
@ -103,17 +101,13 @@ namespace Server.Items
{ {
if (owner.NetState != null && !owner.NetState.NewSecureTrading) if (owner.NetState != null && !owner.NetState.NewSecureTrading)
{ {
int gold; int plat = Math.DivRem(Amount, AccountGold.CurrencyThreshold, out var gold);
int plat = Math.DivRem(Amount, AccountGold.CurrencyThreshold, out gold);
tradeInfo.Plat += plat; tradeInfo.Plat += plat;
tradeInfo.Gold += gold; tradeInfo.Gold += gold;
} }
if (tradeInfo.VirtualCheck != null) tradeInfo.VirtualCheck?.UpdateTrade(tradeInfo.Mobile);
{
tradeInfo.VirtualCheck.UpdateTrade(tradeInfo.Mobile);
}
} }
owner.SendLocalizedMessage(1042763, Amount.ToString("#,0")); owner.SendLocalizedMessage(1042763, Amount.ToString("#,0"));

View file

@ -150,10 +150,9 @@ namespace Server.Items
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
if ( targeted is Item && InteriorDecorator.CheckUse( m_Decorator, from ) ) if ( targeted is Item item && InteriorDecorator.CheckUse( m_Decorator, from ) )
{ {
BaseHouse house = BaseHouse.FindHouseAt( from ); BaseHouse house = BaseHouse.FindHouseAt( from );
Item item = (Item)targeted;
bool isDecorableComponent = false; bool isDecorableComponent = false;
@ -162,23 +161,20 @@ namespace Server.Items
object addon = null; object addon = null;
int count = 0; int count = 0;
if ( item is AddonComponent ) switch (item)
{ {
AddonComponent component = (AddonComponent) item; case AddonComponent component:
count = component.Addon.Components.Count; count = component.Addon.Components.Count;
addon = component.Addon; addon = component.Addon;
} break;
else if ( item is AddonContainerComponent ) case AddonContainerComponent containerComponent:
{ count = containerComponent.Addon.Components.Count;
AddonContainerComponent component = (AddonContainerComponent) item; addon = containerComponent.Addon;
count = component.Addon.Components.Count; break;
addon = component.Addon; case BaseAddonContainer container:
} count = container.Components.Count;
else if ( item is BaseAddonContainer ) addon = container;
{ break;
BaseAddonContainer container = (BaseAddonContainer) item;
count = container.Components.Count;
addon = container;
} }
if ( count == 1 && Core.SE ) if ( count == 1 && Core.SE )
@ -244,12 +240,18 @@ namespace Server.Items
{ {
object addon = null; object addon = null;
if ( item is AddonComponent ) switch (item)
addon = ((AddonComponent) item).Addon; {
else if ( item is AddonContainerComponent ) case AddonComponent component:
addon = ((AddonContainerComponent) item).Addon; addon = component.Addon;
else if ( item is BaseAddonContainer ) break;
addon = (BaseAddonContainer) item; case AddonContainerComponent containerComponent:
addon = containerComponent.Addon;
break;
case BaseAddonContainer container:
addon = container;
break;
}
FlippableAddonAttribute[] aAttributes = (FlippableAddonAttribute[]) addon.GetType().GetCustomAttributes( typeof( FlippableAddonAttribute ), false ); FlippableAddonAttribute[] aAttributes = (FlippableAddonAttribute[]) addon.GetType().GetCustomAttributes( typeof( FlippableAddonAttribute ), false );

View file

@ -50,10 +50,8 @@ namespace Server.Items
foreach ( Item item in items ) foreach ( Item item in items )
{ {
if ( item is Key ) if ( item is Key key )
{ {
Key key = (Key) item;
if ( key.KeyValue == keyValue ) if ( key.KeyValue == keyValue )
key.Delete(); key.Delete();
} }
@ -75,10 +73,8 @@ namespace Server.Items
foreach ( Item item in items ) foreach ( Item item in items )
{ {
if ( item is Key ) if ( item is Key key )
{ {
Key key = (Key) item;
if ( key.KeyValue == keyValue ) if ( key.KeyValue == keyValue )
return true; return true;
} }
@ -293,52 +289,37 @@ namespace Server.Items
{ {
if ( o.KeyValue == this.KeyValue ) if ( o.KeyValue == this.KeyValue )
{ {
if ( o is BaseDoor && !((BaseDoor)o).UseLocks() ) if ( o is BaseDoor door && !door.UseLocks() )
{
return false; return false;
}
else o.Locked = !o.Locked;
if ( o is LockableContainer cont1 )
{ {
o.Locked = !o.Locked; if ( cont1.LockLevel == -255 )
cont1.LockLevel = cont1.RequiredSkill - 10;
if ( o is LockableContainer )
{
LockableContainer cont = (LockableContainer)o;
if ( cont.LockLevel == -255 )
cont.LockLevel = cont.RequiredSkill - 10;
}
if ( o is Item )
{
Item item = (Item) o;
if ( o.Locked )
item.SendLocalizedMessageTo( from, 1048000 ); // You lock it.
else
item.SendLocalizedMessageTo( from, 1048001 ); // You unlock it.
if ( item is LockableContainer )
{
LockableContainer cont = (LockableContainer) item;
if ( cont.TrapType != TrapType.None && cont.TrapOnLockpick )
{
if ( o.Locked )
item.SendLocalizedMessageTo( from, 501673 ); // You re-enable the trap.
else
item.SendLocalizedMessageTo( from, 501672 ); // You disable the trap temporarily. Lock it again to re-enable it.
}
}
}
return true;
} }
if ( o is Item item )
{
if ( o.Locked )
item.SendLocalizedMessageTo( from, 1048000 ); // You lock it.
else
item.SendLocalizedMessageTo( from, 1048001 ); // You unlock it.
if ( item is LockableContainer cont && cont.TrapType != TrapType.None && cont.TrapOnLockpick )
{
if ( o.Locked )
cont.SendLocalizedMessageTo( from, 501673 ); // You re-enable the trap.
else
cont.SendLocalizedMessageTo( from, 501672 ); // You disable the trap temporarily. Lock it again to re-enable it.
}
}
return true;
} }
else
{ return false;
return false;
}
} }
private class RenamePrompt : Prompt private class RenamePrompt : Prompt
@ -388,9 +369,9 @@ namespace Server.Items
from.Prompt = new RenamePrompt( m_Key ); from.Prompt = new RenamePrompt( m_Key );
} }
else if ( targeted is ILockable ) else if ( targeted is ILockable lockable )
{ {
if ( m_Key.UseOn( from, (ILockable) targeted ) ) if ( m_Key.UseOn( from, lockable ) )
number = -1; number = -1;
else else
number = 501668; // This key doesn't seem to unlock that. number = 501668; // This key doesn't seem to unlock that.
@ -426,10 +407,8 @@ namespace Server.Items
int number; int number;
if ( targeted is Key ) if ( targeted is Key k )
{ {
Key k = (Key)targeted;
if ( k.m_KeyVal == 0 ) if ( k.m_KeyVal == 0 )
{ {
number = 501675; // This key is also blank. number = 501675; // This key is also blank.
@ -465,4 +444,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -30,24 +30,20 @@ namespace Server.Items
return false; return false;
} }
Key key = dropped as Key; if ( !(dropped is Key key) || key.KeyValue == 0 )
if ( key == null || key.KeyValue == 0 )
{ {
from.SendLocalizedMessage( 501689 ); // Only non-blank keys can be put on a keyring. from.SendLocalizedMessage( 501689 ); // Only non-blank keys can be put on a keyring.
return false; return false;
} }
else if ( this.Keys.Count >= MaxKeys ) if ( this.Keys.Count >= MaxKeys )
{ {
from.SendLocalizedMessage( 1008138 ); // This keyring is full. from.SendLocalizedMessage( 1008138 ); // This keyring is full.
return false; return false;
} }
else
{ Add( key );
Add( key ); from.SendLocalizedMessage( 501691 ); // You put the key on the keyring.
from.SendLocalizedMessage( 501691 ); // You put the key on the keyring. return true;
return true;
}
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
@ -84,10 +80,8 @@ namespace Server.Items
m_KeyRing.Open( from ); m_KeyRing.Open( from );
from.SendLocalizedMessage( 501685 ); // You open the keyring. from.SendLocalizedMessage( 501685 ); // You open the keyring.
} }
else if ( targeted is ILockable ) else if ( targeted is ILockable o )
{ {
ILockable o = (ILockable) targeted;
foreach ( Key key in m_KeyRing.Keys ) foreach ( Key key in m_KeyRing.Keys )
{ {
if ( key.UseOn( from, o ) ) if ( key.UseOn( from, o ) )
@ -125,9 +119,7 @@ namespace Server.Items
public void Open( Mobile from ) public void Open( Mobile from )
{ {
Container cont = this.Parent as Container; if ( !(this.Parent is Container cont) )
if ( cont == null )
return; return;
for ( int i = m_Keys.Count - 1; i >= 0; i-- ) for ( int i = m_Keys.Count - 1; i >= 0; i-- )

View file

@ -75,9 +75,9 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 1005401 ); // You cannot bury the stone here. from.SendLocalizedMessage( 1005401 ); // You cannot bury the stone here.
} }
else if ( from is PlayerMobile && ((PlayerMobile)from).Young ) else if ( @from is PlayerMobile mobile && mobile.Young )
{ {
from.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young. mobile.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young.
} }
else if ( from.Kills >= 5 ) else if ( from.Kills >= 5 )
{ {

View file

@ -61,14 +61,12 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
} }
else if ( obj is Item && ((Item)obj).RootParent != from ) else if ( obj is Item item && item.RootParent != from )
{ {
from.SendLocalizedMessage( 1005425 ); // You may only wipe down items you are holding or carrying. from.SendLocalizedMessage( 1005425 ); // You may only wipe down items you are holding or carrying.
} }
else if ( obj is BaseWeapon ) else if ( obj is BaseWeapon weapon )
{ {
BaseWeapon weapon = (BaseWeapon)obj;
if ( weapon.Poison == null || weapon.PoisonCharges <= 0 ) if ( weapon.Poison == null || weapon.PoisonCharges <= 0 )
{ {
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1005422 ); // Hmmmm... this does not need to be cleaned. from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1005422 ); // Hmmmm... this does not need to be cleaned.
@ -86,10 +84,8 @@ namespace Server.Items
from.SendLocalizedMessage( 1010497 ); // You have cleaned the item. from.SendLocalizedMessage( 1010497 ); // You have cleaned the item.
} }
} }
else if ( obj == from && obj is PlayerMobile ) else if ( obj == from && obj is PlayerMobile pm )
{ {
PlayerMobile pm = (PlayerMobile)obj;
if ( pm.BodyMod == 183 || pm.BodyMod == 184 ) if ( pm.BodyMod == 183 || pm.BodyMod == 184 )
{ {
pm.SavagePaintExpiration = TimeSpan.Zero; pm.SavagePaintExpiration = TimeSpan.Zero;
@ -107,10 +103,8 @@ namespace Server.Items
} }
} }
#region Firebomb #region Firebomb
else if ( obj is BaseBeverage ) else if ( obj is BaseBeverage beverage )
{ {
BaseBeverage beverage = (BaseBeverage) obj;
if ( beverage.Content == BeverageType.Liquor ) if ( beverage.Content == BeverageType.Liquor )
{ {
Firebomb bomb = new Firebomb( beverage.ItemID ); Firebomb bomb = new Firebomb( beverage.ItemID );

View file

@ -505,7 +505,7 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 501356 ); // This person is already banned! from.SendLocalizedMessage( 501356 ); // This person is already banned!
} }
else if ( poster is BaseCreature && ((BaseCreature)poster).NoHouseRestrictions ) else if ( poster is BaseCreature creature && creature.NoHouseRestrictions )
{ {
from.SendLocalizedMessage( 1062040 ); // You cannot ban that. from.SendLocalizedMessage( 1062040 ); // You cannot ban that.
} }

View file

@ -62,9 +62,7 @@ namespace Server.Items
foreach( Mobile m in GetMobilesInRange( 0 ) ) foreach( Mobile m in GetMobilesInRange( 0 ) )
{ {
BaseCreature bc = m as BaseCreature; if ( m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned) )
if ( m.Alive && !m.IsDeadBondedPet && (bc == null || bc.Controlled || bc.Summoned) )
{ {
toDamage.Add( m ); toDamage.Add( m );
} }

View file

@ -48,13 +48,12 @@ namespace Server.Items
{ {
Mobile m = null; Mobile m = null;
if ( parent is Item ) if ( parent is Item item )
m = ((Item)parent).RootParent as Mobile; m = item.RootParent as Mobile;
else if ( parent is Mobile ) else if ( parent is Mobile mobile )
m = (Mobile)parent; m = mobile;
if ( m != null ) m?.CloseGump( typeof( PromotionalTokenGump ) );
m.CloseGump( typeof( PromotionalTokenGump ) );
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
@ -123,10 +122,10 @@ namespace Server.Items
public override Item CreateItemFor( Mobile from ) public override Item CreateItemFor( Mobile from )
{ {
if ( from != null && from.Account != null ) if ( @from?.Account != null )
return new SoulstoneFragment( from.Account.ToString() ); return new SoulstoneFragment( from.Account.ToString() );
else
return null; return null;
} }
public override TextDefinition ItemGumpName => 1070999;// <center>Soulstone Fragment</center> public override TextDefinition ItemGumpName => 1070999;// <center>Soulstone Fragment</center>

View file

@ -323,8 +323,8 @@ namespace Server.Items
} }
else else
{ {
ClientFlags flags = mobile.NetState == null ? ClientFlags.None : mobile.NetState.Flags; ClientFlags flags = mobile.NetState?.Flags ?? ClientFlags.None;
bool young = mobile is PlayerMobile ? ((PlayerMobile)mobile).Young : false; bool young = mobile is PlayerMobile playerMobile && playerMobile.Young;
if ( Core.SE && (flags & ClientFlags.Tokuno) != 0 ) if ( Core.SE && (flags & ClientFlags.Tokuno) != 0 )
checkLists = young ? PMList.SEListsYoung : PMList.SELists; checkLists = young ? PMList.SEListsYoung : PMList.SELists;

View file

@ -53,9 +53,8 @@ namespace Server.Items
{ {
message = "It cannot weight itself."; message = "It cannot weight itself.";
} }
else if ( targeted is Item ) else if ( targeted is Item item )
{ {
Item item = (Item)targeted;
object root = item.RootParent; object root = item.RootParent;
if ( (root != null && root != from) || item.Parent == from ) if ( (root != null && root != from) || item.Parent == from )
@ -90,4 +89,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -994,7 +994,7 @@ namespace Server.Items
return false; return false;
} }
if (GetFlag(ConditionFlag.DenyFollowers) && (m.Followers != 0 || (m is PlayerMobile && ((PlayerMobile)m).AutoStabled.Count != 0))) if (GetFlag(ConditionFlag.DenyFollowers) && (m.Followers != 0 || (m is PlayerMobile mobile && mobile.AutoStabled.Count != 0)))
{ {
m.SendLocalizedMessage(1077250); // No pets permitted beyond this point. m.SendLocalizedMessage(1077250); // No pets permitted beyond this point.
return false; return false;

View file

@ -54,8 +54,8 @@ namespace Server.Items
from.BodyMod = ( from.Female ? 184 : 183 ); from.BodyMod = ( from.Female ? 184 : 183 );
from.HueMod = 0; from.HueMod = 0;
if ( from is PlayerMobile ) if ( @from is PlayerMobile mobile )
((PlayerMobile)from).SavagePaintExpiration = TimeSpan.FromDays( 7.0 ); mobile.SavagePaintExpiration = TimeSpan.FromDays( 7.0 );
from.SendLocalizedMessage( 1042537 ); // You now bear the markings of the savage tribe. Your body paint will last about a week or you can remove it with an oil cloth. from.SendLocalizedMessage( 1042537 ); // You now bear the markings of the savage tribe. Your body paint will last about a week or you can remove it with an oil cloth.

View file

@ -111,8 +111,8 @@ namespace Server.Items
foreach ( Item item in GetItemsInRange( NeighborRange ) ) foreach ( Item item in GetItemsInRange( NeighborRange ) )
{ {
if ( item != this && item is WarningItem ) if ( item != this && item is WarningItem warningItem )
list.Add( (WarningItem)item ); list.Add( warningItem );
} }
for ( int i = 0; i < list.Count; i++ ) for ( int i = 0; i < list.Count; i++ )

View file

@ -115,9 +115,9 @@ namespace Server.Items
protected override void OnTarget( Mobile from, object target ) protected override void OnTarget( Mobile from, object target )
{ {
if ( target is WayPoint && m_Point != null ) if ( target is WayPoint point && m_Point != null )
{ {
m_Point.NextPoint = (WayPoint)target; m_Point.NextPoint = point;
} }
else else
{ {
@ -137,14 +137,14 @@ namespace Server.Items
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
if ( targeted is WayPoint ) if ( targeted is WayPoint wayPoint )
{ {
if ( m_Last != null ) if ( m_Last != null )
m_Last.NextPoint = (WayPoint)targeted; m_Last.NextPoint = wayPoint;
} }
else if ( targeted is IPoint3D ) else if ( targeted is IPoint3D d )
{ {
Point3D p = new Point3D( (IPoint3D)targeted ); Point3D p = new Point3D( d );
WayPoint point = new WayPoint( m_Last ); WayPoint point = new WayPoint( m_Last );
point.MoveToWorld( p, from.Map ); point.MoveToWorld( p, from.Map );

View file

@ -95,9 +95,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
BaseQuiver quiver = newItem as BaseQuiver; if ( !(newItem is BaseQuiver quiver) )
if ( quiver == null )
return; return;
quiver.m_Attributes = new AosAttributes( newItem, m_Attributes ); quiver.m_Attributes = new AosAttributes( newItem, m_Attributes );
@ -194,20 +192,16 @@ namespace Server.Items
public override void OnAdded(IEntity parent) public override void OnAdded(IEntity parent)
{ {
if ( parent is Mobile ) if ( parent is Mobile mob )
{ {
Mobile mob = (Mobile) parent;
m_Attributes.AddStatBonuses( mob ); m_Attributes.AddStatBonuses( mob );
} }
} }
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
if ( parent is Mobile ) if ( parent is Mobile mob )
{ {
Mobile mob = (Mobile) parent;
m_Attributes.RemoveStatBonuses( mob ); m_Attributes.RemoveStatBonuses( mob );
} }
} }
@ -447,10 +441,8 @@ namespace Server.Items
public void InvalidateWeight() public void InvalidateWeight()
{ {
if ( RootParent is Mobile ) if ( RootParent is Mobile m )
{ {
Mobile m = (Mobile) RootParent;
m.UpdateTotals(); m.UpdateTotals();
} }
} }

View file

@ -140,4 +140,4 @@ namespace Server.ContextMenus
{ {
} }
} }
} }

View file

@ -916,6 +916,7 @@ namespace Server.Network
} }
} }
[Flags]
public enum CMEFlags public enum CMEFlags
{ {
None = 0x00, None = 0x00,