RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Lucid's Advanced Archery - strings don't break

MooJohn

Sorceror
Our shard runs 2.0 RC1 and has run this script from Lucid since it was released. AFAIK it is the latest version of the Advanced Archery that was released. All aspects of it work fine -- bow stringers can be applied and removed, custom ammo & quivers work -- except the bow strings never break. My very basic coding skill says it's because the routines are never called. I just don't know the proper way to call them. I assume it would be done in the OnSwing section of BaseRanged.cs.

Damage bonus from stronger stringers never happens either - again because it's never called. This should happen sometime in the OnHit part of BaseRanged.cs, right?

BaseRanged.cs
Code:
/*
    _________________________________
 -=(_)_______________________________)=-
   /   .   .   . ____  . ___      _/
  /~ /    /   / /     / /   )2006 /
 (~ (____(___/ (____ / /___/     (
  \ ----------------------------- \
   \    [email protected]    \
    \_     ===================      \
     \   -Owner of "The Conjuring"-  \
      \_     ===================     ~\
       )      Lucid's Mega Pack        )
      /~    The Mother Load v1.1     _/
    _/_______________________________/
 -=(_)_______________________________)=-

 */
using System;
using Server.Items;
using Server.Network;
using Server.Spells;
using Server.Mobiles;
using Server.Targeting;
using System.Collections;
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; } }
        
        public BaseRanged( int itemID ) : base( itemID )
        {
        }
        
        public BaseRanged( Serial serial ) : base( serial )
        {
            BRanged = this;
        }
        
        public static void Initialize()
        {
            Mobile from = m_Mobile;
            //Mobile m = (Mobile)parent;
            //BaseWeapon weapon = m.Weapon as BaseWeapon;
        }
        
        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 );
                    }
                }
                
                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 )
        {
            //--<<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 );
            
            base.OnHit( attacker, defender );
        }
        
        public override void OnMiss( Mobile attacker, Mobile defender )
        {
            if ( attacker.Player && 0.4 >= Utility.RandomDouble() )
                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.Unused_xF) 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;
            */

            //only consume ammo if you're a player - monster archers have unlimited ammo
            if (attacker.Player)
            {
                //if they don't have a backpack, or they don't have arrows/bolts in their pack, or they dont have arrows/bolts in
                //their keys, then return false

                if ((pack == null || (!pack.ConsumeTotal(AmmoType, 1))) && (!BaseStoreKey.Consume(pack, AmmoType, 1)) && (quiver == null || !quiver.ConsumeTotal(AmmoType, 1)))
                {
                    return false;
                }
            }
            //---------------------------------------------------- BaseStoreKey ammo END-----------------------------------
            
            attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
            return true;
            //--<<Advanced Archery Edit>>---------------------[End 3/4]
        }
        
        //--<<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) 2 ); // version
        }
        
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
            int version = reader.ReadInt();
            
            switch ( version )
            {
                case 2:
                case 1:
                    {
                        break;
                    }
                case 0:
                    {
                        /*m_EffectID =*/ reader.ReadInt();
                        break;
                    }
            }
            
            if ( version < 2 )
            {
                WeaponAttributes.MageWeapon = 0;
                WeaponAttributes.UseBestSkill = 0;
            }
        }
    }
}

MoreBaseRanged.cs

Code:
/*
    _________________________________
 -=(_)_______________________________)=-
   /   .   .   . ____  . ___      _/
  /~ /    /   / /     / /   )2007 /
 (~ (____(___/ (____ / /___/     (
  \ ----------------------------- \
   \    [email protected]    \
    \_     ===================      \
     \   -Owner of "The Conjuring"-  \
      \_     ===================     ~\
       )      Lucid's Mega Pack        )
      /~    The Mother Load v1.1     _/
    _/_______________________________/
 -=(_)_______________________________)=-

 */
using System;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.ACC.CM;
using Server.Enums;
using Server.LucidNagual;
using System.Collections;
//using Server.LevelSystem;


namespace Server.LucidNagual
{
    public class MoreBaseRanged
    {
        public static readonly TimeSpan PlayerFreezeDuration = TimeSpan.FromSeconds( BaseRanged.PlayerFreezeTimer );
        public static readonly TimeSpan NPCFreezeDuration = TimeSpan.FromSeconds( BaseRanged.NPCFreezeTimer );
        
