Refactoring code related to pulling standard/retro mode variables.

Fixing the display and calculation of Super Ability lengths.
Removing the cap on super ability lengths for values less than 1.
Fixing some display errors regarding retro mode and standard.
This commit is contained in:
nossr50 2019-01-23 15:06:00 -08:00
parent 6c0da22d5e
commit 8f906af99c
7 changed files with 104 additions and 37 deletions

View File

@ -42,7 +42,7 @@ Version 2.1.0
! (Skills) Sword's Rupture now has a max chance to proc of 33% instead of 70% ! (Skills) Sword's Rupture now has a max chance to proc of 33% instead of 70%
! (Skills) Sword's Rupture now deals 50% more damage at above Rank 3 and can last much longer! The base damage for Bleed has been increased as well (update your advanced.yml admins) ! (Skills) Sword's Rupture now deals 50% more damage at above Rank 3 and can last much longer! The base damage for Bleed has been increased as well (update your advanced.yml admins)
! (Skills) Sword's Rupture no longer triggers invincibility frames when damaging your opponent ! (Skills) Sword's Rupture no longer triggers invincibility frames when damaging your opponent
+ (Skills) Ability Lengths now have a default skill cap at which they stop increasing in length, configurable in advanced.yml + (Skills) Ability Lengths now have a default skill cap at which they stop increasing in length, configurable in advanced.yml (endurance perks extend this limit)
+ (Skills) Added a new subskill to some skills 'Understanding The Art' this adds nothing new, but tracks benefits that increase together that seemed unrelated, which was previously a bit obfuscated. + (Skills) Added a new subskill to some skills 'Understanding The Art' this adds nothing new, but tracks benefits that increase together that seemed unrelated, which was previously a bit obfuscated.
+ (Skills) Tool alerts now are sent to the Action Bar + (Skills) Tool alerts now are sent to the Action Bar
+ (Skills) Super Ability activation alerts are now sent to the Action Bar + (Skills) Super Ability activation alerts are now sent to the Action Bar

View File

