Fixed a bug where Retro mode made you 10x luckier

This commit is contained in:
nossr50 2019-01-20 02:08:26 -08:00
parent e962f645b6
commit 87f84a5f66
3 changed files with 13 additions and 4 deletions

View File

@ -216,7 +216,7 @@ public abstract class SkillCommand implements TabExecutor {
} }
protected String[] calculateAbilityDisplayValues(float skillValue, SubSkillType subSkill, boolean isLucky) { protected String[] calculateAbilityDisplayValues(float skillValue, SubSkillType subSkill, boolean isLucky) {
int maxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(subSkill); int maxBonusLevel = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getMaxBonusLevel(subSkill) * 10 : AdvancedConfig.getInstance().getMaxBonusLevel(subSkill);
return calculateAbilityDisplayValues((AdvancedConfig.getInstance().getMaxChance(subSkill) / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky); return calculateAbilityDisplayValues((AdvancedConfig.getInstance().getMaxChance(subSkill) / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
} }

View File

@ -246,7 +246,6 @@ public class Config extends AutoUpdateConfigLoader {
*/ */
/* General Settings */ /* General Settings */
public boolean getIsMetricsEnabled() { return config.getBoolean("Metrics.bstats", true); } public boolean getIsMetricsEnabled() { return config.getBoolean("Metrics.bstats", true); }
//Retro mode will default the value to true if the config file doesn't contain the entry (server is from a previous mcMMO install) //Retro mode will default the value to true if the config file doesn't contain the entry (server is from a previous mcMMO install)

View File

@ -62,10 +62,16 @@ public class SkillUtils {
public static String[] calculateAbilityDisplayValues(float skillValue, SubSkillType subSkillType, boolean isLucky) { public static String[] calculateAbilityDisplayValues(float skillValue, SubSkillType subSkillType, boolean isLucky) {
int maxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(subSkillType); int maxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(subSkillType);
if(Config.getInstance().getIsRetroMode())
maxBonusLevel = maxBonusLevel * 10;
return calculateAbilityDisplayValues((AdvancedConfig.getInstance().getMaxChance(subSkillType) / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky); return calculateAbilityDisplayValues((AdvancedConfig.getInstance().getMaxChance(subSkillType) / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
} }
public static String[] calculateAbilityDisplayValuesCustom(float skillValue, SubSkillType subSkillType, boolean isLucky, int maxBonusLevel, double maxChance) { public static String[] calculateAbilityDisplayValuesCustom(float skillValue, SubSkillType subSkillType, boolean isLucky, int maxBonusLevel, double maxChance) {
if(Config.getInstance().getIsRetroMode())
maxBonusLevel = maxBonusLevel * 10;
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky); return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
} }
@ -259,12 +265,18 @@ public class SkillUtils {
* @return true if random chance succeeds and the event isn't cancelled * @return true if random chance succeeds and the event isn't cancelled
*/ */
private static boolean performRandomSkillCheck(SubSkillType subSkillType, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) { private static boolean performRandomSkillCheck(SubSkillType subSkillType, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) {
if(Config.getInstance().getIsRetroMode())
maxLevel = maxLevel * 10;
double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance; double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance;
return performRandomSkillCheckStatic(subSkillType, player, activationChance, chance); return performRandomSkillCheckStatic(subSkillType, player, activationChance, chance);
} }
/* NEW VERSION */ /* NEW VERSION */
private static boolean performRandomSkillCheck(AbstractSubSkill abstractSubSkill, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) { private static boolean performRandomSkillCheck(AbstractSubSkill abstractSubSkill, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) {
if(Config.getInstance().getIsRetroMode())
maxLevel = maxLevel * 10;
double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance; double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance;
return performRandomSkillCheckStatic(abstractSubSkill, player, activationChance, chance); return performRandomSkillCheckStatic(abstractSubSkill, player, activationChance, chance);
} }
@ -326,10 +338,8 @@ public class SkillUtils {
*/ */
public static boolean isActivationSuccessfulCustom(Player player, AbstractSubSkill abstractSubSkill, double maxChance, int maxBonusLevel) public static boolean isActivationSuccessfulCustom(Player player, AbstractSubSkill abstractSubSkill, double maxChance, int maxBonusLevel)
{ {
int skillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill()); int skillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill());
return performRandomSkillCheck(abstractSubSkill, player, skillLevel, PerksUtils.handleLuckyPerks(player, abstractSubSkill.getPrimarySkill()), maxChance, maxBonusLevel); return performRandomSkillCheck(abstractSubSkill, player, skillLevel, PerksUtils.handleLuckyPerks(player, abstractSubSkill.getPrimarySkill()), maxChance, maxBonusLevel);
} }