Fixes more casting and null propogation

This commit is contained in:
Kamron Batman 2018-09-11 16:20:57 -07:00
parent 403e2a8b9d
commit f211efc3bd
7 changed files with 242 additions and 412 deletions

View file

@ -250,12 +250,12 @@ namespace Server.Mobiles
if (!isOwner && !isFriend)
return;
else if (isFriend && order != OrderType.Follow && order != OrderType.Stay && order != OrderType.Stop)
if (isFriend && order != OrderType.Follow && order != OrderType.Stay && order != OrderType.Stop)
return;
if (order == OrderType.Attack)
{
if (target is BaseCreature && ((BaseCreature)target).IsScaryToPets && m_Mobile.IsScaredOfScaryThings)
if (target is BaseCreature creature && creature.IsScaryToPets && m_Mobile.IsScaredOfScaryThings)
{
m_Mobile.SayTo(from, "Your pet refuses to attack this creature!");
return;

View file

@ -920,7 +920,7 @@ namespace Server.Mobiles
public bool CanDispel( Mobile m )
{
return ( m is BaseCreature && ( (BaseCreature)m ).Summoned && m_Mobile.CanBeHarmful( m, false ) && !( (BaseCreature)m ).IsAnimatedDead );
return ( m is BaseCreature creature && creature.Summoned && m_Mobile.CanBeHarmful( creature, false ) && !creature.IsAnimatedDead );
}
private static int[] m_Offsets = new int[]

View file

@ -61,7 +61,7 @@ namespace Server.Mobiles
m_Mobile.Say( Utility.RandomList( 1005305, 501603 ) );
Action = ActionType.Flee;
return true;
}
@ -88,7 +88,7 @@ namespace Server.Mobiles
m_Mobile.FocusMob = null;
Action = ActionType.Wander;
Action = ActionType.Wander;
}
}
@ -109,28 +109,28 @@ namespace Server.Mobiles
return base.HandlesOnSpeech( from );
}
// Temporary
// Temporary
public override void OnSpeech( SpeechEventArgs e )
{
base.OnSpeech( e );
Mobile from = e.Mobile;
if ( m_Mobile is BaseVendor && from.InRange( m_Mobile, Core.AOS ? 1 : 4 ) && !e.Handled )
if ( m_Mobile is BaseVendor vendor && from.InRange( m_Mobile, Core.AOS ? 1 : 4 ) && !e.Handled )
{
if ( e.HasKeyword( 0x14D ) ) // *vendor sell*
{
e.Handled = true;
((BaseVendor)m_Mobile).VendorSell( from );
m_Mobile.FocusMob = from;
vendor.VendorSell( from );
vendor.FocusMob = from;
}
else if ( e.HasKeyword( 0x3C ) ) // *vendor buy*
{
e.Handled = true;
((BaseVendor)m_Mobile).VendorBuy( from );
m_Mobile.FocusMob = from;
vendor.VendorBuy( from );
vendor.FocusMob = from;
}
else if ( WasNamed( e.Speech ) )
{
@ -138,18 +138,18 @@ namespace Server.Mobiles
{
e.Handled = true;
((BaseVendor)m_Mobile).VendorSell( from );
vendor.VendorSell( from );
}
else if ( e.HasKeyword( 0x171 ) ) // *buy*
{
e.Handled = true;
((BaseVendor)m_Mobile).VendorBuy( from );
vendor.VendorBuy( from );
}
m_Mobile.FocusMob = from;
vendor.FocusMob = from;
}
}
}
}
}
}