@ -64,7 +64,7 @@ public abstract class SkillCommand implements TabExecutor {
float skillValue = mcMMOPlayer.getSkillLevel(skill); float skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier //Send the players a few blank lines to make finding the top of the skill command easier
for(int i = 0; i < 20; i++) for(int i = 0; i < 19; i++)
{ {
player.sendMessage(""); player.sendMessage("");
} }
@ -227,16 +227,26 @@ 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 = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getMaxBonusLevel(subSkill) * 10 : AdvancedConfig.getInstance().getMaxBonusLevel(subSkill); int maxBonusLevel = 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);
} }
protected String[] calculateLengthDisplayValues(Player player, float skillValue) { protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxLength(); int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard(); int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthCapRetro() : AdvancedConfig.getInstance().getAbilityLengthCapStandard(); int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
int length;
if(abilityLengthCap < 0)
{
length = 2 + (int) (skillValue / abilityLengthVar);
}
else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
}
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) { if (maxLength != 0) {

View File

@ -43,7 +43,7 @@ public class SwordsCommand extends SkillCommand {
// SWORDS_RUPTURE // SWORDS_RUPTURE
if (canBleed) { if (canBleed) {
bleedLength = (skillValue >= AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.SWORDS_RUPTURE)) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks; bleedLength = UserManager.getPlayer(player).getSwordsManager().getBleedTicks();
String[] bleedStrings = calculateAbilityDisplayValues(skillValue, SubSkillType.SWORDS_RUPTURE, isLucky); String[] bleedStrings = calculateAbilityDisplayValues(skillValue, SubSkillType.SWORDS_RUPTURE, isLucky);
bleedChance = bleedStrings[0]; bleedChance = bleedStrings[0];

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,12 +31,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
List<String> reason = new ArrayList<String>(); List<String> reason = new ArrayList<String>();
/* GENERAL */ /* GENERAL */
if (getAbilityLengthRetro() < 1) { if (getAbilityLength() < 1) {
reason.add("Skills.General.Ability.Length.RetroMode.IncreaseLevel should be at least 1!"); reason.add("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
}
if (getAbilityLengthStandard() < 1) {
reason.add("Skills.General.Ability.Length.Standard.IncreaseLevel should be at least 1!");
} }
if (getEnchantBuff() < 1) { if (getEnchantBuff() < 1) {
@ -668,13 +665,49 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */ /* GENERAL */
public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); } public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); }
public int getAbilityLengthCapStandard() { return config.getInt("Skills.General.Ability.Length.Standard.Cap", 50); }
public int getAbilityLengthCapRetro() { return config.getInt("Skills.General.Ability.Length.RetroMode.Cap", 500); } /**
public int getAbilityLengthStandard() { return config.getInt("Skills.General.Ability.Length.Standard.IncreaseLevel", 5); } * This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
public int getAbilityLengthRetro() { return config.getInt("Skills.General.Ability.Length.RetroMode.IncreaseLevel", 50); } * It returns a different value depending on whether or not the server is in retro mode
* @return the level at which abilities stop increasing in length
*/
public int getAbilityLengthCap() {
if(!mcMMO.isRetroModeEnabled())
return config.getInt("Skills.General.Ability.Length.Standard.Cap", 50);
else
return config.getInt("Skills.General.Ability.Length.RetroMode.Cap", 500);
}
/**
* This returns the frequency at which abilities will increase in length
* It returns a different value depending on whether or not the server is in retro mode
* @return the number of levels required per ability length increase
*/
public int getAbilityLength() {
if(!mcMMO.isRetroModeEnabled())
return config.getInt("Skills.General.Ability.Length.Standard.IncreaseLevel", 5);
else
return config.getInt("Skills.General.Ability.Length.RetroMode.IncreaseLevel", 50);
}
public int getEnchantBuff() { return config.getInt("Skills.General.Ability.EnchantBuff", 5); } public int getEnchantBuff() { return config.getInt("Skills.General.Ability.EnchantBuff", 5); }
public int getMaxBonusLevel(SubSkillType subSkillType) { return config.getInt(subSkillType.getAdvConfigAddress() + ".MaxBonusLevel"); } /**
* Grabs the max bonus level for a skill used in RNG calculations
* All max level values in the config are multiplied by 10 if the server is in retro mode as the values in the config are based around the new 1-100 skill system scaling
* A value of 10 in the file will be returned as 100 for retro mode servers to accommodate the change in scaling
* @param subSkillType target subskill
* @return the level at which this skills max benefits will be reached on the curve
*/
public int getMaxBonusLevel(SubSkillType subSkillType) {
int maxBonusLevel = config.getInt(subSkillType.getAdvConfigAddress() + ".MaxBonusLevel");
if(mcMMO.isRetroModeEnabled())
maxBonusLevel *= 10;
return maxBonusLevel;
}
public double getMaxChance(SubSkillType subSkillType) { return config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D);} public double getMaxChance(SubSkillType subSkillType) { return config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D);}
public int getMaxBonusLevel(AbstractSubSkill abstractSubSkill) { public int getMaxBonusLevel(AbstractSubSkill abstractSubSkill) {
@ -886,7 +919,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* REPAIR */ /* REPAIR */
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); } public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 1000); } public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 100); }
/* Arcane Forging */ /* Arcane Forging */
public int getArcaneForgingRankLevel(int rank) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + rank); } public int getArcaneForgingRankLevel(int rank) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + rank); }
@ -911,7 +944,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank); } public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank); }
/* SMELTING */ /* SMELTING */
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency.MaxBonusLevel", 1000); } public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency.MaxBonusLevel", 100); }
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency.Multiplier", 3.0D); } public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency.Multiplier", 3.0D); }
/*public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining.UnlockLevel", 250); }*/ /*public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining.UnlockLevel", 250); }*/
@ -925,7 +958,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getRuptureDamagePlayer() { return config.getDouble("Skills.Swords.Rupture.DamagePlayer", 1.0); } public double getRuptureDamagePlayer() { return config.getDouble("Skills.Swords.Rupture.DamagePlayer", 1.0); }
public double getRuptureDamageMobs() { return config.getDouble("Skills.Swords.Rupture.DamageMobs", 2.0); } public double getRuptureDamageMobs() { return config.getDouble("Skills.Swords.Rupture.DamageMobs", 2.0); }
public int getRuptureMaxTicks() { return config.getInt("Skills.Swords.Rupture.MaxTicks", 3); } public int getRuptureMaxTicks() { return config.getInt("Skills.Swords.Rupture.MaxTicks", 8); }
public int getRuptureBaseTicks() { return config.getInt("Skills.Swords.Rupture.BaseTicks", 2); } public int getRuptureBaseTicks() { return config.getInt("Skills.Swords.Rupture.BaseTicks", 2); }
public double getCounterModifier() { return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D); } public double getCounterModifier() { return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D); }

