Skip to content

Commit

Permalink
Refactoring code related to pulling standard/retro mode variables.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nossr50 committed Jan 23, 2019
1 parent 6c0da22 commit 8f906af
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Changelog.txt
Expand Up @@ -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 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) 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) Tool alerts now are sent to the Action Bar
+ (Skills) Super Ability activation alerts are now sent to the Action Bar
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java
Expand Up @@ -64,7 +64,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
float skillValue = mcMMOPlayer.getSkillLevel(skill);

//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("");
}
Expand Down Expand Up @@ -227,16 +227,26 @@ protected String[] calculateAbilityDisplayValues(double chance, 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);
}

protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard();
int abilityLengthCap = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthCapRetro() : AdvancedConfig.getInstance().getAbilityLengthCapStandard();
int length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();

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);

if (maxLength != 0) {
Expand Down
Expand Up @@ -43,7 +43,7 @@ protected void dataCalculations(Player player, float skillValue, boolean isLucky

// SWORDS_RUPTURE
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);
bleedChance = bleedStrings[0];
Expand Down
61 changes: 47 additions & 14 deletions src/main/java/com/gmail/nossr50/config/AdvancedConfig.java
Expand Up @@ -3,6 +3,7 @@
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.ChatColor;

import java.util.ArrayList;
Expand Down Expand Up @@ -30,12 +31,8 @@ protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();

/* GENERAL */
if (getAbilityLengthRetro() < 1) {
reason.add("Skills.General.Ability.Length.RetroMode.IncreaseLevel should be at least 1!");
}

if (getAbilityLengthStandard() < 1) {
reason.add("Skills.General.Ability.Length.Standard.IncreaseLevel should be at least 1!");
if (getAbilityLength() < 1) {
reason.add("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
}

if (getEnchantBuff() < 1) {
Expand Down Expand Up @@ -668,13 +665,49 @@ protected void loadKeys() {}

/* GENERAL */
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); }
public int getAbilityLengthRetro() { return config.getInt("Skills.General.Ability.Length.RetroMode.IncreaseLevel", 50); }

/**
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
* 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 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 int getMaxBonusLevel(AbstractSubSkill abstractSubSkill) {
Expand Down Expand Up @@ -886,7 +919,7 @@ public boolean isSubSkillClassic(SubSkillType subSkillType)

/* REPAIR */
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 */
public int getArcaneForgingRankLevel(int rank) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + rank); }
Expand All @@ -911,7 +944,7 @@ public boolean isSubSkillClassic(SubSkillType subSkillType)
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank); }

/* 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 int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining.UnlockLevel", 250); }*/
Expand All @@ -925,7 +958,7 @@ public boolean isSubSkillClassic(SubSkillType subSkillType)
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 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 double getCounterModifier() { return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D); }
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java
Expand Up @@ -818,9 +818,19 @@ public void checkAbilityActivation(PrimarySkillType skill) {
return;
}

int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard();
int abilityLengthCap = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthCapRetro() : AdvancedConfig.getInstance().getAbilityLengthCapStandard();
int ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, getSkillLevel(skill)) / abilityLengthVar), ability.getMaxLength());
//These values change depending on whether or not the server is in retro mode
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
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
ParticleEffectUtils.playAbilityEnabledEffect(player);
Expand Down
Expand Up @@ -135,7 +135,6 @@ public void addStats(ComponentBuilder componentBuilder, Player player) {
* Graceful is double the odds of a normal roll
*/
String[] gracefulRollStrings = SkillUtils.calculateAbilityDisplayValuesCustom(skillValue,
SubSkillType.ACROBATICS_ROLL,
isLucky,
AdvancedConfig.getInstance().getMaxBonusLevel(this) / 2,
AdvancedConfig.getInstance().getMaxChance(this));
Expand Down
39 changes: 27 additions & 12 deletions src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java
Expand Up @@ -62,23 +62,27 @@ public static String[] calculateAbilityDisplayValues(double chance, boolean isLu
public static String[] calculateAbilityDisplayValues(float skillValue, SubSkillType subSkillType, boolean isLucky) {
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);
}

public static String[] calculateAbilityDisplayValuesCustom(float skillValue, SubSkillType subSkillType, boolean isLucky, int maxBonusLevel, double maxChance) {
if(Config.getInstance().getIsRetroMode())
maxBonusLevel = maxBonusLevel * 10;

public static String[] calculateAbilityDisplayValuesCustom(float skillValue, boolean isLucky, int maxBonusLevel, double maxChance) {
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
}

public static String[] calculateLengthDisplayValues(Player player, float skillValue, PrimarySkillType skill) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = Config.getInstance().getIsRetroMode() ? AdvancedConfig.getInstance().getAbilityLengthRetro() : AdvancedConfig.getInstance().getAbilityLengthStandard();
int length = 2 + (int) (skillValue / abilityLengthVar);
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
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);

if (maxLength != 0) {
Expand Down Expand Up @@ -187,9 +191,20 @@ public static void handleAbilitySpeedIncrease(Player player) {

McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
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 ticks = PerksUtils.handleActivationPerks(player, 2 + (Math.min(abilityLengthCap, mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar), skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;

int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
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);
player.addPotionEffect(abilityBuff, true);
Expand Down

0 comments on commit 8f906af

Please sign in to comment.