Exemple #1
0
        public static SmallInscriptionBOD CreateRandomFor(Mobile m)
        {
            SmallBulkEntry[] entries;

            double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Inscribe);

            entries = SmallBulkEntry.InscriptionSmalls;

            if (entries.Length > 0)
            {
                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);
                }

                CraftSystem system = DefInscription.CraftSystem;

                List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>();

                for (int i = 0; i < entries.Length; ++i)
                {
                    CraftItem item = system.CraftItems.SearchFor(entries[i].Type);

                    if (item != null)
                    {
                        bool   allRequiredSkills = true;
                        double chance            = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);

                        if (allRequiredSkills && chance >= 0.0)
                        {
                            if (chance > 0.0)
                            {
                                validEntries.Add(entries[i]);
                            }
                        }
                    }
                }

                if (validEntries.Count > 0)
                {
                    SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
                    return(new SmallInscriptionBOD(entry, amountMax));
                }
            }

            return(null);
        }
Exemple #2
0
        public static SmallSmithBOD CreateRandomFor(Mobile m)
        {
            SmallBulkEntry[] entries;
            bool             useMaterials;

            if (useMaterials = Utility.RandomBool())
            {
                entries = SmallBulkEntry.BlacksmithArmor;
            }
            else
            {
                entries = SmallBulkEntry.BlacksmithWeapons;
            }

            if (entries.Length > 0)
            {
                double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Blacksmith);
                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.DullCopper, m_BlacksmithMaterialChances);
                        double           skillReq = GetRequiredSkill(check);

                        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());

                CraftSystem system = DefBlacksmithy.CraftSystem;

                List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>();

                for (int i = 0; i < entries.Length; ++i)
                {
                    CraftItem item = system.CraftItems.SearchFor(entries[i].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)
                            {
                                validEntries.Add(entries[i]);
                            }
                        }
                    }
                }

                if (validEntries.Count > 0)
                {
                    SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
                    return(new SmallSmithBOD(entry, material, amountMax, reqExceptional));
                }
            }

            return(null);
        }
Exemple #3
0
        public static SmallTinkerBOD CreateRandomFor(Mobile m)
        {
            SmallBulkEntry[] entries;
            bool             useMaterials;

            if (useMaterials = 0.75 > Utility.RandomDouble())
            {
                entries = SmallBulkEntry.TinkeringSmalls;
            }
            else
            {
                entries = SmallBulkEntry.TinkeringSmallsRegular;
            }

            if (entries.Length > 0)
            {
                double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Tinkering);
                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.DullCopper, m_TinkerMaterialChances);
                        double           skillReq = GetRequiredSkill(check);

                        if (theirSkill >= skillReq)
                        {
                            material = check;
                            break;
                        }
                    }
                }

                double excChance = 0.0;

                if (useMaterials && theirSkill >= 70.1)
                {
                    excChance = (theirSkill + 80.0) / 200.0;
                }

                bool reqExceptional = (excChance > Utility.RandomDouble());

                CraftSystem system = DefTinkering.CraftSystem;

                List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>();

                for (int i = 0; i < entries.Length; ++i)
                {
                    CraftItem item = system.CraftItems.SearchFor(entries[i].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)
                            {
                                validEntries.Add(entries[i]);
                            }
                        }
                    }
                }

                if (validEntries.Count > 0)
                {
                    SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];

                    if (material != BulkMaterialType.None && CannotAssignMaterial(entry.Type))
                    {
                        material = BulkMaterialType.None;
                    }

                    SmallTinkerBOD bod = new SmallTinkerBOD(entry, material, amountMax, reqExceptional);

                    if (entry.Type.IsSubclassOf(typeof(BaseJewel)))
                    {
                        bod.AssignGemType(entry.Type);
                    }

                    return(bod);
                }
            }

            return(null);
        }
Exemple #4
0
        public static SmallTailorBOD CreateRandomFor(Mobile m)
        {
            SmallBulkEntry[] entries;
            bool             useMaterials = Utility.RandomBool();

            double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Tailoring);

            if (useMaterials && theirSkill >= 6.2) // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill.
            {
                entries = SmallBulkEntry.TailorLeather;
            }
            else
            {
                entries = SmallBulkEntry.TailorCloth;
            }

            if (entries.Length > 0)
            {
                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.Spined, m_TailoringMaterialChances);
                        double           skillReq = GetRequiredSkill(check);

                        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());

                CraftSystem system = DefTailoring.CraftSystem;

                List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>();

                for (int i = 0; i < entries.Length; ++i)
                {
                    CraftItem item = system.CraftItems.SearchFor(entries[i].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)
                            {
                                validEntries.Add(entries[i]);
                            }
                        }
                    }
                }

                if (validEntries.Count > 0)
                {
                    SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
                    return(new SmallTailorBOD(entry, material, amountMax, reqExceptional));
                }
            }

            return(null);
        }
Exemple #5
0
        public static SmallCookingBOD CreateRandomFor(Mobile m)
        {
            SmallBulkEntry[] entries;

            double theirSkill     = BulkOrderSystem.GetBODSkill(m, SkillName.Cooking);
            bool   nonexceptional = false;

            if (0.20 > Utility.RandomDouble())
            {
                nonexceptional = true;
                entries        = SmallBulkEntry.CookingSmallsRegular;
            }
            else
            {
                entries = SmallBulkEntry.CookingSmalls;
            }

            if (entries.Length > 0)
            {
                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);
                }

                double excChance = 0.0;

                if (theirSkill >= 70.1)
                {
                    excChance = (theirSkill + 80.0) / 200.0;
                }

                bool reqExceptional = !nonexceptional && excChance > Utility.RandomDouble();

                CraftSystem system = DefCooking.CraftSystem;

                List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>();

                for (int i = 0; i < entries.Length; ++i)
                {
                    CraftItem item = system.CraftItems.SearchFor(entries[i].Type);

                    if (item != null)
                    {
                        bool   allRequiredSkills = true;
                        double chance            = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills);

                        if (allRequiredSkills && chance >= 0.0)
                        {
                            if (chance > 0.0)
                            {
                                validEntries.Add(entries[i]);
                            }
                        }
                    }
                }

                if (validEntries.Count > 0)
                {
                    SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
                    return(new SmallCookingBOD(entry, amountMax, reqExceptional));
                }
            }

            return(null);
        }