More casting fixes

This commit is contained in:
Kamron Batman 2018-09-11 18:59:11 -07:00
parent f211efc3bd
commit 20a80ea2f3
40 changed files with 125 additions and 211 deletions

View file

@ -176,7 +176,7 @@ namespace Server
if ( reflectPhys != 0 ) if ( reflectPhys != 0 )
{ {
if ( @from is ExodusMinion minion && minion.FieldActive || @from is ExodusOverseer overseer && overseer.FieldActive ) if ( from is ExodusMinion minion && minion.FieldActive || from is ExodusOverseer overseer && overseer.FieldActive )
{ {
from.FixedParticles( 0x376A, 20, 10, 0x2530, EffectLayer.Waist ); from.FixedParticles( 0x376A, 20, 10, 0x2530, EffectLayer.Waist );
from.PlaySound( 0x2F4 ); from.PlaySound( 0x2F4 );

View file

@ -651,7 +651,7 @@ namespace Server.Guilds
from.SendGump( new PropertiesGump( from, g ) ); from.SendGump( new PropertiesGump( from, g ) );
if ( NewGuildSystem && from.AccessLevel >= AccessLevel.GameMaster && @from is PlayerMobile pm ) if ( NewGuildSystem && from.AccessLevel >= AccessLevel.GameMaster && from is PlayerMobile pm )
pm.SendGump( new GuildInfoGump( pm, g ) ); pm.SendGump( new GuildInfoGump( pm, g ) );
} }
} }

View file

