Esempio n. 1
0
  /**
   * Check to see if an ability can be activated.
   *
   * @param skill The skill the ability is based on
   */
  public void checkAbilityActivation(SkillType skill) {
    ToolType tool = skill.getTool();
    AbilityType ability = skill.getAbility();

    setToolPreparationMode(tool, false);

    if (getAbilityMode(ability)) {
      return;
    }

    int timeRemaining = calculateTimeRemaining(ability);

    if (timeRemaining > 0) {
      /*
       * Axes and Woodcutting are odd because they share the same tool.
       * We show them the too tired message when they take action.
       */
      if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
        player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
      }

      return;
    }

    if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
      return;
    }

    int ticks =
        PerksUtils.handleActivationPerks(
            player,
            2 + (getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()),
            ability.getMaxLength());

    // Notify people that ability has been activated
    ParticleEffectUtils.playAbilityEnabledEffect(player);

    if (useChatNotifications()) {
      player.sendMessage(ability.getAbilityOn());
    }

    SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));

    // Enable the ability
    profile.setAbilityDATS(
        ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
    setAbilityMode(ability, true);

    if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
      SkillUtils.handleAbilitySpeedIncrease(player);
    }

    new AbilityDisableTask(this, ability)
        .runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
  }
Esempio n. 2
0
 public void setAbilityDATS(AbilityType ability, long DATS) {
   profile.setAbilityDATS(ability, DATS);
 }