Skip to content

Instantly share code, notes, and snippets.

@DarkLotus
Created June 6, 2019 01:47
Show Gist options
  • Save DarkLotus/b4aafddca9bcf02837755d3edd8c371b to your computer and use it in GitHub Desktop.
Save DarkLotus/b4aafddca9bcf02837755d3edd8c371b to your computer and use it in GitHub Desktop.
public static SmallInscriptionBOD CreateRandomFor(Mobile m)
{
SmallBulkEntry[] entries;
double theirSkill = m.Skills[SkillName.Inscribe].Base;
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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment