|
@@ -27,6 +27,9 @@ public class SkillTools {
|
|
|
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
|
|
public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled();
|
|
|
|
|
|
+ public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
|
|
+ public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
|
|
+
|
|
|
public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) {
|
|
|
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
|
|
|
|
|
@@ -205,7 +208,7 @@ public class SkillTools {
|
|
|
profile.setAbilityInformed(ability, false);
|
|
|
player.sendMessage(ability.getAbilityOff());
|
|
|
|
|
|
- Misc.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
|
|
+ sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -420,7 +423,7 @@ public class SkillTools {
|
|
|
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
|
|
player.sendMessage(ability.getAbilityOn());
|
|
|
|
|
|
- Misc.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
|
|
+ SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
|
|
|
|
|
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
|
|
profile.setAbilityMode(ability, true);
|
|
@@ -471,4 +474,42 @@ public class SkillTools {
|
|
|
|
|
|
return activate;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Calculate activation chance for a skill.
|
|
|
+ *
|
|
|
+ * @param isLucky true if the player has the appropriate "lucky" perk, false otherwise
|
|
|
+ * @return the activation chance
|
|
|
+ */
|
|
|
+ public static int calculateActivationChance(boolean isLucky) {
|
|
|
+ if (isLucky) {
|
|
|
+ return LUCKY_SKILL_ACTIVATION_CHANCE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NORMAL_SKILL_ACTIVATION_CHANCE;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void sendSkillMessage(Player player, String message) {
|
|
|
+ for (Player otherPlayer : player.getWorld().getPlayers()) {
|
|
|
+ if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
|
|
|
+ otherPlayer.sendMessage(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Check if a skill level is higher than the max bonus level of the ability.
|
|
|
+ *
|
|
|
+ * @param skillLevel Skill level to check
|
|
|
+ * @param maxLevel Max level of the ability
|
|
|
+ * @return whichever value is lower
|
|
|
+ */
|
|
|
+ public static int skillCheck(int skillLevel, int maxLevel) {
|
|
|
+ //TODO: Could we just use Math.min(skillLevel, maxLevel) here?
|
|
|
+ if (skillLevel > maxLevel) {
|
|
|
+ return maxLevel;
|
|
|
+ }
|
|
|
+
|
|
|
+ return skillLevel;
|
|
|
+ }
|
|
|
}
|