From 3aee334fbd97db3ff3521ad0d8c7d81da2df09d6 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Wed, 2 Jan 2013 00:34:32 +0100 Subject: [PATCH] Fixed Arcobatics & Archery ignoring ChanceMax settings from advanced config --- .../nossr50/skills/acrobatics/Acrobatics.java | 7 ++++++- .../skills/acrobatics/AcrobaticsManager.java | 18 ++++++++++++++---- .../skills/acrobatics/RollEventHandler.java | 2 +- .../nossr50/skills/archery/ArcheryManager.java | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index 1af3cc8c5..c9883433d 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -6,12 +6,17 @@ import com.gmail.nossr50.config.AdvancedConfig; public class Acrobatics { static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); + public static final int DODGE_MAX_CHANCE = advancedConfig.getDodgeChanceMax(); public static final int DODGE_MAX_BONUS_LEVEL = advancedConfig.getDodgeMaxBonusLevel(); public static final int DODGE_XP_MODIFIER = advancedConfig.getDodgeXPModifier(); - public static final int FALL_XP_MODIFIER = advancedConfig.getFallXPModifier(); + public static final int ROLL_MAX_CHANCE = advancedConfig.getRollChanceMax(); public static final int ROLL_MAX_BONUS_LEVEL = advancedConfig.getRollMaxBonusLevel(); + public static final int GRACEFUL_MAX_CHANCE = advancedConfig.getGracefulRollChanceMax(); + public static final int GRACEFUL_MAX_BONUS_LEVEL = advancedConfig.getGracefulRollMaxBonusLevel(); + public static final int ROLL_XP_MODIFIER = advancedConfig.getRollXPModifier(); + public static final int FALL_XP_MODIFIER = advancedConfig.getFallXPModifier(); private static Random random = new Random(); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index cfe6fe8fb..2b417369f 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -40,13 +40,20 @@ public class AcrobaticsManager { RollEventHandler eventHandler = new RollEventHandler(this, event); - int randomChance = 1000; + int randomChance = 100; if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { randomChance = (int) (randomChance * 0.75); } - if (Acrobatics.getRandom().nextInt(randomChance) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) { + float chance = (float) (((double) Acrobatics.ROLL_MAX_CHANCE / (double) Acrobatics.ROLL_MAX_BONUS_LEVEL) * skillLevel); + if (chance > Acrobatics.ROLL_MAX_CHANCE) chance = Acrobatics.ROLL_MAX_CHANCE; + if (eventHandler.isGraceful) { + chance = (float) (((double) Acrobatics.GRACEFUL_MAX_CHANCE / (double) Acrobatics.GRACEFUL_MAX_BONUS_LEVEL) * skillLevel); + if (chance > Acrobatics.GRACEFUL_MAX_CHANCE) chance = Acrobatics.GRACEFUL_MAX_CHANCE; + } + + if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) { eventHandler.modifyEventDamage(); eventHandler.sendAbilityMessage(); eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER); @@ -71,13 +78,16 @@ public class AcrobaticsManager { DodgeEventHandler eventHandler = new DodgeEventHandler(this, event); - int randomChance = 4000; + int randomChance = 100; if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) { randomChance = (int) (randomChance * 0.75); } - if (Acrobatics.getRandom().nextInt(randomChance) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) { + float chance = (float) (((double) Acrobatics.DODGE_MAX_CHANCE / (double) Acrobatics.DODGE_MAX_BONUS_LEVEL) * skillLevel); + if (chance > Acrobatics.DODGE_MAX_CHANCE) chance = Acrobatics.DODGE_MAX_CHANCE; + + if (chance > Acrobatics.getRandom().nextInt(randomChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) { eventHandler.modifyEventDamage(); eventHandler.sendAbilityMessage(); eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java index 4ef6f39d4..1ca82153f 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java @@ -9,7 +9,7 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Skills; public class RollEventHandler extends AcrobaticsEventHandler { - private boolean isGraceful; + public boolean isGraceful; private int damageThreshold; protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 3f26b5e87..1f56eb3a4 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -49,7 +49,10 @@ public class ArcheryManager { if (player.hasPermission("mcmmo.perks.lucky.archery")) { randomChance = (int) (randomChance * 0.75); } - final float chance = (float) (((double) Archery.ARROW_TRACKING_MAX_BONUS / (double) Archery.ARROW_TRACKING_MAX_BONUS_LEVEL) * skillLevel); + + float chance = (float) (((double) Archery.ARROW_TRACKING_MAX_BONUS / (double) Archery.ARROW_TRACKING_MAX_BONUS_LEVEL) * skillLevel); + if (chance > Archery.ARROW_TRACKING_MAX_BONUS) chance = Archery.ARROW_TRACKING_MAX_BONUS; + if (chance > Archery.getRandom().nextInt(randomChance)) { eventHandler.addToTracker(); } @@ -80,7 +83,9 @@ public class ArcheryManager { randomChance = (int) (randomChance * 0.75); } - final float chance = (float) (((double) Archery.DAZE_MAX_BONUS / (double) Archery.DAZE_MAX_BONUS_LEVEL) * skillLevel); + float chance = (float) (((double) Archery.DAZE_MAX_BONUS / (double) Archery.DAZE_MAX_BONUS_LEVEL) * skillLevel); + if (chance > Archery.DAZE_MAX_BONUS) chance = Archery.DAZE_MAX_BONUS; + if (chance > Archery.getRandom().nextInt(randomChance)) { eventHandler.handleDazeEffect(); eventHandler.sendAbilityMessages();