More casting fixes
This commit is contained in:
parent
f211efc3bd
commit
20a80ea2f3
40 changed files with 125 additions and 211 deletions
|
|
@ -22,53 +22,41 @@ namespace Server.Mobiles
|
|||
|
||||
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 )
|
||||
return CheckRedFriendship( bc.ControlMaster );
|
||||
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
|
||||
if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
|
||||
return CheckRedFriendship( bc.SummonMaster );
|
||||
}
|
||||
|
||||
PlayerMobile player = m as PlayerMobile;
|
||||
|
||||
return player != null && player.SolenFriendship == SolenFriendship.Red;
|
||||
return m is PlayerMobile player && player.SolenFriendship == SolenFriendship.Red;
|
||||
}
|
||||
|
||||
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 )
|
||||
return CheckBlackFriendship( bc.ControlMaster );
|
||||
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
|
||||
if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
|
||||
return CheckBlackFriendship( bc.SummonMaster );
|
||||
}
|
||||
|
||||
PlayerMobile player = m as PlayerMobile;
|
||||
|
||||
return player != null && player.SolenFriendship == SolenFriendship.Black;
|
||||
return m is PlayerMobile player && player.SolenFriendship == SolenFriendship.Black;
|
||||
}
|
||||
|
||||
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 )
|
||||
OnRedDamage( bc.ControlMaster );
|
||||
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
|
||||
OnRedDamage( bc.SummonMaster );
|
||||
}
|
||||
|
||||
PlayerMobile player = from as PlayerMobile;
|
||||
|
||||
if ( player != null && player.SolenFriendship == SolenFriendship.Red )
|
||||
if ( from is PlayerMobile player && player.SolenFriendship == SolenFriendship.Red )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
if ( from is BaseCreature )
|
||||
if ( from is BaseCreature bc )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)from;
|
||||
|
||||
if ( bc.Controlled && bc.ControlMaster is PlayerMobile )
|
||||
OnBlackDamage( bc.ControlMaster );
|
||||
else if ( bc.Summoned && bc.SummonMaster is PlayerMobile )
|
||||
OnBlackDamage( bc.SummonMaster );
|
||||
}
|
||||
|
||||
PlayerMobile player = from as PlayerMobile;
|
||||
|
||||
if ( player != null && player.SolenFriendship == SolenFriendship.Black )
|
||||
if ( from is PlayerMobile player && player.SolenFriendship == SolenFriendship.Black )
|
||||
{
|
||||
player.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1054103 ); // The solen revoke their friendship. You will now be considered an intruder.
|
||||
|
||||
|
|
@ -98,4 +82,4 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ namespace Server.Mobiles
|
|||
this.PlaySound( 0xEE );
|
||||
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
|
||||
|
||||
BaseWeapon weapon = this.Weapon as BaseWeapon;
|
||||
if ( weapon != null )
|
||||
if ( this.Weapon is BaseWeapon weapon )
|
||||
weapon.OnHit( this, defender );
|
||||
|
||||
if ( defender.Alive )
|
||||
|
|
@ -128,9 +127,7 @@ namespace Server.Mobiles
|
|||
|
||||
private void Recover_Callback( object state )
|
||||
{
|
||||
Mobile defender = state as Mobile;
|
||||
|
||||
if ( defender != null )
|
||||
if ( state is Mobile defender )
|
||||
{
|
||||
defender.Frozen = false;
|
||||
defender.Combatant = null;
|
||||
|
|
|
|||
|
|
@ -60,9 +60,8 @@ namespace Server.Mobiles
|
|||
|
||||
public void AddArcane( Item item )
|
||||
{
|
||||
if ( item is IArcaneEquip )
|
||||
if ( item is IArcaneEquip eq )
|
||||
{
|
||||
IArcaneEquip eq = (IArcaneEquip)item;
|
||||
eq.CurArcaneCharges = eq.MaxArcaneCharges = 20;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ namespace Server.Mobiles
|
|||
aggressor.PlaySound( 0x307 );
|
||||
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
|
||||
|
||||
if ( aggressor is PlayerMobile )
|
||||
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero;
|
||||
if ( aggressor is PlayerMobile mobile )
|
||||
mobile.SavagePaintExpiration = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,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) )
|
||||
list.Add( m );
|
||||
else if ( m.Player )
|
||||
list.Add( m );
|
||||
|
|
|
|||
|
|
@ -112,8 +112,7 @@ namespace Server.Mobiles
|
|||
this.PlaySound( 0xEE );
|
||||
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
|
||||
|
||||
BaseWeapon weapon = this.Weapon as BaseWeapon;
|
||||
if ( weapon != null )
|
||||
if ( this.Weapon is BaseWeapon weapon )
|
||||
weapon.OnHit( this, defender );
|
||||
|
||||
if ( defender.Alive )
|
||||
|
|
@ -126,9 +125,7 @@ namespace Server.Mobiles
|
|||
|
||||
private void Recover_Callback( object state )
|
||||
{
|
||||
Mobile defender = state as Mobile;
|
||||
|
||||
if ( defender != null )
|
||||
if ( state is Mobile defender )
|
||||
{
|
||||
defender.Frozen = false;
|
||||
defender.Combatant = null;
|
||||
|
|
|
|||
|
|
@ -87,9 +87,7 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool IsEnemy( Mobile m )
|
||||
{
|
||||
PlayerMobile player = m as PlayerMobile;
|
||||
|
||||
if ( player != null && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 ) // Schmendrick's cave
|
||||
if ( m is PlayerMobile player && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 ) // Schmendrick's cave
|
||||
{
|
||||
QuestSystem qs = player.Quest;
|
||||
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ namespace Server.Mobiles
|
|||
aggressor.PlaySound( 0x307 );
|
||||
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
|
||||
|
||||
if ( aggressor is PlayerMobile )
|
||||
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero;
|
||||
if ( aggressor is PlayerMobile mobile )
|
||||
mobile.SavagePaintExpiration = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ namespace Server.Mobiles
|
|||
if ( mount != null )
|
||||
mount.Rider = null;
|
||||
|
||||
if ( mount is Mobile )
|
||||
((Mobile)mount).Delete();
|
||||
if ( mount is Mobile mobile )
|
||||
mobile.Delete();
|
||||
|
||||
return base.OnBeforeDeath();
|
||||
}
|
||||
|
|
@ -98,8 +98,8 @@ namespace Server.Mobiles
|
|||
aggressor.PlaySound( 0x307 );
|
||||
aggressor.SendLocalizedMessage( 1040008 ); // Your skin is scorched as the tribal paint burns away!
|
||||
|
||||
if ( aggressor is PlayerMobile )
|
||||
((PlayerMobile)aggressor).SavagePaintExpiration = TimeSpan.Zero;
|
||||
if ( aggressor is PlayerMobile mobile )
|
||||
mobile.SavagePaintExpiration = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,8 +172,8 @@ namespace Server.Mobiles
|
|||
|
||||
if ( mount != null )
|
||||
{
|
||||
if ( mount is SwampDragon )
|
||||
((SwampDragon)mount).HasBarding = false;
|
||||
if ( mount is SwampDragon dragon )
|
||||
dragon.HasBarding = false;
|
||||
|
||||
mount.Rider = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,9 +111,9 @@ namespace Server.Mobiles
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,12 +239,7 @@ namespace Server.Mobiles
|
|||
|
||||
else if ( !Combat( SummonMaster ))
|
||||
{
|
||||
BaseCreature bc = null;
|
||||
if ( Combatant is BaseCreature )
|
||||
{
|
||||
bc = (BaseCreature)Combatant;
|
||||
}
|
||||
if ( Combatant.Player || ( bc != null && ( bc.Controlled || bc.SummonMaster != null )))
|
||||
if ( Combatant.Player || ( Combatant is BaseCreature bc && ( bc.Controlled || bc.SummonMaster != null )))
|
||||
{
|
||||
SummonMaster.Combatant = Combatant;
|
||||
}
|
||||
|
|
@ -258,14 +253,9 @@ namespace Server.Mobiles
|
|||
private bool Combat( Mobile mobile )
|
||||
{
|
||||
Mobile combatant = mobile.Combatant;
|
||||
if ( combatant == null || combatant.Deleted )
|
||||
{
|
||||
if ( combatant == null || combatant.Deleted || combatant.IsDeadBondedPet || !combatant.Alive )
|
||||
return false;
|
||||
}
|
||||
else if ( combatant.IsDeadBondedPet || !combatant.Alive )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,10 +89,8 @@ namespace Server.Mobiles
|
|||
{
|
||||
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.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}
|
||||
};
|
||||
|
||||
BaseCreature rabid;
|
||||
|
||||
for( int i=0; i<5; i++ )
|
||||
{
|
||||
int x = combatant.X + coord[i][0];
|
||||
|
|
@ -121,6 +117,7 @@ namespace Server.Mobiles
|
|||
if ( !combatant.Map.CanSpawnMobile( loc ) )
|
||||
continue;
|
||||
|
||||
BaseCreature rabid;
|
||||
switch ( i )
|
||||
{
|
||||
case 0: rabid = new EnragedRabbit( this ); break;
|
||||
|
|
@ -155,9 +152,7 @@ namespace Server.Mobiles
|
|||
|
||||
public static void StopEffect( Mobile m, bool message )
|
||||
{
|
||||
Timer t = (Timer)m_Table[m];
|
||||
|
||||
if ( t != null )
|
||||
if ( m_Table[m] is Timer t )
|
||||
{
|
||||
if ( message )
|
||||
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
|
||||
{
|
||||
Torch torch = m.FindItemOnLayer( Layer.TwoHanded ) as Torch;
|
||||
|
||||
if ( torch != null && torch.Burning )
|
||||
if ( m.FindItemOnLayer( Layer.TwoHanded ) is Torch torch && torch.Burning )
|
||||
{
|
||||
StopEffect( m, true );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -158,8 +158,7 @@ namespace Server.Mobiles
|
|||
this.PlaySound( 0xEE );
|
||||
defender.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You have been stunned by a colossal blow!" );
|
||||
|
||||
BaseWeapon weapon = this.Weapon as BaseWeapon;
|
||||
if ( weapon != null )
|
||||
if ( this.Weapon is BaseWeapon weapon )
|
||||
weapon.OnHit( this, defender );
|
||||
|
||||
if ( defender.Alive )
|
||||
|
|
@ -172,9 +171,7 @@ namespace Server.Mobiles
|
|||
|
||||
private void Recover_Callback( object state )
|
||||
{
|
||||
Mobile defender = state as Mobile;
|
||||
|
||||
if ( defender != null )
|
||||
if ( state is Mobile defender )
|
||||
{
|
||||
defender.Frozen = false;
|
||||
defender.Combatant = null;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
for ( int i = 0; i < pack.Items.Count; i++ )
|
||||
{
|
||||
PlagueBeastBlood blood = pack.Items[ i ] as PlagueBeastBlood;
|
||||
|
||||
if ( blood != null && !blood.Patched )
|
||||
if ( pack.Items[ i ] is PlagueBeastBlood blood && !blood.Patched )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -107,7 +105,7 @@ namespace Server.Mobiles
|
|||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if ( m_OpenedBy != null && m_OpenedBy.Holding is PlagueBeastInnard )
|
||||
if ( m_OpenedBy?.Holding is PlagueBeastInnard )
|
||||
m_OpenedBy.Holding.Delete();
|
||||
|
||||
if ( Backpack != null )
|
||||
|
|
|
|||
|
|
@ -64,12 +64,9 @@ namespace Server.Mobiles
|
|||
|
||||
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;
|
||||
|
||||
if ( bc.Controlled || bc.BardTarget == this )
|
||||
damage = 0; // Immune to pets and provoked creatures
|
||||
damage = 0; // Immune to pets and provoked creatures
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,10 +66,8 @@ namespace Server.Mobiles
|
|||
|
||||
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 )
|
||||
damage = 0; // Immune to pets and provoked creatures
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,16 +99,11 @@ namespace Server.Mobiles
|
|||
{
|
||||
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;
|
||||
|
||||
if ( c.Controlled && c.ControlMaster != null )
|
||||
{
|
||||
c.ControlTarget = c.ControlMaster;
|
||||
c.ControlOrder = OrderType.Attack;
|
||||
c.Combatant = c.ControlMaster;
|
||||
}
|
||||
c.ControlTarget = c.ControlMaster;
|
||||
c.ControlOrder = OrderType.Attack;
|
||||
c.Combatant = c.ControlMaster;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace Server.Mobiles
|
|||
if ( this.Map == null )
|
||||
return;
|
||||
|
||||
if ( attacker is BaseCreature && ((BaseCreature)attacker).BardProvoked )
|
||||
if ( attacker is BaseCreature creature && creature.BardProvoked )
|
||||
return;
|
||||
|
||||
if ( 0.2 > Utility.RandomDouble() )
|
||||
|
|
@ -95,9 +95,9 @@ namespace Server.Mobiles
|
|||
|
||||
Mobile target = null;
|
||||
|
||||
if ( attacker is BaseCreature )
|
||||
if ( attacker is BaseCreature baseCreature )
|
||||
{
|
||||
Mobile m = ((BaseCreature)attacker).GetMaster();
|
||||
Mobile m = baseCreature.GetMaster();
|
||||
|
||||
if ( m != null )
|
||||
target = m;
|
||||
|
|
@ -115,7 +115,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 bc && (bc.Controlled || bc.Summoned || bc.Team != this.Team))
|
||||
targets.Add( m );
|
||||
else if ( m.Player && m.Alive )
|
||||
targets.Add( m );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue