Aura.Channel.Skills.Magic.Enchant.GetChance C# (CSharp) Method

GetChance() public static method

Returns success chance, based on skill, option set, and powder used. Unofficial. It kinda matches the debug output of the client, but it is a little off.
public static GetChance ( Creature creature, Item rightHand, SkillId skillId, OptionSetData optionSetData ) : float
creature Aura.Channel.World.Entities.Creature
rightHand Item
skillId SkillId
optionSetData OptionSetData
return float
		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;
		}