Poseidon-Demonic Danger
Squire
Okay, so I've been working on this system for a while, trying to perfect it. The problem I'm having is, the new arrows won't fire from the quiver. I'm not exactly sure where to look for this. I've already modified the basequiver to allow the other arrows, but I'm not sure where it pulls the arrows from the quiver. Here's the basequiver:
Here is the baserange:
Thanks in advance!
Code:
using System;
using Server.Network;
using Server.Engines.Craft;
namespace Server.Items
{
public class BaseQuiver : Container, ICraftable
{
public override int DefaultGumpID{ get{ return 0x108; } }
public override int DefaultMaxItems{ get{ return 1; } }
public override int DefaultMaxWeight{ get{ return 50; } }
public override double DefaultWeight{ get{ return 2.0; } }
private AosAttributes m_Attributes;
private int m_Capacity;
private int m_LowerAmmoCost;
private int m_WeightReduction;
private int m_DamageIncrease;
[CommandProperty( AccessLevel.GameMaster)]
public AosAttributes Attributes
{
get{ return m_Attributes; }
set{}
}
[CommandProperty( AccessLevel.GameMaster)]
public int Capacity
{
get{ return m_Capacity; }
set{ m_Capacity = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster)]
public int LowerAmmoCost
{
get{ return m_LowerAmmoCost; }
set{ m_LowerAmmoCost = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster)]
public int WeightReduction
{
get{ return m_WeightReduction; }
set{ m_WeightReduction = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster)]
public int DamageIncrease
{
get{ return m_DamageIncrease; }
set{ m_DamageIncrease = value; InvalidateProperties(); }
}
private Mobile m_Crafter;
private ClothingQuality m_Quality;
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Crafter
{
get{ return m_Crafter; }
set{ m_Crafter = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public ClothingQuality Quality
{
get{ return m_Quality; }
set{ m_Quality = value; InvalidateProperties(); }
}
public Item Ammo
{
get{ return Items.Count > 0 ? Items[ 0 ] : null; }
}
public BaseQuiver() : this( 0x2FB7 )
{
}
public BaseQuiver( int itemID ) : base( itemID )
{
Weight = 2.0;
Capacity = 500;
Layer = Layer.Cloak;
m_Attributes = new AosAttributes( this );
DamageIncrease = 10;
}
public BaseQuiver( Serial serial ) : base( serial )
{
}
public override void OnAfterDuped( Item newItem )
{
BaseQuiver quiver = newItem as BaseQuiver;
if ( quiver == null )
return;
quiver.m_Attributes = new AosAttributes( newItem, m_Attributes );
}
public override void UpdateTotal( Item sender, TotalType type, int delta )
{
InvalidateProperties();
base.UpdateTotal(sender, type, delta);
}
public override int GetTotal( TotalType type )
{
int total = base.GetTotal( type );
if ( type == TotalType.Weight )
total -= total * m_WeightReduction / 100;
return total;
}
private static Type[] m_Ammo = new Type[]
{
typeof( Arrow ), typeof( Bolt ), typeof( ArmorPiercingArrow ), typeof( ExplosiveArrow ), typeof( FreezeArrow ), typeof( LightningArrow ), typeof( PoisonArrow ), typeof( ArmorPiercingBolt ), typeof( ExplosiveBolt ), typeof( FreezeBolt ), typeof( LightningBolt ), typeof( PoisonBolt )
};
public bool CheckType( Item item )
{
Type type = item.GetType();
Item ammo = Ammo;
if ( ammo != null )
{
if ( ammo.GetType() == type )
return true;
}
else
{
for ( int i = 0; i < m_Ammo.Length; i++ )
{
if ( type == m_Ammo[ i ] )
return true;
}
}
return false;
}
public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
{
if ( !CheckType( item ) )
{
if ( message )
m.SendLocalizedMessage( 1074836 ); // The container can not hold that type of object.
return false;
}
if ( Items.Count < DefaultMaxItems )
{
if ( item.Amount <= m_Capacity )
return base.CheckHold( m, item, message, checkItems, plusItems, plusWeight );
return false;
}
else if ( checkItems )
return false;
Item ammo = Ammo;
if ( ammo == null || ammo.Deleted )
return false;
if ( ammo.Amount + item.Amount <= m_Capacity )
return true;
return false;
}
public override void AddItem( Item dropped )
{
base.AddItem( dropped );
InvalidateWeight();
}
public override void RemoveItem( Item dropped )
{
base.RemoveItem( dropped );
InvalidateWeight();
}
public override void OnAdded( object parent )
{
if ( parent is Mobile )
{
Mobile mob = (Mobile) parent;
m_Attributes.AddStatBonuses( mob );
}
}
public override void OnRemoved( object parent )
{
if ( parent is Mobile )
{
Mobile mob = (Mobile) parent;
m_Attributes.RemoveStatBonuses( mob );
}
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( m_Crafter != null )
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
if ( m_Quality == ClothingQuality.Exceptional )
list.Add( 1063341 ); // exceptional
Item ammo = Ammo;
if ( ammo != null )
{
if ( ammo is Arrow )
list.Add( 1075265, "{0}\t{1}", ammo.Amount, Capacity ); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows
else if ( ammo is Bolt )
list.Add( 1075266, "{0}\t{1}", ammo.Amount, Capacity ); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ bolts
}
else
list.Add( 1075265, "{0}\t{1}", 0, Capacity ); // Ammo: ~1_QUANTITY~/~2_CAPACITY~ arrows
int prop;
if ( (prop = m_DamageIncrease) != 0 )
list.Add( 1074762, prop.ToString() ); // Damage modifier: ~1_PERCENT~%
int phys, fire, cold, pois, nrgy, chaos, direct;
phys = fire = cold = pois = nrgy = chaos = direct = 0;
AlterBowDamage( ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct );
if ( phys != 0 )
list.Add( 1060403, phys.ToString() ); // physical damage ~1_val~%
if ( fire != 0 )
list.Add( 1060405, fire.ToString() ); // fire damage ~1_val~%
if ( cold != 0 )
list.Add( 1060404, cold.ToString() ); // cold damage ~1_val~%
if ( pois != 0 )
list.Add( 1060406, pois.ToString() ); // poison damage ~1_val~%
if ( nrgy != 0 )
list.Add( 1060407, nrgy.ToString() ); // energy damage ~1_val
if ( chaos != 0 )
list.Add( 1072846, chaos.ToString() ); // chaos damage ~1_val~%
if ( direct != 0 )
list.Add( 1079978, direct.ToString() ); // Direct Damage: ~1_PERCENT~%
list.Add( 1075085 ); // Requirement: Mondain's Legacy
if ( (prop = m_Attributes.DefendChance) != 0 )
list.Add( 1060408, prop.ToString() ); // defense chance increase ~1_val~%
if ( (prop = m_Attributes.BonusDex) != 0 )
list.Add( 1060409, prop.ToString() ); // dexterity bonus ~1_val~
if ( (prop = m_Attributes.EnhancePotions) != 0 )
list.Add( 1060411, prop.ToString() ); // enhance potions ~1_val~%
if ( (prop = m_Attributes.CastRecovery) != 0 )
list.Add( 1060412, prop.ToString() ); // faster cast recovery ~1_val~
if ( (prop = m_Attributes.CastSpeed) != 0 )
list.Add( 1060413, prop.ToString() ); // faster casting ~1_val~
if ( (prop = m_Attributes.AttackChance) != 0 )
list.Add( 1060415, prop.ToString() ); // hit chance increase ~1_val~%
if ( (prop = m_Attributes.BonusHits) != 0 )
list.Add( 1060431, prop.ToString() ); // hit point increase ~1_val~
if ( (prop = m_Attributes.BonusInt) != 0 )
list.Add( 1060432, prop.ToString() ); // intelligence bonus ~1_val~
if ( (prop = m_Attributes.LowerManaCost) != 0 )
list.Add( 1060433, prop.ToString() ); // lower mana cost ~1_val~%
if ( (prop = m_Attributes.LowerRegCost) != 0 )
list.Add( 1060434, prop.ToString() ); // lower reagent cost ~1_val~%
if ( (prop = m_Attributes.Luck) != 0 )
list.Add( 1060436, prop.ToString() ); // luck ~1_val~
if ( (prop = m_Attributes.BonusMana) != 0 )
list.Add( 1060439, prop.ToString() ); // mana increase ~1_val~
if ( (prop = m_Attributes.RegenMana) != 0 )
list.Add( 1060440, prop.ToString() ); // mana regeneration ~1_val~
if ( (prop = m_Attributes.NightSight) != 0 )
list.Add( 1060441 ); // night sight
if ( (prop = m_Attributes.ReflectPhysical) != 0 )
list.Add( 1060442, prop.ToString() ); // reflect physical damage ~1_val~%
if ( (prop = m_Attributes.RegenStam) != 0 )
list.Add( 1060443, prop.ToString() ); // stamina regeneration ~1_val~
if ( (prop = m_Attributes.RegenHits) != 0 )
list.Add( 1060444, prop.ToString() ); // hit point regeneration ~1_val~
if ( (prop = m_Attributes.SpellDamage) != 0 )
list.Add( 1060483, prop.ToString() ); // spell damage increase ~1_val~%
if ( (prop = m_Attributes.BonusStam) != 0 )
list.Add( 1060484, prop.ToString() ); // stamina increase ~1_val~
if ( (prop = m_Attributes.BonusStr) != 0 )
list.Add( 1060485, prop.ToString() ); // strength bonus ~1_val~
if ( (prop = m_Attributes.WeaponSpeed) != 0 )
list.Add( 1060486, prop.ToString() ); // swing speed increase ~1_val~%
if ( (prop = m_LowerAmmoCost) > 0 )
list.Add( 1075208, prop.ToString() ); // Lower Ammo Cost ~1_Percentage~%
double weight = 0;
if ( ammo != null )
weight = ammo.Weight * ammo.Amount;
list.Add( 1072241, "{0}\t{1}\t{2}\t{3}", Items.Count, DefaultMaxItems, (int) weight, DefaultMaxWeight ); // Contents: ~1_COUNT~/~2_MAXCOUNT items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones
if ( (prop = m_WeightReduction) != 0 )
list.Add( 1072210, prop.ToString() ); // Weight reduction: ~1_PERCENTAGE~%
}
private static void SetSaveFlag( ref SaveFlag flags, SaveFlag toSet, bool setIf )
{
if ( setIf )
flags |= toSet;
}
private static bool GetSaveFlag( SaveFlag flags, SaveFlag toGet )
{
return ( (flags & toGet) != 0 );
}
[Flags]
private enum SaveFlag
{
None = 0x00000000,
Attributes = 0x00000001,
DamageModifier = 0x00000002,
LowerAmmoCost = 0x00000004,
WeightReduction = 0x00000008,
Crafter = 0x00000010,
Quality = 0x00000020,
Capacity = 0x00000040,
DamageIncrease = 0x00000080
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // version
SaveFlag flags = SaveFlag.None;
SetSaveFlag( ref flags, SaveFlag.Attributes, !m_Attributes.IsEmpty );
SetSaveFlag( ref flags, SaveFlag.LowerAmmoCost, m_LowerAmmoCost != 0 );
SetSaveFlag( ref flags, SaveFlag.WeightReduction, m_WeightReduction != 0 );
SetSaveFlag( ref flags, SaveFlag.DamageIncrease, m_DamageIncrease != 0 );
SetSaveFlag( ref flags, SaveFlag.Crafter, m_Crafter != null );
SetSaveFlag( ref flags, SaveFlag.Quality, true );
SetSaveFlag( ref flags, SaveFlag.Capacity, m_Capacity > 0 );
writer.WriteEncodedInt( (int) flags );
if ( GetSaveFlag( flags, SaveFlag.Attributes ) )
m_Attributes.Serialize( writer );
if ( GetSaveFlag( flags, SaveFlag.LowerAmmoCost ) )
writer.Write( (int) m_LowerAmmoCost );
if ( GetSaveFlag( flags, SaveFlag.WeightReduction ) )
writer.Write( (int) m_WeightReduction );
if ( GetSaveFlag( flags, SaveFlag.DamageIncrease ) )
writer.Write( (int) m_DamageIncrease );
if ( GetSaveFlag( flags, SaveFlag.Crafter ) )
writer.Write( (Mobile) m_Crafter );
if ( GetSaveFlag( flags, SaveFlag.Quality ) )
writer.Write( (int) m_Quality );
if ( GetSaveFlag( flags, SaveFlag.Capacity ) )
writer.Write( (int) m_Capacity );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
SaveFlag flags = (SaveFlag) reader.ReadEncodedInt();
if ( GetSaveFlag( flags, SaveFlag.Attributes ) )
m_Attributes = new AosAttributes( this, reader );
else
m_Attributes = new AosAttributes( this );
if ( GetSaveFlag( flags, SaveFlag.LowerAmmoCost ) )
m_LowerAmmoCost = reader.ReadInt();
if ( GetSaveFlag( flags, SaveFlag.WeightReduction ) )
m_WeightReduction = reader.ReadInt();
if ( GetSaveFlag( flags, SaveFlag.DamageIncrease ) )
m_DamageIncrease = reader.ReadInt();
if ( GetSaveFlag( flags, SaveFlag.Crafter ) )
m_Crafter = reader.ReadMobile();
if ( GetSaveFlag( flags, SaveFlag.Quality ) )
m_Quality = (ClothingQuality) reader.ReadInt();
if ( GetSaveFlag( flags, SaveFlag.Capacity ) )
m_Capacity = reader.ReadInt();
}
public virtual void AlterBowDamage( ref int phys, ref int fire, ref int cold, ref int pois, ref int nrgy, ref int chaos, ref int direct )
{
}
public void InvalidateWeight()
{
if ( RootParent is Mobile )
{
Mobile m = (Mobile) RootParent;
m.UpdateTotals();
}
}
#region ICraftable
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
{
Quality = (ClothingQuality) quality;
if ( makersMark )
Crafter = from;
return quality;
}
#endregion
}
}
Code:
using System;
using Server.Items;
using Server.Network;
using Server.Spells;
using Server.Mobiles;
using Server.Targeting;
using System.Collections;
using System.Collections.Generic;
using Server.Enums;
using Server.ACC.CM;
using Server.LucidNagual;
namespace Server.Items
{
public abstract class BaseRanged : BaseMeleeWeapon
{
//--<<Advanced Archery Edit>>---------------------[Start 1/4]
//SkillModule edit.
private BaseRangedModule m_BaseRangedModule;
[CommandProperty( AccessLevel.GameMaster )]
public BaseRangedModule BaseRangedModule
{
get
{
BaseRangedModule existingModule = ( BaseRangedModule )CentralMemory.GetModule( this.Serial, typeof( BaseRangedModule ) );
if ( existingModule == null )
{
BaseRangedModule module = new BaseRangedModule( this.Serial );
CentralMemory.AppendModule( this.Serial, module, true );
return ( m_BaseRangedModule = module as BaseRangedModule );
}
else
{
if ( m_BaseRangedModule != null )
return m_BaseRangedModule;
return ( m_BaseRangedModule = existingModule as BaseRangedModule );
}
}
}
//SkillModule edit.
public static int PlayerFreezeTimer = 2;
public static int NPCFreezeTimer = 2;
private bool m_IsLevelable;
[CommandProperty( AccessLevel.GameMaster )]
public ArrowType ArrowSelection { get { return m_BaseRangedModule.ArrowSelection; } set { m_BaseRangedModule.ArrowSelection = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public BoltType BoltSelection { get { return m_BaseRangedModule.BoltSelection; } set { m_BaseRangedModule.BoltSelection = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public StringStrength StringStrengthSelection { get { return m_BaseRangedModule.StringStrengthSelection; } set { m_BaseRangedModule.StringStrengthSelection = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public PoundsPerPull PullWeightSelection { get { return m_BaseRangedModule.PullWeightSelection; } set { m_BaseRangedModule.PullWeightSelection = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public bool HasBowString { get{ return m_BaseRangedModule.HasBowString; } set{ m_BaseRangedModule.HasBowString = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public bool IsLevelable { get{ return m_IsLevelable; } set{ m_IsLevelable = value; } }
private static Mobile m_Mobile;
private static BaseRanged BRanged;
public static TimeSpan StringWarningDelay = TimeSpan.FromSeconds( 10.0 );
public static DateTime m_NextStringWarning;
public static TimeSpan AmmoWarningDelay = TimeSpan.FromSeconds( 10.0 );
public static DateTime m_NextAmmoWarning;
//--<<Advanced Archery Edit>>---------------------[End 1/4]
public abstract int EffectID{ get; }
public abstract Type AmmoType{ get; }
public abstract Item Ammo{ get; }
public override int DefHitSound{ get{ return 0x234; } }
public override int DefMissSound{ get{ return 0x238; } }
public override SkillName DefSkill{ get{ return SkillName.Archery; } }
public override WeaponType DefType{ get{ return WeaponType.Ranged; } }
public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootXBow; } }
public override SkillName AccuracySkill{ get{ return SkillName.Archery; } }
private Timer m_RecoveryTimer; // so we don't start too many timers
private bool m_Balanced;
private int m_Velocity;
[CommandProperty( AccessLevel.GameMaster )]
public bool Balanced
{
get{ return m_Balanced; }
set{ m_Balanced = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public int Velocity
{
get{ return m_Velocity; }
set{ m_Velocity = value; InvalidateProperties(); }
}
public BaseRanged( int itemID ) : base( itemID )
{
}
public BaseRanged( Serial serial ) : base( serial )
{
}
public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
{
WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );
// Make sure we've been standing still for .25/.5/1 second depending on Era
if ( DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds( Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0) )) || (Core.AOS && WeaponAbility.GetCurrentAbility( attacker ) is MovingShot) )
{
bool canSwing = true;
if ( Core.AOS )
{
canSwing = ( !attacker.Paralyzed && !attacker.Frozen );
if ( canSwing )
{
Spell sp = attacker.Spell as Spell;
canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
}
}
#region Dueling
if ( attacker is PlayerMobile )
{
PlayerMobile pm = (PlayerMobile)attacker;
if ( pm.DuelContext != null && !pm.DuelContext.CheckItemEquip( attacker, this ) )
canSwing = false;
}
#endregion
if ( canSwing && attacker.HarmfulCheck( defender ) )
{
attacker.DisruptiveAction();
attacker.Send( new Swing( 0, attacker, defender ) );
if ( OnFired( attacker, defender ) )
{
if ( CheckHit( attacker, defender ) )
OnHit( attacker, defender );
else
OnMiss( attacker, defender );
}
}
attacker.RevealingAction();
return GetDelay( attacker );
}
else
{
attacker.RevealingAction();
return TimeSpan.FromSeconds( 0.25 );
}
}
public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
{
//--<<Advanced Archery Edit>>---------------------[Start 2/4]
if ( attacker == null || defender == null )
return;
MoreBaseRanged.CustomAmmoCheck( attacker, defender, AmmoType );
if ( Ammo == null )
attacker.SendMessage( "You are out of arrows, or may have to choose a different type of arrow by double clicking the bow." );
//--<<Advanced Archery Edit>>---------------------[End 2/4]
if ( attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() )
defender.AddToBackpack( Ammo );
if ( Core.ML && m_Velocity > 0 )
{
int bonus = (int) attacker.GetDistanceToSqrt( defender );
if ( bonus > 0 && m_Velocity > Utility.Random( 100 ) )
{
AOS.Damage( defender, attacker, bonus * 3, 100, 0, 0, 0, 0 );
if ( attacker.Player )
attacker.SendLocalizedMessage( 1072794 ); // Your arrow hits its mark with velocity!
if ( defender.Player )
defender.SendLocalizedMessage( 1072795 ); // You have been hit by an arrow with velocity!
}
}
base.OnHit( attacker, defender, damageBonus );
}
public override void OnMiss( Mobile attacker, Mobile defender )
{
if ( attacker.Player && 0.4 >= Utility.RandomDouble() )
{
if ( Core.SE )
{
PlayerMobile p = attacker as PlayerMobile;
if ( p != null )
{
Type ammo = AmmoType;
if ( p.RecoverableAmmo.ContainsKey( ammo ) )
p.RecoverableAmmo[ ammo ]++;
else
p.RecoverableAmmo.Add( ammo, 1 );
if ( !p.Warmode )
{
if ( m_RecoveryTimer == null )
m_RecoveryTimer = Timer.DelayCall( TimeSpan.FromSeconds( 10 ), new TimerCallback( p.RecoverAmmo ) );
if ( !m_RecoveryTimer.Running )
m_RecoveryTimer.Start();
}
}
} else {
Ammo.MoveToWorld( new Point3D( defender.X + Utility.RandomMinMax( -1, 1 ), defender.Y + Utility.RandomMinMax( -1, 1 ), defender.Z ), defender.Map );
}
}
base.OnMiss( attacker, defender );
}
public virtual bool OnFired( Mobile attacker, Mobile defender )
{
//--<<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
return false;
}
if ( Ammo == null )
{
if ( DateTime.Now >= m_NextAmmoWarning )
{
m_NextAmmoWarning = DateTime.Now + AmmoWarningDelay;
attacker.SendMessage( "You are out of ammo." );
return false;
}
else
return false;
}
if( attacker.Player && quiver != null && quiver.LowerAmmoCost > Utility.Random( 100 ) )
{
attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
return true;
}
if( attacker.Player &&
( quiver == null || !quiver.ConsumeTotal( AmmoType, 1 ) ) &&
( pack == null || !pack.ConsumeTotal( AmmoType, 1 ) ) )
return false;
attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
return true;
//--<<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 )
{
// consume ammo
if ( quiver != null && quiver.ConsumeTotal( AmmoType, 1 ) )
quiver.InvalidateWeight();
else if ( pack == null || !pack.ConsumeTotal( AmmoType, 1 ) )
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
return false;
}
}
attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
return true;
}
//--<<Advanced Archery Edit>>---------------------[Start 4/4]
public override void OnDoubleClick( Mobile from )
{
BaseRangedModule module = this.BaseRangedModule;
if ( IsChildOf( from.Backpack ) || Parent == from )
{
if ( module.HasBowString )
{
if ( this is Bow || this is CompositeBow || this is ElvenCompositeLongbow ||
this is MagicalShortbow || this is Yumi )
{
from.SendMessage( "Please choose which type of arrows you wish to use." );
from.Target = new BowTarget( this );
}
if ( this is Crossbow || this is HeavyCrossbow || this is RepeatingCrossbow )
{
from.SendMessage( "Please choose which type of bolts you wish to use." );
from.Target = new CrossbowTarget( this );
}
}
else
{
from.SendMessage( "You must string your bow. Please select a bow stringer." );
from.Target = new StringerTarget( this );
}
}
else
return;
}
/*public override void OnDelete()
{
BaseRangedModule module = this.BaseRangedModule;
if ( module != null )
module.Delete();
base.OnDelete();
}*/
public override bool OnEquip( Mobile from )
{
m_Mobile = from;
return true;
}
public override bool CanEquip( Mobile from )
{
BaseRangedModule module = this.BaseRangedModule;
if ( from != null && !module.HasBowString )
{
from.SendMessage( "You cannot use that without a string." );
return false;
}
base.CanEquip( from );
return true;
}
public virtual Item AmmoArrowSelected()
{
BaseRangedModule module = this.BaseRangedModule;
switch ( module.m_ArrowType )
{
case ArrowType.Normal:
return new Arrow();
case ArrowType.Poison:
return new PoisonArrow();
case ArrowType.Explosive:
return new ExplosiveArrow();
case ArrowType.ArmorPiercing:
return new ArmorPiercingArrow();
case ArrowType.Freeze:
return new FreezeArrow();
case ArrowType.Lightning:
return new LightningArrow();
default:
return new Arrow();
}
}
public virtual Type GetArrowSelected()
{
BaseRangedModule module = this.BaseRangedModule;
switch ( module.m_ArrowType )
{
case ArrowType.Normal:
return typeof( Arrow );
case ArrowType.Poison:
return typeof( PoisonArrow );
case ArrowType.Explosive:
return typeof( ExplosiveArrow );
case ArrowType.ArmorPiercing:
return typeof( ArmorPiercingArrow );
case ArrowType.Freeze:
return typeof( FreezeArrow );
case ArrowType.Lightning:
return typeof( LightningArrow );
default:
return typeof( Arrow );
}
}
public virtual Item AmmoBoltSelected()
{
BaseRangedModule module = this.BaseRangedModule;
switch ( module.m_BoltType )
{
case BoltType.Normal:
return new Bolt();
case BoltType.Poison:
return new PoisonBolt();
case BoltType.Explosive:
return new ExplosiveBolt();
case BoltType.ArmorPiercing:
return new ArmorPiercingBolt();
case BoltType.Freeze:
return new FreezeBolt();
case BoltType.Lightning:
return new LightningBolt();
default:
return new Bolt();
}
}
public virtual Type GetBoltSelected()
{
BaseRangedModule module = this.BaseRangedModule;
switch ( module.m_BoltType )
{
case BoltType.Normal:
return typeof( Bolt );
case BoltType.Poison:
return typeof( PoisonBolt );
case BoltType.Explosive:
return typeof( ExplosiveBolt );
case BoltType.ArmorPiercing:
return typeof( ArmorPiercingBolt );
case BoltType.Freeze:
return typeof( FreezeBolt );
case BoltType.Lightning:
return typeof( LightningBolt );
default:
return typeof( Bolt );
}
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties(list);
BaseRangedModule module = this.BaseRangedModule;
if ( module != null )
{
ArrayList strings = new ArrayList();
strings.Add( ( "---------------" ) );
if ( this is Bow || this is CompositeBow || this is ElvenCompositeLongbow ||
this is MagicalShortbow || this is Yumi )
{
strings.Add( ( "Quiver Using: " + module.m_ArrowType ) );
}
if ( this is Crossbow || this is HeavyCrossbow || this is RepeatingCrossbow )
{
strings.Add( ( "Quiver Using: " + module.m_BoltType ) );
}
strings.Add( ( "lbs per Pull: " + module.m_PullWeight ) );
strings.Add( ( "String Str: " + module.m_Strength ) );
string toAdd = "";
int amount = strings.Count;
int current = 1;
foreach ( string str in strings )
{
toAdd += str;
if ( current != amount )
toAdd += "\n";
++current;
}
if ( toAdd != "" )
list.Add( 1070722, toAdd );
}
else
{
return;
}
}
//--<<Advanced Archery Edit>>---------------------[End 4/4]
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 3 ); // version
writer.Write( (bool) m_Balanced );
writer.Write( (int) m_Velocity );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 3:
{
m_Balanced = reader.ReadBool();
m_Velocity = reader.ReadInt();
goto case 2;
}
case 2:
case 1:
{
break;
}
case 0:
{
/*m_EffectID =*/ reader.ReadInt();
break;
}
}
if ( version < 2 )
{
WeaponAttributes.MageWeapon = 0;
WeaponAttributes.UseBestSkill = 0;
}
}
}
}