예제 #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
파일: AbstractNpcAI.java 프로젝트: D3XV/D3X
  /**
   * This method selects a random player.<br>
   * Player can't be dead and isn't an hidden GM aswell.
   *
   * @param npc to check.
   * @return the random player.
   */
  public static L2PcInstance getRandomPlayer(L2Npc npc) {
    List<L2PcInstance> result = new ArrayList<>();

    for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (player.isDead()) continue;

      if (player.isGM() && player.getAppearance().getInvisible()) continue;

      result.add(player);
    }

    return (result.isEmpty()) ? null : result.get(Rnd.get(result.size()));
  }
예제 #3
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;
  }