SecondaryAbility's API additions

This commit is contained in:
t00thpick1
2013-11-22 12:32:23 -05:00
parent 5d63a4b910
commit 870987bba7
60 changed files with 658 additions and 596 deletions

View File

@ -18,7 +18,9 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@ -187,16 +189,25 @@ public class SkillUtils {
itemStack.setDurability((short) Math.min(itemStack.getDurability() + durabilityModifier, maxDurability));
}
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {
return activationSuccessful(UserManager.getPlayer(player).getSkillLevel(skill), PerksUtils.handleLuckyPerks(player, skill), maxChance, maxLevel);
public static boolean activationSuccessful(SecondaryAbilityType skillAbility, Player player, SkillType skill) {
return activationSuccessful(skillAbility, player, UserManager.getPlayer(player).getSkillLevel(skill), PerksUtils.handleLuckyPerks(player, skill));
}
public static boolean activationSuccessful(int skillLevel, int activationChance, double maxChance, int maxLevel) {
return (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) > Misc.getRandom().nextInt(activationChance);
public static boolean activationSuccessful(SecondaryAbilityType skillAbility, Player player, int skillLevel, int activationChance) {
return activationSuccessful(skillAbility, player, skillLevel, activationChance, AdvancedConfig.getInstance().getMaxChance(skillAbility), AdvancedConfig.getInstance().getMaxBonusLevel(skillAbility));
}
public static boolean treasureDropSuccessful(double dropChance, int activationChance) {
return dropChance > Misc.getRandom().nextDouble() * activationChance;
public static boolean activationSuccessful(SecondaryAbilityType skillAbility, Player player, int skillLevel, int activationChance, double maxChance, int maxLevel) {
double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance);
}
public static boolean treasureDropSuccessful(Player player, double dropChance, int activationChance) {;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, SecondaryAbilityType.EXCAVATION_TREASURE_HUNTER, dropChance / activationChance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > (Misc.getRandom().nextDouble() * activationChance);
}
private static boolean isLocalizedSkill(String skillName) {