        public static void CustomAmmoCheck( Mobile attacker, Mobile defender, Type AmmoType )
        {
            double archery = attacker.Skills[ SkillName.Archery ].Value;
            double dice = Utility.RandomDouble();
            
            //Poison ammo.
            if ( AmmoType == typeof( PoisonArrow ) || AmmoType == typeof( PoisonArrow ) )
            {
                if( archery >= 120 )
                {
                    if ( 0.20 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 4 );

                    if ( 0.40 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 3 );
                    
                    if ( 0.70 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 2 );
                }
                
                else if( archery >= 100 )
                {
                    if ( 0.10 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 4 );

                    if ( 0.30 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 3 );
                    
                    if ( 0.60 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 2 );
                }
                
                else if( archery >= 70 )
                {
                    if ( 0.10 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 3 );
                    
                    if ( 0.30 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 2 );
                    
                    if ( 0.60 > Utility.RandomDouble() )
                        DoPoisonEffect( defender, 1 );
                }
                
                else if( archery >= 50 )
                {
                    switch ( Utility.Random( 2 ) )
                    {
                            case 0: DoPoisonEffect( defender, 2 ); break;
                            case 1: DoPoisonEffect( defender, 1 ); break;
                    }
                }
                
                if( archery < 50 )
                    DoPoisonEffect( defender, 1 );
            }
            
            //Explosive ammo.
            if ( AmmoType == typeof( ExplosiveArrow ) || AmmoType == typeof( ExplosiveBolt ) )
            {
                if( archery >= 120 )
                    DoExplosiveEffect( attacker, defender, 20, 30 );
                
                if( archery >= 100 )
                    DoExplosiveEffect( attacker, defender, 14, 28 );
                
                if( attacker.Skills[SkillName.Archery].Value < 100 )
                    DoExplosiveEffect( attacker, defender, 5, 20 );
            }
            
            //Piercing ammo.
            if ( AmmoType == typeof( ArmorPiercingArrow ) || AmmoType == typeof( ArmorPiercingBolt ) )
            {
                if( archery >= 120 )
                    DoPiercingEffect( attacker, defender, 20, 30 );
                
                if( attacker.Skills[SkillName.Archery].Value >= 100 )
                    DoPiercingEffect( attacker, defender, 14, 28 );
                
                if( attacker.Skills[SkillName.Archery].Value < 100 )
                    DoPiercingEffect( attacker, defender, 5, 20 );
            }

            //Freeze ammo.
            if ( AmmoType == typeof( FreezeArrow ) || AmmoType == typeof( FreezeBolt ) )
            {
                if( archery >= 120 )
                    DoFreezeEffect( attacker, defender, 20, 30 );
                
                if( archery >= 100 )
                    DoFreezeEffect( attacker, defender, 14, 28 );
                
                if( archery < 100 )
                    DoFreezeEffect( attacker, defender, 5, 20 );
            }

            //Lightning ammo.
            if ( AmmoType == typeof( LightningArrow ) || AmmoType == typeof( LightningBolt ) )
            {
                if( archery >= 120 )
                    DoLightningEffect( attacker, defender, 20, 30 );
                
                if( archery >= 100 )
                    DoLightningEffect( attacker, defender, 14, 28 );
                
                if( archery < 100 )
                    DoLightningEffect( attacker, defender, 5, 20 );
            }
        }
        
        public static void DoPoisonEffect( Mobile defender, int code )
        {
            defender.FixedParticles( 0x3728, 200, 25, 69, EffectLayer.Waist );
            
            if ( code == 1 ) //Lesser.
                defender.ApplyPoison( defender, Poison.Lesser );
            
            if ( code == 2 ) //Regular.
                defender.ApplyPoison( defender, Poison.Regular );
            
            if ( code == 3 ) //Greater.
                defender.ApplyPoison( defender, Poison.Greater );
            
            if ( code == 4 ) //Deadly.
                defender.ApplyPoison( defender, Poison.Deadly );
        }
        
        public static void DoExplosiveEffect( Mobile attacker, Mobile defender, int min, int max )
        {
            defender.FixedParticles( 0x36BD, 20, 10, 5044, EffectLayer.Waist );
            defender.PlaySound( 0x307 );
            attacker.DoHarmful( defender );
            AOS.Damage( defender, attacker, Utility.RandomMinMax( min, max ), 0, 100, 0, 0, 0 );
        }
        
        public static void DoPiercingEffect( Mobile attacker, Mobile defender, int min, int max )
        {
            defender.FixedParticles( 0x3728, 200, 25, 9942, EffectLayer.Waist );
            defender.PlaySound( 0x56 );
            attacker.DoHarmful( defender );
            AOS.Damage( defender, attacker, Utility.RandomMinMax( min, max ), 100, 0, 0, 0, 0 );
        }
        