@ -26,7 +26,7 @@ namespace Server.Misc
{ {
case 0x002A: // *i resign from my guild* case 0x002A: // *i resign from my guild*
{ {
((Guild)@from.Guild)?.RemoveMember( @from ); ((Guild)from.Guild)?.RemoveMember( from );
break; break;
} }
@ -45,7 +45,7 @@ namespace Server.Misc
} }
case 0x0035: // i renounce my young player status* case 0x0035: // i renounce my young player status*
{ {
if ( @from is PlayerMobile mobile && mobile.Young && !mobile.HasGump( typeof( RenounceYoungGump ) ) ) if ( from is PlayerMobile mobile && mobile.Young && !mobile.HasGump( typeof( RenounceYoungGump ) ) )
{ {
mobile.SendGump( new RenounceYoungGump() ); mobile.SendGump( new RenounceYoungGump() );
} }

View file

@ -43,7 +43,7 @@ namespace Server.Misc
{ {
Mobile from = state.Mobile; Mobile from = state.Mobile;
if ( @from.Guild is Guild guild ) if ( from.Guild is Guild guild )
{ {
bool locations = pvSrc.ReadByte() != 0; bool locations = pvSrc.ReadByte() != 0;

View file

@ -51,7 +51,7 @@ namespace Server
public static bool CheckML( Mobile from, bool message = true) public static bool CheckML( Mobile from, bool message = true)
{ {
if ( @from?.NetState == null ) if ( from?.NetState == null )
return false; return false;
if ( from.NetState.SupportsExpansion( Expansion.ML ) ) if ( from.NetState.SupportsExpansion( Expansion.ML ) )

View file

@ -70,7 +70,7 @@ namespace Server.Misc
PlayerMobile pmFrom = from as PlayerMobile; PlayerMobile pmFrom = from as PlayerMobile;
PlayerMobile pmTarg = target as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile;
if ( pmFrom == null && @from is BaseCreature bcFrom ) if ( pmFrom == null && from is BaseCreature bcFrom )
{ {
if ( bcFrom.Summoned ) if ( bcFrom.Summoned )
pmFrom = bcFrom.SummonMaster as PlayerMobile; pmFrom = bcFrom.SummonMaster as PlayerMobile;
@ -103,7 +103,7 @@ namespace Server.Misc
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) ) if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
return false; return false;
if ( @from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ ) if ( from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
return false; return false;
sz = target.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone; sz = target.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone;
@ -137,7 +137,7 @@ namespace Server.Misc
if ( pmFrom?.Young == true || pmTarg?.Young == true ) if ( pmFrom?.Young == true || pmTarg?.Young == true )
return false; // Young players cannot perform beneficial actions towards older players return false; // Young players cannot perform beneficial actions towards older players
if ( @from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) ) if ( from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) )
return true; // Guild members can be beneficial return true; // Guild members can be beneficial
return CheckBeneficialStatus( GetGuildStatus( from ), GetGuildStatus( target ) ); return CheckBeneficialStatus( GetGuildStatus( from ), GetGuildStatus( target ) );
@ -153,7 +153,7 @@ namespace Server.Misc
PlayerMobile pmTarg = target as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile;
BaseCreature bcTarg = target as BaseCreature; BaseCreature bcTarg = target as BaseCreature;
if ( pmFrom == null && @from is BaseCreature bcFrom && bcFrom.Summoned ) if ( pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned )
pmFrom = bcFrom.SummonMaster as PlayerMobile; pmFrom = bcFrom.SummonMaster as PlayerMobile;
if ( pmTarg == null && bcTarg?.Summoned == true ) if ( pmTarg == null && bcTarg?.Summoned == true )
@ -177,7 +177,7 @@ namespace Server.Misc
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) ) if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
return false; return false;
if ( @from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ ) if ( from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
return false; return false;
sz = target.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone; sz = target.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone;
@ -191,7 +191,7 @@ namespace Server.Misc
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 ) if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
return true; // In felucca, anything goes return true; // In felucca, anything goes
if ( !from.Player && !(@from is BaseCreature bc && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player ) ) if ( !from.Player && !(from is BaseCreature bc && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player ) )
{ {
if ( !CheckAggressor( from.Aggressors, target ) && !CheckAggressed( from.Aggressed, target ) && pmTarg?.CheckYoungProtection( from ) == true ) if ( !CheckAggressor( from.Aggressors, target ) && !CheckAggressed( from.Aggressed, target ) && pmTarg?.CheckYoungProtection( from ) == true )
return false; return false;

View file

@ -89,7 +89,7 @@ namespace Server.Misc
int points =(int)(from.Skills[SkillName.Focus].Value * 0.1); int points =(int)(from.Skills[SkillName.Focus].Value * 0.1);
if ( (@from is BaseCreature creature && creature.IsParagon) || from is Leviathan ) if ( (from is BaseCreature creature && creature.IsParagon) || from is Leviathan )
points += 40; points += 40;
int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenStam ); int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenStam );
@ -137,7 +137,7 @@ namespace Server.Misc
double totalPoints = focusPoints + medPoints + (from.Meditating ? (medPoints > 13.0 ? 13.0 : medPoints) : 0.0); double totalPoints = focusPoints + medPoints + (from.Meditating ? (medPoints > 13.0 ? 13.0 : medPoints) : 0.0);
if ( (@from is BaseCreature creature && creature.IsParagon) || from is Leviathan ) if ( (from is BaseCreature creature && creature.IsParagon) || from is Leviathan )
totalPoints += 40; totalPoints += 40;
int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenMana ); int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenMana );

View file

@ -135,7 +135,7 @@ namespace Server.Misc
if ( gc < 0.01 ) if ( gc < 0.01 )
gc = 0.01; gc = 0.01;
if ( @from is BaseCreature creature && creature.Controlled ) if ( from is BaseCreature creature && creature.Controlled )
gc *= 2; gc *= 2;
if ( from.Alive && ( ( gc >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) ) if ( from.Alive && ( ( gc >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) )
@ -183,7 +183,7 @@ namespace Server.Misc
if ( Core.AOS && Faction.InSkillLoss( from ) ) //Changed some time between the introduction of AoS and SE. if ( Core.AOS && Faction.InSkillLoss( from ) ) //Changed some time between the introduction of AoS and SE.
return false; return false;
if ( AntiMacroCode && @from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID] ) if ( AntiMacroCode && from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID] )
return mobile.AntiMacroCheck( skill, obj ); return mobile.AntiMacroCheck( skill, obj );
return true; return true;
@ -196,7 +196,7 @@ namespace Server.Misc
if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) ) if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) )
return; return;
if ( @from is BaseCreature creature && creature.IsDeadPet ) if ( from is BaseCreature creature && creature.IsDeadPet )
return; return;
if ( skill.SkillName == SkillName.Focus && from is BaseCreature ) if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
@ -227,7 +227,7 @@ namespace Server.Misc
#region Scroll of Alacrity #region Scroll of Alacrity
if ( @from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow ) if ( from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow )
toGain *= Utility.RandomMinMax(2, 5); toGain *= Utility.RandomMinMax(2, 5);
#endregion #endregion
@ -264,7 +264,7 @@ namespace Server.Misc
public static bool CanRaise( Mobile from, Stat stat ) public static bool CanRaise( Mobile from, Stat stat )
{ {
if ( !(@from is BaseCreature creature && creature.Controlled) ) if ( !(from is BaseCreature creature && creature.Controlled) )
{ {
if ( from.RawStatTotal >= from.StatCap ) if ( from.RawStatTotal >= from.StatCap )
return false; return false;
@ -343,7 +343,7 @@ namespace Server.Misc
{ {
case Stat.Str: case Stat.Str:
{ {
if ( @from is BaseCreature creature && creature.Controlled ) { if ( from is BaseCreature creature && creature.Controlled ) {
if ( (creature.LastStrGain + m_PetStatGainDelay) >= DateTime.UtcNow ) if ( (creature.LastStrGain + m_PetStatGainDelay) >= DateTime.UtcNow )
return; return;
} }
@ -355,7 +355,7 @@ namespace Server.Misc
} }
case Stat.Dex: case Stat.Dex:
{ {
if ( @from is BaseCreature creature && creature.Controlled ) { if ( from is BaseCreature creature && creature.Controlled ) {
if ( (creature.LastDexGain + m_PetStatGainDelay) >= DateTime.UtcNow ) if ( (creature.LastDexGain + m_PetStatGainDelay) >= DateTime.UtcNow )
return; return;
} }
@ -367,7 +367,7 @@ namespace Server.Misc
} }
case Stat.Int: case Stat.Int:
{ {
if ( @from is BaseCreature creature && creature.Controlled ) { if ( from is BaseCreature creature && creature.Controlled ) {
if ( (creature.LastIntGain + m_PetStatGainDelay) >= DateTime.UtcNow ) if ( (creature.LastIntGain + m_PetStatGainDelay) >= DateTime.UtcNow )
return; return;
} }

View file

@ -96,7 +96,7 @@ namespace Server.Misc
return; return;
} }
if ( @from is PlayerMobile pm ) if ( from is PlayerMobile pm )
{ {
int amt = ( pm.Mounted ? 48 : 16 ); int amt = ( pm.Mounted ? 48 : 16 );

View file

@ -225,7 +225,7 @@ namespace Server.Mobiles
from.Target = new AIControlMobileTarget(this, order); from.Target = new AIControlMobileTarget(this, order);
} }
else if (@from.Target is AIControlMobileTarget t) else if (from.Target is AIControlMobileTarget t)
{ {
if (t.Order == order) if (t.Order == order)
t.AddAI(this); t.AddAI(this);
@ -1321,7 +1321,7 @@ namespace Server.Mobiles
} }
else else
{ {
bool youngFrom = @from is PlayerMobile mobile && mobile.Young; bool youngFrom = from is PlayerMobile mobile && mobile.Young;
bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young; bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young;
if (youngFrom && !youngTo) if (youngFrom && !youngTo)
@ -1675,7 +1675,7 @@ namespace Server.Mobiles
if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14)) if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14))
return false; return false;
bool youngFrom = @from is PlayerMobile mobile && mobile.Young; bool youngFrom = from is PlayerMobile mobile && mobile.Young;
bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young; bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young;
if (accepted && youngFrom && !youngTo) if (accepted && youngFrom && !youngTo)
@ -1769,7 +1769,7 @@ namespace Server.Mobiles
{ {
m_Mobile.DebugSay("Begin transfer with {0}", to.Name); m_Mobile.DebugSay("Begin transfer with {0}", to.Name);
bool youngFrom = @from is PlayerMobile mobile && mobile.Young; bool youngFrom = from is PlayerMobile mobile && mobile.Young;
bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young; bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young;
if (youngFrom && !youngTo) if (youngFrom && !youngTo)

View file

@ -1471,7 +1471,7 @@ namespace Server.Mobiles
if ( speechType != null && !willKill ) if ( speechType != null && !willKill )
speechType.OnDamage( this, amount ); speechType.OnDamage( this, amount );
m_ReceivedHonorContext?.OnTargetDamaged( @from, amount ); m_ReceivedHonorContext?.OnTargetDamaged( from, amount );
if ( !willKill ) if ( !willKill )
{ {
@ -1480,7 +1480,7 @@ namespace Server.Mobiles
CheckDistracted( from ); CheckDistracted( from );
} }
} }
else if ( @from is PlayerMobile mobile ) else if ( from is PlayerMobile mobile )
{ {
Timer.DelayCall( TimeSpan.FromSeconds( 10 ), new TimerCallback( mobile.RecoverAmmo ) ); Timer.DelayCall( TimeSpan.FromSeconds( 10 ), new TimerCallback( mobile.RecoverAmmo ) );
} }
@ -2367,7 +2367,7 @@ namespace Server.Mobiles
// Note: Yes, this happens for all questers (regardless of type, e.g. escorts), // Note: Yes, this happens for all questers (regardless of type, e.g. escorts),
// even if they can't offer you anything at the moment // even if they can't offer you anything at the moment
if ( MLQuestSystem.Enabled && CanGiveMLQuest && @from is PlayerMobile mobile ) if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile )
{ {
MLQuestSystem.Tell( this, mobile, 1074893 ); // You need to mark your quest items so I don't take the wrong object. Then speak to me. MLQuestSystem.Tell( this, mobile, 1074893 ); // You need to mark your quest items so I don't take the wrong object. Then speak to me.
return false; return false;
@ -4370,7 +4370,7 @@ namespace Server.Mobiles
{ {
Container pack = this.Backpack; Container pack = this.Backpack;
pack?.DisplayTo( @from ); pack?.DisplayTo( from );
} }
if ( this.DeathAdderCharmable && from.CanBeHarmful( this, false ) ) if ( this.DeathAdderCharmable && from.CanBeHarmful( this, false ) )
@ -4382,7 +4382,7 @@ namespace Server.Mobiles
} }
} }
if ( MLQuestSystem.Enabled && CanGiveMLQuest && @from is PlayerMobile mobile ) if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile )
MLQuestSystem.OnDoubleClick( this, mobile ); MLQuestSystem.OnDoubleClick( this, mobile );
base.OnDoubleClick( from ); base.OnDoubleClick( from );
@ -4402,7 +4402,7 @@ namespace Server.Mobiles
if ( !m_Charmed.DeathAdderCharmable || m_Charmed.Combatant != null || !from.CanBeHarmful( m_Charmed, false ) ) if ( !m_Charmed.DeathAdderCharmable || m_Charmed.Combatant != null || !from.CanBeHarmful( m_Charmed, false ) )
return; return;
if ( !(SummonFamiliarSpell.Table[@from] is DeathAdder da) || da.Deleted ) if ( !(SummonFamiliarSpell.Table[from] is DeathAdder da) || da.Deleted )
return; return;
if ( !(targeted is Mobile targ) || !from.CanBeHarmful( targ, false ) ) if ( !(targeted is Mobile targ) || !from.CanBeHarmful( targ, false ) )

