Sets a default parameter for OnHit. More casting cleanup.
This commit is contained in:
parent
74f498c1c8
commit
d6c0bf2d4c
96 changed files with 350 additions and 579 deletions
|
|
@ -31,7 +31,7 @@ namespace Server.Items
|
|||
TransformContext context = TransformationSpellHelper.GetContext( defender );
|
||||
|
||||
if ( (context != null && ( context.Type == typeof( LichFormSpell ) || context.Type == typeof( WraithFormSpell ))) ||
|
||||
(defender is BaseCreature && ((BaseCreature)defender).BleedImmune) )
|
||||
(defender is BaseCreature creature && creature.BleedImmune) )
|
||||
{
|
||||
attacker.SendLocalizedMessage( 1062052 ); // Your target is not affected by the bleed attack!
|
||||
return;
|
||||
|
|
@ -63,8 +63,7 @@ namespace Server.Items
|
|||
{
|
||||
Timer t = (Timer)m_Table[m];
|
||||
|
||||
if ( t != null )
|
||||
t.Stop();
|
||||
t?.Stop();
|
||||
|
||||
t = new InternalTimer( from, m );
|
||||
m_Table[m] = t;
|
||||
|
|
|
|||
|
|
@ -60,9 +60,7 @@ namespace Server.Items
|
|||
|
||||
public static bool GetBonus( Mobile targ, ref int bonus )
|
||||
{
|
||||
BlockInfo info = m_Table[targ] as BlockInfo;
|
||||
|
||||
if ( info == null )
|
||||
if ( !(m_Table[targ] is BlockInfo info) )
|
||||
return false;
|
||||
|
||||
bonus = info.m_Bonus;
|
||||
|
|
@ -81,12 +79,9 @@ namespace Server.Items
|
|||
|
||||
public static void EndBlock( Mobile m )
|
||||
{
|
||||
BlockInfo info = m_Table[m] as BlockInfo;
|
||||
|
||||
if ( info != null )
|
||||
if ( m_Table[m] is BlockInfo info )
|
||||
{
|
||||
if ( info.m_Timer != null )
|
||||
info.m_Timer.Stop();
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
m_Table.Remove( m );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ namespace Server.Items
|
|||
|
||||
int modifier = (int)(30.0 * ((Math.Max( attacker.Skills[SkillName.Bushido].Value, attacker.Skills[SkillName.Ninjitsu].Value ) - 50.0) / 70.0));
|
||||
|
||||
DefenseMasteryInfo info = m_Table[attacker] as DefenseMasteryInfo;
|
||||
|
||||
if ( info != null )
|
||||
if ( m_Table[attacker] is DefenseMasteryInfo info )
|
||||
EndDefense( (object)info );
|
||||
|
||||
ResistanceMod mod = new ResistanceMod( ResistanceType.Physical, 50 + modifier );
|
||||
|
|
@ -74,9 +72,7 @@ namespace Server.Items
|
|||
|
||||
public static bool GetMalus( Mobile targ, ref int damageMalus )
|
||||
{
|
||||
DefenseMasteryInfo info = m_Table[targ] as DefenseMasteryInfo;
|
||||
|
||||
if ( info == null )
|
||||
if ( !(m_Table[targ] is DefenseMasteryInfo info) )
|
||||
return false;
|
||||
|
||||
damageMalus = info.m_DamageMalus;
|
||||
|
|
@ -90,8 +86,7 @@ namespace Server.Items
|
|||
if ( info.m_Mod != null )
|
||||
info.m_From.RemoveResistanceMod( info.m_Mod );
|
||||
|
||||
if ( info.m_Timer != null )
|
||||
info.m_Timer.Stop();
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
// No message is sent to the player.
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,7 @@ namespace Server.Items
|
|||
|
||||
public override bool RequiresTactics( Mobile from )
|
||||
{
|
||||
BaseWeapon weapon = from.Weapon as BaseWeapon;
|
||||
|
||||
if ( weapon == null )
|
||||
if ( !(from.Weapon is BaseWeapon weapon) )
|
||||
return false;
|
||||
|
||||
return weapon.Skill != SkillName.Wrestling;
|
||||
|
|
|
|||
|
|
@ -72,36 +72,32 @@ namespace Server.Items
|
|||
defender.PlaySound( 0x140 );
|
||||
defender.FixedParticles( 0x3728, 10, 15, 9955, EffectLayer.Waist );
|
||||
|
||||
if (defender is PlayerMobile)
|
||||
if (defender is PlayerMobile mobile)
|
||||
{
|
||||
if (Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(defender))
|
||||
if (Server.Spells.Ninjitsu.AnimalForm.UnderTransformation(mobile))
|
||||
{
|
||||
defender.SendLocalizedMessage(1114066, attacker.Name); // ~1_NAME~ knocked you out of animal form!
|
||||
mobile.SendLocalizedMessage(1114066, attacker.Name); // ~1_NAME~ knocked you out of animal form!
|
||||
}
|
||||
else if (defender.Mounted)
|
||||
else if (mobile.Mounted)
|
||||
{
|
||||
defender.SendLocalizedMessage(1040023); // You have been knocked off of your mount!
|
||||
mobile.SendLocalizedMessage(1040023); // You have been knocked off of your mount!
|
||||
}
|
||||
|
||||
(defender as PlayerMobile).SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds(10), true);
|
||||
mobile.SetMountBlock(BlockMountType.Dazed, TimeSpan.FromSeconds(10), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
defender.Mount.Rider = null;
|
||||
}
|
||||
|
||||
if ( attacker is PlayerMobile )
|
||||
if ( attacker is PlayerMobile playerMobile )
|
||||
{
|
||||
(attacker as PlayerMobile).SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, true );
|
||||
playerMobile.SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, true );
|
||||
}
|
||||
else if ( Core.ML && attacker is BaseCreature )
|
||||
else if ( Core.ML && attacker is BaseCreature bc )
|
||||
{
|
||||
BaseCreature bc = attacker as BaseCreature;
|
||||
|
||||
if ( bc.ControlMaster is PlayerMobile )
|
||||
if ( bc.ControlMaster is PlayerMobile pm )
|
||||
{
|
||||
PlayerMobile pm = bc.ControlMaster as PlayerMobile;
|
||||
|
||||
pm.SetMountBlock(BlockMountType.DismountRecovery, RemountDelay, false );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ namespace Server.Items
|
|||
if ( map == null )
|
||||
return;
|
||||
|
||||
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
|
||||
|
||||
if ( weapon == null )
|
||||
if ( !(attacker.Weapon is BaseWeapon weapon) )
|
||||
return;
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
|
|
@ -88,9 +86,7 @@ namespace Server.Items
|
|||
Mobile m = (Mobile)targets[i];
|
||||
attacker.DoHarmful( m, true );
|
||||
|
||||
Timer t = Registry[m] as Timer;
|
||||
|
||||
if ( t != null )
|
||||
if ( Registry[m] is Timer t )
|
||||
{
|
||||
t.Stop();
|
||||
Registry.Remove( m );
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ namespace Server.Items
|
|||
|
||||
ClearCurrentAbility( attacker );
|
||||
|
||||
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
|
||||
|
||||
if ( weapon == null )
|
||||
if ( !(attacker.Weapon is BaseWeapon weapon) )
|
||||
return;
|
||||
|
||||
Poison p = weapon.Poison;
|
||||
|
|
|
|||
|
|
@ -40,9 +40,7 @@ namespace Server.Items
|
|||
|
||||
public override bool RequiresTactics( Mobile from )
|
||||
{
|
||||
BaseWeapon weapon = from.Weapon as BaseWeapon;
|
||||
|
||||
if ( weapon == null )
|
||||
if ( !(from.Weapon is BaseWeapon weapon) )
|
||||
return true;
|
||||
|
||||
return weapon.Skill != SkillName.Wrestling;
|
||||
|
|
|
|||
|
|
@ -85,9 +85,7 @@ namespace Server.Items
|
|||
|
||||
public virtual bool CheckWeaponSkill( Mobile from )
|
||||
{
|
||||
BaseWeapon weapon = from.Weapon as BaseWeapon;
|
||||
|
||||
if ( weapon == null )
|
||||
if ( !(from.Weapon is BaseWeapon weapon) )
|
||||
return false;
|
||||
|
||||
Skill skill = from.Skills[weapon.Skill];
|
||||
|
|
@ -141,7 +139,7 @@ namespace Server.Items
|
|||
|
||||
if ( from.Mana < mana )
|
||||
{
|
||||
if ( ( from is BaseCreature ) && ( from as BaseCreature ).HasManaOveride )
|
||||
if ( from is BaseCreature creature && creature.HasManaOveride )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -336,9 +334,7 @@ namespace Server.Items
|
|||
if ( !m.Player )
|
||||
return true;
|
||||
|
||||
BaseWeapon weapon = m.Weapon as BaseWeapon;
|
||||
|
||||
return ( weapon != null && (weapon.PrimaryAbility == a || weapon.SecondaryAbility == a) );
|
||||
return ( m.Weapon is BaseWeapon weapon && (weapon.PrimaryAbility == a || weapon.SecondaryAbility == a) );
|
||||
}
|
||||
|
||||
public virtual bool ValidatesDuringHit => true;
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ namespace Server.Items
|
|||
if ( map == null )
|
||||
return;
|
||||
|
||||
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
|
||||
|
||||
if ( weapon == null )
|
||||
if ( !(attacker.Weapon is BaseWeapon weapon) )
|
||||
return;
|
||||
|
||||
if ( !CheckMana( attacker, true ) )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue