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!

Carpentry BOD issue

Hammerhand

Knight
I have almost everything working just fine with the new BOD's I've been slaving away on, except for a minor little issue. Carp weapons, both exceptional & non work beautifully. Carp items the same. Carp Instruments... not so much. Non exceptional work just fine & exceptional instruments go into non exceptional BODs, but they will NOT go into the exceptional BODs. Keeps telling me they are not exceptional, even when they crafted exceptional & show it on mouseover. Heres the SmallCarpenterBOD for your perusal.. This is on RunUO 2.3 if it matters. I'm thinking it may be related to both BaseWeapon & BaseArmor having actual save flags for quality & BaseInstrument not having one. In [props, there is no quality flag showing in an instrument.

Code:
/* Modified by Hammerhand */
using System;
using System.Collections.Generic;
using Server;
using Server.Engines.Craft;
using Server.Items;
using Mat = Server.Engines.BulkOrders.BulkMaterialType;
 
namespace Server.Engines.BulkOrders
{
    [TypeAlias( "Scripts.Engines.BulkOrders.SmallCarpenterBOD" )]
    public class SmallCarpenterBOD : SmallBOD
    {
        public static double[] m_CarpenterMaterialChances = new double[]
            {
                0.140, // None
                0.130, // OakWood
                0.120, // AshWood
                0.110, // YewWood
                0.100, // Heartwood
                0.090, // Bloodwood
                0.080, // Frostwood
            };
 
        public override int ComputeFame()
        {
            return CarpenterRewardCalculator.Instance.ComputeFame( this );
        }
 
        public override int ComputeGold()
        {
            return CarpenterRewardCalculator.Instance.ComputeGold( this );
        }
 
        public override List<Item> ComputeRewards( bool full )
        {
            List<Item> list = new List<Item>();
 
            RewardGroup rewardGroup = CarpenterRewardCalculator.Instance.LookupRewards( CarpenterRewardCalculator.Instance.ComputePoints( this ) );
 
            if ( rewardGroup != null )
            {
                if ( full )
                {
                    for ( int i = 0; i < rewardGroup.Items.Length; ++i )
                    {
                        Item item = rewardGroup.Items[i].Construct();
 
                        if ( item != null )
                            list.Add( item );
                    }
                }
                else
                {
                    RewardItem rewardItem = rewardGroup.AcquireItem();
 
                    if ( rewardItem != null )
                    {
                        Item item = rewardItem.Construct();
 
                        if ( item != null )
                            list.Add( item );
                    }
                }
            }
 
            return list;
        }
 
        public static SmallCarpenterBOD CreateRandomFor( Mobile m )
        {
            SmallBulkEntry[] entries;
            bool useMaterials;
 
            if ( useMaterials = Utility.RandomBool() )
                entries = SmallBulkEntry.CarpenterStaff;
            else
                entries = SmallBulkEntry.CarpenterInstrument;
 
            if ( entries.Length > 0 )
            {
                double theirSkill = m.Skills[SkillName.Carpentry].Base;
                int amountMax;
 
                if ( theirSkill >= 70.1 )
                    amountMax = Utility.RandomList( 10, 15, 20, 20 );
                else if ( theirSkill >= 50.1 )
                    amountMax = Utility.RandomList( 10, 15, 15, 20 );
                else
                    amountMax = Utility.RandomList( 10, 10, 15, 20 );
 
                BulkMaterialType material = BulkMaterialType.None;
 
                if ( useMaterials && theirSkill >= 70.1 )
                {
                    for ( int i = 0; i < 20; ++i )
                    {
                        BulkMaterialType check = GetRandomMaterial( BulkMaterialType.OakWood, m_CarpenterMaterialChances );
                        double skillReq = 0.0;
 
                        switch ( check )
                        {
                            case BulkMaterialType.DullCopper: skillReq = 65.0; break;
                            case BulkMaterialType.ShadowIron: skillReq = 70.0; break;
                            case BulkMaterialType.Copper: skillReq = 75.0; break;
                            case BulkMaterialType.Bronze: skillReq = 80.0; break;
                            case BulkMaterialType.Gold: skillReq = 85.0; break;
                            case BulkMaterialType.Agapite: skillReq = 90.0; break;
                            case BulkMaterialType.Verite: skillReq = 95.0; break;
                            case BulkMaterialType.Valorite: skillReq = 100.0; break;
                            case BulkMaterialType.Spined: skillReq = 65.0; break;
                            case BulkMaterialType.Horned: skillReq = 80.0; break;
                            case BulkMaterialType.Barbed: skillReq = 99.0; break;
                            case BulkMaterialType.OakWood: skillReq = 65.0; break;
                            case BulkMaterialType.AshWood: skillReq = 70.0; break;
                            case BulkMaterialType.YewWood: skillReq = 75.0; break;
                            case BulkMaterialType.Heartwood: skillReq = 80.0; break;
                            case BulkMaterialType.Bloodwood: skillReq = 85.0; break;
                            case BulkMaterialType.Frostwood: skillReq = 90.0; break;
                        }
 
                        if ( theirSkill >= skillReq )
                        {
                            material = check;
                            break;
                        }
                    }
                }
 
                double excChance = 0.0;
 
                if (theirSkill >= 70.1)
                    excChance = (theirSkill + 80.0) / 200.0;
 
                bool reqExceptional = (excChance > Utility.RandomDouble());
 
                SmallBulkEntry entry = null;
 
                CraftSystem system = DefCarpentry.CraftSystem;
 
                for (int i = 0; i < 150; ++i)
                {
                    SmallBulkEntry check = entries[Utility.Random(entries.Length)];
 
                    CraftItem item = system.CraftItems.SearchFor(check.Type);
 
                    if (item != null)
                    {
                        bool allRequiredSkills = true;
                        double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);
 
                        if (allRequiredSkills && chance >= 0.0)
                        {
                            if (reqExceptional)
                                chance = item.GetExceptionalChance(system, chance, m);
 
                            if (chance > 0.0)
                            {
                                entry = check;
                                break;
                            }
                        }
                    }
                }
 
                if (entry != null)
                    return new SmallCarpenterBOD(entry, material, amountMax, reqExceptional);
            }
 
            return null;
        }
 
        private SmallCarpenterBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional)
        {
            this.Hue = 0x30;
            this.AmountMax = amountMax;
            this.Type = entry.Type;
            this.Number = entry.Number;
            this.Graphic = entry.Graphic;
            this.RequireExceptional = reqExceptional;
            this.Material = material;
        }
 
        [Constructable]
        public SmallCarpenterBOD()
        {
            SmallBulkEntry[] entries;
            bool useMaterials;
 
            if ( useMaterials = Utility.RandomBool() )
                entries = SmallBulkEntry.CarpenterStaff;
            else
                entries = SmallBulkEntry.CarpenterInstrument;
 
            if ( entries.Length > 0 )
            {
                int hue = 0x30;
                int amountMax = Utility.RandomList( 10, 15, 20 );
 
                BulkMaterialType material;
 
                if ( useMaterials )
                    material = GetRandomMaterial( BulkMaterialType.OakWood, m_CarpenterMaterialChances );
                else
                    material = BulkMaterialType.None;
 
                bool reqExceptional = Utility.RandomBool() || (material == BulkMaterialType.None);
 
                SmallBulkEntry entry = entries[Utility.Random( entries.Length )];
 
                this.Hue = hue;
                this.AmountMax = amountMax;
                this.Type = entry.Type;
                this.Number = entry.Number;
                this.Graphic = entry.Graphic;
                this.RequireExceptional = reqExceptional;
                this.Material = material;
            }
        }
 
        public SmallCarpenterBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, BulkMaterialType mat)
        {
            this.Hue = 0x30;
            this.AmountMax = amountMax;
            this.AmountCur = amountCur;
            this.Type = type;
            this.Number = number;
            this.Graphic = graphic;
            this.RequireExceptional = reqExceptional;
            this.Material = mat;
        }
 
        public SmallCarpenterBOD( Serial serial ) : base( serial )
        {
        }
 
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
 
            writer.Write( (int) 0 ); // version
        }
 
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
 
            int version = reader.ReadInt();
        }
    }
}
 

Hammerhand

