@Override
 public void runImpl() throws Exception {
   _activeChar.sendActionFailed();
   _activeChar.clearCastVars(false);
   if (_activeChar.isDead() || _target.isDead()) return;
   _target.addAbsorber(_activeChar);
 }
Exemplo n.º 2
0
  @Override
  public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) {
    Player player;
    if (playable.isPlayer()) player = (Player) playable;
    else if (playable.isPet()) player = playable.getPlayer();
    else return false;

    GameObject target = player.getTarget();
    if (target == null || !target.isMonster()) {
      player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      return false;
    }

    MonsterInstance monster = (MonsterInstance) player.getTarget();

    if (!monster.isDead()) {
      player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      return false;
    }

    Skill skill = SkillTable.getInstance().getInfo(HARVESTER_SKILL_ID, 1);
    if (skill != null && skill.checkCondition(player, monster, false, false, true)) {
      player.getAI().Cast(skill, monster);
      return true;
    }
    return false;
  }
  @Override
  public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) {
    if (playable == null || !playable.isPlayer()) return false;
    Player player = playable.getPlayer();

    if (player.getTarget() == null || !player.getTarget().isMonster()) {
      player.sendPacket(SystemMsg.INVALID_TARGET, ActionFail.STATIC);
      return false;
    }

    if (player.isImmobilized() || player.isCastingNow()) {
      player.sendActionFailed();
      return false;
    }

    MonsterInstance target = (MonsterInstance) player.getTarget();

    // u can use soul crystal only when target hp goes to <50%
    if (target.getCurrentHpPercents() >= 50) {
      player.sendPacket(
          SystemMsg.THE_SOUL_CRYSTAL_WAS_NOT_ABLE_TO_ABSORB_THE_SOUL, ActionFail.STATIC);
      return false;
    }

    // Soul Crystal Casting section
    int skillHitTime = SkillTable.getInstance().getInfo(SOUL_CRYSTAL_SKILL_ID, 1).getHitTime();
    player.broadcastPacket(new MagicSkillUse(player, SOUL_CRYSTAL_SKILL_ID, 1, skillHitTime, 0));
    player.sendPacket(new SetupGauge(player, SetupGauge.Colors.BLUE, skillHitTime));
    // End Soul Crystal Casting section

    // Continue execution later
    player._skillTask =
        ThreadPoolManager.getInstance()
            .schedule(new CrystalFinalizer(player, target), skillHitTime);
    return true;
  }