View file

@ -274,8 +274,8 @@ namespace Server.Mobiles
TeleportTo( target ); TeleportTo( target );
target.BoltEffect( 0 ); target.BoltEffect( 0 );
if ( target is BaseCreature ) if ( target is BaseCreature creature )
((BaseCreature)target).NoKillAwards = true; creature.NoKillAwards = true;
target.Damage( target.HitsMax, m_Owner ); target.Damage( target.HitsMax, m_Owner );
target.Kill(); // just in case, maybe Damage is overridden on some shard target.Kill(); // just in case, maybe Damage is overridden on some shard

View file

@ -20,10 +20,8 @@ namespace Server.Mobiles
foreach ( Mobile m in target.GetMobilesInRange( 15 ) ) foreach ( Mobile m in target.GetMobilesInRange( 15 ) )
{ {
if ( m is BaseGuard ) if ( m is BaseGuard g )
{ {
BaseGuard g = (BaseGuard)m;
if ( g.Focus == null ) // idling if ( g.Focus == null ) // idling
{ {
g.Focus = target; g.Focus = target;

View file

@ -289,8 +289,8 @@ namespace Server.Mobiles
TeleportTo( target ); TeleportTo( target );
target.BoltEffect( 0 ); target.BoltEffect( 0 );
if ( target is BaseCreature ) if ( target is BaseCreature creature )
((BaseCreature)target).NoKillAwards = true; creature.NoKillAwards = true;
target.Damage( target.HitsMax, m_Owner ); target.Damage( target.HitsMax, m_Owner );
target.Kill(); // just in case, maybe Damage is overridden on some shard target.Kill(); // just in case, maybe Damage is overridden on some shard

View file

@ -132,9 +132,9 @@ namespace Server.Mobiles
OfferResurrection( m ); OfferResurrection( m );
} }
} }
else if ( this.HealsYoungPlayers && m.Hits < m.HitsMax && m is PlayerMobile && ((PlayerMobile)m).Young ) else if ( this.HealsYoungPlayers && m.Hits < m.HitsMax && m is PlayerMobile mobile && mobile.Young )
{ {
OfferHeal( (PlayerMobile) m ); OfferHeal( mobile );
} }
} }
} }

