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
|
|
@ -49,7 +49,7 @@ namespace Server.Items
|
|||
|
||||
public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
|
||||
{
|
||||
WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );
|
||||
// WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );
|
||||
|
||||
// Make sure we've been standing still for .25/.5/1 second depending on Era
|
||||
if (Core.TickCount - attacker.LastMoveTime >= (Core.SE ? 250 : Core.AOS ? 500 : 1000) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
|
||||
|
|
@ -62,17 +62,13 @@ namespace Server.Items
|
|||
|
||||
if ( canSwing )
|
||||
{
|
||||
Spell sp = attacker.Spell as Spell;
|
||||
|
||||
canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
|
||||
canSwing = ( !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement );
|
||||
}
|
||||
}
|
||||
|
||||
#region Dueling
|
||||
if ( attacker is PlayerMobile )
|
||||
if ( attacker is PlayerMobile pm )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)attacker;
|
||||
|
||||
if ( pm.DuelContext != null && !pm.DuelContext.CheckItemEquip( attacker, this ) )
|
||||
canSwing = false;
|
||||
}
|
||||
|
|
@ -104,7 +100,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
|
||||
public override void OnHit( Mobile attacker, Mobile defender, double damageBonus = 1)
|
||||
{
|
||||
if ( attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() )
|
||||
defender.AddToBackpack( Ammo );
|
||||
|
|
@ -134,21 +130,19 @@ namespace Server.Items
|
|||
{
|
||||
if ( Core.SE )
|
||||
{
|
||||
PlayerMobile p = attacker as PlayerMobile;
|
||||
|
||||
if ( p != null )
|
||||
if ( attacker is PlayerMobile pm )
|
||||
{
|
||||
Type ammo = AmmoType;
|
||||
|
||||
if ( p.RecoverableAmmo.ContainsKey( ammo ) )
|
||||
p.RecoverableAmmo[ ammo ]++;
|
||||
if ( pm.RecoverableAmmo.ContainsKey( ammo ) )
|
||||
pm.RecoverableAmmo[ ammo ]++;
|
||||
else
|
||||
p.RecoverableAmmo.Add( ammo, 1 );
|
||||
pm.RecoverableAmmo.Add( ammo, 1 );
|
||||
|
||||
if ( !p.Warmode )
|
||||
if ( !pm.Warmode )
|
||||
{
|
||||
if ( m_RecoveryTimer == null )
|
||||
m_RecoveryTimer = Timer.DelayCall( TimeSpan.FromSeconds( 10 ), new TimerCallback( p.RecoverAmmo ) );
|
||||
m_RecoveryTimer = Timer.DelayCall( TimeSpan.FromSeconds( 10 ), new TimerCallback( pm.RecoverAmmo ) );
|
||||
|
||||
if ( !m_RecoveryTimer.Running )
|
||||
m_RecoveryTimer.Start();
|
||||
|
|
|
|||
|
|
@ -47,9 +47,7 @@ namespace Server.Items
|
|||
|
||||
public void OnTargetGears( Mobile from, object targ )
|
||||
{
|
||||
Gears g = targ as Gears;
|
||||
|
||||
if ( g == null || !g.IsChildOf( from.Backpack ) )
|
||||
if ( !(targ is Gears g) || !g.IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.SendMessage( "Those are not gears." ); // Apparently gears that aren't in your backpack aren't really gears at all. :-(
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue