diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 85632cb4e..f9a32ce3d 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -61,6 +61,7 @@ public class AdvancedConfig extends ConfigLoader { public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); } public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); } + public int getArmorImpactMaxDurabilityDamage() { return config.getInt("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20); } /* EXCAVATION */ //Nothing to configure, everything is already configurable in config.yml diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java index b7e4c9dbc..37117fcdc 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java @@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; @@ -130,6 +131,8 @@ public class Axes { /* Every 30 Skill Levels you gain 1 durability damage */ int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel(); + double impactMaxDamage = (double) advancedConfig.getArmorImpactMaxDurabilityDamage() / 100; + short maxDurability; durabilityDamage += (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel); if (!hasArmor(targetPlayer)) { @@ -137,8 +140,11 @@ public class Axes { } else { for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) { - if(Math.random() * 100 > 75) + if(Math.random() * 100 > 75) { + maxDurability = (short) (ItemChecks.getMaxDurabilityArmor(armor) * impactMaxDamage); + if (durabilityDamage > maxDurability) durabilityDamage = (short) maxDurability; armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece + } } targetPlayer.updateInventory(); } diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 098a42a9e..41c987f98 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -474,4 +474,39 @@ public class ItemChecks { public static boolean isEnchantable(ItemStack is) { return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || (is.getType() == Material.BOW); } + + /** + * Get the maximum durability of an armor type. + * + * @param is Item to check + * @return maximum durability value. + */ + public static int getMaxDurabilityArmor(ItemStack is) { + int durability = 0; + if (isDiamondArmor(is)) { + if (isHelmet(is)) durability = 364; + else if (isChestplate(is)) durability = 529; + else if (isPants(is)) durability = 496; + else if (isBoots(is)) durability = 430; + } + else if (isIronArmor(is)) { + if (isHelmet(is)) durability = 166; + else if (isChestplate(is)) durability = 242; + else if (isPants(is)) durability = 226; + else if (isBoots(is)) durability = 196; + } + else if (isGoldArmor(is)) { + if (isHelmet(is)) durability = 78; + else if (isChestplate(is)) durability = 114; + else if (isPants(is)) durability = 106; + else if (isBoots(is)) durability = 92; + } + else if (isLeatherArmor(is)) { + if (isHelmet(is)) durability = 56; + else if (isChestplate(is)) durability = 82; + else if (isPants(is)) durability = 76; + else if (isBoots(is)) durability = 66; + } + return durability; + } } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 939e69e55..1191f3f79 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -45,6 +45,7 @@ Skills: GreaterImpact_KnockbackModifier: 1.5 GreaterImpact_BonusDamage: 2 ArmorImpact_IncreaseLevel: 50 + ArmorImpact_MaxPercentageDurabilityDamage: 20 Fishing: Shake_UnlockLevel: 150 Enchantment_Chance: 10