Fixing some issues with Arcane Forging.

This commit is contained in:
Glitchfinder 2012-11-24 15:47:28 -08:00
parent b8755b808e
commit b1cf9d139a
2 changed files with 18 additions and 12 deletions

View File

@ -14,15 +14,15 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Repairable;
public class RepairCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private int arcaneForgingRank;
private String repairMasteryBonus;
private String superRepairChance;
private float repairMasteryChanceMax = advancedConfig.getRepairMasteryChanceMax();
private float repairMasteryMaxBonusLevel = advancedConfig.getRepairMasteryMaxLevel();
private float superRepairChanceMax = advancedConfig.getSuperRepairChanceMax();
private float superRepairMaxBonusLevel = advancedConfig.getSuperRepairMaxLevel();
private float repairMasteryChanceMax = advancedConfig.getRepairMasteryChanceMax();
private float repairMasteryMaxBonusLevel = advancedConfig.getRepairMasteryMaxLevel();
private float superRepairChanceMax = advancedConfig.getSuperRepairChanceMax();
private float superRepairMaxBonusLevel = advancedConfig.getSuperRepairMaxLevel();
private boolean canSuperRepair;
private boolean canMasterRepair;
@ -35,6 +35,7 @@ public class RepairCommand extends SkillCommand {
private boolean canRepairString;
private boolean canRepairLeather;
private boolean canRepairWood;
private boolean arcaneBypass;
private int salvageLevel;
private int diamondLevel;
@ -48,7 +49,7 @@ public class RepairCommand extends SkillCommand {
@Override
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0");
DecimalFormat df = new DecimalFormat("#.0");
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
@ -63,10 +64,10 @@ public class RepairCommand extends SkillCommand {
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax);
else repairMasteryBonus = df.format((repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillValue);
else repairMasteryBonus = df.format((repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillValue);
if(skillValue >= superRepairMaxBonusLevel) superRepairChance = df.format(superRepairChanceMax);
else superRepairChance = df.format((superRepairChanceMax / superRepairMaxBonusLevel) * skillValue);
else superRepairChance = df.format((superRepairChanceMax / superRepairMaxBonusLevel) * skillValue);
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}
@ -84,6 +85,7 @@ public class RepairCommand extends SkillCommand {
canRepairString = permInstance.stringRepair(player);
canRepairLeather = permInstance.leatherRepair(player);
canRepairWood = permInstance.woodRepair(player);
arcaneBypass = permInstance.arcaneBypass(player);
}
@Override
@ -154,11 +156,11 @@ public class RepairCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)) }));
}
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank)) }));
}
}
}

View File

@ -91,6 +91,10 @@ public class Repair {
* @param is Item being repaired
*/
protected static void addEnchants(Player player, ItemStack is) {
if(permInstance.arcaneBypass(player)) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
return;
}
Map<Enchantment, Integer> enchants = is.getEnchantments();
if (enchants.size() == 0) {
@ -122,7 +126,7 @@ public class Repair {
int enchantLevel = enchant.getValue();
if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
if (random.nextInt(100) < getDowngradeChance(rank)) {
if (random.nextInt(randomChance) < getDowngradeChance(rank)) {
is.addEnchantment(enchantment, --enchantLevel);
downgraded = true;
}
@ -209,7 +213,7 @@ public class Repair {
// float bonus = (float) skillLevel / 500;
float bonus;
if(skillLevel >= repairMasteryMaxBonusLevel) bonus = repairMasteryChanceMax;
else bonus = (repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillLevel;
else bonus = ((float) skillLevel / (float) repairMasteryMaxBonusLevel) * (float) repairMasteryChanceMax;
if (permInstance.repairMastery(player)) {
bonus = (repairAmount * bonus);