View File

@ -818,9 +818,19 @@ public class McMMOPlayer {
return; return;
} }
int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard(); //These values change depending on whether or not the server is in retro mode
int abilityLengthCap = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthCapRetro() : AdvancedConfig.getInstance().getAbilityLengthCapStandard(); int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, getSkillLevel(skill)) / abilityLengthVar), ability.getMaxLength()); int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int ticks;
//Ability cap of 0 or below means no cap
if(abilityLengthCap > 0)
{
ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, getSkillLevel(skill)) / abilityLengthVar), ability.getMaxLength());
} else {
ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(skill) / abilityLengthVar), ability.getMaxLength());
}
// Notify people that ability has been activated // Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player); ParticleEffectUtils.playAbilityEnabledEffect(player);

View File

@ -135,7 +135,6 @@ public class Roll extends AcrobaticsSubSkill implements RandomChance {
* Graceful is double the odds of a normal roll * Graceful is double the odds of a normal roll
*/ */
String[] gracefulRollStrings = SkillUtils.calculateAbilityDisplayValuesCustom(skillValue, String[] gracefulRollStrings = SkillUtils.calculateAbilityDisplayValuesCustom(skillValue,
SubSkillType.ACROBATICS_ROLL,
isLucky, isLucky,
AdvancedConfig.getInstance().getMaxBonusLevel(this) / 2, AdvancedConfig.getInstance().getMaxBonusLevel(this) / 2,
AdvancedConfig.getInstance().getMaxChance(this)); AdvancedConfig.getInstance().getMaxChance(this));

View File

@ -62,23 +62,27 @@ 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, 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);
} }
public static String[] calculateLengthDisplayValues(Player player, float skillValue, PrimarySkillType skill) { public static String[] calculateLengthDisplayValues(Player player, float skillValue, PrimarySkillType skill) {
int maxLength = skill.getAbility().getMaxLength(); int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard(); int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int length = 2 + (int) (skillValue / abilityLengthVar); int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int length;
if(abilityLengthCap > 0)
{
length = (int) Math.min(abilityLengthCap, 2 + (skillValue / abilityLengthVar));
} else {
length = 2 + (int) (skillValue / abilityLengthVar);
}
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) { if (maxLength != 0) {
@ -187,9 +191,20 @@ public class SkillUtils {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PrimarySkillType skill = mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) ? PrimarySkillType.MINING : PrimarySkillType.EXCAVATION; PrimarySkillType skill = mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) ? PrimarySkillType.MINING : PrimarySkillType.EXCAVATION;
int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard();
int abilityLengthCap = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthCapRetro() : AdvancedConfig.getInstance().getAbilityLengthCapStandard(); int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar), skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR; int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int ticks;
if(abilityLengthCap > 0)
{
ticks = PerksUtils.handleActivationPerks(player, Math.min(abilityLengthCap, 2 + (mcMMOPlayer.getSkillLevel(skill) / abilityLengthVar)),
skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
} else {
ticks = PerksUtils.handleActivationPerks(player, 2 + ((mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar),
skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
}
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10); PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
player.addPotionEffect(abilityBuff, true); player.addPotionEffect(abilityBuff, true);