More casting fixes
This commit is contained in:
parent
f211efc3bd
commit
20a80ea2f3
40 changed files with 125 additions and 211 deletions
|
|
@ -50,8 +50,8 @@ namespace Server.Mobiles
|
|||
|
||||
public override void OnMovement( Mobile m, Point3D oldLocation )
|
||||
{
|
||||
if ( m is Ferret && m.InRange( this, 3 ) && m.Alive )
|
||||
Talk( (Ferret) m );
|
||||
if ( m is Ferret ferret && ferret.InRange( this, 3 ) && ferret.Alive )
|
||||
Talk( ferret );
|
||||
}
|
||||
|
||||
private static string[] m_Vocabulary = new string[]
|
||||
|
|
|
|||
|
|
@ -74,12 +74,10 @@ namespace Server.Mobiles
|
|||
if ( m == this || !CanBeHarmful( m, false ) || ( Core.AOS && !InLOS( m ) ) )
|
||||
continue;
|
||||
|
||||
if ( m is BaseCreature )
|
||||
if ( m is BaseCreature bc )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
|
||||
if ( bc.Controlled || bc.Summoned || bc.Team != Team )
|
||||
list.Add( m );
|
||||
list.Add( bc );
|
||||
}
|
||||
else if ( m.Player )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ namespace Server.Mobiles
|
|||
if ( target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || 0.1 < Utility.RandomDouble() )
|
||||
return;
|
||||
|
||||
PlayerMobile p = target as PlayerMobile;
|
||||
|
||||
if ( p != null && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful( p ) )
|
||||
if ( target is PlayerMobile p && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful( p ) )
|
||||
{
|
||||
p.PeacedUntil = DateTime.UtcNow + TimeSpan.FromMinutes( 1 );
|
||||
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 )
|
||||
{
|
||||
if ( target != null && m_Suppressed.ContainsKey( target ) )
|
||||
if ( target != null && m_Suppressed[target] is Timer t )
|
||||
{
|
||||
Timer timer = m_Suppressed[ target ];
|
||||
|
||||
if ( timer != null || timer.Running )
|
||||
timer.Stop();
|
||||
if ( t.Running )
|
||||
t.Stop();
|
||||
|
||||
m_Suppressed.Remove( target );
|
||||
}
|
||||
|
|
@ -196,10 +192,8 @@ namespace Server.Mobiles
|
|||
|
||||
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 ) )
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -231,8 +231,8 @@ namespace Server.Mobiles
|
|||
|
||||
private void EndCacophonic_Callback( object state )
|
||||
{
|
||||
if ( state is Mobile )
|
||||
CacophonicEnd( (Mobile)state );
|
||||
if ( state is Mobile mobile )
|
||||
CacophonicEnd( mobile );
|
||||
}
|
||||
|
||||
public virtual void CacophonicEnd( Mobile from )
|
||||
|
|
@ -362,10 +362,8 @@ namespace Server.Mobiles
|
|||
|
||||
foreach ( Mobile m in GetMobilesInRange( 0 ) )
|
||||
{
|
||||
if ( m is BaseCreature )
|
||||
if ( m is BaseCreature bc )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
|
||||
if ( !bc.Controlled && !bc.Summoned )
|
||||
continue;
|
||||
}
|
||||
|
|
@ -398,9 +396,7 @@ namespace Server.Mobiles
|
|||
|
||||
for ( int i = 0; i < items.Count; ++i )
|
||||
{
|
||||
IDurability wearable = items[i] as IDurability;
|
||||
|
||||
if ( wearable != null && wearable.HitPoints >= 10 && Utility.RandomDouble() < 0.25 )
|
||||
if ( items[i] is IDurability wearable && wearable.HitPoints >= 10 && Utility.RandomDouble() < 0.25 )
|
||||
{
|
||||
wearable.HitPoints -= ( wearable.HitPoints == 10 ) ? Utility.Random( 1, 5 ) : 10;
|
||||
damaged = true;
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
if (m == this || !CanBeHarmful(m))
|
||||
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);
|
||||
else if (m.Player)
|
||||
targets.Add(m);
|
||||
|
|
@ -187,15 +187,14 @@ namespace Server.Mobiles
|
|||
for (int i = 0; i < targets.Count; ++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 != null && pm.Mounted)
|
||||
if (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)
|
||||
damage = 10.0;
|
||||
else if (damage > 75.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue