Files
abysmal-isle/Scripts/Services/BulkOrders/SmallBODs/SmallCarpentryBOD.cs
Unstable Kitsune b918192e4e Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
2023-11-28 23:20:26 -05:00

190 lines
6.1 KiB
C#

using System;
using System.Collections.Generic;
using Server.Engines.Craft;
namespace Server.Engines.BulkOrders
{
public class SmallCarpentryBOD : SmallBOD
{
public static double[] m_CarpentryMaterialChances = new double[]
{
0.513718750, // None
0.292968750, // Oak
0.117187500, // Ash
0.046875000, // Yew
0.018750000, // Heartwood
0.007500000, // Bloodwood
0.003000000 // Frostwood
};
public override BODType BODType { get { return BODType.Carpentry; } }
[Constructable]
public SmallCarpentryBOD()
{
SmallBulkEntry[] entries;
bool useMaterials = Utility.RandomBool();
entries = SmallBulkEntry.CarpentrySmalls;
if (entries.Length > 0)
{
int amountMax = Utility.RandomList(10, 15, 20);
BulkMaterialType material = BulkMaterialType.None;
if(useMaterials)
material = GetRandomMaterial(BulkMaterialType.OakWood, m_CarpentryMaterialChances);
bool reqExceptional = Utility.RandomBool() || (material == BulkMaterialType.None);
SmallBulkEntry entry = entries[Utility.Random(entries.Length)];
this.Hue = 1512;
this.AmountMax = amountMax;
this.Type = entry.Type;
this.Number = entry.Number;
this.Graphic = entry.Graphic;
this.RequireExceptional = reqExceptional;
this.Material = material;
this.GraphicHue = entry.Hue;
}
}
public SmallCarpentryBOD(int amountCur, int amountMax, Type type, int number, int graphic, bool reqExceptional, BulkMaterialType mat, int hue)
{
this.Hue = 1512;
this.AmountMax = amountMax;
this.AmountCur = amountCur;
this.Type = type;
this.Number = number;
this.Graphic = graphic;
this.RequireExceptional = reqExceptional;
this.Material = mat;
this.GraphicHue = hue;
}
public SmallCarpentryBOD(Serial serial)
: base(serial)
{
}
private SmallCarpentryBOD(SmallBulkEntry entry, BulkMaterialType material, int amountMax, bool reqExceptional)
{
this.Hue = 1512;
this.AmountMax = amountMax;
this.Type = entry.Type;
this.Number = entry.Number;
this.Graphic = entry.Graphic;
this.RequireExceptional = reqExceptional;
this.Material = material;
}
public static SmallCarpentryBOD CreateRandomFor(Mobile m)
{
SmallBulkEntry[] entries;
bool useMaterials = Utility.RandomBool();
double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Carpentry);
entries = SmallBulkEntry.CarpentrySmalls;
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.OakWood, m_CarpentryMaterialChances);
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 = DefCarpentry.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 SmallCarpentryBOD(entry, material, amountMax, reqExceptional);
}
}
return null;
}
public override int ComputeFame()
{
return CarpentryRewardCalculator.Instance.ComputeFame(this);
}
public override int ComputeGold()
{
return CarpentryRewardCalculator.Instance.ComputeGold(this);
}
public override List<Item> ComputeRewards(bool full)
{
return null;
}
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();
}
}
}