Implementing an durability cap for ArmorImpact

This commit is contained in:
TfT_02 2012-12-27 17:36:12 +01:00
parent bd1850db69
commit de3bae41ae
4 changed files with 44 additions and 1 deletions

View File

@ -61,6 +61,7 @@ public class AdvancedConfig extends ConfigLoader {
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); } public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); } public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
public int getArmorImpactMaxDurabilityDamage() { return config.getInt("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20); }
/* EXCAVATION */ /* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml //Nothing to configure, everything is already configurable in config.yml

View File

@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
@ -130,6 +131,8 @@ public class Axes {
/* Every 30 Skill Levels you gain 1 durability damage */ /* Every 30 Skill Levels you gain 1 durability damage */
int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel(); int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
double impactMaxDamage = (double) advancedConfig.getArmorImpactMaxDurabilityDamage() / 100;
short maxDurability;
durabilityDamage += (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel); durabilityDamage += (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel);
if (!hasArmor(targetPlayer)) { if (!hasArmor(targetPlayer)) {
@ -137,8 +140,11 @@ public class Axes {
} }
else { else {
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) { 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 armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
}
} }
targetPlayer.updateInventory(); targetPlayer.updateInventory();
} }

View File

@ -474,4 +474,39 @@ public class ItemChecks {
public static boolean isEnchantable(ItemStack is) { public static boolean isEnchantable(ItemStack is) {
return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || (is.getType() == Material.BOW); 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;
}
} }

View File

@ -45,6 +45,7 @@ Skills:
GreaterImpact_KnockbackModifier: 1.5 GreaterImpact_KnockbackModifier: 1.5
GreaterImpact_BonusDamage: 2 GreaterImpact_BonusDamage: 2
ArmorImpact_IncreaseLevel: 50 ArmorImpact_IncreaseLevel: 50
ArmorImpact_MaxPercentageDurabilityDamage: 20
Fishing: Fishing:
Shake_UnlockLevel: 150 Shake_UnlockLevel: 150
Enchantment_Chance: 10 Enchantment_Chance: 10