Пример #1
0
  @Override
  public String onSpawn(L2Npc npc) {
    for (L2PcInstance target : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (!target.isDead()
          && GeoData.getInstance().canSeeTarget(npc, target)
          && Util.checkIfInRange(npc.getAggroRange(), npc, target, true)) {
        if (target.getActiveWeaponInstance() != null
            && !npc.isInCombat()
            && npc.getTarget() == null) {
          npc.setTarget(target);
          npc.broadcastNpcSay(
              ((target.getAppearance().getSex()) ? "Sister " : "Brother ")
                  + target.getName()
                  + ", move your weapon away!");

          switch (npc.getNpcId()) {
            case 22124:
            case 22126:
            case 22127:
              npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
              break;

            default:
              attack(((L2Attackable) npc), target);
              break;
          }
        }
      }
    }
    return super.onSpawn(npc);
  }
Пример #2
0
  @Override
  public String onSkillSee(
      L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) {
    // Caster is an allied.
    if (caster.isAlliedWithKetra()) {
      // Caster's skill is a positive effect ? Go further.
      switch (skill.getSkillType()) {
        case BUFF:
        case HEAL:
        case HEAL_PERCENT:
        case HEAL_STATIC:
        case BALANCE_LIFE:
        case HOT:
          for (L2Character target : (L2Character[]) targets) {
            // Character isn't existing, is dead or is current caster, we drop check.
            if (target == null || target.isDead() || target == caster) continue;

            // Target isn't a summon nor a player, we drop check.
            if (!(target instanceof L2Playable)) continue;

            // Retrieve the player behind that target.
            final L2PcInstance player = target.getActingPlayer();

            // If player is neutral or enemy, go further.
            if (!(player.isAlliedWithKetra())) {
              // If the NPC got that player registered in aggro list, go further.
              if (((L2Attackable) npc).containsTarget(player)) {
                // Save current target for future use.
                final L2Object oldTarget = npc.getTarget();

                // Curse the heretic or his pet.
                npc.setTarget((isPet && player.getPet() != null) ? caster.getPet() : caster);
                npc.doCast(FrequentSkill.VARKA_KETRA_PETRIFICATION.getSkill());

                // Revert to old target && drop the loop.
                npc.setTarget(oldTarget);
                break;
              }
            }
          }
          break;
      }
    }

    // Continue normal behavior.
    return super.onSkillSee(npc, caster, skill, targets, isPet);
  }
Пример #3
0
  @Override
  public String onAggro(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (player == null) return null;

    // Instant use
    npc.setTarget(npc);
    npc.doCast((npc.getNpcId() == 18345) ? ANESTHESIA : POISON);

    // Launch a task every 15sec.
    if (getQuestTimer("skill", npc, null) == null) startQuestTimer("skill", 15000, npc, null, true);

    return super.onAggro(npc, player, isPet);
  }
Пример #4
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if (!(npc instanceof L2Attackable)) return null;

    if (event.equalsIgnoreCase("skill")) {
      int playableCounter = 0;
      for (L2Playable playable :
          npc.getKnownList().getKnownTypeInRadius(L2Playable.class, npc.getAggroRange())) {
        if (!playable.isDead()) playableCounter++;
      }

      // If no one is inside aggro range, drop the task.
      if (playableCounter == 0) {
        cancelQuestTimer("skill", npc, null);
        return null;
      }

      npc.setTarget(npc);
      npc.doCast((npc.getNpcId() == 18345) ? ANESTHESIA : POISON);
    }
    return null;
  }
Пример #5
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg();
    QuestState st = player.getQuestState(getName());
    if (st == null) return htmltext;

    if (Util.isDigit(event)) {
      final int eventId = Integer.parseInt(event);
      if (eventId >= 0 && eventId <= 7) {
        if (st.getQuestItemsCount(HORN) >= BUFF[eventId - 1][2]) {
          st.takeItems(HORN, BUFF[eventId - 1][2]);
          npc.setTarget(player);
          npc.doCast(SkillTable.getInstance().getInfo(BUFF[eventId - 1][0], BUFF[eventId - 1][1]));
          npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
          htmltext = "31372-4.htm";
        }
      }
    } else if (event.equals("Withdraw")) {
      if (player.getWarehouse().getSize() == 0) htmltext = "31374-0.htm";
      else {
        player.sendPacket(ActionFailed.STATIC_PACKET);
        player.setActiveWarehouse(player.getWarehouse());
        player.sendPacket(new WareHouseWithdrawalList(player, 1));
      }
    } else if (event.equals("Teleport")) {
      switch (player.getAllianceWithVarkaKetra()) {
        case 4:
          htmltext = "31376-4.htm";
          break;
        case 5:
          htmltext = "31376-5.htm";
          break;
      }
    }

    return htmltext;
  }
Пример #6
0
  @Override
  public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (!npc.isInCombat()) {
      if (player.getActiveWeaponInstance() != null) {
        npc.setTarget(player);
        npc.broadcastNpcSay(
            ((player.getAppearance().getSex()) ? "Sister " : "Brother ")
                + player.getName()
                + ", move your weapon away!");

        switch (npc.getNpcId()) {
          case 22124:
          case 22126:
            npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
            break;

          default:
            attack(((L2Attackable) npc), player);
            break;
        }
      } else if (((L2Attackable) npc).getMostHated() == null) return null;
    }
    return super.onAggroRangeEnter(npc, player, isPet);
  }