Exemplo n.º 1
0
  @Override
  public void onAction(final Player player, boolean shift) {
    if (!isTargetable(player)) {
      player.sendActionFailed();
      return;
    }

    if (player.getTarget() != this) player.setTarget(this);
    else if (isAutoAttackable(player)) player.getAI().Attack(this, false, shift);
    else if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_FOLLOW) {
      if (!shift)
        player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this, Config.FOLLOW_RANGE);
      else player.sendActionFailed();
    } else player.sendActionFailed();
  }
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 void onAction(Player player, boolean shift) {
    if (Events.onAction(player, this, shift)) {
      player.sendActionFailed();
      return;
    }

    if (this != player.getTarget()) {
      player.setTarget(this);
      player.sendPacket(new ValidateLocation(this));
    } else {
      player.sendPacket(new MyTargetSelected(player, this));
      if (!isInRange(player, INTERACTION_DISTANCE))
        player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
      else if (buffs.size() > 4) showChatWindow(player, 1);
      else showChatWindow(player, 0);
      player.sendActionFailed();
    }
  }