public static float GetChance(Creature creature, Item rightHand, SkillId skillId, OptionSetData optionSetData)
{
// Check right hand, only use it if it's powder
if (rightHand != null && !rightHand.HasTag("/enchant/powder/"))
rightHand = null;
// Get base chance, based on skill and powder
var baseChance = _baseChanceB00; // (Blessed) Magic Powder/None
if (skillId == SkillId.Enchant && rightHand != null)
{
if (rightHand.HasTag("/powder02/")) // Elite Magic Powder
baseChance = _baseChanceB05;
else if (rightHand.HasTag("/powder03/")) // Elven Magic Powder
baseChance = _baseChanceB10;
else if (rightHand.HasTag("/powder01/")) // Ancient Magic Powder
baseChance = _baseChanceB50;
else if (rightHand.HasTag("/powder04/") && rightHand.Info.Id == 85865) // Notorious Magic Powder
baseChance = _baseChanceB60;
}
// Get chance
var rank = Math2.Clamp(0, _baseChanceB00.Length - 1, (int)optionSetData.Rank - 1);
var chance = baseChance[rank];
var intBonus = 1f;
var thursdayBonus = 0f;
// Int bonus if using powder
if (skillId == SkillId.Enchant && rightHand != null)
intBonus = 1f + ((creature.Int - 35f) / 350f);
// Thursday bonus
if (ErinnTime.Now.Month == 4)
thursdayBonus = Math.Max(0, (15 - rank) / 2f);
// Result
var result = Math2.Clamp(0, 90, chance * intBonus + thursdayBonus);
// Debug
if (creature.Titles.SelectedTitle == TitleId.devCAT)
{
Send.ServerMessage(creature,
"Debug: Enchant success chance: {0:0} (base: {1:0}, int: {2:0}, thu: {3:0})",
result, chance, (chance / 1f * (intBonus - 1f)), thursdayBonus);
}
return result;
}