Starting work on converting skills to use the new 100-scale system

This commit is contained in:
nossr50
2018-12-26 23:59:43 -08:00
parent 24e4c28355
commit 93d10c0739
12 changed files with 82 additions and 23 deletions

View File

@ -116,7 +116,7 @@ public class FormulaManager {
switch (formulaType) {
case LINEAR:
if (!experienceNeededLinear.containsKey(level)) {
experience = (int) Math.floor(base + level * multiplier);
experience = (int) Math.floor( 10 * (base + level * multiplier));
experienceNeededLinear.put(level, experience);
}
@ -124,7 +124,7 @@ public class FormulaManager {
case EXPONENTIAL:
if (!experienceNeededExponential.containsKey(level)) {
experience = (int) Math.floor(multiplier * Math.pow(level, exponent) + base);
experience = (int) Math.floor( 10 * multiplier * Math.pow(level, exponent) + base);
experienceNeededExponential.put(level, experience);
}

View File

@ -208,6 +208,18 @@ public class SkillUtils {
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) {
double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance;
return propagateSecondaryAbilityEvent(skillAbility, player, activationChance, chance);
}
/**
* Sends an event out regarding activation of RNG based sub-skills
* @param skillAbility The random-chance ability
* @param player The player that the skill belong to
* @param activationChance parameter used in activation calculations
* @param chance parameter used in activation calculations
* @return returns true if successful
*/
private static boolean propagateSecondaryAbilityEvent(SecondaryAbility skillAbility, Player player, int activationChance, double chance) {
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
@ -215,9 +227,7 @@ public class SkillUtils {
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, double staticChance, int activationChance) {
double chance = staticChance / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
return propagateSecondaryAbilityEvent(skillAbility, player, activationChance, chance);
}
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player) {