Fixing Graceful Roll in the new system.

This commit is contained in:
nossr50
2019-01-14 18:35:37 -08:00
parent d9dd4ea016
commit 918b94b1ff
3 changed files with 41 additions and 7 deletions

View File

@ -128,7 +128,14 @@ public class Roll extends AcrobaticsSubSkill implements RandomChance {
rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1];
String[] gracefulRollStrings = SkillUtils.calculateAbilityDisplayValues(skillValue, SubSkillType.ACROBATICS_ROLL, isLucky);
/*
* 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));
gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1];
@ -250,7 +257,12 @@ public class Roll extends AcrobaticsSubSkill implements RandomChance {
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
double modifiedDamage = calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
if (!isFatal(player, modifiedDamage) && SkillUtils.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player, getPrimarySkill(), skillLevel, getActivationChance(mcMMOPlayer))) {
if (!isFatal(player, modifiedDamage)
&& SkillUtils.isActivationSuccessfulCustom(player,
this,
AdvancedConfig.getInstance().getMaxChance(SubSkillType.ACROBATICS_ROLL),
AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL) / 2)) //This effectively makes it so you reach the max chance for success at half the requirements of roll's max chance (which would make graceful roll twice as likely per skill level)
{
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
@ -373,7 +385,7 @@ public class Roll extends AcrobaticsSubSkill implements RandomChance {
chancePerLevel = (1/curve) * maxBonusLevel;
return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxBonusLevel, chancePerLevel, damageThreshold);
return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxBonusLevel, chancePerLevel, damageThreshold, damageThreshold * 2);
}
/**

View File

@ -65,6 +65,10 @@ public class SkillUtils {
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) {
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();
@ -285,10 +289,10 @@ public class SkillUtils {
* @param player The owner of this sub-skill
* @param skill The identifier for the parent of our sub-skill
* @param activationChance This is the value that we roll against, 100 is normal, and 75 is for lucky perk
* @param subskillActivationType this value represents what kind of activation procedures this sub-skill uses
* @param skillActivationType this value represents what kind of activation procedures this sub-skill uses
* @return returns true if all conditions are met and they event is not cancelled
*/
public static boolean isActivationSuccessful(SkillActivationType subskillActivationType, SubSkillType subSkillType, Player player,
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player,
PrimarySkillType skill, int skillLevel, int activationChance)
{
//Maximum chance to succeed
@ -296,7 +300,7 @@ public class SkillUtils {
//Maximum roll we can make
int maxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(subSkillType);
switch(subskillActivationType)
switch(skillActivationType)
{
//100 Skill = Guaranteed
case RANDOM_LINEAR_100_SCALE_NO_CAP:
@ -315,6 +319,24 @@ public class SkillUtils {
}
}
/**
* This method is for running a random success check with custom maxChance and maxBonusLevel values
* Mostly used for RNG effects that can't be directly associated with a specific AbstractSubSkill
* @param player target player
* @param abstractSubSkill this abstract subskill
* @param maxChance custom max chance
* @param maxBonusLevel custom max bonus level
* @return true if activation was successful
*/
public static boolean isActivationSuccessfulCustom(Player player, AbstractSubSkill abstractSubSkill, double maxChance, int maxBonusLevel)
{
int skillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill());
return performRandomSkillCheck(abstractSubSkill, player, skillLevel, PerksUtils.handleLuckyPerks(player, abstractSubSkill.getPrimarySkill()), maxChance, maxBonusLevel);
}
public static double getChanceOfSuccess(int skillLevel, double maxLevelBonus, double curve)
{
return getChanceOfSuccess((double) skillLevel, maxLevelBonus, curve);