        public static void DoFreezeEffect( Mobile attacker, Mobile defender, int min, int max )
        {
            defender.PlaySound( 0x204 );
            defender.Freeze( defender.Player ? PlayerFreezeDuration : NPCFreezeDuration );
            defender.FixedEffect( 0x376A, 9, 32 );
            attacker.DoHarmful( defender );
            AOS.Damage( defender, attacker, Utility.RandomMinMax( min, max ), 0, 0, 100, 0, 0 );
        }
        
        public static void DoLightningEffect( Mobile attacker, Mobile defender, int min, int max )
        {
            defender.PlaySound( 1471 );
            defender.BoltEffect( 1153 );
            attacker.DoHarmful( defender );
            AOS.Damage( defender, attacker, Utility.RandomMinMax( min, max ), 0, 0, 0, 0, 100 );
        }
        
        public virtual void DoDamage( Mobile attacker, Mobile defender, int min, int max )
        {
            attacker.DoHarmful( defender );
            AOS.Damage( defender, attacker, Utility.RandomMinMax( min, max ), 100, 0, 0, 0, 0 );
        }
        
        public virtual bool CheckStringDamage( Mobile attacker, Mobile defender, BaseRanged ranged )
        {

            Console.WriteLine("Making it to base ranged module");

            BaseRangedModule module = ranged.BaseRangedModule;



            if ( module.HasBowString )
            {
                if ( module.StringStrengthSelection == StringStrength.VeryWeak )
                {
                    if ( .05 > Utility.Random( 100 ) )
                    {
                        BonusDamage( attacker, defender, ranged );
                        return true;
                    }
                    if ( .10 > Utility.Random( 1000 ) ) //1 in a 100 chances of breaking.
                    {
                        module.HasBowString = false;
                        module.StringStrengthSelection = StringStrength.NoString;
                        attacker.SendMessage( "Your string just broke." );
                    }
                    return true;
                }
                else if ( module.StringStrengthSelection == StringStrength.Weak )
                {
                    if ( .10 > Utility.Random( 100 ) )
                    {
                        BonusDamage( attacker, defender, ranged );
                        return true;
                    }
                    if ( .09 > Utility.Random( 1000 ) ) //1 in a 110 chances of breaking.
                    {
                        module.HasBowString = false;
                        module.StringStrengthSelection = StringStrength.NoString;
                        attacker.SendMessage( "Your string just broke." );
                    }
                    return true;
                }
                else if ( module.StringStrengthSelection == StringStrength.Sturdy )
                {
                    if ( .15 > Utility.Random( 100 ) )
                    {
                        BonusDamage( attacker, defender, ranged );
                        return true;
                    }
                    if ( .08 > Utility.Random( 1000 ) ) //1 in a 125 chances of breaking.
                    {
                        module.HasBowString = false;
                        module.StringStrengthSelection = StringStrength.NoString;
                        attacker.SendMessage( "Your string just broke." );
                    }
                    return true;
                }
                else if ( module.StringStrengthSelection == StringStrength.Strong )
                {
                    if ( .20 > Utility.Random( 100 ) )
                    {
                        BonusDamage( attacker, defender, ranged );
                        return true;
                    }
                    if ( .05 > Utility.Random( 1000 ) ) //1 in a 200 chances of breaking.
                    {
                        module.HasBowString = false;
                        module.StringStrengthSelection = StringStrength.NoString;
                        attacker.SendMessage( "Your string just broke." );
                    }
                }
                else if ( module.StringStrengthSelection == StringStrength.Dependable )
                {
                    if ( .25 > Utility.Random( 100 ) )
                    {
                        BonusDamage( attacker, defender, ranged );
                        return true;
                    }
                    if ( .03 > Utility.Random( 1000 ) ) //1 in a 333 chances of breaking.
                    {
                        module.HasBowString = false;
                        module.StringStrengthSelection = StringStrength.NoString;
                        attacker.SendMessage( "Your string just broke." );
                    }
                    return true;
                }
                else if ( module.StringStrengthSelection == StringStrength.Indestructable )
                {
                    if ( .33 > Utility.Random( 100 ) )
                    {
                        BonusDamage( attacker, defender, ranged );
                        return true;
                    }
                    //No chance of breaking.
                    return true;
                }
                else
                {
                    Console.WriteLine("String damage check returning false");
                    return false;
                    
                }
            }
            else
            {
                return false;
            }
            
            return false;
        }
        
        public virtual bool BonusDamage( Mobile attacker, Mobile defender, BaseRanged ranged )
        {
            BaseRangedModule module = ranged.BaseRangedModule;

            attacker.SendMessage( "" );
            attacker.SendMessage( 0x35, "** Bonus Hit **" );
            attacker.SendMessage( "" );
            attacker.SendMessage( 0x35, "The strength of your bow and your immpecable skill have given you a perfect hit." );
            attacker.SendMessage( "" );
            
            defender.Say( "* Ouch, that hurt! *" );
            defender.PlaySound( 315 );
            
            if ( module.HasBowString )
            {
                if ( module.m_PullWeight == PoundsPerPull.Fourty )
                {
                    attacker.DoHarmful( defender );
                    AOS.Damage( defender, attacker, Utility.RandomMinMax( 2, 5 ), 100, 0, 0, 0, 0 );
                    return true;
                }
                else if ( module.m_PullWeight == PoundsPerPull.Sixty )
                {
                    attacker.DoHarmful( defender );
                    AOS.Damage( defender, attacker, Utility.RandomMinMax( 6, 10 ), 100, 0, 0, 0, 0 );
                    return true;
                }
                else if ( module.m_PullWeight == PoundsPerPull.Eighty )
                {
                    attacker.DoHarmful( defender );
                    AOS.Damage( defender, attacker, Utility.RandomMinMax( 11, 15 ), 100, 0, 0, 0, 0 );
                    return true;
                }
                else if ( module.m_PullWeight == PoundsPerPull.Hundred )
                {
                    attacker.DoHarmful( defender );
                    AOS.Damage( defender, attacker, Utility.RandomMinMax( 16, 20 ), 100, 0, 0, 0, 0 );
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
                return true;
        }
        
        public virtual void CheckStringCondition( Mobile from, BaseRanged ranged )
        {
            BaseRangedModule module = ranged.BaseRangedModule;
            
            if ( module.HasBowString && module.StringStrengthSelection == StringStrength.NoString )
            {
                module.HasBowString = false;
            }
            
            if ( !module.HasBowString )
            {
                if ( module.StringStrengthSelection == StringStrength.NoString )
                {
                    module.HasBowString = false;
                    //from.SendMessage( "You need a string to use this bow. See a local fletcher to apply the string." );
                }
                else
                {
                    module.StringStrengthSelection = StringStrength.NoString;
                }
            }
        }
        
        public static bool CheckForString( Mobile from, string errorMsg, BaseRanged ranged )
        {
            BaseRangedModule module = ranged.BaseRangedModule;

            if ( !module.HasBowString )
            {
                return true;
            }
            else
            {
                if ( module.HasBowString && module.StringStrengthSelection == StringStrength.NoString )
                {
                    from.SendMessage( "" );
                    from.SendMessage( 33, "--------------------" );
                    from.SendMessage( "" );
                    from.SendMessage( 33, "The bow has an internal error and is now being fixed..." );
                    from.SendMessage( "" );
                    from.SendMessage( 33, "--------------------" );
                    from.SendMessage( "" );
                    module.HasBowString = false;
                    return true;
                }
                else
                {
                    from.SendMessage( "{0}", errorMsg );
                    return false;
                }
            }
        }
        
        public static void CutString( Mobile from, BaseRanged ranged )
        {
            BaseRangedModule module = ranged.BaseRangedModule;
            
            module.StringStrengthSelection = StringStrength.NoString;
            module.PullWeightSelection = PoundsPerPull.Zero;
            module.HasBowString = false;
            
            from.PlaySound( 0x248 );
            from.SendMessage( "You have just removed the string from your bow." );
            
            ranged.InvalidateProperties();
        }
        
        public virtual void CheckStringError( Mobile from, BaseRanged ranged )
        {
            BaseRangedModule module = ranged.BaseRangedModule;
            
            if ( module.HasBowString && module.StringStrengthSelection == StringStrength.NoString )
            {
                from.SendMessage( "The bow has an internal error. The bow is now being fixed..." );
                module.HasBowString = false;
            }
        }
    }
}

I would be very grateful for any assistance in getting these strings to break! I'm sure it'll be a simple edit for someone else but my ability is limited to basic editing of existing scripts. I'll get there one day though!
 

MooJohn

Sorceror
Fixed! And it wasn't simple after all. It took quite a bit of changes to make it work but it is done. Bow strings are snapping all over the shard now :D
 
Top