using System; using System.Collections.Generic; using Server.Engines.Craft; namespace Server.Engines.BulkOrders { [TypeAlias("Scripts.Engines.BulkOrders.SmallSmithBOD")] public class SmallSmithBOD : SmallBOD { public override BODType BODType { get { return BODType.Smith; } } public static double[] m_BlacksmithMaterialChances = new double[] { 0.501953125, // None 0.250000000, // Dull Copper 0.125000000, // Shadow Iron 0.062500000, // Copper 0.031250000, // Bronze 0.015625000, // Gold 0.007812500, // Agapite 0.003906250, // Verite 0.001953125 // Valorite }; [Constructable] public SmallSmithBOD() { SmallBulkEntry[] entries; bool useMaterials; if (useMaterials = Utility.RandomBool()) entries = SmallBulkEntry.BlacksmithArmor; else entries = SmallBulkEntry.BlacksmithWeapons; if (entries.Length > 0) { int hue = 0x44E; int amountMax = Utility.RandomList(10, 15, 20); BulkMaterialType material; if (useMaterials) material = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); else material = BulkMaterialType.None; bool reqExceptional = Utility.RandomBool() || (material == BulkMaterialType.None); SmallBulkEntry entry = entries[Utility.Random(entries.Length)]; Hue = hue; AmountMax = amountMax; Type = entry.Type; Number = entry.Number; Graphic = entry.Graphic; RequireExceptional = reqExceptional; Material = material; GraphicHue = entry.Hue; } } public SmallSmithBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, BulkMaterialType mat, int hue) { Hue = 0x44E; AmountMax = amountMax; AmountCur = amountCur; Type = type; Number = number; Graphic = graphic; RequireExceptional = reqExceptional; Material = mat; GraphicHue = hue; } public SmallSmithBOD(Serial serial) : base(serial) { } private SmallSmithBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional) { Hue = 0x44E; AmountMax = amountMax; Type = entry.Type; Number = entry.Number; Graphic = entry.Graphic; RequireExceptional = reqExceptional; Material = material; } 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 validEntries = new List(); 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; } public override int ComputeFame() { return SmithRewardCalculator.Instance.ComputeFame(this); } public override int ComputeGold() { return SmithRewardCalculator.Instance.ComputeGold(this); } public override List ComputeRewards(bool full) { List list = new List(); RewardGroup rewardGroup = SmithRewardCalculator.Instance.LookupRewards(SmithRewardCalculator.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 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(); } } }