Calculating Enchantment Rarity

Discussion in 'Spigot Plugin Development' started by Hunky524, Jun 16, 2016.

  1. I do not a have a specific issue I need help with, I just want peoples' opinions. There is no right or wrong answer, but maybe there are better answers than some. I need to develop an algorithm to calculate a price modifier depending on enchantments that an item has on it. Now I have found a website here that shows the percentage chance of getting a specific enchantment on a specific item, or the chance of getting any of the enchantments on a book. The chance varies depending on the initial level, however, the chance also depends on if you are using the item or a book. For example, at level 30, there is a 41.2% change to get Efficiency 4, but on a book where you can get all enchantments, there is a 5.6% chance. This can skew an algorithm to raise the price of enchantments that might not be worth as much as the algorithm makes them out to be. Another example would be Lure 3; it has a 0.1% chance for a book, but a 5.1% chance on a fishing rod. I'm wondering if you would use the book list to determine rarity or go on an item by item basis for rarity.


    Another question is if any of you have possible ideas of an algorithm for enchantment price. A simple one would be:
    Code (Text):
    newPrice = baseItemPrice + (baseItemPrice * (1 - enchantmentPercentageChance));


    I am open to all ideas, and there isn't really a wrong or right answer.
     
  2. Code (Text):
    newPrice = baseItemPrice + ((baseItemPrice * ((enchantLevel / 2) + 1)) * (1- enchantPercentChance));
     
  3. When you say enchantLevel, is that the level of the enchantment as in Protection 4, or the experience level from 1-30?
     
  4. Level of the enchantment of course. That would be a terrible variable name for the XP cost :p