Knight
The combine coding is in SmallBOD.cs
Code:
        public void BeginCombine( Mobile from )
        {
            if ( m_AmountCur < m_AmountMax )
                from.Target = new SmallBODTarget( this );
            else
                from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed.
        }
 
        public abstract List<Item> ComputeRewards( bool full );
        public abstract int ComputeGold();
        public abstract int ComputeFame();
 
        public virtual void GetRewards( out Item reward, out int gold, out int fame )
        {
            reward = null;
            gold = ComputeGold();
            fame = ComputeFame();
 
            List<Item> rewards = ComputeRewards( false );
 
            if ( rewards.Count > 0 )
            {
                reward = rewards[Utility.Random( rewards.Count )];
 
                for ( int i = 0; i < rewards.Count; ++i )
                {
                    if ( rewards[i] != reward )
                        rewards[i].Delete();
                }
            }
        }
 
        public static BulkMaterialType GetMaterial( CraftResource resource )
        {
            switch ( resource )
            {
                case CraftResource.DullCopper: return BulkMaterialType.DullCopper;
                case CraftResource.ShadowIron: return BulkMaterialType.ShadowIron;
                case CraftResource.Copper: return BulkMaterialType.Copper;
                case CraftResource.Bronze: return BulkMaterialType.Bronze;
                case CraftResource.Gold: return BulkMaterialType.Gold;
                case CraftResource.Agapite: return BulkMaterialType.Agapite;
                case CraftResource.Verite: return BulkMaterialType.Verite;
                case CraftResource.Valorite: return BulkMaterialType.Valorite;
                case CraftResource.SpinedLeather: return BulkMaterialType.Spined;
                case CraftResource.HornedLeather: return BulkMaterialType.Horned;
                case CraftResource.BarbedLeather: return BulkMaterialType.Barbed;
                case CraftResource.OakWood: return BulkMaterialType.OakWood;
                case CraftResource.AshWood: return BulkMaterialType.AshWood;
                case CraftResource.YewWood: return BulkMaterialType.YewWood;
                case CraftResource.Heartwood: return BulkMaterialType.Heartwood;
                case CraftResource.Bloodwood: return BulkMaterialType.Bloodwood;
                case CraftResource.Frostwood: return BulkMaterialType.Frostwood;
            }
 
            return BulkMaterialType.None;
        }
 
        public void EndCombine( Mobile from, object o )
        {
            if ( o is Item && ((Item)o).IsChildOf( from.Backpack ) )
            {
                Type objectType = o.GetType();
 
                if ( m_AmountCur >= m_AmountMax )
                {
                    from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed.
                }
                else if (m_Type == null || (objectType != m_Type && !objectType.IsSubclassOf(m_Type)) || (!(o is BaseWeapon) && !(o is BaseArmor) && !(o is BaseClothing) && !(o is BaseTool) && !(o is Item) && !(o is BaseInstrument)))
                {
                    from.SendLocalizedMessage( 1045169 ); // The item is not in the request.
                }
                else
                {
 
                    BulkMaterialType material = BulkMaterialType.None;
 
                    if ( o is BaseArmor )
                        material = GetMaterial( ((BaseArmor)o).Resource );
                    else if (o is BaseWeapon)
                        material = GetMaterial(((BaseWeapon)o).Resource);
                    else if ( o is BaseClothing )
                        material = GetMaterial( ((BaseClothing)o).Resource );
 
                    if ( m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite && material != m_Material )
                    {
                        from.SendLocalizedMessage( 1045168 ); // The item is not made from the requested ore.
                    }
                    else if ( m_Material >= BulkMaterialType.Spined && m_Material <= BulkMaterialType.Barbed && material != m_Material )
                    {
                        from.SendLocalizedMessage( 1049352 ); // The item is not made from the requested leather type.
                    }
                    else if (m_Material >= BulkMaterialType.OakWood && m_Material <= BulkMaterialType.Frostwood && material != m_Material)
                    {
                        from.SendMessage("The item is not made from the requested wood type."); // The item is not made from the requested leather type.
                    }
                    else
                    {
                        bool isExceptional = false;
 
                        if ( o is BaseWeapon )
                            isExceptional = ( ((BaseWeapon)o).Quality == WeaponQuality.Exceptional );
                        else if ( o is BaseArmor )
                            isExceptional = ( ((BaseArmor)o).Quality == ArmorQuality.Exceptional );
                        else if ( o is BaseClothing )
                            isExceptional = ( ((BaseClothing)o).Quality == ClothingQuality.Exceptional );
 
                        if ( m_RequireExceptional && !isExceptional )
                        {
                            from.SendLocalizedMessage( 1045167 ); // The item must be exceptional.
                        }
                        else
                        {
                            ((Item)o).Delete();
                            ++AmountCur;
 
                            from.SendLocalizedMessage( 1045170 ); // The item has been combined with the deed.
 
                            from.SendGump( new SmallBODGump( from, this ) );
 
                            if ( m_AmountCur < m_AmountMax )
                                BeginCombine( from );
                        }
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it.
            }
        }
 

daat99

Moderator
Staff member
Let's take a look at this code snippet:
Code:
                        bool isExceptional = false;
 
                        if ( o is BaseWeapon )
                            isExceptional = ( ((BaseWeapon)o).Quality == WeaponQuality.Exceptional );
                        else if ( o is BaseArmor )
                            isExceptional = ( ((BaseArmor)o).Quality == ArmorQuality.Exceptional );
                        else if ( o is BaseClothing )
                            isExceptional = ( ((BaseClothing)o).Quality == ClothingQuality.Exceptional );
 
                        if ( m_RequireExceptional && !isExceptional )
                        {
                            from.SendLocalizedMessage( 1045167 ); // The item must be exceptional.
                        }
Let's take a closer look at the "isExceptional" variable.
As we can see it is initially set to "false".

Later on in the code we check if it's a weapon, armor or clothing and update it accordingly.

I don't see anything here about carpentry though.
 

Hammerhand

Knight
it never even occured to me to try this..
Code:
                        bool isExceptional = false;
 
                        if ( o is BaseWeapon )
                            isExceptional = ( ((BaseWeapon)o).Quality == WeaponQuality.Exceptional );
                        else if ( o is BaseArmor )
                            isExceptional = ( ((BaseArmor)o).Quality == ArmorQuality.Exceptional );
                        else if ( o is BaseClothing )
                            isExceptional = ( ((BaseClothing)o).Quality == ClothingQuality.Exceptional );
                        else if (o is BaseInstrument)
                            isExceptional = (((BaseInstrument)o).Quality == InstrumentQuality.Exceptional);  <<<
Just tried it and what do you know..... it works like a charm. 1 step closer to having them fully working properly! Thx daat99! :D
 
Top