Epoxide-Software / Enchanting-Plus

The official repository for the Enchanting Plus mod.
36 stars 26 forks source link

Re-balancing costs. #89

Closed Darkhax closed 7 years ago

Darkhax commented 7 years ago

The current enchantment cost calculation system can be pretty messy. One of the biggest issues was the cost from level to level was not linear. Some of the calculations such as calculating the cost of increasing an enchantment from level 3 to level 5 expect it to be, and perform best when that is the case. There are also more factors that need to be included in the cost, such as treasure enchantments, and curses. While those could be retrofitted into the older method, the new one is much more straight forward. Included in this issue are the new code methods, and a table of the results.

The old method

    public static int calculateEnchantmentCost (Enchantment enchantment, int level) {

        int cost = (int) Math.floor(Math.max(1F, 1F + 2F * level * ((float) level / enchantment.getMaxLevel()) + (10 - enchantment.getRarity().getWeight()) * 0.2F));
        cost = cost + (int) (cost * 1.5f);
        cost = cost + (enchantment.getRarity() == Rarity.COMMON ? 1 : enchantment.getRarity() == Rarity.UNCOMMON ? 5 : enchantment.getRarity() == Rarity.RARE ? 10 : 20);
        return cost;
    }

The new method

    // New
    public static int calculateNewEnchCost(Enchantment enchantment, int level) {

        // Base cost is equal to roughly 2.5 levels of EXP.
        int cost = 25;

        // Cost is multiplied up to 10, based on rarity of the enchant.
        // Rarer the enchant, higher the cost.
        cost *= Math.max(11 - enchantment.getRarity().getWeight(), 1);

        // Linear cost increase based on level.
        cost *= level;

        // The cost factor is applied. Default is 1.5.
        // TODO make configurable
        cost *= 1.5f;

        // Curses cost even more to apply
        if (enchantment.isCurse()) {

            // TODO make configurable
            cost *= 1.5f;
        }

        // Treasures cost more to apply
        if (enchantment.isTreasureEnchantment()) {

            // TODO make configurable
            cost *= 1.5f;
        }

        return cost;
    }

Enchantment costs

Enchantment Old Cost New Cost
Protection I 3 2
Protection II 8 4
Protection III 13 6
Protection IV 23 8
Fire Protection I 10 13
Fire Protection II 15 22
Fire Protection III 20 27
Fire Protection IV 30 31
Feather Falling I 10 13
Feather Falling II 15 22
Feather Falling III 20 27
Feather Falling IV 30 31
Blast Protection I 17 18
Blast Protection II 20 27
Blast Protection III 27 32
Blast Protection IV 35 36
Projectile Protection I 10 13
Projectile Protection II 15 22
Projectile Protection III 20 27
Projectile Protection IV 30 31
Respiration I 17 18
Respiration II 22 27
Respiration III 30 32
Aqua Affinity 20 18
Thorns I 27 20
Thorns II 32 28
Thorns III 40 34
Depth Strider I 17 18
Depth Strider II 22 27
Depth Strider III 30 32
Frost Walker I 17 23
Frost Walker II 25 32
§cCurse of Binding 30 30
Sharpness I 3 2
Sharpness II 6 4
Sharpness III 11 6
Sharpness IV 18 8
Sharpness V 28 11
Smite I 10 13
Smite II 12 22
Smite III 17 27
Smite IV 25 31
Smite V 35 34
Bane of Arthropods I 10 13
Bane of Arthropods II 12 22
Bane of Arthropods III 17 27
Bane of Arthropods IV 25 31
Bane of Arthropods V 35 34
Knockback I 12 13
Knockback II 20 22
Fire Aspect I 17 18
Fire Aspect II 25 27
Looting I 17 18
Looting II 22 27
Looting III 30 32
Sweeping Edge I 17 18
Sweeping Edge II 22 27
Sweeping Edge III 30 32
Efficiency I 3 2
Efficiency II 6 4
Efficiency III 11 6
Efficiency IV 18 8
Efficiency V 28 11
Silk Touch 30 20
Unbreaking I 10 13
Unbreaking II 15 22
Unbreaking III 25 27
Fortune I 17 18
Fortune II 22 27
Fortune III 30 32
Power I 3 2
Power II 6 4
Power III 11 6
Power IV 18 8
Power V 28 11
Punch I 17 18
Punch II 25 27
Flame 20 18
Infinity 30 20
Luck of the Sea I 17 18
Luck of the Sea II 22 27
Luck of the Sea III 30 32
Lure I 17 18
Lure II 22 27
Lure III 30 32
Mending 20 23
§cCurse of Vanishing 30 30