public virtual bool OnFired( Mobile attacker, Mobile defender )
{
Console.WriteLine("OnFired started.");
//--<<Advanced Archery Edit>>---------------------[Start 3/4]
PlayerMobile a_pm = attacker as PlayerMobile;
Container pack = attacker.Backpack;
BaseQuiver quiver = attacker.FindItemOnLayer( Layer.MiddleTorso ) as BaseQuiver;
BaseRangedModule module = this.BaseRangedModule;
if ( !module.HasBowString )
{
if ( DateTime.Now >= m_NextStringWarning )
{
m_NextStringWarning = DateTime.Now + StringWarningDelay;
attacker.SendMessage( "You need a string to use this bow. See a local fletcher to apply the string." );
return false;
}
else
{
Console.WriteLine("Returning false because {0}", "String is null");
return false;
}
}
if ( Ammo == null )
{
if ( DateTime.Now >= m_NextAmmoWarning )
{
m_NextAmmoWarning = DateTime.Now + AmmoWarningDelay;
attacker.SendMessage( "You are out of ammo." );
Console.WriteLine("Returning false because there is no ammo");
return false;
}
else
{
Console.WriteLine("Returning false because {0}", "Ammo is null");
return false;
}
}
if( attacker.Player && quiver != null && quiver.LowerAmmoCost > Utility.Random( 100 ) )
{
attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
Console.WriteLine("Returning true because quiver.lowerammocost.");
return true;
}
//NEWEST EDIT
if ( quiver != null )
{
Item[] typedItems = quiver.FindItemsByType( typeof( LightningArrow ), true );
Console.WriteLine("FindItemsByType was able to find {0} items.", typedItems.Length); //try Count if it doesn't compile
if ( typedItems.Length > 0 )
{
Console.WriteLine("The amount of the first item is: {0}", typedItems[0].Amount);
typedItems[0].Consume( 1 );
Console.WriteLine("The amount of the first item after consuming 1 is: {1}", typedItems[0].Amount);
}
}
else
{
Console.WriteLine("the quiver is null");
}
//end of change
if( attacker.Player &&
( quiver == null || !quiver.ConsumeTotal( AmmoType, 1 ) ) &&
( pack == null || !pack.ConsumeTotal( AmmoType, 1 ) ) )
Console.WriteLine("Returning false because not consuming");
return false;
//--<<Advanced Archery Edit>>---------------------[End 3/4]
if ( attacker.Player )
{
//BaseQuiver quiver = attacker.FindItemOnLayer( Layer.Cloak ) as BaseQuiver;
//Container pack = attacker.Backpack;
if ( quiver == null || Utility.Random( 100 ) >= quiver.LowerAmmoCost )
{
if ( quiver != null && quiver.ConsumeTotal( AmmoType, 1 ) )
quiver.InvalidateWeight();
else if ( pack == null || !pack.ConsumeTotal( AmmoType, 1 ) )
Console.WriteLine("returning false because quiver != null");
return false;
}
else if ( quiver.FindItemByType( AmmoType ) == null && ( pack == null || pack.FindItemByType( AmmoType ) == null ) )
{
// lower ammo cost should not work when we have no ammo at all
Console.WriteLine("returning false because ammo");
return false;
}
}
attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
Console.WriteLine("Returning true because Moving Effect");
return true;
}