View file

@ -22,53 +22,41 @@ namespace Server.Mobiles
public static bool CheckRedFriendship( Mobile m ) public static bool CheckRedFriendship( Mobile m )
{ {
if ( m is BaseCreature ) if ( m is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)m;
if ( bc.Controlled && bc.ControlMaster is PlayerMobile ) if ( bc.Controlled && bc.ControlMaster is PlayerMobile )
return CheckRedFriendship( bc.ControlMaster ); return CheckRedFriendship( bc.ControlMaster );
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile ) if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
return CheckRedFriendship( bc.SummonMaster ); return CheckRedFriendship( bc.SummonMaster );
} }
PlayerMobile player = m as PlayerMobile; return m is PlayerMobile player && player.SolenFriendship == SolenFriendship.Red;
return player != null && player.SolenFriendship == SolenFriendship.Red;
} }
public static bool CheckBlackFriendship( Mobile m ) public static bool CheckBlackFriendship( Mobile m )
{ {
if ( m is BaseCreature ) if ( m is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)m;
if ( bc.Controlled && bc.ControlMaster is PlayerMobile ) if ( bc.Controlled && bc.ControlMaster is PlayerMobile )
return CheckBlackFriendship( bc.ControlMaster ); return CheckBlackFriendship( bc.ControlMaster );
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile ) if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
return CheckBlackFriendship( bc.SummonMaster ); return CheckBlackFriendship( bc.SummonMaster );
} }
PlayerMobile player = m as PlayerMobile; return m is PlayerMobile player && player.SolenFriendship == SolenFriendship.Black;
return player != null && player.SolenFriendship == SolenFriendship.Black;
} }
public static void OnRedDamage( Mobile from ) public static void OnRedDamage( Mobile from )
{ {
if ( from is BaseCreature ) if ( from is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)from;
if ( bc.Controlled && bc.ControlMaster is PlayerMobile ) if ( bc.Controlled && bc.ControlMaster is PlayerMobile )
OnRedDamage( bc.ControlMaster ); OnRedDamage( bc.ControlMaster );
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile ) else if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
OnRedDamage( bc.SummonMaster ); OnRedDamage( bc.SummonMaster );
} }
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player && player.SolenFriendship == SolenFriendship.Red )
if ( player != null && player.SolenFriendship == SolenFriendship.Red )
{ {
player.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1054103 ); // The solen revoke their friendship. You will now be considered an intruder. player.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1054103 ); // The solen revoke their friendship. You will now be considered an intruder.
@ -78,19 +66,15 @@ namespace Server.Mobiles
public static void OnBlackDamage( Mobile from ) public static void OnBlackDamage( Mobile from )
{ {
if ( from is BaseCreature ) if ( from is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)from;
if ( bc.Controlled && bc.ControlMaster is PlayerMobile ) if ( bc.Controlled && bc.ControlMaster is PlayerMobile )
OnBlackDamage( bc.ControlMaster ); OnBlackDamage( bc.ControlMaster );
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile ) else if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
OnBlackDamage( bc.SummonMaster ); OnBlackDamage( bc.SummonMaster );
} }
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player && player.SolenFriendship == SolenFriendship.Black )
if ( player != null && player.SolenFriendship == SolenFriendship.Black )
{ {
player.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1054103 ); // The solen revoke their friendship. You will now be considered an intruder. player.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1054103 ); // The solen revoke their friendship. You will now be considered an intruder.

View file

@ -114,8 +114,7 @@ namespace Server.Mobiles
this.PlaySound( 0xEE ); this.PlaySound( 0xEE );
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" ); defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
BaseWeapon weapon = this.Weapon as BaseWeapon; if ( this.Weapon is BaseWeapon weapon )
if ( weapon != null )
weapon.OnHit( this, defender ); weapon.OnHit( this, defender );
if ( defender.Alive ) if ( defender.Alive )
@ -128,9 +127,7 @@ namespace Server.Mobiles
private void Recover_Callback( object state ) private void Recover_Callback( object state )
{ {
Mobile defender = state as Mobile; if ( state is Mobile defender )
if ( defender != null )
{ {
defender.Frozen = false; defender.Frozen = false;
defender.Combatant = null; defender.Combatant = null;

View file

@ -60,9 +60,8 @@ namespace Server.Mobiles
public void AddArcane( Item item ) public void AddArcane( Item item )
{ {
if ( item is IArcaneEquip ) if ( item is IArcaneEquip eq )
{ {
IArcaneEquip eq = (IArcaneEquip)item;
eq.CurArcaneCharges = eq.MaxArcaneCharges = 20; eq.CurArcaneCharges = eq.MaxArcaneCharges = 20;
} }

View file

@ -94,8 +94,8 @@ namespace Server.Mobiles
aggressor.PlaySound( 0x307 ); aggressor.PlaySound( 0x307 );
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away! aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
if ( aggressor is PlayerMobile ) if ( aggressor is PlayerMobile mobile )
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero; mobile.SavagePaintExpiration = TimeSpan.Zero;
} }
} }

View file

@ -64,7 +64,7 @@ namespace Server.Mobiles
if ( m == this || !CanBeHarmful( m ) ) if ( m == this || !CanBeHarmful( m ) )
continue; continue;
if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team) ) if ( m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != this.Team) )
list.Add( m ); list.Add( m );
else if ( m.Player ) else if ( m.Player )
list.Add( m ); list.Add( m );

View file

@ -112,8 +112,7 @@ namespace Server.Mobiles
this.PlaySound( 0xEE ); this.PlaySound( 0xEE );
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" ); defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
BaseWeapon weapon = this.Weapon as BaseWeapon; if ( this.Weapon is BaseWeapon weapon )
if ( weapon != null )
weapon.OnHit( this, defender ); weapon.OnHit( this, defender );
if ( defender.Alive ) if ( defender.Alive )
@ -126,9 +125,7 @@ namespace Server.Mobiles
private void Recover_Callback( object state ) private void Recover_Callback( object state )
{ {
Mobile defender = state as Mobile; if ( state is Mobile defender )
if ( defender != null )
{ {
defender.Frozen = false; defender.Frozen = false;
defender.Combatant = null; defender.Combatant = null;

View file

@ -87,9 +87,7 @@ namespace Server.Mobiles
public override bool IsEnemy( Mobile m ) public override bool IsEnemy( Mobile m )
{ {
PlayerMobile player = m as PlayerMobile; if ( m is PlayerMobile player && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 ) // Schmendrick's cave
if ( player != null && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 ) // Schmendrick's cave
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;

View file

@ -88,8 +88,8 @@ namespace Server.Mobiles
aggressor.PlaySound( 0x307 ); aggressor.PlaySound( 0x307 );
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away! aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
if ( aggressor is PlayerMobile ) if ( aggressor is PlayerMobile mobile )
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero; mobile.SavagePaintExpiration = TimeSpan.Zero;
} }
} }

View file

@ -71,8 +71,8 @@ namespace Server.Mobiles
if ( mount != null ) if ( mount != null )
mount.Rider = null; mount.Rider = null;
if ( mount is Mobile ) if ( mount is Mobile mobile )
((Mobile)mount).Delete(); mobile.Delete();
return base.OnBeforeDeath(); return base.OnBeforeDeath();
} }
@ -98,8 +98,8 @@ namespace Server.Mobiles
aggressor.PlaySound( 0x307 ); aggressor.PlaySound( 0x307 );
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away! aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
if ( aggressor is PlayerMobile ) if ( aggressor is PlayerMobile mobile )
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero; mobile.SavagePaintExpiration = TimeSpan.Zero;
} }
} }

View file

@ -172,8 +172,8 @@ namespace Server.Mobiles
if ( mount != null ) if ( mount != null )
{ {
if ( mount is SwampDragon ) if ( mount is SwampDragon dragon )
((SwampDragon)mount).HasBarding = false; dragon.HasBarding = false;
mount.Rider = null; mount.Rider = null;
} }

View file

@ -111,9 +111,9 @@ namespace Server.Mobiles
foreach ( Mobile m in this.GetMobilesInRange( 8 ) ) foreach ( Mobile m in this.GetMobilesInRange( 8 ) )
{ {
if ( m is JukaLord && IsFriend( m ) && m.Combatant != null && CanBeBeneficial( m ) && m.CanBeginAction( typeof( JukaMage ) ) && InLOS( m ) ) if ( m is JukaLord lord && IsFriend( lord ) && lord.Combatant != null && CanBeBeneficial( lord ) && lord.CanBeginAction( typeof( JukaMage ) ) && InLOS( lord ) )
{ {
toBuff = (JukaLord)m; toBuff = lord;
break; break;
} }
} }

View file

@ -239,12 +239,7 @@ namespace Server.Mobiles
else if ( !Combat( SummonMaster )) else if ( !Combat( SummonMaster ))
{ {
BaseCreature bc = null; if ( Combatant.Player || ( Combatant is BaseCreature bc && ( bc.Controlled || bc.SummonMaster != null )))
if ( Combatant is BaseCreature )
{
bc = (BaseCreature)Combatant;
}
if ( Combatant.Player || ( bc != null && ( bc.Controlled || bc.SummonMaster != null )))
{ {
SummonMaster.Combatant = Combatant; SummonMaster.Combatant = Combatant;
} }
@ -258,14 +253,9 @@ namespace Server.Mobiles
private bool Combat( Mobile mobile ) private bool Combat( Mobile mobile )
{ {
Mobile combatant = mobile.Combatant; Mobile combatant = mobile.Combatant;
if ( combatant == null || combatant.Deleted ) if ( combatant == null || combatant.Deleted || combatant.IsDeadBondedPet || !combatant.Alive )
{
return false; return false;
}
else if ( combatant.IsDeadBondedPet || !combatant.Alive )
{
return false;
}
return true; return true;
} }

View file

@ -89,10 +89,8 @@ namespace Server.Mobiles
{ {
m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds( Utility.RandomMinMax( 20, 30 ) ); m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds( Utility.RandomMinMax( 20, 30 ) );
if ( combatant is BaseCreature ) if ( combatant is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)combatant;
if ( bc.Controlled && bc.ControlMaster != null && !bc.ControlMaster.Deleted && bc.ControlMaster.Alive ) if ( bc.Controlled && bc.ControlMaster != null && !bc.ControlMaster.Deleted && bc.ControlMaster.Alive )
{ {
if ( bc.ControlMaster.Map == this.Map && bc.ControlMaster.InRange( this, 12 ) && !UnderEffect( bc.ControlMaster ) ) if ( bc.ControlMaster.Map == this.Map && bc.ControlMaster.InRange( this, 12 ) && !UnderEffect( bc.ControlMaster ) )
@ -109,8 +107,6 @@ namespace Server.Mobiles
new int[]{-4,-6}, new int[]{4,-6}, new int[]{0,-8}, new int[]{-5,5}, new int[]{5,5} new int[]{-4,-6}, new int[]{4,-6}, new int[]{0,-8}, new int[]{-5,5}, new int[]{5,5}
}; };
BaseCreature rabid;
for( int i=0; i<5; i++ ) for( int i=0; i<5; i++ )
{ {
int x = combatant.X + coord[i][0]; int x = combatant.X + coord[i][0];
@ -121,6 +117,7 @@ namespace Server.Mobiles
if ( !combatant.Map.CanSpawnMobile( loc ) ) if ( !combatant.Map.CanSpawnMobile( loc ) )
continue; continue;
BaseCreature rabid;
switch ( i ) switch ( i )
{ {
case 0: rabid = new EnragedRabbit( this ); break; case 0: rabid = new EnragedRabbit( this ); break;
@ -155,9 +152,7 @@ namespace Server.Mobiles
public static void StopEffect( Mobile m, bool message ) public static void StopEffect( Mobile m, bool message )
{ {
Timer t = (Timer)m_Table[m]; if ( m_Table[m] is Timer t )
if ( t != null )
{ {
if ( message ) if ( message )
m.PublicOverheadMessage( Network.MessageType.Emote, m.SpeechHue, true, "* The open flame begins to scatter the swarm of insects *" ); m.PublicOverheadMessage( Network.MessageType.Emote, m.SpeechHue, true, "* The open flame begins to scatter the swarm of insects *" );
@ -180,9 +175,7 @@ namespace Server.Mobiles
} }
else else
{ {
Torch torch = m.FindItemOnLayer( Layer.TwoHanded ) as Torch; if ( m.FindItemOnLayer( Layer.TwoHanded ) is Torch torch && torch.Burning )
if ( torch != null && torch.Burning )
{ {
StopEffect( m, true ); StopEffect( m, true );
} }

View file

@ -50,8 +50,8 @@ namespace Server.Mobiles
public override void OnMovement( Mobile m, Point3D oldLocation ) public override void OnMovement( Mobile m, Point3D oldLocation )
{ {
if ( m is Ferret && m.InRange( this, 3 ) && m.Alive ) if ( m is Ferret ferret && ferret.InRange( this, 3 ) && ferret.Alive )
Talk( (Ferret) m ); Talk( ferret );
} }
private static string[] m_Vocabulary = new string[] private static string[] m_Vocabulary = new string[]

View file

@ -74,12 +74,10 @@ namespace Server.Mobiles
if ( m == this || !CanBeHarmful( m, false ) || ( Core.AOS && !InLOS( m ) ) ) if ( m == this || !CanBeHarmful( m, false ) || ( Core.AOS && !InLOS( m ) ) )
continue; continue;
if ( m is BaseCreature ) if ( m is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)m;
if ( bc.Controlled || bc.Summoned || bc.Team != Team ) if ( bc.Controlled || bc.Summoned || bc.Team != Team )
list.Add( m ); list.Add( bc );
} }
else if ( m.Player ) else if ( m.Player )
{ {

View file

@ -70,9 +70,7 @@ namespace Server.Mobiles
if ( target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || 0.1 < Utility.RandomDouble() ) if ( target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || 0.1 < Utility.RandomDouble() )
return; return;
PlayerMobile p = target as PlayerMobile; if ( target is PlayerMobile p && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful( p ) )
if ( p != null && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful( p ) )
{ {
p.PeacedUntil = DateTime.UtcNow + TimeSpan.FromMinutes( 1 ); p.PeacedUntil = DateTime.UtcNow + TimeSpan.FromMinutes( 1 );
p.SendLocalizedMessage( 500616 ); // You hear lovely music, and forget to continue battling! p.SendLocalizedMessage( 500616 ); // You hear lovely music, and forget to continue battling!
@ -121,12 +119,10 @@ namespace Server.Mobiles
public static void SuppressRemove( Mobile target ) public static void SuppressRemove( Mobile target )
{ {
if ( target != null && m_Suppressed.ContainsKey( target ) ) if ( target != null && m_Suppressed[target] is Timer t )
{ {
Timer timer = m_Suppressed[ target ]; if ( t.Running )
t.Stop();
if ( timer != null || timer.Running )
timer.Stop();
m_Suppressed.Remove( target ); m_Suppressed.Remove( target );
} }
@ -196,10 +192,8 @@ namespace Server.Mobiles
foreach ( Mobile m in GetMobilesInRange( RangePerception ) ) foreach ( Mobile m in GetMobilesInRange( RangePerception ) )
{ {
if ( m is BaseCreature ) if ( m is BaseCreature c )
{ {
BaseCreature c = (BaseCreature) m;
if ( c == this || c == target || c.Unprovokable || c.IsParagon || c.BardProvoked || c.AccessLevel != AccessLevel.Player || !c.CanBeHarmful( target ) ) if ( c == this || c == target || c.Unprovokable || c.IsParagon || c.BardProvoked || c.AccessLevel != AccessLevel.Player || !c.CanBeHarmful( target ) )
continue; continue;

View file

@ -231,8 +231,8 @@ namespace Server.Mobiles
private void EndCacophonic_Callback( object state ) private void EndCacophonic_Callback( object state )
{ {
if ( state is Mobile ) if ( state is Mobile mobile )
CacophonicEnd( (Mobile)state ); CacophonicEnd( mobile );
} }
public virtual void CacophonicEnd( Mobile from ) public virtual void CacophonicEnd( Mobile from )
@ -362,10 +362,8 @@ namespace Server.Mobiles
foreach ( Mobile m in GetMobilesInRange( 0 ) ) foreach ( Mobile m in GetMobilesInRange( 0 ) )
{ {
if ( m is BaseCreature ) if ( m is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)m;
if ( !bc.Controlled && !bc.Summoned ) if ( !bc.Controlled && !bc.Summoned )
continue; continue;
} }
@ -398,9 +396,7 @@ namespace Server.Mobiles
for ( int i = 0; i < items.Count; ++i ) for ( int i = 0; i < items.Count; ++i )
{ {
IDurability wearable = items[i] as IDurability; if ( items[i] is IDurability wearable && wearable.HitPoints >= 10 && Utility.RandomDouble() < 0.25 )
if ( wearable != null && wearable.HitPoints >= 10 && Utility.RandomDouble() < 0.25 )
{ {
wearable.HitPoints -= ( wearable.HitPoints == 10 ) ? Utility.Random( 1, 5 ) : 10; wearable.HitPoints -= ( wearable.HitPoints == 10 ) ? Utility.Random( 1, 5 ) : 10;
damaged = true; damaged = true;

View file

@ -178,7 +178,7 @@ namespace Server.Mobiles
{ {
if (m == this || !CanBeHarmful(m)) if (m == this || !CanBeHarmful(m))
continue; continue;
if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team)) if (m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != this.Team))
targets.Add(m); targets.Add(m);
else if (m.Player) else if (m.Player)
targets.Add(m); targets.Add(m);
@ -187,15 +187,14 @@ namespace Server.Mobiles
for (int i = 0; i < targets.Count; ++i) for (int i = 0; i < targets.Count; ++i)
{ {
Mobile m = (Mobile)targets[i]; Mobile m = (Mobile)targets[i];
if ( m != null && !m.Deleted && m is PlayerMobile ) if ( m != null && !m.Deleted && m is PlayerMobile pm )
{ {
PlayerMobile pm = m as PlayerMobile; if (pm.Mounted)
if (pm != null && pm.Mounted)
{ {
pm.Mount.Rider=null; pm.Mount.Rider = null;
} }
} }
double damage = m.Hits * 0.6;//was .6 double damage = m.Hits * 0.6; //was .6
if (damage < 10.0) if (damage < 10.0)
damage = 10.0; damage = 10.0;
else if (damage > 75.0) else if (damage > 75.0)

View file

@ -158,8 +158,7 @@ namespace Server.Mobiles
this.PlaySound( 0xEE ); this.PlaySound( 0xEE );
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" ); defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
BaseWeapon weapon = this.Weapon as BaseWeapon; if ( this.Weapon is BaseWeapon weapon )
if ( weapon != null )
weapon.OnHit( this, defender ); weapon.OnHit( this, defender );
if ( defender.Alive ) if ( defender.Alive )
@ -172,9 +171,7 @@ namespace Server.Mobiles
private void Recover_Callback( object state ) private void Recover_Callback( object state )
{ {
Mobile defender = state as Mobile; if ( state is Mobile defender )
if ( defender != null )
{ {
defender.Frozen = false; defender.Frozen = false;
defender.Combatant = null; defender.Combatant = null;

View file

@ -29,9 +29,7 @@ namespace Server.Mobiles
{ {
for ( int i = 0; i < pack.Items.Count; i++ ) for ( int i = 0; i < pack.Items.Count; i++ )
{ {
PlagueBeastBlood blood = pack.Items[ i ] as PlagueBeastBlood; if ( pack.Items[ i ] is PlagueBeastBlood blood && !blood.Patched )
if ( blood != null && !blood.Patched )
return true; return true;
} }
} }
@ -107,7 +105,7 @@ namespace Server.Mobiles
public override void OnDelete() public override void OnDelete()
{ {
if ( m_OpenedBy != null && m_OpenedBy.Holding is PlagueBeastInnard ) if ( m_OpenedBy?.Holding is PlagueBeastInnard )
m_OpenedBy.Holding.Delete(); m_OpenedBy.Holding.Delete();
if ( Backpack != null ) if ( Backpack != null )

View file

@ -64,12 +64,9 @@ namespace Server.Mobiles
public override void AlterMeleeDamageFrom( Mobile from, ref int damage ) public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
{ {
if ( from is BaseCreature ) if ( from is BaseCreature bc && (bc.Controlled || bc.BardTarget == this) )
{ {
BaseCreature bc = (BaseCreature)from; damage = 0; // Immune to pets and provoked creatures
if ( bc.Controlled || bc.BardTarget == this )
damage = 0; // Immune to pets and provoked creatures
} }
} }

View file

@ -66,10 +66,8 @@ namespace Server.Mobiles
public override void AlterMeleeDamageFrom( Mobile from, ref int damage ) public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
{ {
if ( from is BaseCreature ) if ( @from is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)from;
if ( bc.Controlled || bc.BardTarget == this ) if ( bc.Controlled || bc.BardTarget == this )
damage = 0; // Immune to pets and provoked creatures damage = 0; // Immune to pets and provoked creatures
} }

View file

@ -99,16 +99,11 @@ namespace Server.Mobiles
{ {
base.OnGotMeleeAttack( attacker ); base.OnGotMeleeAttack( attacker );
if ( !Core.SE && 0.2 > Utility.RandomDouble() && attacker is BaseCreature ) if ( !Core.SE && 0.2 > Utility.RandomDouble() && attacker is BaseCreature c && c.Controlled && c.ControlMaster != null )
{ {
BaseCreature c = (BaseCreature)attacker; c.ControlTarget = c.ControlMaster;
c.ControlOrder = OrderType.Attack;
if ( c.Controlled && c.ControlMaster != null ) c.Combatant = c.ControlMaster;
{
c.ControlTarget = c.ControlMaster;
c.ControlOrder = OrderType.Attack;
c.Combatant = c.ControlMaster;
}
} }
} }

View file

@ -81,7 +81,7 @@ namespace Server.Mobiles
if ( this.Map == null ) if ( this.Map == null )
return; return;
if ( attacker is BaseCreature && ((BaseCreature)attacker).BardProvoked ) if ( attacker is BaseCreature creature && creature.BardProvoked )
return; return;
if ( 0.2 > Utility.RandomDouble() ) if ( 0.2 > Utility.RandomDouble() )
@ -95,9 +95,9 @@ namespace Server.Mobiles
Mobile target = null; Mobile target = null;
if ( attacker is BaseCreature ) if ( attacker is BaseCreature baseCreature )
{ {
Mobile m = ((BaseCreature)attacker).GetMaster(); Mobile m = baseCreature.GetMaster();
if ( m != null ) if ( m != null )
target = m; target = m;
@ -115,7 +115,7 @@ namespace Server.Mobiles
if ( m == this || !CanBeHarmful( m ) ) if ( m == this || !CanBeHarmful( m ) )
continue; continue;
if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team) ) if ( m is BaseCreature bc && (bc.Controlled || bc.Summoned || bc.Team != this.Team))
targets.Add( m ); targets.Add( m );
else if ( m.Player && m.Alive ) else if ( m.Player && m.Alive )
targets.Add( m ); targets.Add( m );

View file

@ -140,11 +140,9 @@ namespace Server.Mobiles
if (!Flying) if (!Flying)
{ {
// No message? // No message?
if (Spell is FlySpell) if (Spell is FlySpell spell)
{
FlySpell spell = (FlySpell)Spell;
spell.Stop(); spell.Stop();
}
new FlySpell(this).Cast(); new FlySpell(this).Cast();
} }
else else
@ -629,11 +627,9 @@ namespace Server.Mobiles
{ {
object[] objs = type.GetCustomAttributes( typeof( FlippableAttribute ), true ); object[] objs = type.GetCustomAttributes( typeof( FlippableAttribute ), true );
if ( objs != null && objs.Length > 0 ) if ( objs.Length > 0 )
{ {
FlippableAttribute fp = objs[0] as FlippableAttribute; if ( objs[0] is FlippableAttribute fp )
if ( fp != null )
{ {
int[] itemIDs = fp.ItemIDs; int[] itemIDs = fp.ItemIDs;
@ -732,11 +728,9 @@ namespace Server.Mobiles
{ {
foreach( Mobile m in World.Mobiles.Values ) foreach( Mobile m in World.Mobiles.Values )
{ {
if ( m is PlayerMobile ) if ( m is PlayerMobile pm )
{ {
PlayerMobile pm = (PlayerMobile)m; if ((( !pm.Mounted || ( pm.Mount is EtherealMount )) && ( pm.AllFollowers.Count > pm.AutoStabled.Count )) ||
if ((( !pm.Mounted || ( pm.Mount != null && pm.Mount is EtherealMount )) && ( pm.AllFollowers.Count > pm.AutoStabled.Count )) ||
( pm.Mounted && ( pm.AllFollowers.Count > ( pm.AutoStabled.Count +1 )))) ( pm.Mounted && ( pm.AllFollowers.Count > ( pm.AutoStabled.Count +1 ))))
{ {
pm.AutoStablePets(); /* autostable checks summons, et al: no need here */ pm.AutoStablePets(); /* autostable checks summons, et al: no need here */
@ -915,9 +909,7 @@ namespace Server.Mobiles
{ {
string notice; string notice;
Accounting.Account acct = from.Account as Accounting.Account; if ( !(@from.Account is Account acct) || !acct.HasAccess( from.NetState ) )
if ( acct == null || !acct.HasAccess( from.NetState ) )
{ {
if ( from.AccessLevel == AccessLevel.Player ) if ( from.AccessLevel == AccessLevel.Player )
notice = "The server is currently under lockdown. No players are allowed to log in at this time."; notice = "The server is currently under lockdown. No players are allowed to log in at this time.";
@ -939,8 +931,8 @@ namespace Server.Mobiles
return; return;
} }
if ( from is PlayerMobile ) if ( @from is PlayerMobile mobile )
((PlayerMobile)from).ClaimAutoStabledPets(); mobile.ClaimAutoStabledPets();
} }
private bool m_NoDeltaRecursion; private bool m_NoDeltaRecursion;
@ -1021,10 +1013,8 @@ namespace Server.Mobiles
} }
#endregion #endregion
if ( item is BaseWeapon ) if ( item is BaseWeapon weapon )
{ {
BaseWeapon weapon = (BaseWeapon)item;
bool drop = false; bool drop = false;
if ( dex < weapon.DexRequirement ) if ( dex < weapon.DexRequirement )
@ -1048,10 +1038,8 @@ namespace Server.Mobiles
moved = true; moved = true;
} }
} }
else if ( item is BaseArmor ) else if ( item is BaseArmor armor )
{ {
BaseArmor armor = (BaseArmor)item;
bool drop = false; bool drop = false;
if ( !armor.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster ) if ( !armor.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster )
@ -1096,10 +1084,8 @@ namespace Server.Mobiles
moved = true; moved = true;
} }
} }
else if ( item is BaseClothing ) else if ( item is BaseClothing clothing )
{ {
BaseClothing clothing = (BaseClothing)item;
bool drop = false; bool drop = false;
if ( !clothing.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster ) if ( !clothing.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster )