/// <summary> /// Applies all upgrade effects of option set to item. /// </summary> /// <param name="optionSetData">Option set to apply.</param> /// <param name="clear">Remove existing upgrade effects of the same type?</param> public void ApplyOptionSet(OptionSetData optionSetData, bool clear) { var rnd = RandomProvider.Get(); lock (_upgrades) { if (clear) _upgrades.RemoveAll(a => a.Type == optionSetData.Type); foreach (var effect in optionSetData.Effects) this.AddUpgradeEffect(effect.GetUpgradeEffect(rnd)); } }
/// <summary> /// Returns success chance, based on skill, option set, and powder /// used. /// <remarks> /// Unofficial. It kinda matches the debug output of the client, /// but it is a little off. /// </remarks> /// </summary> /// <param name="creature"></param> /// <param name="rightHand"></param> /// <param name="skill"></param> /// <param name="optionSetData"></param> /// <returns></returns> private float GetChance(Creature creature, Item rightHand, Skill skill, 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 (skill.Info.Id == 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 (skill.Info.Id == 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); }
/// <summary> /// Returns success chance, based on skill, option set, and powder /// used. /// <remarks> /// Unofficial. It kinda matches the debug output of the client, /// but it is a little off. /// </remarks> /// </summary> /// <param name="creature"></param> /// <param name="rightHand"></param> /// <param name="skill"></param> /// <param name="optionSetData"></param> /// <returns></returns> private float GetChance(Creature creature, Item rightHand, Skill skill, 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 (skill.Info.Id == 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 (skill.Info.Id == 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; }